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",
753 G4cout <<
"-------------- Start Printing State " <<
GetName()
754 <<
" ---------------" <<
G4endl;
758 G4cout <<
"--------------Print electronic state of " <<
GetName()
759 <<
"---------------" <<
G4endl;
768 G4cout <<
"--- No electron occupancy set up ---" <<
G4endl;
782 <<
" -----------------------" <<
G4endl;
788const vector<const G4MolecularDissociationChannel*>*
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;
830 <<
"No G4ElectronOccupancy was defined for molecule definition : "
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())
875 fUserIDTable[userID] = molecule;
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;
928 LabelTable& table2 = it1->second;
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];
959 LabelTable& tmpMap = fLabelTable[molDef];
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;
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;
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",
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",
1322 MolElectronConfTable::iterator it1 = fElecOccTable.find(molDef);
1324 if(it1 == fElecOccTable.end())
1329 ElectronOccupancyTable& table2 = it1->second;
1330 ElectronOccupancyTable::iterator it = table2.find(eOcc);
1332 if(it == table2.end())
1354 MolChargeConfTable::iterator it1 = fChargeTable.find(molDef);
1356 if(it1 == fChargeTable.end())
1364 ChargeTable& table2 = it1->second;
1365 ChargeTable::iterator it = table2.find(charge);
1367 if(it == table2.end())
1389 WRITE(out, moleculeName);
1411 READ(in, moleculeName);
1484 return pow(10, 4.311
1485 - 2.722e3/temperature_K
1486 + 8.565e5/(temperature_K *temperature_K)
1487 - 1.181e8/(temperature_K*temperature_K*temperature_K ))*1e-9*m2/s;
1499 G4cout <<
"Scaling factor = " << D_water_f/D_water_0 <<
G4endl;
1508 double D_f = D_water_f * D_0 /D_water_0;
1544 for(
auto it : fMolConfPerID)
1546 if(it->GetUserID() == userID)
return it;
1563 const std::vector<G4MolecularConfiguration*>& species =
1566 for(
size_t i = 0; i < species.size() ; ++i)
1568 species[i]->Finalize();
G4double(* function)(G4double)
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)