51#define __func__ __FUNCTION__
119 errMsg <<
"This molecular configuration " <<
GetName()
120 <<
" is already finalized. Therefore its "
121 " properties cannot be changed.";
122 G4Exception(
"G4MolecularConfiguration::MakeExceptionIfFinalized",
137 fgManager =
new G4MolecularConfiguration::
138 G4MolecularConfigurationManager();
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();
183 ElectronOccupancyTable& table2 = fElecOccTable[molDef];
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())
229 ElectronOccupancyTable& table2 = it1->second;
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;
254 ElectronOccupancyTable& table2 = it1->second;
255 ElectronOccupancyTable::iterator it = table2.find(eOcc);
257 if(it == table2.end())
278 ChargeTable& table2 = fChargeTable[molDef];
279 ChargeTable::iterator it = table2.find(charge);
281 if(it == table2.end())
283 table2[charge] = molConf;
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;
316 ChargeTable& table2 = it1->second;
317 ChargeTable::iterator it = table2.find(charge);
319 if(it == table2.end())
548 newElectronOccupancy);
553 newElectronOccupancy);
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",
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",
678 G4int orbitToFill)
const
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",
737 G4cout <<
"-------------- Start Printing State " <<
GetName()
738 <<
" ---------------" <<
G4endl;
742 G4cout <<
"--------------Print electronic state of " <<
GetName()
743 <<
"---------------" <<
G4endl;
752 G4cout <<
"--- No electron occupancy set up ---" <<
G4endl;
766 <<
" -----------------------" <<
G4endl;
772const vector<const G4MolecularDissociationChannel*>*
784 else G4Exception(
"G4MolecularConfiguration::GetMoleculeID",
787 "You should first enter a molecule definition");
796 const char* pDelimeter = strrchr(path,
'\\');
797 if (pDelimeter) path = pDelimeter + 1;
799 pDelimeter = strrchr(path,
'/');
800 if (pDelimeter) path = pDelimeter + 1;
814 <<
"No G4ElectronOccupancy was defined for molecule definition : "
816 <<
". The definition was probably defined using the charge state, "
817 "rather than electron state.";
832 LabelTable::iterator it = tmpMap.find(*molConf->
fLabel);
834 if(it == tmpMap.end())
836 tmpMap[*(molConf->
fLabel)] = molConf;
841 errMsg <<
"The same molecular configuration seemed to be recorded twice";
843 "SetMolecularConfiguration(const G4MoleculeDefinition* molDef,"
844 "const G4String& label,"
845 "G4MolecularConfiguration* molConf)",
855 UserIDTable::iterator it = fUserIDTable.find(userID);
857 if(it == fUserIDTable.end())
859 fUserIDTable[userID] = molecule;
861 else if(molecule != it->second)
866 description <<
"The user identifier " << userID
867 <<
" was already given in another configuration in the table"
869 G4Exception(
"G4MolecularConfiguration::G4MolecularConfigurationManager::AddUserID",
870 "CONF_ALREADY_RECORDED",
881 MolElectronConfTable::iterator it1 =
883 MolElectronConfTable::iterator end = fElecOccTable.end();
885 if (it1 == end)
return;
887 std::map<G4ElectronOccupancy, G4MolecularConfiguration*, comparator>::
891 if (it2 == it1->second.end())
return;
908 MolLabelConfTable::iterator it1 = fLabelTable.find(molDef);
910 if(it1 == fLabelTable.end())
return 0;
912 LabelTable& table2 = it1->second;
914 LabelTable::iterator it2 = table2.find(label);
918 if(it2 == table2.end())
return 0;
928 if(moleculeID > (
int) fMolConfPerID.size() ||
929 moleculeID < 0)
return 0;
931 return fMolConfPerID[moleculeID];
943 LabelTable& tmpMap = fLabelTable[molDef];
944 LabelTable::iterator it = tmpMap.find(label);
946 if(it == tmpMap.end())
949 tmpMap[label] = molConf;
956 errMsg <<
"The same molecular configuration seemed to be recorded twice";
958 "SetMolecularConfiguration(const G4MoleculeDefinition* molDef,"
959 "const G4String& label,"
960 "G4MolecularConfiguration* molConf)",
964 fMolConfPerID.push_back(molConf);
966 return fLastMoleculeID;
993 bool& wasAlreadyCreated)
995 wasAlreadyCreated =
false;
1005 wMsg <<
"The molecular configuration for the definition named "
1007 <<
" with charge " << charge <<
" has already been created "
1008 "but with NO label";
1009 G4Exception(
"G4MolecularConfiguration::CreateMolecularConfiguration",
1014 else if(*(molConf->
fLabel) ==
"" )
1018 else if(*(molConf->
fLabel) != label)
1021 errMsg <<
"The molecular configuration for the definition named "
1023 <<
" with charge " << charge <<
" has already been created "
1024 "but with a different label :"
1026 G4Exception(
"G4MolecularConfiguration::CreateMolecularConfiguration",
1038 wMsg <<
"The molecular configuration for the definition named "
1040 <<
" with label " << label <<
" has already been created.";
1041 G4Exception(
"G4MolecularConfiguration::CreateMolecularConfiguration",
1049 errMsg <<
"The molecular configuration for the definition named "
1051 <<
" with label " << label <<
" has already been created "
1052 "BUT with a different user ID :"
1054 G4Exception(
"G4MolecularConfiguration::CreateMolecularConfiguration",
1061 wasAlreadyCreated =
true;
1084 bool& wasAlreadyCreated)
1086 wasAlreadyCreated =
false;
1090 if(preRegisteredMolConf)
1094 wasAlreadyCreated =
true;
1095 return preRegisteredMolConf;
1115 errMsg <<
"A molecular configuration for the definition named "
1116 << molDef->
GetName() <<
" has already been created "
1117 "and recorded with a different user ID "
1119 G4Exception(
"G4MolecularConfiguration::CreateMolecularConfiguration",
1126 errMsg <<
"A molecular configuration for the definition named "
1127 << molDef->
GetName() <<
" has already been created.";
1128 G4Exception(
"G4MolecularConfiguration::CreateMolecularConfiguration",
1132 wasAlreadyCreated =
true;
1166 bool& wasAlreadyCreated)
1168 assert(label !=
"");
1169 wasAlreadyCreated =
false;
1176 && *molConf->
fLabel == label)
1178 wasAlreadyCreated =
true;
1181 else if(molConf->
fLabel == 0)
1183 wasAlreadyCreated =
true;
1187 else if(*molConf->
fLabel ==
"")
1189 wasAlreadyCreated =
true;
1196 errMsg <<
"A molecular configuration for the definition named "
1198 <<
" has already been created "
1202 G4Exception(
"G4MolecularConfiguration::CreateMolecularConfiguration",
1233 bool& wasAlreadyCreated)
1235 assert(label !=
"");
1236 wasAlreadyCreated =
false;
1249 wasAlreadyCreated =
true;
1252 else if(molConf->
fLabel == 0)
1254 wasAlreadyCreated =
true;
1258 else if(*molConf->
fLabel ==
"")
1260 wasAlreadyCreated =
true;
1270 errMsg <<
"A molecular configuration for the definition named "
1272 <<
" has already been created "
1275 <<
" and possible different electronic state";
1276 G4Exception(
"G4MolecularConfiguration::CreateMolecularConfiguration",
1306 MolElectronConfTable::iterator it1 = fElecOccTable.find(molDef);
1308 if(it1 == fElecOccTable.end())
1313 ElectronOccupancyTable& table2 = it1->second;
1314 ElectronOccupancyTable::iterator it = table2.find(eOcc);
1316 if(it == table2.end())
1338 MolChargeConfTable::iterator it1 = fChargeTable.find(molDef);
1340 if(it1 == fChargeTable.end())
1348 ChargeTable& table2 = it1->second;
1349 ChargeTable::iterator it = table2.find(charge);
1351 if(it == table2.end())
1373 WRITE(out, moleculeName);
1395 READ(in, moleculeName);
1468 return pow(10, 4.311
1469 - 2.722e3/temperature_K
1470 + 8.565e5/(temperature_K *temperature_K)
1471 - 1.181e8/(temperature_K*temperature_K*temperature_K ))*1e-9*m2/s;
1483 G4cout <<
"Scaling factor = " << D_water_f/D_water_0 <<
G4endl;
1492 double D_f = D_water_f * D_0 /D_water_0;
1528 for(
auto it : fMolConfPerID)
1530 if(it->GetUserID() == userID)
return it;
1547 const std::vector<G4MolecularConfiguration*>& species =
1550 for(std::size_t i = 0; i < species.size() ; ++i)
1552 species[i]->Finalize();
1559 const std::vector<G4MolecularConfiguration*>& species =
1562 G4cout<<
"Molecular Config"<<std::setw(25)<<
" | Diffusion Coefficient (m2 / s) "<<std::setw(20)<<
" | Radius (nm) "<<
G4endl;
1563 G4cout<<
"__________________________________________"
1564 "___________________________________"<<
G4endl;
1565 for(std::size_t i = 0; i < species.size() ; ++i)
1567 G4cout<<species[i]->GetName()
1568 <<std::setw(
G4int(30 - species[i]->
GetName().length()))
1569 <<right<<species[i]->GetDiffusionCoefficient() * 1.0e3<<std::setw(30)
1570 <<species[i]->GetVanDerVaalsRadius()/CLHEP::nm<<
G4endl;
1571 G4cout<<
"__________________________________________"
1572 "___________________________________"<<
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)
G4MolecularConfiguration::G4MolecularConfigurationManager MolecularConfigurationManager
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)