51#define __func__ __FUNCTION__
118 errMsg <<
"This molecular configuration " <<
GetName()
119 <<
" is already finalized. Therefore its "
120 " properties cannot be changed.";
121 G4Exception(
"G4MolecularConfiguration::MakeExceptionIfFinalized",
136 fgManager =
new G4MolecularConfiguration::
137 G4MolecularConfigurationManager();
154 G4MolecularConfigurationManager::MolElectronConfTable::iterator it1;
155 G4MolecularConfigurationManager::ElectronOccupancyTable::
158 for (it1 = fElecOccTable.begin(); it1 != fElecOccTable.end(); it1++)
160 for (it2 = it1->second.begin(); it2 != it1->second.end(); it2++)
168 fElecOccTable.clear();
182 ElectronOccupancyTable& table2 = fElecOccTable[molDef];
183 auto it = table2.find(eOcc);
185 if(it == table2.end())
187 table2[eOcc] = molConf;
192 errMsg <<
"The same molecular configuration seemed to be recorded twice";
194 "SetMolecularConfiguration(const G4MoleculeDefinition* molDef,"
195 "const G4ElectronOccupancy& eOcc,"
196 "G4MolecularConfiguration* molConf)",
205 fMolConfPerID.push_back(molConf);
208 return fLastMoleculeID;
220 auto it1 = fElecOccTable.find(molDef);
222 if(it1 == fElecOccTable.end())
228 ElectronOccupancyTable& table2 = it1->second;
229 auto it2 = table2.find(eOcc);
233 if (it2 == table2.end())
239 return &(it2->first);
249 auto it1 = fElecOccTable.find(molDef);
251 if(it1 == fElecOccTable.end())
return nullptr;
253 ElectronOccupancyTable& table2 = it1->second;
254 auto it = table2.find(eOcc);
256 if(it == table2.end())
273 ChargeTable& table2 = fChargeTable[molDef];
274 auto it = table2.find(charge);
276 if(it == table2.end())
278 table2[charge] = molConf;
284 errMsg <<
"The same molecular configuration seemed to be recorded twice";
286 "SetMolecularConfiguration(const G4MoleculeDefinition* molDef,"
288 "G4MolecularConfiguration* molConf)",
293 fMolConfPerID.push_back(molConf);
295 return fLastMoleculeID;
307 auto it1 = fChargeTable.find(molDef);
309 if(it1 == fChargeTable.end())
return nullptr;
311 ChargeTable& table2 = it1->second;
312 auto it = table2.find(charge);
314 if(it == table2.end())
336 if (molConf !=
nullptr)
344 newConf->SetUserID(molDef->
GetName());
350 if(molConf !=
nullptr)
357 newConf->SetUserID(molDef->
GetName());
395 if(molConf !=
nullptr)
529 newElectronOccupancy);
531 if (output ==
nullptr)
534 newElectronOccupancy);
547 if (output ==
nullptr)
591 if (newElectronOccupancy.
GetOccupancy(IonizedLevel) != 0)
597 G4String errMsg =
"There is no electron on the orbit "
599 +
" you want to free. The molecule's name you want to ionized is "
601 G4Exception(
"G4MolecularConfiguration::IonizeMolecule",
642 G4String errMsg =
"There is already no electron into the orbit "
644 +
" you want to free. The molecule's name is " +
GetName();
645 G4Exception(
"G4MolecularConfiguration::RemoveElectron",
659 G4int orbitToFill)
const
665 if (newElectronOccupancy.
GetOccupancy(orbitToFree) >= 1)
672 G4String errMsg =
"There is no electron on the orbit "
674 +
" you want to free. The molecule's name is " +
GetName();
675 G4Exception(
"G4MolecularConfiguration::MoveOneElectron",
718 G4cout <<
"-------------- Start Printing State " <<
GetName()
719 <<
" ---------------" <<
G4endl;
723 G4cout <<
"--------------Print electronic state of " <<
GetName()
724 <<
"---------------" <<
G4endl;
733 G4cout <<
"--- No electron occupancy set up ---" <<
G4endl;
747 <<
" -----------------------" <<
G4endl;
753const vector<const G4MolecularDissociationChannel*>*
765 G4Exception(
"G4MolecularConfiguration::GetMoleculeID",
768 "You should first enter a molecule definition");
777 const char* pDelimeter = strrchr(path,
'\\');
778 if (pDelimeter !=
nullptr) path = pDelimeter + 1;
780 pDelimeter = strrchr(path,
'/');
781 if (pDelimeter !=
nullptr) path = pDelimeter + 1;
795 <<
"No G4ElectronOccupancy was defined for molecule definition : "
797 <<
". The definition was probably defined using the charge state, "
798 "rather than electron state.";
813 auto it = tmpMap.find(*molConf->
fLabel);
815 if(it == tmpMap.end())
817 tmpMap[*(molConf->
fLabel)] = molConf;
822 errMsg <<
"The same molecular configuration seemed to be recorded twice";
824 "SetMolecularConfiguration(const G4MoleculeDefinition* molDef,"
825 "const G4String& label,"
826 "G4MolecularConfiguration* molConf)",
836 auto it = fUserIDTable.find(userID);
838 if(it == fUserIDTable.end())
840 fUserIDTable[userID] = molecule;
842 else if(molecule != it->second)
847 description <<
"The user identifier " << userID
848 <<
" was already given in another configuration in the table"
850 G4Exception(
"G4MolecularConfiguration::G4MolecularConfigurationManager::AddUserID",
851 "CONF_ALREADY_RECORDED",
864 auto end = fElecOccTable.end();
866 if (it1 == end)
return;
871 if (it2 == it1->second.end())
return;
888 auto it1 = fLabelTable.find(molDef);
890 if(it1 == fLabelTable.end())
return nullptr;
892 LabelTable& table2 = it1->second;
894 auto it2 = table2.find(label);
898 if(it2 == table2.end())
return nullptr;
908 if(moleculeID > (
int) fMolConfPerID.size() ||
909 moleculeID < 0)
return nullptr;
911 return fMolConfPerID[moleculeID];
923 LabelTable& tmpMap = fLabelTable[molDef];
924 auto it = tmpMap.find(label);
926 if(it == tmpMap.end())
929 tmpMap[label] = molConf;
936 errMsg <<
"The same molecular configuration seemed to be recorded twice";
938 "SetMolecularConfiguration(const G4MoleculeDefinition* molDef,"
939 "const G4String& label,"
940 "G4MolecularConfiguration* molConf)",
944 fMolConfPerID.push_back(molConf);
946 return fLastMoleculeID;
973 bool& wasAlreadyCreated)
975 wasAlreadyCreated =
false;
979 if (molConf !=
nullptr)
981 if(molConf->
fLabel ==
nullptr)
985 wMsg <<
"The molecular configuration for the definition named "
987 <<
" with charge " << charge <<
" has already been created "
989 G4Exception(
"G4MolecularConfiguration::CreateMolecularConfiguration",
994 else if(molConf->
fLabel->empty() )
998 else if(*(molConf->
fLabel) != label)
1001 errMsg <<
"The molecular configuration for the definition named "
1003 <<
" with charge " << charge <<
" has already been created "
1004 "but with a different label :"
1006 G4Exception(
"G4MolecularConfiguration::CreateMolecularConfiguration",
1018 wMsg <<
"The molecular configuration for the definition named "
1020 <<
" with label " << label <<
" has already been created.";
1021 G4Exception(
"G4MolecularConfiguration::CreateMolecularConfiguration",
1029 errMsg <<
"The molecular configuration for the definition named "
1031 <<
" with label " << label <<
" has already been created "
1032 "BUT with a different user ID :"
1034 G4Exception(
"G4MolecularConfiguration::CreateMolecularConfiguration",
1041 wasAlreadyCreated =
true;
1047 newConf->fUserIdentifier = userIdentifier;
1062 bool& wasAlreadyCreated)
1064 wasAlreadyCreated =
false;
1068 if(preRegisteredMolConf !=
nullptr)
1072 wasAlreadyCreated =
true;
1073 return preRegisteredMolConf;
1084 if(molConf !=
nullptr)
1093 errMsg <<
"A molecular configuration for the definition named "
1094 << molDef->
GetName() <<
" has already been created "
1095 "and recorded with a different user ID "
1097 G4Exception(
"G4MolecularConfiguration::CreateMolecularConfiguration",
1104 errMsg <<
"A molecular configuration for the definition named "
1105 << molDef->
GetName() <<
" has already been created.";
1106 G4Exception(
"G4MolecularConfiguration::CreateMolecularConfiguration",
1110 wasAlreadyCreated =
true;
1117 newConf->fUserIdentifier = userIdentifier;
1140 bool& wasAlreadyCreated)
1142 assert(label !=
"");
1143 wasAlreadyCreated =
false;
1147 if(molConf !=
nullptr)
1149 if((molConf->
fLabel !=
nullptr)
1150 && *molConf->
fLabel == label)
1152 wasAlreadyCreated =
true;
1155 if(molConf->
fLabel ==
nullptr)
1157 wasAlreadyCreated =
true;
1161 if(molConf->
fLabel->empty())
1163 wasAlreadyCreated =
true;
1170 errMsg <<
"A molecular configuration for the definition named "
1172 <<
" has already been created "
1176 G4Exception(
"G4MolecularConfiguration::CreateMolecularConfiguration",
1188 newConf->fUserIdentifier = userIdentifier;
1207 bool& wasAlreadyCreated)
1209 assert(label !=
"");
1210 wasAlreadyCreated =
false;
1215 if(molConf !=
nullptr)
1221 if((molConf->
fLabel !=
nullptr) && *molConf->
fLabel == label)
1223 wasAlreadyCreated =
true;
1226 if(molConf->
fLabel ==
nullptr)
1228 wasAlreadyCreated =
true;
1232 if(molConf->
fLabel->empty())
1234 wasAlreadyCreated =
true;
1244 errMsg <<
"A molecular configuration for the definition named "
1246 <<
" has already been created "
1249 <<
" and possible different electronic state";
1250 G4Exception(
"G4MolecularConfiguration::CreateMolecularConfiguration",
1261 newConf->fUserIdentifier = userIdentifier;
1280 auto it1 = fElecOccTable.find(molDef);
1282 if(it1 == fElecOccTable.end())
1287 ElectronOccupancyTable& table2 = it1->second;
1288 auto it = table2.find(eOcc);
1290 if(it == table2.end())
1308 auto it1 = fChargeTable.find(molDef);
1310 if(it1 == fChargeTable.end())
1318 ChargeTable& table2 = it1->second;
1319 auto it = table2.find(charge);
1321 if(it == table2.end())
1339 WRITE(out, moleculeName);
1361 READ(in, moleculeName);
1411 else if(
fLabel !=
nullptr)
1434 return pow(10, 4.311
1435 - 2.722e3/temperature_K
1436 + 8.565e5/(temperature_K *temperature_K)
1437 - 1.181e8/(temperature_K*temperature_K*temperature_K ))*1e-9*m2/s;
1449 G4cout <<
"Scaling factor = " << D_water_f/D_water_0 <<
G4endl;
1458 double D_f = D_water_f * D_0 /D_water_0;
1494 for(
auto it : fMolConfPerID)
1496 if(it->GetUserID() == userID)
return it;
1513 const std::vector<G4MolecularConfiguration*>& species =
1516 for(
auto specie : species)
1525 const std::vector<G4MolecularConfiguration*>& species =
1528 G4cout<<
"Molecular Config"<<std::setw(25)<<
" | Diffusion Coefficient (m2 / s) "<<std::setw(20)<<
" | Radius (nm) "<<
G4endl;
1529 G4cout<<
"__________________________________________"
1530 "___________________________________"<<
G4endl;
1531 for(
auto specie : species)
1533 G4cout<<specie->GetName()
1534 <<std::setw(
G4int(30 - specie->GetName().length()))
1535 <<right<<specie->GetDiffusionCoefficient() * 1.0e3<<std::setw(30)
1536 <<specie->GetVanDerVaalsRadius()/CLHEP::nm<<
G4endl;
1537 G4cout<<
"__________________________________________"
1538 "___________________________________"<<
G4endl;
G4double(*)(G4double) function
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
const char * removePath(const char *path)
void WRITE(std::ostream &out, const T &toBeSaved)
void READ(std::istream &in, T &toBeSaved)
G4GLOB_DLL std::ostream G4cout
G4int GetTotalOccupancy() const
G4int AddElectron(G4int orbit, G4int number=1)
G4int RemoveElectron(G4int orbit, G4int number=1)
G4int GetOccupancy(G4int orbit) const
void RemoveMolecularConfigurationFromTable(G4MolecularConfiguration *)
const G4ElectronOccupancy * FindCommonElectronOccupancy(const G4MoleculeDefinition *molDef, const G4ElectronOccupancy &eOcc)
G4int Insert(const G4MoleculeDefinition *molDef, const G4ElectronOccupancy &eOcc, G4MolecularConfiguration *molConf)
const std::vector< G4MolecularConfiguration * > & GetAllSpecies()
void RecordNewlyLabeledConfiguration(G4MolecularConfiguration *molConf)
int GetNumberOfCreatedSpecies()
G4MolecularConfiguration * GetOrCreateMolecularConfiguration(const G4MoleculeDefinition *molDef, const G4ElectronOccupancy &eOcc)
static G4Mutex fManagerCreationMutex
G4MolecularConfiguration * GetMolecularConfiguration(const G4MoleculeDefinition *molDef, const G4ElectronOccupancy &eOcc)
~G4MolecularConfigurationManager()
void AddUserID(const G4String &name, G4MolecularConfiguration *molecule)
void SetDiffusionCoefficient(G4double)
static G4MolecularConfiguration * Load(std::istream &)
static int GetNumberOfSpecies()
void CreateDefaultDiffCoeffParam()
void SetUserID(const G4String &userID)
static G4MolecularConfigurationManager * GetManager()
void MakeExceptionIfFinalized()
const G4String & GetName() const
const G4ElectronOccupancy * fElectronOccupancy
G4MolecularConfiguration * IonizeMolecule(G4int) const
static void FinalizeAll()
void SetLabel(const G4String &)
const G4String & GetLabel() const
G4MolecularConfiguration * ChangeConfiguration(const G4ElectronOccupancy &newElectronOccupancy) const
G4MolecularConfiguration & operator=(G4MolecularConfiguration &right)
G4MolecularConfiguration * RemoveElectron(G4int, G4int number=1) const
const G4MoleculeDefinition * GetDefinition() const
static void ScaleAllDiffusionCoefficientsOnWater(double temperature_K)
G4double fDynDiffusionCoefficient
G4int GetFakeParticleID() const
static void DeleteManager()
G4MolecularConfiguration * MoveOneElectron(G4int, G4int) const
~G4MolecularConfiguration()
G4double fDynVanDerVaalsRadius
static double ReturnDefaultDiffCoeff(const G4Material *, double, const G4MolecularConfiguration *molConf)
void Unserialize(std::istream &)
const G4MoleculeDefinition * fMoleculeDefinition
static double fgTemperature
static void SetGlobalTemperature(G4double)
void Serialize(std::ostream &)
static G4MolecularConfiguration * GetOrCreateMolecularConfiguration(const G4MoleculeDefinition *)
const G4ElectronOccupancy * GetElectronOccupancy() const
void CheckElectronOccupancy(const char *line) const
const std::vector< const G4MolecularDissociationChannel * > * GetDissociationChannels() const
const G4String & GetFormatedName() const
static G4MolecularConfigurationManager * fgManager
G4MolecularConfiguration(const G4MoleculeDefinition *, const G4ElectronOccupancy &, const G4String &label="")
G4double GetNbElectrons() const
static G4MolecularConfiguration * GetMolecularConfiguration(const G4MoleculeDefinition *, const G4String &label)
G4MolecularConfiguration * ExciteMolecule(G4int) const
static double DiffCoeffWater(double temperature_K)
G4DiffCoeffParam fDiffParam
G4MolecularConfiguration * AddElectron(G4int orbit, G4int n=1) const
G4double GetDiffusionCoefficient() const
static G4double GetGlobalTemperature()
static G4MolecularConfiguration * CreateMolecularConfiguration(const G4String &userIdentifier, const G4MoleculeDefinition *, bool &wasAlreadyCreated)
G4int GetAtomsNumber() const
const G4ElectronOccupancy * GetGroundStateElectronOccupancy() const
const G4String & GetName() const
G4int GetAtomsNumber() const
const G4String & GetFormatedName() const
G4double GetVanDerVaalsRadius() const
G4double GetDecayTime() const
G4double GetDiffusionCoefficient() const
G4int GetNbElectrons() const
const std::vector< const G4MolecularDissociationChannel * > * GetDecayChannels(const G4MolecularConfiguration *) const
G4MoleculeDefinition * GetMoleculeDefinition(const G4String &, bool mustExist=true)
static G4MoleculeTable * Instance()
G4ConfigurationIterator GetConfigurationIterator()
G4int GetPDGEncoding() const
static G4String ConvertToString(G4bool boolVal)