Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 26 27 #include "ChemistryWorld.hh" 27 #include "ChemistryWorld.hh" 28 << 29 #include "G4DNABoundingBox.hh" 28 #include "G4DNABoundingBox.hh" 30 #include "G4DNAMolecularReactionTable.hh" 29 #include "G4DNAMolecularReactionTable.hh" 31 #include "G4MoleculeTable.hh" 30 #include "G4MoleculeTable.hh" 32 //....oooOO0OOooo........oooOO0OOooo........oo << 33 31 34 ChemistryWorld::ChemistryWorld() : G4VChemistr << 32 ChemistryWorld::ChemistryWorld() : G4VChemistryWorld(), G4UImessenger() { 35 { << 36 fpChemWoldDir = std::make_unique<G4UIdirecto 33 fpChemWoldDir = std::make_unique<G4UIdirectory>("/UHDR/env/", false); 37 fpChemWoldDir->SetGuidance("chemistry enviro 34 fpChemWoldDir->SetGuidance("chemistry environment commands"); 38 35 39 fpAddpH = std::make_unique<G4UIcmdWithADoubl 36 fpAddpH = std::make_unique<G4UIcmdWithADouble>("/UHDR/env/pH", this); 40 fpAddpH->SetGuidance("Add pH for water."); 37 fpAddpH->SetGuidance("Add pH for water."); 41 fpAddpH->SetParameterName("pH", false); 38 fpAddpH->SetParameterName("pH", false); 42 fpAddpH->SetToBeBroadcasted(false); 39 fpAddpH->SetToBeBroadcasted(false); 43 40 44 fpAddScavengerName = std::make_unique<G4UIcm << 41 fpAddScavengerName = >> 42 std::make_unique<G4UIcmdWithAString>("/UHDR/env/scavenger", this); 45 fpAddScavengerName->SetToBeBroadcasted(false 43 fpAddScavengerName->SetToBeBroadcasted(false); 46 44 47 fpTargetVolume = std::make_unique<G4UIcmdWit 45 fpTargetVolume = std::make_unique<G4UIcmdWithADoubleAndUnit>("/UHDR/env/volume", this); 48 fpTargetVolume->SetGuidance("Volume of water 46 fpTargetVolume->SetGuidance("Volume of water."); 49 fpTargetVolume->SetParameterName("Volume", f 47 fpTargetVolume->SetParameterName("Volume", false); 50 fpTargetVolume->AvailableForStates(G4State_P 48 fpTargetVolume->AvailableForStates(G4State_PreInit); 51 fpTargetVolume->SetToBeBroadcasted(false); 49 fpTargetVolume->SetToBeBroadcasted(false); 52 } 50 } 53 //....oooOO0OOooo........oooOO0OOooo........oo << 54 51 55 void ChemistryWorld::ConstructChemistryBoundar << 52 void ChemistryWorld::ConstructChemistryBoundary() { 56 { << 53 fHalfBox = 1.6 * um; // halfBox 57 fHalfBox = 1.6 * um; // halfBox << 54 std::initializer_list<G4double> l{fHalfBox, -fHalfBox, fHalfBox, 58 std::initializer_list<G4double> l{fHalfBox, << 55 -fHalfBox, fHalfBox, -fHalfBox}; 59 fpChemistryBoundary = std::make_unique<G4DNA 56 fpChemistryBoundary = std::make_unique<G4DNABoundingBox>(l); 60 } 57 } 61 //....oooOO0OOooo........oooOO0OOooo........oo << 62 58 63 void ChemistryWorld::SetNewValue(G4UIcommand* << 59 void ChemistryWorld::SetNewValue(G4UIcommand *command, G4String newValue) { 64 { << 65 if (command == fpAddpH.get()) { 60 if (command == fpAddpH.get()) { 66 fpH = fpAddpH->GetNewDoubleValue(newValue) 61 fpH = fpAddpH->GetNewDoubleValue(newValue); 67 ConstructChemistryComponents(); 62 ConstructChemistryComponents(); 68 } << 63 } else if (command == fpAddScavengerName.get()) { 69 else if (command == fpAddScavengerName.get() << 70 std::istringstream iss(newValue); 64 std::istringstream iss(newValue); 71 G4String species; 65 G4String species; 72 iss >> species; 66 iss >> species; 73 auto scavengerConf = G4MoleculeTable::Inst 67 auto scavengerConf = G4MoleculeTable::Instance()->GetConfiguration(species); 74 G4double concentraion; 68 G4double concentraion; 75 iss >> concentraion; 69 iss >> concentraion; 76 G4String unit; 70 G4String unit; 77 iss >> unit; 71 iss >> unit; 78 if (unit == "M") { 72 if (unit == "M") { 79 G4double ConcentrationInM = concentraion 73 G4double ConcentrationInM = concentraion / (mole * liter); 80 fpChemicalComponent[scavengerConf] = Con 74 fpChemicalComponent[scavengerConf] = ConcentrationInM; 81 } << 75 } else if (unit == "mM") { 82 else if (unit == "mM") { << 83 G4double ConcentrationInM = concentraion 76 G4double ConcentrationInM = concentraion / (mole * liter * 1e3); 84 fpChemicalComponent[scavengerConf] = Con 77 fpChemicalComponent[scavengerConf] = ConcentrationInM; 85 } << 78 } else if (unit == "uM") { 86 else if (unit == "uM") { << 87 G4double ConcentrationInM = concentraion 79 G4double ConcentrationInM = concentraion / (mole * liter * 1e6); 88 fpChemicalComponent[scavengerConf] = Con 80 fpChemicalComponent[scavengerConf] = ConcentrationInM; 89 } << 81 } else if (unit == "%") // only for O2 90 else if (unit == "%") // only for O2 << 91 { 82 { 92 G4double ConcentrationInM = (concentraio << 83 G4double ConcentrationInM = >> 84 (concentraion / 100) * 0.0013 / (mole * liter); 93 fpChemicalComponent[scavengerConf] = Con 85 fpChemicalComponent[scavengerConf] = ConcentrationInM; 94 } << 86 } else { 95 else { << 96 throw std::runtime_error("Unit should be 87 throw std::runtime_error("Unit should be in Molarity"); 97 } 88 } 98 } << 89 }else if (command == fpTargetVolume.get()) { 99 else if (command == fpTargetVolume.get()) { << 100 fHalfBox = G4UIcmdWithADoubleAndUnit::GetN 90 fHalfBox = G4UIcmdWithADoubleAndUnit::GetNewDoubleValue(newValue); 101 std::initializer_list<G4double> l{fHalfBox 91 std::initializer_list<G4double> l{fHalfBox, -fHalfBox, fHalfBox, 102 -fHalfBo 92 -fHalfBox, fHalfBox, -fHalfBox}; 103 fpChemistryBoundary = std::make_unique<G4D 93 fpChemistryBoundary = std::make_unique<G4DNABoundingBox>(l); 104 } 94 } >> 95 105 } 96 } 106 //....oooOO0OOooo........oooOO0OOooo........oo << 107 97 108 void ChemistryWorld::ConstructChemistryCompone << 98 void ChemistryWorld::ConstructChemistryComponents() { 109 { << 110 auto O2 = G4MoleculeTable::Instance()->GetCo 99 auto O2 = G4MoleculeTable::Instance()->GetConfiguration("O2"); 111 auto H2O = G4MoleculeTable::Instance()->GetC 100 auto H2O = G4MoleculeTable::Instance()->GetConfiguration("H2O"); 112 auto H3Op = G4MoleculeTable::Instance()->Get 101 auto H3Op = G4MoleculeTable::Instance()->GetConfiguration("H3Op(B)"); 113 auto OHm = G4MoleculeTable::Instance()->GetC 102 auto OHm = G4MoleculeTable::Instance()->GetConfiguration("OHm(B)"); 114 103 115 //////////////////////////////////////////// << 104 //////////////////////////////////////////////////////////////////// 116 // Water is defined from NIST material datab << 105 // Water is defined from NIST material database 117 // water 55.3 M, 9.9x10-8 M, and 9.9x10-8 M << 106 // water 55.3 M, 9.9x10-8 M, and 9.9x10-8 M 118 // water density = 18.01528 g/mol * 55.3 M << 107 // water density = 18.01528 g/mol * 55.3 M = 996.24498 g/l 119 // H3OpB density = 1 g/mol * 9.9x10-8 M << 108 // H3OpB density = 1 g/mol * 9.9x10-8 M 120 // OHmB density = 17.01528 g/mol * 9.9x10-8 << 109 // OHmB density = 17.01528 g/mol * 9.9x10-8 M 121 // O2B density = 15.999 g/mol * 2.58e-4 M << 110 // O2B density = 15.999 g/mol * 2.58e-4 M 122 //////////////////////////////////////////// << 111 ///////////////////////////////////////////////////////////////// 123 G4double pKw = 14; // at 25°C pK of water << 112 G4double pKw = 14; // at 25°C pK of water is 14 124 G4double waterMolarity = 55.3 / (mole * lite << 113 G4double waterMolarity = 55.3 / (mole * liter); // 55.3 M 125 fpChemicalComponent[H2O] = waterMolarity; 114 fpChemicalComponent[H2O] = waterMolarity; 126 115 127 G4double H3OpBMolarity = std::pow(10, -fpH) << 116 G4double H3OpBMolarity = std::pow(10, -fpH) / (mole * liter); // pH = 7 128 fpChemicalComponent[H3Op] = H3OpBMolarity; 117 fpChemicalComponent[H3Op] = H3OpBMolarity; 129 118 130 G4double OHmBMolarity = std::pow(10, -(pKw - << 119 G4double OHmBMolarity = std::pow(10, -(pKw - fpH)) / (mole * liter); // pH = 7 131 fpChemicalComponent[OHm] = OHmBMolarity; 120 fpChemicalComponent[OHm] = OHmBMolarity; 132 // oxygen 121 // oxygen 133 G4double O2Molarity = (0. / 100) * 0.0013 / 122 G4double O2Molarity = (0. / 100) * 0.0013 / (mole * liter); 134 fpChemicalComponent[O2] = O2Molarity; 123 fpChemicalComponent[O2] = O2Molarity; 135 } << 124 } 136 //....oooOO0OOooo........oooOO0OOooo........oo << 137