Geant4 11.4.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

 ~G4DNAMolecularReactionTable () override
void SetReaction (G4double observedReactionRate, Reactant *reactive1, Reactant *reactive2)
void SetReaction (G4DNAMolecularReactionData *)
void SetGeometry (G4VDNAMolecularGeometry *geometry)
G4VDNAMolecularGeometryGetGeometry () const
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 *=nullptr)
void Reset ()
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 {false}
G4VDNAMolecularGeometryfGeometry {nullptr}
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

Definition at line 387 of file G4DNAMolecularReactionTable.cc.

388 :
389 fpMessenger(new G4ReactionTableMessenger(this))
390{
391}
std::unique_ptr< G4ReactionTableMessenger > fpMessenger

Referenced by GetReactionTable(), and Instance().

◆ ~G4DNAMolecularReactionTable()

G4DNAMolecularReactionTable::~G4DNAMolecularReactionTable ( )
overridedefault

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 661 of file G4DNAMolecularReactionTable.cc.

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

Referenced by PrintTable().

◆ DeleteInstance()

void G4DNAMolecularReactionTable::DeleteInstance ( )
static

Definition at line 376 of file G4DNAMolecularReactionTable.cc.

377{
378
379
380 delete fpInstance;
381
382 fpInstance = nullptr;
383}
static G4DNAMolecularReactionTable * fpInstance

Referenced by G4DNAChemistryManager::Clear().

◆ GetAllReactionData()

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

Definition at line 641 of file G4DNAMolecularReactionTable.cc.

642{
643 return fReactionData;
644}

◆ GetGeometry()

G4VDNAMolecularGeometry * G4DNAMolecularReactionTable::GetGeometry ( ) const

Definition at line 599 of file G4DNAMolecularReactionTable.cc.

600{
601 return fGeometry;
602}

◆ GetNReactions()

size_t G4DNAMolecularReactionTable::GetNReactions ( ) const

Definition at line 840 of file G4DNAMolecularReactionTable.cc.

841{
842 return fVectorOfReactionData.size();
843}
std::vector< std::unique_ptr< Data > > fVectorOfReactionData

◆ GetReaction()

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

Definition at line 828 of file G4DNAMolecularReactionTable.cc.

829{
830 for (auto& pData : fVectorOfReactionData)
831 {
832 if (pData->GetReactionID() == reactionID)
833 {
834 return pData.get();
835 }
836 }
837 return nullptr;
838}

◆ GetReactionData() [1/3]

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

Definition at line 742 of file G4DNAMolecularReactionTable.cc.

743{
744 if (fReactionDataMV.empty())
745 {
746 G4String errMsg = "No reaction table was implemented";
747 G4Exception("G4MolecularInteractionTable::CanInteractWith", "",
748 FatalErrorInArgument, errMsg);
749 }
750 auto it = fReactionDataMV.find(molecule);
751
752 if (it == fReactionDataMV.end())
753 {
754 if (fVerbose) {
756 errMsg << "No reaction table was implemented for this molecule Definition : "
757 + molecule->GetName();
758 G4Exception(G4String("G4MolecularInteractionTable::GetReactionData"),
759 "", JustWarning, errMsg);
760 }
761 return nullptr;
762 }
763
764 return &(it->second);
765}
@ JustWarning
std::ostringstream G4ExceptionDescription
const G4String & GetName() const

◆ GetReactionData() [2/3]

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

Definition at line 769 of file G4DNAMolecularReactionTable.cc.

771{
772 const auto pConf1 = G4MoleculeTable::GetMoleculeTable()->GetConfiguration(mol1);
773 const auto pConf2 = G4MoleculeTable::GetMoleculeTable()->GetConfiguration(mol2);
774 return GetReactionData(pConf1, pConf2);
775}
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 605 of file G4DNAMolecularReactionTable.cc.

607{
608 if (fReactionData.empty())
609 {
610 G4String errMsg = "No reaction table was implemented";
611 G4Exception("G4MolecularInteractionTable::GetReactionData", "",
612 FatalErrorInArgument, errMsg);
613 }
614
615 auto it1 = fReactionData.find(pReactant1);
616
617 if (it1 == fReactionData.end())
618 {
619 if (fVerbose) {
621 errMsg << "No reaction table was implemented for this molecule Definition : "
622 + pReactant1->GetName();
623 G4Exception(G4String("G4MolecularInteractionTable::GetReactionData"),
624 "", JustWarning, errMsg);
625 }
626 return nullptr;
627 }
628
629 auto it2 = it1->second.find(pReactant2);
630
631 if (it2 == it1->second.end())
632 {
633 //no reactant should return nullptr reaction data (not an exception).
634 //This helps UI chemistry
635 return nullptr;
636 }
637
638 return (it2->second);
639}

Referenced by GetReactionData(), and G4DiffusionControlledReactionModel::GetTimeToEncounter().

◆ GetReactionTable()

◆ GetReativesNData()

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

Definition at line 707 of file G4DNAMolecularReactionTable.cc.

708{
709 if (fReactionData.empty())
710 {
711 G4String errMsg = "No reaction table was implemented";
712 G4Exception("G4MolecularInteractionTable::CanInteractWith", "",
713 FatalErrorInArgument, errMsg);
714 }
715
716 auto itReactivesMap = fReactionData.find(molecule);
717
718 if (itReactivesMap == fReactionData.end())
719 {
720 return nullptr;
721 }
722
723 if (fVerbose)
724 {
725 G4cout << " G4MolecularInteractionTable::CanReactWith :" << G4endl;
726 G4cout << "You are checking reactants for : " << molecule->GetName() << G4endl;
727 G4cout << " the number of reactants is : " << itReactivesMap->second.size() << G4endl;
728
729 auto itProductsVector = itReactivesMap->second.begin();
730
731 for (; itProductsVector != itReactivesMap->second.end(); itProductsVector++)
732 {
733 G4cout << itProductsVector->first->GetName() << G4endl;
734 }
735 }
736 return &(itReactivesMap->second);
737}

◆ GetVectorOfReactionData()

G4DNAMolecularReactionTable::DataList G4DNAMolecularReactionTable::GetVectorOfReactionData ( )

Definition at line 646 of file G4DNAMolecularReactionTable.cc.

647{
648 DataList dataList;
649
650 for (const auto& pData : fVectorOfReactionData)
651 {
652 dataList.emplace_back(pData.get());
653 }
654
655 return dataList;
656}

Referenced by G4ChemEquilibrium::Initialize().

◆ Instance()

◆ PrintTable()

void G4DNAMolecularReactionTable::PrintTable ( G4VDNAReactionModel * pReactionModel = nullptr)

Definition at line 427 of file G4DNAMolecularReactionTable.cc.

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

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

◆ Reset()

void G4DNAMolecularReactionTable::Reset ( )

Definition at line 845 of file G4DNAMolecularReactionTable.cc.

846{
847 fReactionData.clear();
848 fReactantsMV.clear();
849 fReactionDataMV.clear();
850 fVectorOfReactionData.clear();
851}

◆ ScaleReactionRateForNewTemperature()

void G4DNAMolecularReactionTable::ScaleReactionRateForNewTemperature ( double temp_K)

Definition at line 807 of file G4DNAMolecularReactionTable.cc.

808{
809 for (const auto& pData : fVectorOfReactionData)
810 {
811 const_cast<G4DNAMolecularReactionData*>(pData.get())->ScaleForNewTemperature(temp_K);
812 }
813}

Referenced by G4DNAChemistryManager::SetGlobalTemperature().

◆ SetGeometry()

void G4DNAMolecularReactionTable::SetGeometry ( G4VDNAMolecularGeometry * geometry)
inline

Definition at line 211 of file G4DNAMolecularReactionTable.hh.

211{fGeometry = geometry;};

◆ SetReaction() [1/2]

void G4DNAMolecularReactionTable::SetReaction ( G4DNAMolecularReactionData * pReactionData)

Definition at line 395 of file G4DNAMolecularReactionTable.cc.

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

◆ 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 417 of file G4DNAMolecularReactionTable.cc.

420{
421 auto reactionData = new G4DNAMolecularReactionData(reactionRate, pReactant1, pReactant2);
422 SetReaction(reactionData);
423}
void SetReaction(G4double observedReactionRate, Reactant *reactive1, Reactant *reactive2)

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

Member Data Documentation

◆ fGeometry

G4VDNAMolecularGeometry* G4DNAMolecularReactionTable::fGeometry {nullptr}
protected

Definition at line 246 of file G4DNAMolecularReactionTable.hh.

246{nullptr};

Referenced by GetGeometry(), and SetGeometry().

◆ 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 251 of file G4DNAMolecularReactionTable.hh.

Referenced by G4DNAMolecularReactionTable().

◆ fReactantsMV

ReactivesMV G4DNAMolecularReactionTable::fReactantsMV
protected

Definition at line 248 of file G4DNAMolecularReactionTable.hh.

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

◆ fReactionData

ReactionDataMap G4DNAMolecularReactionTable::fReactionData
protected

◆ fReactionDataMV

ReactionDataMV G4DNAMolecularReactionTable::fReactionDataMV
protected

Definition at line 249 of file G4DNAMolecularReactionTable.hh.

Referenced by GetReactionData(), Reset(), and SetReaction().

◆ fVectorOfReactionData

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

◆ fVerbose

G4bool G4DNAMolecularReactionTable::fVerbose {false}
protected

Definition at line 244 of file G4DNAMolecularReactionTable.hh.

244{false};

Referenced by CanReactWith(), GetReactionData(), GetReactionData(), and GetReativesNData().


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