ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
utils.cpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2010-2022 The ESPResSo project
3 *
4 * This file is part of ESPResSo.
5 *
6 * ESPResSo is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * ESPResSo is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#include "reaction_methods/SingleReaction.hpp"
21
23
24#include <cmath>
25#include <unordered_map>
26
27namespace ReactionMethods {
28
30 auto value = 0.;
31 if (nu_i) {
32 if (nu_i > 0) {
33 for (int i = 1; i <= nu_i; i++) {
34 value -= std::log(static_cast<double>(Ni0 + i));
35 }
36 } else {
37 if (Ni0 + nu_i < 0.) {
38 value = -std::numeric_limits<double>::max();
39 } else {
40 for (int i = 0; i < -nu_i; i++) {
41 value += std::log(static_cast<double>(Ni0 - i));
42 }
43 }
44 }
45 }
46 return value;
47}
48
50 SingleReaction const &reaction,
51 std::unordered_map<int, int> const &particle_numbers) {
52 auto value = 0.;
53 // factorial contribution of reactants
54 for (int i = 0; i < reaction.reactant_types.size(); i++) {
55 auto const nu_i = -1 * reaction.reactant_coefficients[i];
56 auto const N_i0 = particle_numbers.at(reaction.reactant_types[i]);
58 }
59 // factorial contribution of products
60 for (int i = 0; i < reaction.product_types.size(); i++) {
61 auto const nu_i = reaction.product_coefficients[i];
62 auto const N_i0 = particle_numbers.at(reaction.product_types[i]);
64 }
65 return value;
66}
67
69 SingleReaction const &reaction,
70 std::unordered_map<int, int> const &particle_numbers) {
71 auto value = 0.;
72 // factorial contribution of reactants
73 {
74 auto const nu_i = -1 * reaction.reactant_coefficients[0];
75 auto const N_i0 = particle_numbers.at(reaction.reactant_types[0]);
77 }
78 // factorial contribution of products
79 {
80 auto const nu_i = reaction.product_coefficients[0];
81 auto const N_i0 = particle_numbers.at(reaction.product_types[0]);
83 }
84 return value;
85}
86
87} // namespace ReactionMethods
double calculate_factorial_expression(SingleReaction const &reaction, std::unordered_map< int, int > const &particle_numbers)
Calculates the logarithm of whole product of factorial expressions which occur in the reaction ensemb...
Definition utils.cpp:49
double calculate_factorial_expression_cpH(SingleReaction const &reaction, std::unordered_map< int, int > const &particle_numbers)
Calculates the logarithm of factorial expression which occurs in the constant pH method with symmetri...
Definition utils.cpp:68
double ln_factorial_Ni0_divided_by_factorial_Ni0_plus_nu_i(int Ni0, int nu_i)
Calculates the logaritm of factorial expression which occurs in the reaction ensemble acceptance prob...
Definition utils.cpp:29