51 #define __func__ __FUNCTION__
68 return GetManager()->GetNumberOfCreatedSpecies();
83 fMoleculeDefinition = moleculeDef;
87 fMoleculeID = GetManager()->Insert(moleculeDef,
90 fElectronOccupancy = 0;
94 fDynMass = fMoleculeDefinition->GetMass();
96 fDynDiffusionCoefficient = fMoleculeDefinition->GetDiffusionCoefficient();
97 fDynVanDerVaalsRadius = fMoleculeDefinition->GetVanDerVaalsRadius();
98 fDynDecayTime = fMoleculeDefinition->GetDecayTime();
100 fName = fMoleculeDefinition->GetName();
104 fFormatedName = fMoleculeDefinition->GetFormatedName();
105 fFormatedName +=
"^";
106 fFormatedName +=
"{";
108 fFormatedName +=
"}";
111 fIsFinalized =
false;
119 errMsg <<
"This molecular configuration " << GetName()
120 <<
" is already finalized. Therefore its "
121 " properties cannot be changed.";
122 G4Exception(
"G4MolecularConfiguration::MakeExceptionIfFinalized",
155 G4MolecularConfigurationManager::MolElectronConfTable::iterator it1;
156 G4MolecularConfigurationManager::ElectronOccupancyTable::
159 for (it1 = fElecOccTable.begin(); it1 != fElecOccTable.end(); it1++)
161 for (it2 = it1->second.begin(); it2 != it1->second.end(); it2++)
169 fElecOccTable.clear();
184 ElectronOccupancyTable::iterator
it = table2.find(eOcc);
186 if(it == table2.end())
188 table2[eOcc] = molConf;
193 errMsg <<
"The same molecular configuration seemed to be recorded twice";
195 "SetMolecularConfiguration(const G4MoleculeDefinition* molDef,"
196 "const G4ElectronOccupancy& eOcc,"
197 "G4MolecularConfiguration* molConf)",
206 fMolConfPerID.push_back(molConf);
209 return fLastMoleculeID;
221 MolElectronConfTable::iterator it1 = fElecOccTable.find(molDef);
223 if(it1 == fElecOccTable.end())
230 ElectronOccupancyTable::iterator it2 = table2.find(eOcc);
234 if (it2 == table2.end())
240 return &(it2->first);
250 MolElectronConfTable::iterator it1 = fElecOccTable.find(molDef);
252 if(it1 == fElecOccTable.end())
return 0;
255 ElectronOccupancyTable::iterator
it = table2.find(eOcc);
257 if(it == table2.end())
279 ChargeTable::iterator
it = table2.find(charge);
281 if(it == table2.end())
289 errMsg <<
"The same molecular configuration seemed to be recorded twice";
291 "SetMolecularConfiguration(const G4MoleculeDefinition* molDef,"
293 "G4MolecularConfiguration* molConf)",
298 fMolConfPerID.push_back(molConf);
300 return fLastMoleculeID;
312 MolChargeConfTable::iterator it1 = fChargeTable.find(molDef);
314 if(it1 == fChargeTable.end())
return 0;
317 ChargeTable::iterator
it = table2.find(charge);
319 if(it == table2.end())
429 if (fgManager)
delete fgManager;
441 fMoleculeDefinition = moleculeDef;
443 fMoleculeID = GetManager()->Insert(moleculeDef,
446 fElectronOccupancy = GetManager()->FindCommonElectronOccupancy(moleculeDef,
457 - fElectronOccupancy->GetTotalOccupancy()
459 fDynMass = fMoleculeDefinition->GetMass();
461 fDynDiffusionCoefficient = fMoleculeDefinition->GetDiffusionCoefficient();
462 fDynVanDerVaalsRadius = fMoleculeDefinition->GetVanDerVaalsRadius();
463 fDynDecayTime = fMoleculeDefinition->GetDecayTime();
465 fName = fMoleculeDefinition->GetName();
469 fFormatedName = fMoleculeDefinition->GetFormatedName();
470 fFormatedName +=
"^";
471 fFormatedName +=
"{";
473 fFormatedName +=
"}";
484 fIsFinalized =
false;
493 fMoleculeDefinition = moleculeDef;
495 fMoleculeID = GetManager()->Insert(moleculeDef,
498 fElectronOccupancy = 0;
501 fDynMass = fMoleculeDefinition->GetMass();
503 fDynDiffusionCoefficient = fMoleculeDefinition->GetDiffusionCoefficient();
504 fDynVanDerVaalsRadius = fMoleculeDefinition->GetVanDerVaalsRadius();
505 fDynDecayTime = fMoleculeDefinition->GetDecayTime();
507 fName = fMoleculeDefinition->GetName();
511 fFormatedName = fMoleculeDefinition->GetFormatedName();
512 fFormatedName +=
"^";
513 fFormatedName +=
"{";
515 fFormatedName +=
"}";
521 fIsFinalized =
false;
528 if (fgManager) fgManager->RemoveMolecularConfigurationFromTable(
this);
548 newElectronOccupancy);
553 newElectronOccupancy);
590 CheckElectronOccupancy(__func__);
596 return ChangeConfiguration(newElectronOccupancy);
607 CheckElectronOccupancy(__func__);
610 if (newElectronOccupancy.
GetOccupancy(IonizedLevel) != 0)
616 G4String errMsg =
"There is no electron on the orbit "
618 +
" you want to free. The molecule's name you want to ionized is "
620 G4Exception(
"G4MolecularConfiguration::IonizeMolecule",
630 return ChangeConfiguration(newElectronOccupancy);
639 CheckElectronOccupancy(__func__);
642 return ChangeConfiguration(newElectronOccupancy);
652 CheckElectronOccupancy(__func__);
661 G4String errMsg =
"There is already no electron into the orbit "
663 +
" you want to free. The molecule's name is " + GetName();
664 G4Exception(
"G4MolecularConfiguration::RemoveElectron",
671 return ChangeConfiguration(newElectronOccupancy);
678 G4int orbitToFill)
const
681 CheckElectronOccupancy(__func__);
684 if (newElectronOccupancy.
GetOccupancy(orbitToFree) >= 1)
691 G4String errMsg =
"There is no electron on the orbit "
693 +
" you want to free. The molecule's name is " + GetName();
694 G4Exception(
"G4MolecularConfiguration::MoveOneElectron",
701 return ChangeConfiguration(newElectronOccupancy);
731 return fFormatedName;
738 return fMoleculeDefinition->GetAtomsNumber();
745 CheckElectronOccupancy(__func__);
746 return fElectronOccupancy->GetTotalOccupancy();
753 G4cout <<
"-------------- Start Printing State " << GetName()
754 <<
" ---------------" <<
G4endl;
756 if (fElectronOccupancy)
758 G4cout <<
"--------------Print electronic state of " << GetName()
759 <<
"---------------" <<
G4endl;
760 fElectronOccupancy->DumpInfo();
761 if(fElectronOccupancy==fMoleculeDefinition->GetGroundStateElectronOccupancy())
768 G4cout <<
"--- No electron occupancy set up ---" <<
G4endl;
781 G4cout <<
"-------------- End Of State " << GetName()
782 <<
" -----------------------" <<
G4endl;
788 const vector<const G4MolecularDissociationChannel*>*
792 return fMoleculeDefinition->GetDecayChannels(
this);
799 if(fMoleculeDefinition)
return fMoleculeDefinition->GetPDGEncoding();
800 else G4Exception(
"G4MolecularConfiguration::GetMoleculeID",
803 "You should first enter a molecule definition");
812 const char* pDelimeter = strrchr(path,
'\\');
813 if (pDelimeter) path = pDelimeter + 1;
815 pDelimeter = strrchr(path,
'/');
816 if (pDelimeter) path = pDelimeter + 1;
825 if (fElectronOccupancy == 0)
830 <<
"No G4ElectronOccupancy was defined for molecule definition : "
831 << fMoleculeDefinition->GetName()
832 <<
". The definition was probably defined using the charge state, "
833 "rather than electron state.";
848 LabelTable::iterator
it = tmpMap.find(*molConf->
fLabel);
850 if(it == tmpMap.end())
852 tmpMap[*(molConf->
fLabel)] = molConf;
857 errMsg <<
"The same molecular configuration seemed to be recorded twice";
859 "SetMolecularConfiguration(const G4MoleculeDefinition* molDef,"
860 "const G4String& label,"
861 "G4MolecularConfiguration* molConf)",
871 UserIDTable::iterator
it = fUserIDTable.find(userID);
873 if(it == fUserIDTable.end())
877 else if(molecule != it->second)
882 description <<
"The user identifier " << userID
883 <<
" was already given in another configuration in the table"
885 G4Exception(
"G4MolecularConfiguration::G4MolecularConfigurationManager::AddUserID",
886 "CONF_ALREADY_RECORDED",
897 MolElectronConfTable::iterator it1 =
899 MolElectronConfTable::iterator end = fElecOccTable.end();
901 if (it1 == end)
return;
903 std::map<G4ElectronOccupancy, G4MolecularConfiguration*, comparator>::
907 if (it2 == it1->second.end())
return;
924 MolLabelConfTable::iterator it1 = fLabelTable.find(molDef);
926 if(it1 == fLabelTable.end())
return 0;
930 LabelTable::iterator it2 = table2.find(label);
934 if(it2 == table2.end())
return 0;
944 if(moleculeID > (
int) fMolConfPerID.size() ||
945 moleculeID < 0)
return 0;
947 return fMolConfPerID[moleculeID];
960 LabelTable::iterator
it = tmpMap.find(label);
962 if(it == tmpMap.end())
965 tmpMap[label] = molConf;
972 errMsg <<
"The same molecular configuration seemed to be recorded twice";
974 "SetMolecularConfiguration(const G4MoleculeDefinition* molDef,"
975 "const G4String& label,"
976 "G4MolecularConfiguration* molConf)",
980 fMolConfPerID.push_back(molConf);
982 return fLastMoleculeID;
1009 bool& wasAlreadyCreated)
1011 wasAlreadyCreated =
false;
1021 wMsg <<
"The molecular configuration for the definition named "
1023 <<
" with charge " << charge <<
" has already been created "
1024 "but with NO label";
1025 G4Exception(
"G4MolecularConfiguration::CreateMolecularConfiguration",
1030 else if(*(molConf->
fLabel) ==
"" )
1034 else if(*(molConf->
fLabel) != label)
1037 errMsg <<
"The molecular configuration for the definition named "
1039 <<
" with charge " << charge <<
" has already been created "
1040 "but with a different label :"
1042 G4Exception(
"G4MolecularConfiguration::CreateMolecularConfiguration",
1054 wMsg <<
"The molecular configuration for the definition named "
1056 <<
" with label " << label <<
" has already been created.";
1057 G4Exception(
"G4MolecularConfiguration::CreateMolecularConfiguration",
1065 errMsg <<
"The molecular configuration for the definition named "
1067 <<
" with label " << label <<
" has already been created "
1068 "BUT with a different user ID :"
1070 G4Exception(
"G4MolecularConfiguration::CreateMolecularConfiguration",
1077 wasAlreadyCreated =
true;
1086 GetManager()->AddUserID(userIdentifier, newConf);
1100 bool& wasAlreadyCreated)
1102 wasAlreadyCreated =
false;
1106 if(preRegisteredMolConf)
1110 wasAlreadyCreated =
true;
1111 return preRegisteredMolConf;
1131 errMsg <<
"A molecular configuration for the definition named "
1132 << molDef->
GetName() <<
" has already been created "
1133 "and recorded with a different user ID "
1135 G4Exception(
"G4MolecularConfiguration::CreateMolecularConfiguration",
1142 errMsg <<
"A molecular configuration for the definition named "
1143 << molDef->
GetName() <<
" has already been created.";
1144 G4Exception(
"G4MolecularConfiguration::CreateMolecularConfiguration",
1148 wasAlreadyCreated =
true;
1158 GetManager()->AddUserID(userIdentifier, newConf);
1167 return CreateMolecularConfiguration(userIdentifier,
1182 bool& wasAlreadyCreated)
1184 assert(label !=
"");
1185 wasAlreadyCreated =
false;
1192 && *molConf->
fLabel == label)
1194 wasAlreadyCreated =
true;
1197 else if(molConf->
fLabel == 0)
1199 wasAlreadyCreated =
true;
1203 else if(*molConf->
fLabel ==
"")
1205 wasAlreadyCreated =
true;
1212 errMsg <<
"A molecular configuration for the definition named "
1214 <<
" has already been created "
1218 G4Exception(
"G4MolecularConfiguration::CreateMolecularConfiguration",
1232 GetManager()->AddUserID(userIdentifier, newConf);
1249 bool& wasAlreadyCreated)
1251 assert(label !=
"");
1252 wasAlreadyCreated =
false;
1265 wasAlreadyCreated =
true;
1268 else if(molConf->
fLabel == 0)
1270 wasAlreadyCreated =
true;
1274 else if(*molConf->
fLabel ==
"")
1276 wasAlreadyCreated =
true;
1286 errMsg <<
"A molecular configuration for the definition named "
1288 <<
" has already been created "
1291 <<
" and possible different electronic state";
1292 G4Exception(
"G4MolecularConfiguration::CreateMolecularConfiguration",
1305 GetManager()->AddUserID(userIdentifier, newConf);
1322 MolElectronConfTable::iterator it1 = fElecOccTable.find(molDef);
1324 if(it1 == fElecOccTable.end())
1330 ElectronOccupancyTable::iterator
it = table2.find(eOcc);
1332 if(it == table2.end())
1354 MolChargeConfTable::iterator it1 = fChargeTable.find(molDef);
1356 if(it1 == fChargeTable.end())
1365 ChargeTable::iterator
it = table2.find(charge);
1367 if(it == table2.end())
1388 G4String moleculeName = fMoleculeDefinition->GetName();
1389 WRITE(out, moleculeName);
1395 WRITE(out,fDynDiffusionCoefficient);
1396 WRITE(out,fDynVanDerVaalsRadius);
1397 WRITE(out,fDynDecayTime);
1398 WRITE(out,fDynMass);
1399 WRITE(out,fDynCharge);
1400 WRITE(out,fMoleculeID);
1401 WRITE(out,fFormatedName);
1403 WRITE(out,fIsFinalized);
1411 READ(in, moleculeName);
1412 fMoleculeDefinition =
1423 READ(in,fDynDiffusionCoefficient);
1424 READ(in,fDynVanDerVaalsRadius);
1425 READ(in,fDynDecayTime);
1427 READ(in,fDynCharge);
1428 READ(in,fMoleculeID);
1429 READ(in,fFormatedName);
1431 READ(in,fIsFinalized);
1447 fMoleculeDefinition = 0;
1448 fElectronOccupancy = 0;
1449 if(fElectronOccupancy)
1451 GetManager()->Insert(fMoleculeDefinition, *fElectronOccupancy,
this);
1452 fElectronOccupancy =
1453 GetManager()->FindCommonElectronOccupancy(fMoleculeDefinition,
1454 *fElectronOccupancy);
1458 GetManager()->RecordNewlyLabeledConfiguration(
this);
1463 fMoleculeID = GetManager()->Insert(fMoleculeDefinition, *fLabel,
this);
1467 fMoleculeID = GetManager()->Insert(fMoleculeDefinition, fDynCharge,
this);
1475 fUserIdentifier = userID;
1476 GetManager()->AddUserID(userID,
this);
1484 return pow(10, 4.311
1485 - 2.722
e3/temperature_K
1486 + 8.565
e5/(temperature_K *temperature_K)
1487 - 1.181e8/(temperature_K*temperature_K*temperature_K ))*1
e-9*
m2/
s;
1496 double D_water_0 = DiffCoeffWater(fgTemperature);
1497 double D_water_f = DiffCoeffWater(temperature_K);
1499 G4cout <<
"Scaling factor = " << D_water_f/D_water_0 <<
G4endl;
1508 double D_f = D_water_f * D_0 /D_water_0;
1517 if(
bool(fDiffParam) ==
false)
1527 ScaleAllDiffusionCoefficientsOnWater(temperature);
1528 fgTemperature = temperature;
1535 return fgTemperature;
1544 for(
auto it : fMolConfPerID)
1546 if(
it->GetUserID() == userID)
return it;
1563 const std::vector<G4MolecularConfiguration*>& species =
1564 GetManager()->GetAllSpecies();
1566 for(
size_t i = 0; i < species.size() ; ++i)
1568 species[i]->Finalize();