Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:58:08

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 //
0027 // Author: Mathieu Karamitros
0028 
0029 // The code is developed in the framework of the ESA AO7146
0030 //
0031 // We would be very happy hearing from you, send us your feedback! :)
0032 //
0033 // In order for Geant4-DNA to be maintained and still open-source,
0034 // article citations are crucial.
0035 // If you use Geant4-DNA chemistry and you publish papers about your software,
0036 // in addition to the general paper on Geant4-DNA:
0037 //
0038 // Int. J. Model. Simul. Sci. Comput. 1 (2010) 157–178
0039 //
0040 // we would be very happy if you could please also cite the following
0041 // reference papers on chemistry:
0042 //
0043 // J. Comput. Phys. 274 (2014) 841-882
0044 // Prog. Nucl. Sci. Tec. 2 (2011) 503-508
0045 
0046 #pragma once
0047 
0048 #include "G4ITReactionTable.hh"
0049 #include "G4MolecularConfiguration.hh"
0050 #include "G4ReferenceCast.hh"
0051 #include "G4VDNAMolecularGeometry.hh"
0052 #include <vector>
0053 #include <map>
0054 #include <functional>
0055 #include <memory>
0056 
0057 class G4VDNAReactionModel;
0058 class G4DNAMolecularReactionTable;
0059 class G4ReactionTableMessenger;
0060 
0061 /**
0062  * G4DNAMolecularReactionData contains the information
0063  * relative to a given reaction (eg : °OH + °OH -> H2O2)
0064  */
0065 class G4DNAMolecularReactionData
0066 {
0067 public:
0068     //----------------------------------------------------------------------------
0069 
0070     G4DNAMolecularReactionData(G4double reactionRate,
0071                                const G4MolecularConfiguration* reactive1,
0072                                const G4MolecularConfiguration* reactive2);
0073 
0074     G4DNAMolecularReactionData(G4double reactionRate,
0075                                const G4String& reactive1,
0076                                const G4String& reactive2);
0077     ~G4DNAMolecularReactionData();
0078 
0079     using Reactant = const G4MolecularConfiguration;
0080     using ReactantPair = std::pair<Reactant*, Reactant*>;
0081     using ReactionProducts = std::vector<Reactant*>;
0082 
0083     int GetReactionID() const;
0084     void SetReactionID(int ID);
0085 
0086     ReactantPair GetReactants();
0087 
0088     Reactant* GetReactant1() const;
0089     Reactant* GetReactant2() const;
0090 
0091     void SetObservedReactionRateConstant(G4double rate);
0092     G4double GetObservedReactionRateConstant() const;
0093     G4double GetActivationRateConstant() const;
0094     G4double GetDiffusionRateConstant() const;
0095 
0096     void SetReactionRadius(G4double radius);
0097     G4double GetReactionRadius() const;
0098 
0099     void SetEffectiveReactionRadius(G4double radius);
0100     G4double GetEffectiveReactionRadius() const;
0101     G4double GetOnsagerRadius() const;
0102 
0103     void SetProbability(G4double prob);
0104     G4double GetProbability() const;
0105 
0106     void SetReactionType(G4int type);
0107     G4int GetReactionType() const;
0108 
0109     void SetReactant1(Reactant* reactive);
0110     void SetReactant2(Reactant* reactive);
0111 
0112     void SetReactants(Reactant* reactive1,
0113                       Reactant* reactive2);
0114 
0115     void AddProduct(Reactant* molecule);
0116 
0117     void SetReactant1(const G4String& reactive);
0118     void SetReactant2(const G4String& reactive);
0119     void SetReactants(const G4String& reactive1, const G4String& reactive2);
0120     void AddProduct(const G4String& molecule);
0121 
0122     G4int GetNbProducts() const;
0123     Reactant* GetProduct(G4int i) const;
0124 
0125     const ReactionProducts* GetProducts() const;
0126     void RemoveProducts();
0127 
0128     //----------------------------------------------------------------------------
0129     // Temperature scaling
0130     using RateParam = std::function<double (double)>;
0131 
0132     static double PolynomialParam(double temp_K, std::vector<double> P);
0133     static double ArrehniusParam(double temp_K, std::vector<double> P);
0134     static double ScaledParameterization(double temp_K,
0135                                          double temp_init,
0136                                          double rateCste_init);
0137 
0138     void SetPolynomialParameterization(const std::vector<double>& P);
0139 
0140     void SetArrehniusParameterization(double A0, double E_R);
0141     void SetScaledParameterization(double temperature_K,
0142                                    double rateCste);
0143 
0144     void ScaleForNewTemperature(double temp_K);
0145 
0146     void ComputeEffectiveRadius();
0147 
0148 protected:
0149     G4DNAMolecularReactionData();
0150     Reactant* fpReactant1;
0151     Reactant* fpReactant2;
0152 
0153     G4double fObservedReactionRate;
0154     G4double fActivationRate;
0155     G4double fDiffusionRate;
0156 
0157     G4double fOnsagerRadius;
0158 
0159     G4double fReactionRadius;
0160     G4double fEffectiveReactionRadius;
0161 
0162     G4double fProbability;
0163     G4int fType;
0164 
0165     ReactionProducts fProducts;
0166     RateParam fRateParam;
0167     int fReactionID;
0168 };
0169 
0170 /**
0171  * G4DNAMolecularReactionTable sorts out the G4DNAMolecularReactionData
0172  * for bimolecular reaction
0173  */
0174 class G4DNAMolecularReactionTable : public G4ITReactionTable
0175 {
0176 protected:
0177     G4DNAMolecularReactionTable();
0178     static G4DNAMolecularReactionTable* fpInstance;
0179 
0180 public:
0181     static G4DNAMolecularReactionTable* GetReactionTable();
0182     static G4DNAMolecularReactionTable* Instance();
0183     static void DeleteInstance();
0184     ~G4DNAMolecularReactionTable() override;
0185 
0186     using Reactant = const G4MolecularConfiguration;
0187     using Data = const G4DNAMolecularReactionData;
0188     using ReactantList = std::vector<Reactant*>;
0189     using DataList = std::vector<Data*>;
0190     using SpecificDataList = std::map<Reactant*, Data*>;
0191 
0192     using ReactionDataMap = std::map<Reactant*, SpecificDataList>;
0193     using ReactivesMV = std::map<Reactant*, ReactantList>;
0194     using ReactionDataMV = std::map<Reactant*, DataList>;
0195 
0196     /**
0197      * Define a reaction :
0198      * First argument : reaction rate
0199      * Second argument : reactant 1
0200      * Third argument : reactant 2
0201      * Fourth argument : a std::vector holding the molecular products
0202      * if this last argument is NULL then it will be interpreted as
0203      * a reaction giving no products
0204      */
0205     void SetReaction(G4double observedReactionRate,
0206                      Reactant* reactive1,
0207                      Reactant* reactive2);
0208 
0209     void SetReaction(G4DNAMolecularReactionData*);
0210 
0211     void SetGeometry(G4VDNAMolecularGeometry* geometry){fGeometry = geometry;};
0212     G4VDNAMolecularGeometry* GetGeometry() const;
0213 
0214     Data* GetReactionData(Reactant*, Reactant*) const;
0215 
0216     Data* GetReactionData(const G4String&, const G4String&) const;
0217 
0218     Data* GetReaction(int reactionID) const;
0219 
0220     size_t GetNReactions() const;
0221 
0222     //_________________________________________________________________
0223     /**
0224      * Given a molecule's type, it returns with which a reaction is allowed
0225      */
0226     const ReactantList* CanReactWith(Reactant*) const;
0227 
0228     const SpecificDataList* GetReativesNData(const G4MolecularConfiguration*) const;
0229 
0230     const DataList* GetReactionData(const G4MolecularConfiguration*) const;
0231 
0232     const ReactionDataMap& GetAllReactionData();
0233 
0234     DataList GetVectorOfReactionData();
0235 
0236     void ScaleReactionRateForNewTemperature(double temp_K);
0237 
0238     //_________________________________________________________________
0239     void PrintTable(G4VDNAReactionModel* = nullptr);
0240 
0241     void Reset();
0242 
0243 protected:
0244     G4bool fVerbose{false};
0245 
0246     G4VDNAMolecularGeometry* fGeometry{nullptr};
0247     ReactionDataMap fReactionData;
0248     ReactivesMV     fReactantsMV;
0249     ReactionDataMV  fReactionDataMV;
0250     std::vector<std::unique_ptr<Data>> fVectorOfReactionData;
0251     std::unique_ptr<G4ReactionTableMessenger> fpMessenger;
0252 };