Loading [MathJax]/extensions/TeX/AMSmath.js
ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages Concepts
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 = 1.;
31 if (nu_i) {
32 if (nu_i > 0) {
33 for (int i = 1; i <= nu_i; i++) {
34 value *= static_cast<double>(Ni0 + i);
35 }
36 value = 1. / value;
37 } else {
38 for (int i = 0; i < -nu_i; i++) {
39 value *= static_cast<double>(Ni0 - i);
40 }
41 }
42 }
43 return value;
44}
45
47 SingleReaction const &reaction,
48 std::unordered_map<int, int> const &particle_numbers) {
49 auto value = 1.;
50 // factorial contribution of reactants
51 for (int i = 0; i < reaction.reactant_types.size(); i++) {
52 auto const nu_i = -1 * reaction.reactant_coefficients[i];
53 auto const N_i0 = particle_numbers.at(reaction.reactant_types[i]);
55 }
56 // factorial contribution of products
57 for (int i = 0; i < reaction.product_types.size(); i++) {
58 auto const nu_i = reaction.product_coefficients[i];
59 auto const N_i0 = particle_numbers.at(reaction.product_types[i]);
61 }
62 return value;
63}
64
66 SingleReaction const &reaction,
67 std::unordered_map<int, int> const &particle_numbers) {
68 auto value = 1.;
69 // factorial contribution of reactants
70 {
71 auto const nu_i = -1 * reaction.reactant_coefficients[0];
72 auto const N_i0 = particle_numbers.at(reaction.reactant_types[0]);
74 }
75 // factorial contribution of products
76 {
77 auto const nu_i = reaction.product_coefficients[0];
78 auto const N_i0 = particle_numbers.at(reaction.product_types[0]);
80 }
81 return value;
82}
83
84} // namespace ReactionMethods
double calculate_factorial_expression(SingleReaction const &reaction, std::unordered_map< int, int > const &particle_numbers)
Calculates the whole product of factorial expressions which occur in the reaction ensemble acceptance...
Definition utils.cpp:46
double factorial_Ni0_divided_by_factorial_Ni0_plus_nu_i(int Ni0, int nu_i)
Calculates the factorial expression which occurs in the reaction ensemble acceptance probability.
Definition utils.cpp:29
double calculate_factorial_expression_cpH(SingleReaction const &reaction, std::unordered_map< int, int > const &particle_numbers)
Calculates the factorial expression which occurs in the constant pH method with symmetric proposal pr...
Definition utils.cpp:65