Geant4  10.03
G4ReactionTableMessenger.cc
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 /*
27  * G4ReactionTableMessenger.cc
28  *
29  * Created on: Sep 14, 2015
30  * Author: mkaramit
31  */
32 
35 #include <G4UIcmdWithAString.hh>
37 #include <G4UnitsTable.hh>
38 #include <G4SystemOfUnits.hh>
40 
41 //------------------------------------------------------------------------------
42 
45 {
46  fpTable = table;
47 
48  fpNewDiffContReaction = new G4UIcmdWithAString("/chem/reaction/new", this);
49  fpAddReaction = new G4UIcmdWithAString("/chem/reaction/add", this);
50 // fpNewPartDiffContReactionByRadius =
51 // new G4UIcmdWithAString("/chem/reaction/newPartDiffByRadius", this);
52 //
53 // fpNewPartDiffContReactionByReactionRate =
54 // new G4UIcmdWithAString("/chem/reaction/newPartDiffByRate", this);
55 
56  fpPrintTable = new G4UIcmdWithoutParameter("/chem/reaction/print", this);
57 }
58 
59 //------------------------------------------------------------------------------
60 
62 {
64  if(fpAddReaction) delete fpAddReaction;
65  if(fpPrintTable) delete fpPrintTable;
66 }
67 
68 //------------------------------------------------------------------------------
69 
71  G4String newValue)
72 {
73 
74  if(command == fpNewDiffContReaction)
75  {
76  std::istringstream iss(newValue);
77 
78  G4String species1;
79  iss >> species1;
80 
81  G4String species2;
82  iss >> species2;
83 
84  double reactionRate;
85  iss >> reactionRate;
86 
87 // G4String reactionRateUnit;
88 // iss >> reactionRateUnit;
89 
90  double dimensionedReactionRate = reactionRate * (1e-3 * m3 / (mole * s));
91 // G4UIcmdWithADoubleAndUnit::ConvertToDimensionedDouble((reactionRate
92 // + G4String(" ") + reactionRateUnit).c_str());
93 
94  G4DNAMolecularReactionData* reactionData =
95  new G4DNAMolecularReactionData(dimensionedReactionRate,
96  species1,
97  species2);
98 
99 // G4String productionRate;
100 // iss >> productionRate;
101 //
102 // if(productionRate != "" && productionRate != "X")
103 // {
104 // double prodRateReal = G4UIcommand::ConvertToDouble(productionRate);
105 //
106 // if(prodRateReal == 0 || isnan(prodRateReal))
107 // {
108 // G4Exception("G4ReactionTableMessenger",
109 // "WRONG_PRODUCTION_RATE",
110 // FatalException, "");
111 // }
112 //
113 // double dimensionedProductionRate = prodRateReal
114 // * (1e-3 * m3 / (mole * s));
115 // reactionData->SetProductionRate(dimensionedProductionRate);
116 // }
117 
118  while(iss.eof() == false)
119  {
120  G4String product;
121  iss >> product;
122 
123  if(product != "")
124  {
125  reactionData->AddProduct(product);
126  }
127  else
128  {
129  break;
130  }
131  };
132 
133  fpTable->SetReaction(reactionData);
134  }
135 // else if(command == fpNewPartDiffContReactionByRadius)
136 // {
137 // std::istringstream iss(newValue);
138 //
139 // G4String species1;
140 // iss >> species1;
141 //
142 // G4String species2;
143 // iss >> species2;
144 //
145 // double reactionRate;
146 // iss >> reactionRate;
147 //
150 //
153 //
154 // double reactionRadius;
155 // iss >> reactionRadius;
156 //
159 //
160 // double dimensionedReactionRate = reactionRate * (1e-3 * m3 / (mole * s));
161 //
165 //
166 // double dimensionedReactionRadius = reactionRadius * nm;
169 //
170 // G4DNAMolecularReactionData* reactionData =
171 // new G4DNAMolecularReactionData(dimensionedReactionRate,
172 // species1,
173 // species2);
174 // reactionData->SetPartiallyDiffusionControlledReaction(dimensionedReactionRate,
175 // dimensionedReactionRadius);
176 //
177 // while(iss.eof() == false)
178 // {
179 // G4String product;
180 // iss >> product;
181 //
182 // if(product != "")
183 // {
184 // reactionData->AddProduct(product);
185 // }
186 // else
187 // {
188 // break;
189 // }
190 // }
191 //
192 // fpTable->SetReaction(reactionData);
193 // }
194 // else if(command == fpNewPartDiffContReactionByReactionRate)
195 // {
196 // std::istringstream iss(newValue);
197 //
198 // G4String species1;
199 // iss >> species1;
200 //
201 // G4String species2;
202 // iss >> species2;
203 //
204 // double reactionRate;
205 // iss >> reactionRate;
206 //
207 // // G4String reactionRateUnit;
208 // // iss >> reactionRateUnit;
209 //
210 // // G4String reactionRateUnit;
211 // // iss >> reactionRateUnit;
212 //
213 // double activationRate;
214 // iss >> activationRate;
215 //
216 // // G4String reactionRadiusUnit;
217 // // iss >> reactionRadiusUnit;
218 //
219 // double dimensionedReactionRate = reactionRate * (1e-3 * m3 / (mole * s));
220 //
221 // double dimensionedActivationRate = activationRate
222 // * (1e-3 * m3 / (mole * s));
223 //
224 // G4DNAMolecularReactionData* reactionData =
225 // new G4DNAMolecularReactionData(dimensionedReactionRate,
226 // species1,
227 // species2);
228 // reactionData->
229 // SetPartiallyDiffusionControlledReactionByActivation(dimensionedReactionRate,
230 // dimensionedActivationRate);
231 //
232 // while(iss.eof() == false)
233 // {
234 // G4String product;
235 // iss >> product;
236 //
237 // if(product != "")
238 // {
239 // reactionData->AddProduct(product);
240 // }
241 // else
242 // {
243 // break;
244 // }
245 // }
246 //
247 // fpTable->SetReaction(reactionData);
248 // }
249  else if(command == fpPrintTable)
250  {
251  fpTable->PrintTable();
252  }
253  else if(command == fpAddReaction)
254  {
255  std::istringstream iss(newValue);
256 
257  //--------------------------------------------------------------------------
258  // Reactants definition
259 
260  G4String species1;
261  iss >> species1;
262 
263  G4String marker;
264  iss >> marker; // peut etre +, ->, |
265 
266  G4String species2;
267 
268  if(marker == "+")
269  {
270  iss >> species2;
271  iss >> marker; // peut etre ->, |
272  }
273 
274  //--------------------------------------------------------------------------
275 
276  G4DNAMolecularReactionData* reactionData =
278  species1,
279  species2);
280  //fpTable->SetReaction(reactionData);
281 
282  //--------------------------------------------------------------------------
283  // Add products
284  if(marker == "->")
285  {
286  iss >> marker; // doit etre = species name
287 
288  while(marker!="|"
289  //&& marker!=""
290  && iss.eof() == false
291  )
292  {
293  G4cout << marker << G4endl;
294  if(marker == "+")
295  {
296  iss >> marker; // doit etre species name
297  continue;
298  }
299  reactionData->AddProduct(marker);
300  iss >> marker; // peut etre species name, +, |
301  };
302  }
303 
304 // G4cout << "out of 1st loop" << G4endl;
305 
306  //--------------------------------------------------------------------------
307  // Add reaction rate method
308  G4String rateconst_method;
309  iss >> rateconst_method;
310  if(rateconst_method == "Fix")
311  {
312  iss >> marker; // must be |
313  double reactionRate;
314  iss >> reactionRate;
315 
316  double dimensionedReactionRate = reactionRate * (1e-3 * m3 / (mole * s));
317  reactionData->SetObservedReactionRateConstant(dimensionedReactionRate);
318 
319 // G4String productionRate;
320 // iss >> productionRate;
321 //
322 // if(productionRate != "" && productionRate != "X")
323 // {
324 // double prodRateReal = G4UIcommand::ConvertToDouble(productionRate);
325 //
326 // if(prodRateReal == 0 || isnan(prodRateReal))
327 // {
328 // G4Exception("G4ReactionTableMessenger",
329 // "WRONG_PRODUCTION_RATE",
330 // FatalException,
331 // "");
332 // }
333 //
334 // double dimensionedProductionRate = prodRateReal
335 // * (1e-3 * m3 / (mole * s));
336 // reactionData->SetProductionRate(dimensionedProductionRate);
337 // }
338  }
339  else if(rateconst_method == "Arr")
340  {
341  iss >> marker; // must be |
342  double A0 = 0;
343  double E_R = 0;
344 
345  iss >> A0;
346  iss >> E_R;
347  reactionData->SetArrehniusParameterization(A0, E_R);
348  }
349  else if(rateconst_method == "Pol")
350  {
351  iss >> marker; // must be |
352  std::vector<double> P = {0, 0, 0, 0, 0};
353 
354  size_t i = 0;
355  while(i < 4) // could be changed to 5 only if marker is used as delimiter
356  {
357  double tmp;
358  iss >> tmp;
359  P[i] = tmp;
360 // G4cout << newValue << G4endl;
361 // G4cout << tmp << G4endl;
362 // G4cout << P[i] << G4endl;
363  ++i;
364  };
365  reactionData->SetPolynomialParameterization(P);
366  }
367  else if(rateconst_method == "Scale")
368  {
369  iss >> marker; // must be |
370  double temp_K;
371  iss >> temp_K;
372  double reactionRateCste;
373  iss >> reactionRateCste;
374  double dimensionedReactionRate = reactionRateCste * (1e-3 * m3 / (mole * s));
375  reactionData->SetObservedReactionRateConstant(dimensionedReactionRate);
376  reactionData->SetScaledParameterization(temp_K, dimensionedReactionRate);
377  }
378 
379 // if(iss.eof() == false)
380 // {
381 // iss >> marker;
382 //
383 // if(marker == "|")
384 // {
385 // G4String productionRate ;
386 // iss >> productionRate;
387 //
389 //
390 // double dimProductionRate = G4UIcommand::ConvertToDouble(productionRate)* (1e-3 * m3 / (mole * s));
391 //
392 // G4cout << " DIM PROD RATE = " << reactionData->GetReactant1()->GetName()
393 // << " + " << reactionData->GetReactant2()->GetName() << " = " << dimProductionRate << G4endl;
394 //
395 // reactionData->SetProductionRate(dimProductionRate);
396 // }
397 // }
398  fpTable->SetReaction(reactionData);
399 // G4cout << "Reaction " << species1 << " + " << species2 << " added" << G4endl;
400  }
401 }
G4DNAMolecularReactionTable * fpTable
static constexpr double s
Definition: G4SIunits.hh:169
G4DNAMolecularReactionTable sorts out the G4DNAMolecularReactionData for bimolecular reaction...
static constexpr double m3
Definition: G4SIunits.hh:131
static double P[]
void SetReaction(G4double observedReactionRate, G4MolecularConfiguration *reactive1, G4MolecularConfiguration *reactive2)
Define a reaction : First argument : reaction rate Second argument : reactant 1 Third argument : reac...
virtual void SetNewValue(G4UIcommand *command, G4String newValue)
G4GLOB_DLL std::ostream G4cout
void SetArrehniusParameterization(double A0, double E_R)
void PrintTable(G4VDNAReactionModel *=0)
void AddProduct(G4MolecularConfiguration *molecule)
G4UIcmdWithAString * fpAddReaction
G4DNAMolecularReactionData contains the information relative to a given reaction (eg : °OH + °OH -> H...
G4UIcmdWithoutParameter * fpPrintTable
void SetObservedReactionRateConstant(G4double rate)
G4ReactionTableMessenger(G4DNAMolecularReactionTable *)
G4UIcmdWithAString * fpNewDiffContReaction
void SetPolynomialParameterization(const std::vector< double > &P)
void SetScaledParameterization(double temperature_K, double rateCste)
#define G4endl
Definition: G4ios.hh:61
static constexpr double mole
Definition: G4SIunits.hh:286