Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4ReactionTableMessenger Class Reference

#include <G4ReactionTableMessenger.hh>

+ Inheritance diagram for G4ReactionTableMessenger:

Public Member Functions

 G4ReactionTableMessenger (G4DNAMolecularReactionTable *)
 
 ~G4ReactionTableMessenger () override
 
void SetNewValue (G4UIcommand *command, G4String newValue) override
 
- Public Member Functions inherited from G4UImessenger
 G4UImessenger ()=default
 
 G4UImessenger (const G4String &path, const G4String &dsc, G4bool commandsToBeBroadcasted=true)
 
virtual ~G4UImessenger ()
 
virtual G4String GetCurrentValue (G4UIcommand *command)
 
G4bool CommandsShouldBeInMaster () const
 

Protected Attributes

G4DNAMolecularReactionTablefpTable
 
std::unique_ptr< G4UIcmdWithoutParameterfpActivateReactionUI
 
G4UIcmdWithAStringfpAddReaction
 
G4UIcmdWithAStringfpNewDiffContReaction
 
G4UIcmdWithoutParameterfpPrintTable
 
- Protected Attributes inherited from G4UImessenger
G4UIdirectorybaseDir = nullptr
 
G4String baseDirName = ""
 
G4bool commandsShouldBeInMaster = false
 

Additional Inherited Members

- Protected Member Functions inherited from G4UImessenger
G4String ItoS (G4int i)
 
G4String LtoS (G4long l)
 
G4String DtoS (G4double a)
 
G4String BtoS (G4bool b)
 
G4int StoI (const G4String &s)
 
G4long StoL (const G4String &s)
 
G4double StoD (const G4String &s)
 
G4bool StoB (G4String s)
 
void AddUIcommand (G4UIcommand *newCommand)
 
void CreateDirectory (const G4String &path, const G4String &dsc, G4bool commandsToBeBroadcasted=true)
 
template<typename T >
T * CreateCommand (const G4String &cname, const G4String &dsc)
 

Detailed Description

Definition at line 45 of file G4ReactionTableMessenger.hh.

Constructor & Destructor Documentation

◆ G4ReactionTableMessenger()

G4ReactionTableMessenger::G4ReactionTableMessenger ( G4DNAMolecularReactionTable * table)

Definition at line 44 of file G4ReactionTableMessenger.cc.

45 :
46 fpTable(table)
47 , fpActivateReactionUI(new G4UIcmdWithoutParameter("/chem/reaction/UI", this))
48{
49 fpNewDiffContReaction = new G4UIcmdWithAString("/chem/reaction/new", this);
50 fpAddReaction = new G4UIcmdWithAString("/chem/reaction/add", this);
51 fpPrintTable = new G4UIcmdWithoutParameter("/chem/reaction/print", this);
52}
G4UIcmdWithoutParameter * fpPrintTable
G4DNAMolecularReactionTable * fpTable
std::unique_ptr< G4UIcmdWithoutParameter > fpActivateReactionUI
G4UIcmdWithAString * fpNewDiffContReaction

◆ ~G4ReactionTableMessenger()

G4ReactionTableMessenger::~G4ReactionTableMessenger ( )
override

Definition at line 56 of file G4ReactionTableMessenger.cc.

57{
59 delete fpAddReaction;
60 delete fpPrintTable;
61}

Member Function Documentation

◆ SetNewValue()

void G4ReactionTableMessenger::SetNewValue ( G4UIcommand * command,
G4String newValue )
overridevirtual

Reimplemented from G4UImessenger.

Definition at line 64 of file G4ReactionTableMessenger.cc.

66{
67 if(command == fpActivateReactionUI.get())
68 {
69 //assert(false);
70 fpTable->Reset();//release reaction data
71 }
72
73 if(command == fpNewDiffContReaction)
74 {
75 std::istringstream iss(newValue);
76
77 G4String species1;
78 iss >> species1;
79
80 G4String species2;
81 iss >> species2;
82
83 double reactionRate;
84 iss >> reactionRate;
85
86// G4String reactionRateUnit;
87// iss >> reactionRateUnit;
88
89 double dimensionedReactionRate = reactionRate * (1e-3 * m3 / (mole * s));
90// G4UIcmdWithADoubleAndUnit::ConvertToDimensionedDouble((reactionRate
91// + G4String(" ") + reactionRateUnit).c_str());
92
93 auto reactionData =
94 new G4DNAMolecularReactionData(dimensionedReactionRate,
95 species1,
96 species2);
97
98// G4String productionRate;
99// iss >> productionRate;
100//
101// if(productionRate != "" && productionRate != "X")
102// {
103// double prodRateReal = G4UIcommand::ConvertToDouble(productionRate);
104//
105// if(prodRateReal == 0 || isnan(prodRateReal))
106// {
107// G4Exception("G4ReactionTableMessenger",
108// "WRONG_PRODUCTION_RATE",
109// FatalException, "");
110// }
111//
112// double dimensionedProductionRate = prodRateReal
113// * (1e-3 * m3 / (mole * s));
114// reactionData->SetProductionRate(dimensionedProductionRate);
115// }
116
117 while(!iss.eof())
118 {
119 G4String product;
120 iss >> product;
121
122 if(!product.empty())
123 {
124 reactionData->AddProduct(product);
125 }
126 else
127 {
128 break;
129 }
130 };
131
132 fpTable->SetReaction(reactionData);
133 }
134// else if(command == fpNewPartDiffContReactionByRadius)
135// {
136// std::istringstream iss(newValue);
137//
138// G4String species1;
139// iss >> species1;
140//
141// G4String species2;
142// iss >> species2;
143//
144// double reactionRate;
145// iss >> reactionRate;
146//
147//// G4String reactionRateUnit;
148//// iss >> reactionRateUnit;
149//
150//// G4String reactionRateUnit;
151//// iss >> reactionRateUnit;
152//
153// double reactionRadius;
154// iss >> reactionRadius;
155//
156//// G4String reactionRadiusUnit;
157//// iss >> reactionRadiusUnit;
158//
159// double dimensionedReactionRate = reactionRate * (1e-3 * m3 / (mole * s));
160//
161//// double dimensionedReactionRate =
162//// G4UIcmdWithADoubleAndUnit::ConvertToDimensionedDouble((reactionRate
163//// + " " + reactionRateUnit).c_str());
164//
165// double dimensionedReactionRadius = reactionRadius * nm;
166//// G4UIcmdWithADoubleAndUnit::ConvertToDimensionedDouble((reactionRadius
167//// + " " + reactionRadiusUnit).c_str());
168//
169// G4DNAMolecularReactionData* reactionData =
170// new G4DNAMolecularReactionData(dimensionedReactionRate,
171// species1,
172// species2);
173// reactionData->SetPartiallyDiffusionControlledReaction(dimensionedReactionRate,
174// dimensionedReactionRadius);
175//
176// while(iss.eof() == false)
177// {
178// G4String product;
179// iss >> product;
180//
181// if(product != "")
182// {
183// reactionData->AddProduct(product);
184// }
185// else
186// {
187// break;
188// }
189// }
190//
191// fpTable->SetReaction(reactionData);
192// }
193// else if(command == fpNewPartDiffContReactionByReactionRate)
194// {
195// std::istringstream iss(newValue);
196//
197// G4String species1;
198// iss >> species1;
199//
200// G4String species2;
201// iss >> species2;
202//
203// double reactionRate;
204// iss >> reactionRate;
205//
206// // G4String reactionRateUnit;
207// // iss >> reactionRateUnit;
208//
209// // G4String reactionRateUnit;
210// // iss >> reactionRateUnit;
211//
212// double activationRate;
213// iss >> activationRate;
214//
215// // G4String reactionRadiusUnit;
216// // iss >> reactionRadiusUnit;
217//
218// double dimensionedReactionRate = reactionRate * (1e-3 * m3 / (mole * s));
219//
220// double dimensionedActivationRate = activationRate
221// * (1e-3 * m3 / (mole * s));
222//
223// G4DNAMolecularReactionData* reactionData =
224// new G4DNAMolecularReactionData(dimensionedReactionRate,
225// species1,
226// species2);
227// reactionData->
228// SetPartiallyDiffusionControlledReactionByActivation(dimensionedReactionRate,
229// dimensionedActivationRate);
230//
231// while(iss.eof() == false)
232// {
233// G4String product;
234// iss >> product;
235//
236// if(product != "")
237// {
238// reactionData->AddProduct(product);
239// }
240// else
241// {
242// break;
243// }
244// }
245//
246// fpTable->SetReaction(reactionData);
247// }
248 else if(command == fpPrintTable)
249 {
251 }
252 else if(command == fpAddReaction)
253 {
254 std::istringstream iss(newValue);
255
256 //--------------------------------------------------------------------------
257 // Reactants definition
258
259 G4String species1;
260 iss >> species1;
261
262 G4String marker;
263 iss >> marker; // peut etre +, ->, |
264
265 G4String species2;
266
267 if(marker == "+")
268 {
269 iss >> species2;
270 iss >> marker; // peut etre ->, |
271 }
272
273 //--------------------------------------------------------------------------
274
275 auto reactionData =
277 species1,
278 species2);
279 //fpTable->SetReaction(reactionData);
280
281 //--------------------------------------------------------------------------
282 // Add products
283 if(marker == "->")
284 {
285 iss >> marker; // doit etre = species name
286
287 while(marker!="|"
288 //&& marker!=""
289 && !iss.eof()
290 )
291 {
292 //G4cout << marker << G4endl;
293 if(marker == "+")
294 {
295 iss >> marker; // doit etre species name
296 continue;
297 }
298 if(marker != "H2O")
299 {
300 reactionData->AddProduct(marker);
301 }
302
303 iss >> marker; // peut etre species name, +, |
304 };
305 }
306
307// G4cout << "out of 1st loop" << G4endl;
308
309 //--------------------------------------------------------------------------
310 // Add reaction rate method
311 G4String rateconst_method;
312 iss >> rateconst_method;
313 if(rateconst_method == "Fix")
314 {
315 iss >> marker; // must be |
316 double reactionRate;
317 iss >> reactionRate;
318
319 double dimensionedReactionRate = reactionRate * (1e-3 * m3 / (mole * s));
320 reactionData->SetObservedReactionRateConstant(dimensionedReactionRate);
321 reactionData->ComputeEffectiveRadius();
322 G4String markerType;
323 iss >> markerType; // must be |
324 if(markerType == "|")
325 {
326 G4int reactionType;
327 iss >> reactionType;
328 if(reactionType == 1)
329 {
330 reactionData->SetReactionType(reactionType);
331 }
332 }
333
334
335// G4String productionRate;
336// iss >> productionRate;
337//
338// if(productionRate != "" && productionRate != "X")
339// {
340// double prodRateReal = G4UIcommand::ConvertToDouble(productionRate);
341//
342// if(prodRateReal == 0 || isnan(prodRateReal))
343// {
344// G4Exception("G4ReactionTableMessenger",
345// "WRONG_PRODUCTION_RATE",
346// FatalException,
347// "");
348// }
349//
350// double dimensionedProductionRate = prodRateReal
351// * (1e-3 * m3 / (mole * s));
352// reactionData->SetProductionRate(dimensionedProductionRate);
353// }
354 }
355 else if(rateconst_method == "Arr")
356 {
357 iss >> marker; // must be |
358 double A0 = 0;
359 double E_R = 0;
360
361 iss >> A0;
362 iss >> E_R;
363 reactionData->SetArrehniusParameterization(A0, E_R);
364 }
365 else if(rateconst_method == "Pol")
366 {
367 iss >> marker; // must be |
368 std::vector<double> P = {0, 0, 0, 0, 0};
369
370 size_t i = 0;
371 while(i < 4) // could be changed to 5 only if marker is used as delimiter
372 {
373 double tmp;
374 iss >> tmp;
375 P[i] = tmp;
376// G4cout << newValue << G4endl;
377// G4cout << tmp << G4endl;
378// G4cout << P[i] << G4endl;
379 ++i;
380 };
381 reactionData->SetPolynomialParameterization(P);
382 }
383 else if(rateconst_method == "Scale")
384 {
385 iss >> marker; // must be |
386 double temp_K;
387 iss >> temp_K;
388 double reactionRateCste;
389 iss >> reactionRateCste;
390 double dimensionedReactionRate = reactionRateCste * (1e-3 * m3 / (mole * s));
391 reactionData->SetObservedReactionRateConstant(dimensionedReactionRate);
392 reactionData->SetScaledParameterization(temp_K, dimensionedReactionRate);
393 }
394
395// if(iss.eof() == false)
396// {
397// iss >> marker;
398//
399// if(marker == "|")
400// {
401// G4String productionRate ;
402// iss >> productionRate;
403//
404//// G4cout << productionRate << G4endl;
405//
406// double dimProductionRate = G4UIcommand::ConvertToDouble(productionRate)* (1e-3 * m3 / (mole * s));
407//
408// G4cout << " DIM PROD RATE = " << reactionData->GetReactant1()->GetName()
409// << " + " << reactionData->GetReactant2()->GetName() << " = " << dimProductionRate << G4endl;
410//
411// reactionData->SetProductionRate(dimProductionRate);
412// }
413// }
414 fpTable->SetReaction(reactionData);
415// G4cout << "Reaction " << species1 << " + " << species2 << " added" << G4endl;
416 }
417}
int G4int
Definition G4Types.hh:85
void SetReaction(G4double observedReactionRate, Reactant *reactive1, Reactant *reactive2)
void PrintTable(G4VDNAReactionModel *=nullptr)

Member Data Documentation

◆ fpActivateReactionUI

std::unique_ptr<G4UIcmdWithoutParameter> G4ReactionTableMessenger::fpActivateReactionUI
protected

Definition at line 54 of file G4ReactionTableMessenger.hh.

Referenced by SetNewValue().

◆ fpAddReaction

G4UIcmdWithAString* G4ReactionTableMessenger::fpAddReaction
protected

◆ fpNewDiffContReaction

G4UIcmdWithAString* G4ReactionTableMessenger::fpNewDiffContReaction
protected

◆ fpPrintTable

G4UIcmdWithoutParameter* G4ReactionTableMessenger::fpPrintTable
protected

◆ fpTable

G4DNAMolecularReactionTable* G4ReactionTableMessenger::fpTable
protected

Definition at line 53 of file G4ReactionTableMessenger.hh.

Referenced by SetNewValue().


The documentation for this class was generated from the following files: