50#define __func__ __FUNCTION__
117 errMsg <<
"This molecular configuration " <<
GetName()
118 <<
" is already finalized. Therefore its "
119 " properties cannot be changed.";
120 G4Exception(
"G4MolecularConfiguration::MakeExceptionIfFinalized",
135 fgManager =
new G4MolecularConfiguration::
136 G4MolecularConfigurationManager();
149 G4MolecularConfigurationManager::MolElectronConfTable::iterator it1;
150 G4MolecularConfigurationManager::ElectronOccupancyTable::
153 for (it1 = fElecOccTable.begin(); it1 != fElecOccTable.end(); it1++)
155 for (it2 = it1->second.begin(); it2 != it1->second.end(); it2++)
163 fElecOccTable.clear();
177 ElectronOccupancyTable& table2 = fElecOccTable[molDef];
178 auto it = table2.find(eOcc);
180 if(it == table2.end())
182 table2[eOcc] = molConf;
187 errMsg <<
"The same molecular configuration seemed to be recorded twice";
189 "SetMolecularConfiguration(const G4MoleculeDefinition* molDef,"
190 "const G4ElectronOccupancy& eOcc,"
191 "G4MolecularConfiguration* molConf)",
200 fMolConfPerID.push_back(molConf);
203 return fLastMoleculeID;
215 auto it1 = fElecOccTable.find(molDef);
217 if(it1 == fElecOccTable.end())
223 ElectronOccupancyTable& table2 = it1->second;
224 auto it2 = table2.find(eOcc);
228 if (it2 == table2.end())
234 return &(it2->first);
244 auto it1 = fElecOccTable.find(molDef);
246 if(it1 == fElecOccTable.end())
return nullptr;
248 ElectronOccupancyTable& table2 = it1->second;
249 auto it = table2.find(eOcc);
251 if(it == table2.end())
268 ChargeTable& table2 = fChargeTable[molDef];
269 auto it = table2.find(charge);
271 if(it == table2.end())
273 table2[charge] = molConf;
279 errMsg <<
"The same molecular configuration seemed to be recorded twice";
281 "SetMolecularConfiguration(const G4MoleculeDefinition* molDef,"
283 "G4MolecularConfiguration* molConf)",
288 fMolConfPerID.push_back(molConf);
290 return fLastMoleculeID;
302 auto it1 = fChargeTable.find(molDef);
304 if(it1 == fChargeTable.end())
return nullptr;
306 ChargeTable& table2 = it1->second;
307 auto it = table2.find(charge);
309 if(it == table2.end())
331 if (molConf !=
nullptr)
339 newConf->SetUserID(molDef->
GetName());
345 if(molConf !=
nullptr)
352 newConf->SetUserID(molDef->
GetName());
390 if(molConf !=
nullptr)
515 newElectronOccupancy);
517 if (output ==
nullptr)
520 newElectronOccupancy);
533 if (output ==
nullptr)
577 if (newElectronOccupancy.
GetOccupancy(IonizedLevel) != 0)
583 G4String errMsg =
"There is no electron on the orbit "
585 +
" you want to free. The molecule's name you want to ionized is "
587 G4Exception(
"G4MolecularConfiguration::IonizeMolecule",
628 G4String errMsg =
"There is already no electron into the orbit "
630 +
" you want to free. The molecule's name is " +
GetName();
631 G4Exception(
"G4MolecularConfiguration::RemoveElectron",
645 G4int orbitToFill)
const
651 if (newElectronOccupancy.
GetOccupancy(orbitToFree) >= 1)
658 G4String errMsg =
"There is no electron on the orbit "
660 +
" you want to free. The molecule's name is " +
GetName();
661 G4Exception(
"G4MolecularConfiguration::MoveOneElectron",
704 G4cout <<
"-------------- Start Printing State " <<
GetName()
705 <<
" ---------------" <<
G4endl;
709 G4cout <<
"--------------Print electronic state of " <<
GetName()
710 <<
"---------------" <<
G4endl;
719 G4cout <<
"--- No electron occupancy set up ---" <<
G4endl;
733 <<
" -----------------------" <<
G4endl;
739const vector<const G4MolecularDissociationChannel*>*
751 G4Exception(
"G4MolecularConfiguration::GetMoleculeID",
754 "You should first enter a molecule definition");
763 const char* pDelimeter = strrchr(path,
'\\');
764 if (pDelimeter !=
nullptr) path = pDelimeter + 1;
766 pDelimeter = strrchr(path,
'/');
767 if (pDelimeter !=
nullptr) path = pDelimeter + 1;
781 <<
"No G4ElectronOccupancy was defined for molecule definition : "
783 <<
". The definition was probably defined using the charge state, "
784 "rather than electron state.";
799 auto it = tmpMap.find(*molConf->
fLabel);
801 if(it == tmpMap.end())
803 tmpMap[*(molConf->
fLabel)] = molConf;
808 errMsg <<
"The same molecular configuration seemed to be recorded twice";
810 "SetMolecularConfiguration(const G4MoleculeDefinition* molDef,"
811 "const G4String& label,"
812 "G4MolecularConfiguration* molConf)",
822 auto it = fUserIDTable.find(userID);
824 if(it == fUserIDTable.end())
826 fUserIDTable[userID] = molecule;
828 else if(molecule != it->second)
833 description <<
"The user identifier " << userID
834 <<
" was already given in another configuration in the table"
836 G4Exception(
"G4MolecularConfiguration::G4MolecularConfigurationManager::AddUserID",
837 "CONF_ALREADY_RECORDED",
850 auto end = fElecOccTable.end();
852 if (it1 == end)
return;
857 if (it2 == it1->second.end())
return;
874 auto it1 = fLabelTable.find(molDef);
876 if(it1 == fLabelTable.end())
return nullptr;
878 LabelTable& table2 = it1->second;
880 auto it2 = table2.find(label);
884 if(it2 == table2.end())
return nullptr;
894 if(moleculeID > (
int) fMolConfPerID.size() ||
895 moleculeID < 0)
return nullptr;
897 return fMolConfPerID[moleculeID];
909 LabelTable& tmpMap = fLabelTable[molDef];
910 auto it = tmpMap.find(label);
912 if(it == tmpMap.end())
915 tmpMap[label] = molConf;
922 errMsg <<
"The same molecular configuration seemed to be recorded twice";
924 "SetMolecularConfiguration(const G4MoleculeDefinition* molDef,"
925 "const G4String& label,"
926 "G4MolecularConfiguration* molConf)",
930 fMolConfPerID.push_back(molConf);
932 return fLastMoleculeID;
959 bool& wasAlreadyCreated)
961 wasAlreadyCreated =
false;
965 if (molConf !=
nullptr)
967 if(molConf->
fLabel ==
nullptr)
971 wMsg <<
"The molecular configuration for the definition named "
973 <<
" with charge " << charge <<
" has already been created "
975 G4Exception(
"G4MolecularConfiguration::CreateMolecularConfiguration",
980 else if(molConf->
fLabel->empty() )
984 else if(*(molConf->
fLabel) != label)
987 errMsg <<
"The molecular configuration for the definition named "
989 <<
" with charge " << charge <<
" has already been created "
990 "but with a different label :"
992 G4Exception(
"G4MolecularConfiguration::CreateMolecularConfiguration",
1004 wMsg <<
"The molecular configuration for the definition named "
1006 <<
" with label " << label <<
" has already been created.";
1007 G4Exception(
"G4MolecularConfiguration::CreateMolecularConfiguration",
1015 errMsg <<
"The molecular configuration for the definition named "
1017 <<
" with label " << label <<
" has already been created "
1018 "BUT with a different user ID :"
1020 G4Exception(
"G4MolecularConfiguration::CreateMolecularConfiguration",
1027 wasAlreadyCreated =
true;
1033 newConf->fUserIdentifier = userIdentifier;
1048 bool& wasAlreadyCreated)
1050 wasAlreadyCreated =
false;
1054 if(preRegisteredMolConf !=
nullptr)
1058 wasAlreadyCreated =
true;
1059 return preRegisteredMolConf;
1070 if(molConf !=
nullptr)
1079 errMsg <<
"A molecular configuration for the definition named "
1080 << molDef->
GetName() <<
" has already been created "
1081 "and recorded with a different user ID "
1083 G4Exception(
"G4MolecularConfiguration::CreateMolecularConfiguration",
1090 errMsg <<
"A molecular configuration for the definition named "
1091 << molDef->
GetName() <<
" has already been created.";
1092 G4Exception(
"G4MolecularConfiguration::CreateMolecularConfiguration",
1096 wasAlreadyCreated =
true;
1103 newConf->fUserIdentifier = userIdentifier;
1126 bool& wasAlreadyCreated)
1128 assert(label !=
"");
1129 wasAlreadyCreated =
false;
1133 if(molConf !=
nullptr)
1135 if((molConf->
fLabel !=
nullptr)
1136 && *molConf->
fLabel == label)
1138 wasAlreadyCreated =
true;
1141 if(molConf->
fLabel ==
nullptr)
1143 wasAlreadyCreated =
true;
1147 if(molConf->
fLabel->empty())
1149 wasAlreadyCreated =
true;
1156 errMsg <<
"A molecular configuration for the definition named "
1158 <<
" has already been created "
1162 G4Exception(
"G4MolecularConfiguration::CreateMolecularConfiguration",
1174 newConf->fUserIdentifier = userIdentifier;
1193 bool& wasAlreadyCreated)
1195 assert(label !=
"");
1196 wasAlreadyCreated =
false;
1201 if(molConf !=
nullptr)
1207 if((molConf->
fLabel !=
nullptr) && *molConf->
fLabel == label)
1209 wasAlreadyCreated =
true;
1212 if(molConf->
fLabel ==
nullptr)
1214 wasAlreadyCreated =
true;
1218 if(molConf->
fLabel->empty())
1220 wasAlreadyCreated =
true;
1230 errMsg <<
"A molecular configuration for the definition named "
1232 <<
" has already been created "
1235 <<
" and possible different electronic state";
1236 G4Exception(
"G4MolecularConfiguration::CreateMolecularConfiguration",
1247 newConf->fUserIdentifier = userIdentifier;
1266 auto it1 = fElecOccTable.find(molDef);
1268 if(it1 == fElecOccTable.end())
1273 ElectronOccupancyTable& table2 = it1->second;
1274 auto it = table2.find(eOcc);
1276 if(it == table2.end())
1294 auto it1 = fChargeTable.find(molDef);
1296 if(it1 == fChargeTable.end())
1304 ChargeTable& table2 = it1->second;
1305 auto it = table2.find(charge);
1307 if(it == table2.end())
1325 WRITE(out, moleculeName);
1347 READ(in, moleculeName);
1397 else if(
fLabel !=
nullptr)
1420 return pow(10, 4.311
1421 - 2.722e3/temperature_K
1422 + 8.565e5/(temperature_K *temperature_K)
1423 - 1.181e8/(temperature_K*temperature_K*temperature_K ))*1e-9*m2/s;
1435 G4cout <<
"Scaling factor = " << D_water_f/D_water_0 <<
G4endl;
1444 double D_f = D_water_f * D_0 /D_water_0;
1480 for(
auto it : fMolConfPerID)
1482 if(it->GetUserID() == userID)
return it;
1499 const std::vector<G4MolecularConfiguration*>& species =
1502 for(
auto specie : species)
1511 const std::vector<G4MolecularConfiguration*>& species =
1514 G4cout<<
"Molecular Config"<<std::setw(25)<<
" | Diffusion Coefficient (m2 / s) "<<std::setw(20)<<
" | Radius (nm) "<<
G4endl;
1515 G4cout<<
"__________________________________________"
1516 "___________________________________"<<
G4endl;
1517 for(
auto specie : species)
1519 G4cout<<specie->GetName()
1520 <<std::setw(
G4int(30 - specie->GetName().length()))
1521 <<right<<specie->GetDiffusionCoefficient() * 1.0e3<<std::setw(30)
1522 <<specie->GetVanDerVaalsRadius()/CLHEP::nm<<
G4endl;
1523 G4cout<<
"__________________________________________"
1524 "___________________________________"<<
G4endl;
G4TemplateAutoLock< G4Mutex > G4AutoLock
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)
G4MolecularConfiguration::G4MolecularConfigurationManager MolecularConfigurationManager
G4MoleculeIterator< G4MolecularConfiguration > G4ConfigurationIterator
void WRITE(std::ostream &out, const T &toBeSaved)
void READ(std::istream &in, T &toBeSaved)
G4GLOB_DLL std::ostream G4cout
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
G4MoleculeDefinition * GetMoleculeDefinition(const G4String &, bool mustExist=true)
static G4MoleculeTable * Instance()
G4ConfigurationIterator GetConfigurationIterator()
static G4String ConvertToString(G4bool boolVal)