54 const std::vector<G4String> &product,
55 const G4double &reactionRate,
62 }
else if (type ==
"II") {
67 }
else if (type ==
"III") {
72 }
else if (type ==
"IV") {
77 }
else if (type ==
"VI") {
88 std::vector<G4String> &reactant,
89 std::vector<G4String> &product,
90 G4double &reactionRate) {
94 G4bool readReaction =
true;
95 G4bool readReactant =
true;
96 G4bool readProduct =
false;
97 G4bool readRate =
false;
99 std::stringstream aStream;
100 aStream << reactionString;
102 while (!aStream.eof() && readReaction) {
107 readReaction =
false;
108 }
else if (readReactant) {
110 readReactant =
false;
112 }
else if (aString !=
G4String(
"+")) {
116 if (reactant.size() < 2) {
117 reactant.push_back(aString);
120 }
else if (readProduct) {
128 product.push_back(aString);
130 }
else if (readRate) {
131 std::stringstream aStreamTmp;
132 aStreamTmp << aString;
133 aStreamTmp >> reactionRate;
135 if (reactant.size() == 1) {
137 reactionRate *= (1 * 1 / s);
139 reactionRate *= (1e-3 * m3 / (mole * s));
143 readReaction =
false;
148 if (reactant.size() == 1) {
149 reactant.emplace_back(
"NoneM");
177 G4double concentration = 0.;
180 G4bool readScavenger =
true;
181 G4bool readName =
false;
182 G4bool readConcentration =
false;
184 std::stringstream aStream;
185 aStream << reservoirString;
187 while (!aStream.eof() && readScavenger) {
192 readScavenger =
false;
193 }
else if (aString ==
G4String(
"scavenger:")) {
195 }
else if (readName) {
201 readConcentration =
true;
202 }
else if (readConcentration) {
203 std::stringstream aStreamTmp;
204 aStreamTmp << aString;
205 aStreamTmp >> concentration;
206 concentration *= (mole / (1e-3 * m3));
207 readConcentration =
false;
208 readScavenger =
false;
212 if (concentration > 0.) {
216 G4ExceptionDescription exception;
217 exception <<
"Scavenger already defined previously:\n"
218 <<
"scavenger will not be registered!";
219 G4Exception(
"ParserChemReaction::ReadReservoir",
"parchem02",
220 JustWarning, exception);
223 G4ExceptionDescription exception;
224 exception <<
"Null or negative scavenger concentration:\n"
225 <<
"scavenger will not be registered!";
226 G4Exception(
"ParserChemReaction::ReadReservoir",
"parchem03",
227 JustWarning, exception);
235 std::vector<G4String> reactant;
236 std::vector<G4String> product;
237 G4double reactionRate = -1;
239 G4bool reservoir =
false;
245 ReadReaction(reactionString, reactant, product, reactionRate);
247 if (!reactant.empty() && (reactionRate <= 0)) {
248 G4ExceptionDescription exception;
249 exception <<
"Null or negative reaction rate: "
250 <<
"reaction will not be registered!";
251 G4Exception(
"ParserChemReaction::AddReaction",
"parchem04",
252 JustWarning, exception);
256 G4double concentration;
258 if (reservoir && (reactant.size() >= 2)) {
265 if (concentration != -1) {
266 reactionRate *= concentration;
267 reactant[0].append(
"(B)");
277 if (concentration != -1) {
278 reactionRate *= concentration;
279 reactant[1].append(
"(B)");
283 }
else if (reactant[1] ==
"NoneM") {
287 G4ExceptionDescription exception;
288 exception <<
"Missing or unsuitable square brackets:\n"
289 <<
"reaction will not be registered.\n"
290 <<
"Verify the writing of chemical reactions!";
291 G4Exception(
"ParserChemReaction::AddReaction",
"parchem05",
292 JustWarning, exception);
294 }
else if (reactant.size() >= 2) {
297 && (reactant[1] !=
"NoneM")) {
299 }
else if (reactant[1] ==
"NoneM") {
300 G4ExceptionDescription exception;
301 exception <<
"Unsuitable reaction type: "
302 <<
"reaction will not be registered.\n"
303 <<
"For first-order reaction, use reaction type 6.";
304 G4Exception(
"ParserChemReaction::AddReaction",
"parchem06",
305 JustWarning, exception);
307 G4ExceptionDescription exception;
308 exception <<
"Unsuitable square brackets: "
309 <<
"reaction will not be registered.\n"
310 <<
"Verify the writing of chemical reactions!";
311 G4Exception(
"ParserChemReaction::AddReaction",
"parchem07",
312 JustWarning, exception);