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

#include <G4DNAMolecularReactionTable.hh>

+ Inheritance diagram for G4DNAMolecularReactionTable:

Public Types

using Reactant = const G4MolecularConfiguration
 
using Data = const G4DNAMolecularReactionData
 
using ReactantList = std::vector< Reactant * >
 
using DataList = std::vector< Data * >
 
using SpecificDataList = std::map< Reactant *, Data * >
 
using ReactionDataMap = std::map< Reactant *, SpecificDataList >
 
using ReactivesMV = std::map< Reactant *, ReactantList >
 
using ReactionDataMV = std::map< Reactant *, DataList >
 

Public Member Functions

virtual ~G4DNAMolecularReactionTable ()
 
void SetReaction (G4double observedReactionRate, Reactant *reactive1, Reactant *reactive2)
 
void SetReaction (G4DNAMolecularReactionData *)
 
DataGetReactionData (Reactant *, Reactant *) const
 
DataGetReactionData (const G4String &, const G4String &) const
 
DataGetReaction (int reactionID) const
 
size_t GetNReactions () const
 
const ReactantListCanReactWith (Reactant *) const
 
const SpecificDataListGetReativesNData (const G4MolecularConfiguration *) const
 
const DataListGetReactionData (const G4MolecularConfiguration *) const
 
const ReactionDataMapGetAllReactionData ()
 
DataList GetVectorOfReactionData ()
 
void ScaleReactionRateForNewTemperature (double temp_K)
 
void PrintTable (G4VDNAReactionModel *=0)
 
- Public Member Functions inherited from G4ITReactionTable
 G4ITReactionTable ()
 
virtual ~G4ITReactionTable ()
 
 G4ITReactionTable (const G4ITReactionTable &)
 
G4ITReactionTableoperator= (const G4ITReactionTable &)
 

Static Public Member Functions

static G4DNAMolecularReactionTableGetReactionTable ()
 
static G4DNAMolecularReactionTableInstance ()
 
static void DeleteInstance ()
 

Protected Member Functions

 G4DNAMolecularReactionTable ()
 

Protected Attributes

G4bool fVerbose
 
ReactionDataMap fReactionData
 
ReactivesMV fReactantsMV
 
ReactionDataMV fReactionDataMV
 
std::vector< std::unique_ptr< Data > > fVectorOfReactionData
 
std::unique_ptr< G4ReactionTableMessengerfpMessenger
 

Static Protected Attributes

static G4DNAMolecularReactionTablefpInstance
 

Detailed Description

G4DNAMolecularReactionTable sorts out the G4DNAMolecularReactionData for bimolecular reaction

Definition at line 174 of file G4DNAMolecularReactionTable.hh.

Member Typedef Documentation

◆ Data

◆ DataList

Definition at line 189 of file G4DNAMolecularReactionTable.hh.

◆ Reactant

◆ ReactantList

Definition at line 188 of file G4DNAMolecularReactionTable.hh.

◆ ReactionDataMap

◆ ReactionDataMV

◆ ReactivesMV

◆ SpecificDataList

Constructor & Destructor Documentation

◆ G4DNAMolecularReactionTable()

G4DNAMolecularReactionTable::G4DNAMolecularReactionTable ( )
protected

◆ ~G4DNAMolecularReactionTable()

G4DNAMolecularReactionTable::~G4DNAMolecularReactionTable ( )
virtualdefault

Member Function Documentation

◆ CanReactWith()

const G4DNAMolecularReactionTable::ReactantList * G4DNAMolecularReactionTable::CanReactWith ( Reactant pMolecule) const

Given a molecule's type, it returns with which a reaction is allowed

Definition at line 650 of file G4DNAMolecularReactionTable.cc.

651{
652 if (fReactantsMV.empty())
653 {
654 G4String errMsg = "No reaction table was implemented";
655 G4Exception("G4MolecularInteractionTable::CanReactWith", "",
656 FatalErrorInArgument, errMsg);
657 return 0;
658 }
659
660 auto itReactivesMap = fReactantsMV.find(pMolecule);
661
662 if (itReactivesMap == fReactantsMV.end())
663 {
664#ifdef G4VERBOSE
665 if (fVerbose)
666 {
667 G4String errMsg = "No reaction table was implemented for this molecule : "
668 + pMolecule->GetName();
669 // G4Exception("G4MolecularInteractionTable::CanReactWith","",FatalErrorInArgument, errMsg);
670 G4cout << "--- G4MolecularInteractionTable::GetReactionData ---" << G4endl;
671 G4cout << errMsg << G4endl;
672 }
673#endif
674 return nullptr;
675 }
676
677 if (fVerbose)
678 {
679 G4cout << " G4MolecularInteractionTable::CanReactWith :" << G4endl;
680 G4cout << "You are checking reactants for : " << pMolecule->GetName() << G4endl;
681 G4cout << " the number of reactants is : " << itReactivesMap->second.size() << G4endl;
682
683 auto itProductsVector = itReactivesMap->second.cbegin();
684
685 for (; itProductsVector != itReactivesMap->second.end(); itProductsVector++)
686 {
687 G4cout << (*itProductsVector)->GetName() << G4endl;
688 }
689 }
690 return &(itReactivesMap->second);
691}
@ FatalErrorInArgument
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout

Referenced by G4DNAIRTMoleculeEncounterStepper::CalculateStep(), G4DNAMoleculeEncounterStepper::CalculateStep(), PrintTable(), and G4DNAIRT::Sampling().

◆ DeleteInstance()

void G4DNAMolecularReactionTable::DeleteInstance ( )
static

Definition at line 371 of file G4DNAMolecularReactionTable.cc.

372{
373 if (fpInstance)
374 {
375 delete fpInstance;
376 }
377 fpInstance = nullptr;
378}
static G4DNAMolecularReactionTable * fpInstance

Referenced by G4DNAChemistryManager::Clear().

◆ GetAllReactionData()

const G4DNAMolecularReactionTable::ReactionDataMap & G4DNAMolecularReactionTable::GetAllReactionData ( )

Definition at line 630 of file G4DNAMolecularReactionTable.cc.

631{
632 return fReactionData;
633}

◆ GetNReactions()

size_t G4DNAMolecularReactionTable::GetNReactions ( ) const

Definition at line 824 of file G4DNAMolecularReactionTable.cc.

825{
826 return fVectorOfReactionData.size();
827}
std::vector< std::unique_ptr< Data > > fVectorOfReactionData

◆ GetReaction()

G4DNAMolecularReactionTable::Data * G4DNAMolecularReactionTable::GetReaction ( int  reactionID) const

Definition at line 812 of file G4DNAMolecularReactionTable.cc.

813{
814 for (auto& pData : fVectorOfReactionData)
815 {
816 if (pData->GetReactionID() == reactionID)
817 {
818 return pData.get();
819 }
820 }
821 return nullptr;
822}

◆ GetReactionData() [1/3]

const G4DNAMolecularReactionTable::DataList * G4DNAMolecularReactionTable::GetReactionData ( const G4MolecularConfiguration molecule) const

Definition at line 731 of file G4DNAMolecularReactionTable.cc.

732{
733 if (fReactionDataMV.empty())
734 {
735 G4String errMsg = "No reaction table was implemented";
736 G4Exception("G4MolecularInteractionTable::CanInteractWith", "",
737 FatalErrorInArgument, errMsg);
738 }
739 auto it = fReactionDataMV.find(molecule);
740
741 if (it == fReactionDataMV.end())
742 {
743 G4String errMsg = "No reaction table was implemented for this molecule Definition : "
744 + molecule->GetName();
745 G4Exception("G4MolecularInteractionTable::GetReactionData", "", FatalErrorInArgument, errMsg);
746 }
747
748 return &(it->second);
749}
const G4String & GetName() const

◆ GetReactionData() [2/3]

G4DNAMolecularReactionTable::Data * G4DNAMolecularReactionTable::GetReactionData ( const G4String mol1,
const G4String mol2 
) const

Definition at line 753 of file G4DNAMolecularReactionTable.cc.

755{
756 const auto pConf1 = G4MoleculeTable::GetMoleculeTable()->GetConfiguration(mol1);
757 const auto pConf2 = G4MoleculeTable::GetMoleculeTable()->GetConfiguration(mol2);
758 return GetReactionData(pConf1, pConf2);
759}
Data * GetReactionData(Reactant *, Reactant *) const
static G4MoleculeTable * GetMoleculeTable()
G4MolecularConfiguration * GetConfiguration(const G4String &, bool mustExist=true)

◆ GetReactionData() [3/3]

G4DNAMolecularReactionTable::Data * G4DNAMolecularReactionTable::GetReactionData ( Reactant pReactant1,
Reactant pReactant2 
) const

Definition at line 596 of file G4DNAMolecularReactionTable.cc.

598{
599 if (fReactionData.empty())
600 {
601 G4String errMsg = "No reaction table was implemented";
602 G4Exception("G4MolecularInteractionTable::GetReactionData", "",
603 FatalErrorInArgument, errMsg);
604 }
605
606 auto it1 = fReactionData.find(pReactant1);
607
608 if (it1 == fReactionData.end())
609 {
610 G4String errMsg =
611 "No reaction table was implemented for this molecule Definition : " + pReactant1
612 ->GetName();
613 G4Exception("G4MolecularInteractionTable::GetReactionData", "",
614 FatalErrorInArgument, errMsg);
615 }
616
617 ReactionDataMap::mapped_type::const_iterator it2 = it1->second.find(pReactant2);
618
619 if (it2 == it1->second.end())
620 {
621 G4cout << "Name : " << pReactant2->GetName() << G4endl;
622 G4String errMsg = "No reaction table was implemented for this molecule : "
623 + pReactant2->GetName();
624 G4Exception("G4MolecularInteractionTable::GetReactionData", "", FatalErrorInArgument, errMsg);
625 }
626
627 return (it2->second);
628}

Referenced by G4DNAIRT::GetIndependentReactionTime(), GetReactionData(), G4DNASmoluchowskiReactionModel::GetReactionRadius(), G4DNASmoluchowskiReactionModel::Initialise(), G4DNASmoluchowskiReactionModel::InitialiseToPrint(), G4DNAIRT::MakeReaction(), G4DNAMolecularReaction::MakeReaction(), and G4DNAIRT::Sampling().

◆ GetReactionTable()

◆ GetReativesNData()

const G4DNAMolecularReactionTable::SpecificDataList * G4DNAMolecularReactionTable::GetReativesNData ( const G4MolecularConfiguration molecule) const

Definition at line 696 of file G4DNAMolecularReactionTable.cc.

697{
698 if (fReactionData.empty())
699 {
700 G4String errMsg = "No reaction table was implemented";
701 G4Exception("G4MolecularInteractionTable::CanInteractWith", "",
702 FatalErrorInArgument, errMsg);
703 }
704
705 ReactionDataMap::const_iterator itReactivesMap = fReactionData.find(molecule);
706
707 if (itReactivesMap == fReactionData.end())
708 {
709 return nullptr;
710 }
711
712 if (fVerbose)
713 {
714 G4cout << " G4MolecularInteractionTable::CanReactWith :" << G4endl;
715 G4cout << "You are checking reactants for : " << molecule->GetName() << G4endl;
716 G4cout << " the number of reactants is : " << itReactivesMap->second.size() << G4endl;
717
718 SpecificDataList::const_iterator itProductsVector = itReactivesMap->second.begin();
719
720 for (; itProductsVector != itReactivesMap->second.end(); itProductsVector++)
721 {
722 G4cout << itProductsVector->first->GetName() << G4endl;
723 }
724 }
725 return &(itReactivesMap->second);
726}

◆ GetVectorOfReactionData()

G4DNAMolecularReactionTable::DataList G4DNAMolecularReactionTable::GetVectorOfReactionData ( )

Definition at line 635 of file G4DNAMolecularReactionTable.cc.

636{
637 DataList dataList;
638
639 for (const auto& pData : fVectorOfReactionData)
640 {
641 dataList.emplace_back(pData.get());
642 }
643
644 return dataList;
645}

◆ Instance()

G4DNAMolecularReactionTable * G4DNAMolecularReactionTable::Instance ( )
static

Definition at line 360 of file G4DNAMolecularReactionTable.cc.

361{
362 if (!fpInstance)
363 {
365 }
366 return fpInstance;
367}

Referenced by G4DNAChemistryManager::SetGlobalTemperature().

◆ PrintTable()

void G4DNAMolecularReactionTable::PrintTable ( G4VDNAReactionModel pReactionModel = 0)

Definition at line 423 of file G4DNAMolecularReactionTable.cc.

424{
425 // Print Reactions and Interaction radius for jump step = 3ps
426
427 G4IosFlagsSaver iosfs(G4cout);
428
429 if (pReactionModel && !(pReactionModel->GetReactionTable()))
430 {
431 pReactionModel->SetReactionTable(this);
432 }
433
434 ReactivesMV::iterator itReactives;
435
436 std::map<Reactant*, std::map<Reactant*, G4bool>> alreadyPrint;
437
438 G4cout << "Number of chemical species involved in reactions = "
439 << fReactantsMV.size() << G4endl;
440
441 G4int nbPrintable = fReactantsMV.size() * fReactantsMV.size();
442
443 G4String* outputReaction = new G4String[nbPrintable];
444 G4String* outputReactionRate = new G4String[nbPrintable];
445 G4String* outputRange = new G4String[nbPrintable];
446 G4int n = 0;
447
448 for (itReactives = fReactantsMV.begin(); itReactives != fReactantsMV.end();
449 itReactives++)
450 {
451 Reactant* moleculeA = (Reactant*)itReactives->first;
452 const vector<Reactant*>* reactivesVector = CanReactWith(moleculeA);
453
454 if (pReactionModel) pReactionModel->InitialiseToPrint(moleculeA);
455
456 G4int nbReactants = fReactantsMV[itReactives->first].size();
457
458 for (G4int iReact = 0; iReact < nbReactants; iReact++)
459 {
460 auto moleculeB = (Reactant*)(*reactivesVector)[iReact];
461
462 Data* reactionData = fReactionData[moleculeA][moleculeB];
463
464 //-----------------------------------------------------------
465 // Name of the reaction
466 if (!alreadyPrint[moleculeA][moleculeB])
467 {
468 outputReaction[n] = moleculeA->GetName() + " + " + moleculeB->GetName();
469
470 G4int nbProducts = reactionData->GetNbProducts();
471
472 if (nbProducts)
473 {
474 outputReaction[n] += " -> " + reactionData->GetProduct(0)->GetName();
475
476 for (G4int j = 1; j < nbProducts; j++)
477 {
478 outputReaction[n] += " + " + reactionData->GetProduct(j)->GetName();
479 }
480 }
481 else
482 {
483 outputReaction[n] += " -> No product";
484 }
485
486 //-----------------------------------------------------------
487 // Interaction Rate
488 outputReactionRate[n] = G4UIcommand::ConvertToString(
489 reactionData->GetObservedReactionRateConstant() / (1e-3 * m3 / (mole * s)));
490
491 //-----------------------------------------------------------
492 // Calculation of the Interaction Range
493 G4double interactionRange = -1;
494 if (pReactionModel) interactionRange =
495 pReactionModel->GetReactionRadius(iReact);
496
497 if (interactionRange != -1)
498 {
499 outputRange[n] = G4UIcommand::ConvertToString(
500 interactionRange / nanometer);
501 }
502 else
503 {
504 outputRange[n] = "";
505 }
506
507 alreadyPrint[moleculeB][moleculeA] = TRUE;
508 n++;
509 }
510 }
511 }
512 // G4cout<<"Number of possible reactions: "<< n << G4endl;
513
514 ////////////////////////////////////////////////////////////////////
515 // Tableau dynamique en fonction du nombre de caractere maximal dans
516 // chaque colonne
517 ////////////////////////////////////////////////////////////////////
518
519 G4int maxlengthOutputReaction = -1;
520 G4int maxlengthOutputReactionRate = -1;
521
522 for (G4int i = 0; i < n; i++)
523 {
524 if (maxlengthOutputReaction < (G4int)outputReaction[i].length())
525 {
526 maxlengthOutputReaction = outputReaction[i].length();
527 }
528 if (maxlengthOutputReactionRate < (G4int)outputReactionRate[i].length())
529 {
530 maxlengthOutputReactionRate = outputReactionRate[i].length();
531 }
532 }
533
534 maxlengthOutputReaction += 2;
535 maxlengthOutputReactionRate += 2;
536
537 if (maxlengthOutputReaction < 10) maxlengthOutputReaction = 10;
538 if (maxlengthOutputReactionRate < 30) maxlengthOutputReactionRate = 30;
539
540 G4String* title;
541
542 if (pReactionModel) title = new G4String[3];
543 else title = new G4String[2];
544
545 title[0] = "Reaction";
546 title[1] = "Reaction Rate [dm3/(mol*s)]";
547
548 if (pReactionModel) title[2] =
549 "Interaction Range for chosen reaction model [nm]";
550
551 G4cout << setfill(' ') << setw(maxlengthOutputReaction) << left << title[0]
552 << setw(maxlengthOutputReactionRate) << left << title[1];
553
554 if (pReactionModel) G4cout << setw(2) << left << title[2];
555
556 G4cout << G4endl;
557
558 G4cout.fill('-');
559 if (pReactionModel) G4cout.width(
560 maxlengthOutputReaction + 2 + maxlengthOutputReactionRate + 2
561 + (G4int)title[2].length());
562 else G4cout.width(maxlengthOutputReaction + 2 + maxlengthOutputReactionRate);
563 G4cout << "-" << G4endl;
564 G4cout.fill(' ');
565
566 for (G4int i = 0; i < n; i++)
567 {
568 G4cout << setw(maxlengthOutputReaction) << left << outputReaction[i]
569 << setw(maxlengthOutputReactionRate) << left
570 << outputReactionRate[i];
571
572 if (pReactionModel) G4cout << setw(2) << left << outputRange[i];
573
574 G4cout << G4endl;
575
576 G4cout.fill('-');
577 if (pReactionModel) G4cout.width(
578 maxlengthOutputReaction + 2 + maxlengthOutputReactionRate + 2
579 + (G4int)title[2].length());
580 else G4cout.width(
581 maxlengthOutputReaction + 2 + maxlengthOutputReactionRate);
582 G4cout << "-" << G4endl;
583 G4cout.fill(' ');
584 }
585
586 delete[] title;
587 delete[] outputReaction;
588 delete[] outputReactionRate;
589 delete[] outputRange;
590}
double G4double
Definition: G4Types.hh:83
int G4int
Definition: G4Types.hh:85
#define TRUE
Definition: Globals.hh:27
const G4MolecularConfiguration Reactant
const ReactantList * CanReactWith(Reactant *) const
const G4DNAMolecularReactionData Data
static G4String ConvertToString(G4bool boolVal)
Definition: G4UIcommand.cc:430
virtual void InitialiseToPrint(const G4MolecularConfiguration *)=0
const G4DNAMolecularReactionTable * GetReactionTable()
void SetReactionTable(const G4DNAMolecularReactionTable *)
virtual G4double GetReactionRadius(const G4MolecularConfiguration *, const G4MolecularConfiguration *)=0

Referenced by G4EmDNAChemistry_option2::ConstructTimeStepModel(), G4EmDNAChemistry::ConstructTimeStepModel(), G4EmDNAChemistry_option1::ConstructTimeStepModel(), and G4ReactionTableMessenger::SetNewValue().

◆ ScaleReactionRateForNewTemperature()

void G4DNAMolecularReactionTable::ScaleReactionRateForNewTemperature ( double  temp_K)

Definition at line 791 of file G4DNAMolecularReactionTable.cc.

792{
793 for (const auto& pData : fVectorOfReactionData)
794 {
795 const_cast<G4DNAMolecularReactionData*>(pData.get())->ScaleForNewTemperature(temp_K);
796 }
797}

Referenced by G4DNAChemistryManager::SetGlobalTemperature().

◆ SetReaction() [1/2]

void G4DNAMolecularReactionTable::SetReaction ( G4DNAMolecularReactionData pReactionData)

Definition at line 391 of file G4DNAMolecularReactionTable.cc.

392{
393 const auto pReactant1 = pReactionData->GetReactant1();
394 const auto pReactant2 = pReactionData->GetReactant2();
395
396 fReactionData[pReactant1][pReactant2] = pReactionData;
397 fReactantsMV[pReactant1].push_back(pReactant2);
398 fReactionDataMV[pReactant1].push_back(pReactionData);
399
400 if (pReactant1 != pReactant2)
401 {
402 fReactionData[pReactant2][pReactant1] = pReactionData;
403 fReactantsMV[pReactant2].push_back(pReactant1);
404 fReactionDataMV[pReactant2].push_back(pReactionData);
405 }
406
407 fVectorOfReactionData.emplace_back(pReactionData);
408 pReactionData->SetReactionID(fVectorOfReactionData.size());
409}

◆ SetReaction() [2/2]

void G4DNAMolecularReactionTable::SetReaction ( G4double  observedReactionRate,
Reactant reactive1,
Reactant reactive2 
)

Define a reaction : First argument : reaction rate Second argument : reactant 1 Third argument : reactant 2 Fourth argument : a std::vector holding the molecular products if this last argument is NULL then it will be interpreted as a reaction giving no products

Definition at line 413 of file G4DNAMolecularReactionTable.cc.

416{
417 auto reactionData = new G4DNAMolecularReactionData(reactionRate, pReactant1, pReactant2);
418 SetReaction(reactionData);
419}
void SetReaction(G4double observedReactionRate, Reactant *reactive1, Reactant *reactive2)

Referenced by G4EmDNAChemistry_option2::ConstructReactionTable(), G4EmDNAChemistry::ConstructReactionTable(), G4EmDNAChemistry_option1::ConstructReactionTable(), G4EmDNAChemistry_option3::ConstructReactionTable(), G4ReactionTableMessenger::SetNewValue(), and SetReaction().

Member Data Documentation

◆ fpInstance

G4DNAMolecularReactionTable * G4DNAMolecularReactionTable::fpInstance
staticprotected

Definition at line 178 of file G4DNAMolecularReactionTable.hh.

Referenced by DeleteInstance(), GetReactionTable(), and Instance().

◆ fpMessenger

std::unique_ptr<G4ReactionTableMessenger> G4DNAMolecularReactionTable::fpMessenger
protected

Definition at line 245 of file G4DNAMolecularReactionTable.hh.

◆ fReactantsMV

ReactivesMV G4DNAMolecularReactionTable::fReactantsMV
protected

Definition at line 242 of file G4DNAMolecularReactionTable.hh.

Referenced by CanReactWith(), PrintTable(), and SetReaction().

◆ fReactionData

ReactionDataMap G4DNAMolecularReactionTable::fReactionData
protected

◆ fReactionDataMV

ReactionDataMV G4DNAMolecularReactionTable::fReactionDataMV
protected

Definition at line 243 of file G4DNAMolecularReactionTable.hh.

Referenced by GetReactionData(), and SetReaction().

◆ fVectorOfReactionData

std::vector<std::unique_ptr<Data> > G4DNAMolecularReactionTable::fVectorOfReactionData
protected

◆ fVerbose

G4bool G4DNAMolecularReactionTable::fVerbose
protected

Definition at line 239 of file G4DNAMolecularReactionTable.hh.

Referenced by CanReactWith(), and GetReativesNData().


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