chemmisol 0.1
Loading...
Searching...
No Matches
reaction.h
Go to the documentation of this file.
1#ifndef CHEMMISOL_REACTION_H
2#define CHEMMISOL_REACTION_H
3
4#include "species.h"
5#include <cmath>
6
13namespace chemmisol {
14
18 struct Reagent {
22 std::string name;
32
33 Reagent() = default;
43 const std::string& name,
45 double coefficient)
47 }
48
60 const std::string& name,
61 double coefficient)
62 : name(name), phase(name == "H2O" ? SOLVENT : AQUEOUS), coefficient(coefficient) {
63 }
64 };
65
66 class ChemicalSystem;
67 class Reaction;
68
77 class InvalidReaction : public std::exception {
78 protected:
88
89 public:
102
108 return *chemical_system;
109 }
110
115 return *invalid_reaction;
116 }
117 };
118
123 private:
124 std::string message;
125 public:
136
141 const char* what() const noexcept override {
142 return message.c_str();
143 }
144 };
145
151 private:
152 std::string message;
153 public:
164
170 const char* what() const noexcept override {
171 return message.c_str();
172 }
173 };
174
184 private:
185 std::string message;
186
187 public:
203 const char* what() const noexcept override {
204 return message.c_str();
205 }
206 };
207
289 class Reaction {
290 private:
291 std::string name;
292 std::size_t index;
293 double K;
294 double log_K;
295 std::vector<Reagent> reagents;
296
297 public:
319 const std::string& name, std::size_t index, double log_K,
320 const std::vector<Reagent>& reagents
321 )
322 : name(name), index(index), K(std::pow(10, log_K)), log_K(log_K), reagents(reagents) {
323 }
324
329 const std::string& getName() const {
330 return name;
331 }
332
338 std::size_t getIndex() const {
339 return index;
340 }
341
345 double getK() const {
346 return K;
347 }
348
352 double getLogK() const {
353 return log_K;
354 }
355
359 const std::vector<Reagent>& getReagents() const {
360 return reagents;
361 }
362 };
363
364}
365#endif /*CHEMMISOL_REACTION_H*/
Definition system.h:196
Definition reaction.h:122
const char * what() const noexcept override
Definition reaction.h:141
EmptyReagents(const ChemicalSystem *chemical_system, const Reaction *invalid_reaction)
Definition reaction.h:77
const Reaction & getInvalidReaction() const
Definition reaction.h:114
const ChemicalSystem & getChemicalSystem() const
Definition reaction.h:107
const ChemicalSystem * chemical_system
Definition reaction.h:83
const Reaction * invalid_reaction
Definition reaction.h:87
InvalidReaction(const ChemicalSystem *chemical_system, const Reaction *invalid_reaction)
Definition reaction.h:97
MissingProducedSpeciesInReaction(const ChemicalSystem *chemical_system, const Reaction *invalid_reaction)
const char * what() const noexcept override
Definition reaction.h:170
Definition reaction.h:289
std::size_t getIndex() const
Definition reaction.h:338
const std::vector< Reagent > & getReagents() const
Definition reaction.h:359
Reaction(const std::string &name, std::size_t index, double log_K, const std::vector< Reagent > &reagents)
Definition reaction.h:318
const std::string & getName() const
Definition reaction.h:329
double getK() const
Definition reaction.h:345
double getLogK() const
Definition reaction.h:352
const char * what() const noexcept override
Definition reaction.h:203
TooManyProducedSpeciesInReaction(const ChemicalSystem *chemical_system, const Reaction *invalid_reaction)
Definition chemmisol.h:31
Phase
Definition species.h:18
Definition reaction.h:18
Reagent(const std::string &name, double coefficient)
Definition reaction.h:59
std::string name
Definition reaction.h:22
Reagent(const std::string &name, Phase phase, double coefficient)
Definition reaction.h:42
Phase phase
Definition reaction.h:26
double coefficient
Definition reaction.h:31