63 oscillatorStoreIonisation(0),oscillatorStoreCompton(0),atomicNumber(0),
64 atomicMass(0),excitationEnergy(0),plasmaSquared(0),atomsPerMolecule(0),
65 atomTablePerMolecule(0)
68 for (
G4int i=0;i<5;i++)
70 for (
G4int j=0;j<2000;j++)
102 G4cout <<
" G4PenelopeOscillatorManager::Clear() - Clean Oscillator Tables" <<
G4endl;
110 for (
size_t k=0;
k<table->size();
k++)
113 delete ((*table)[
k]);
126 for (
size_t k=0;
k<table->size();
k++)
129 delete ((*table)[
k]);
151 G4cout <<
" G4PenelopeOscillatorManager::Dump " <<
G4endl;
152 G4cout <<
"Problem in retrieving the Ionisation Oscillator Table for " << material->
GetName() <<
G4endl;
155 G4cout <<
"*********************************************************************" <<
G4endl;
157 G4cout <<
"*********************************************************************" <<
G4endl;
158 G4cout <<
"The table contains " << theTable->size() <<
" oscillators " <<
G4endl;
159 G4cout <<
"*********************************************************************" <<
G4endl;
160 if (theTable->size() < 10)
161 for (
size_t k=0;
k<theTable->size();
k++)
163 G4cout <<
"Oscillator # " <<
k <<
" Z = " << (*theTable)[
k]->GetParentZ() <<
164 " Shell Flag = " << (*theTable)[
k]->GetShellFlag() <<
165 " Parent shell ID = " << (*theTable)[
k]->GetParentShellID() <<
G4endl;
166 G4cout <<
"Ionisation energy = " << (*theTable)[
k]->GetIonisationEnergy()/
eV <<
" eV" <<
G4endl;
167 G4cout <<
"Occupation number = " << (*theTable)[
k]->GetOscillatorStrength() <<
G4endl;
168 G4cout <<
"Resonance energy = " << (*theTable)[
k]->GetResonanceEnergy()/
eV <<
" eV" <<
G4endl;
169 G4cout <<
"Cufoff resonance energy = " <<
170 (*theTable)[
k]->GetCutoffRecoilResonantEnergy()/
eV <<
" eV" <<
G4endl;
171 G4cout <<
"*********************************************************************" <<
G4endl;
173 for (
size_t k=0;
k<theTable->size();
k++)
175 G4cout <<
k <<
" " << (*theTable)[
k]->GetOscillatorStrength() <<
" " <<
176 (*theTable)[
k]->GetIonisationEnergy()/
eV <<
" " << (*theTable)[
k]->GetResonanceEnergy()/
eV <<
" " <<
177 (*theTable)[
k]->GetParentZ() <<
" " << (*theTable)[
k]->GetShellFlag() <<
" " <<
178 (*theTable)[
k]->GetParentShellID() <<
G4endl;
180 G4cout <<
"*********************************************************************" <<
G4endl;
187 G4cout <<
" G4PenelopeOscillatorManager::Dump " <<
G4endl;
188 G4cout <<
"Problem in retrieving the Compton Oscillator Table for " << material->
GetName() <<
G4endl;
191 G4cout <<
"*********************************************************************" <<
G4endl;
193 G4cout <<
"*********************************************************************" <<
G4endl;
194 G4cout <<
"The table contains " << theTable->size() <<
" oscillators " <<
G4endl;
195 G4cout <<
"*********************************************************************" <<
G4endl;
196 if (theTable->size() < 10)
197 for (
size_t k=0;
k<theTable->size();
k++)
199 G4cout <<
"Oscillator # " <<
k <<
" Z = " << (*theTable)[
k]->GetParentZ() <<
200 " Shell Flag = " << (*theTable)[
k]->GetShellFlag() <<
201 " Parent shell ID = " << (*theTable)[
k]->GetParentShellID() <<
G4endl;
202 G4cout <<
"Compton index = " << (*theTable)[
k]->GetHartreeFactor() <<
G4endl;
203 G4cout <<
"Ionisation energy = " << (*theTable)[
k]->GetIonisationEnergy()/
eV <<
" eV" <<
G4endl;
204 G4cout <<
"Occupation number = " << (*theTable)[
k]->GetOscillatorStrength() <<
G4endl;
205 G4cout <<
"*********************************************************************" <<
G4endl;
207 for (
size_t k=0;
k<theTable->size();
k++)
209 G4cout <<
k <<
" " << (*theTable)[
k]->GetOscillatorStrength() <<
" " <<
210 (*theTable)[
k]->GetIonisationEnergy()/
eV <<
" " << (*theTable)[
k]->GetHartreeFactor() <<
" " <<
211 (*theTable)[
k]->GetParentZ() <<
" " << (*theTable)[
k]->GetShellFlag() <<
" " <<
212 (*theTable)[
k]->GetParentShellID() <<
G4endl;
214 G4cout <<
"*********************************************************************" <<
G4endl;
232 G4Exception(
"G4PenelopeOscillatorManager::GetOscillatorTableIonisation()",
234 "Problem in allocating the Oscillator Store for Ionisation");
244 G4Exception(
"G4PenelopeOscillatorManager::GetOscillatorTableIonisation()",
246 "Problem in allocating the Oscillator Store for Compton");
250 atomicNumber =
new std::map<const G4Material*,G4double>;
252 atomicMass =
new std::map<const G4Material*,G4double>;
283 G4cout <<
"G4PenelopeOscillatorManager::GetTotalZ() " <<
G4endl;
308 G4cout <<
"G4PenelopeOscillatorManager::GetTotalA() " <<
G4endl;
336 G4cout <<
"G4PenelopeOscillatorManager::GetOscillatorTableIonisation() " <<
G4endl;
337 G4cout <<
"Impossible to create ionisation oscillator table for " << mat->
GetName() <<
G4endl;
348 if (((
size_t)index) < theTable->size())
349 return (*theTable)[index];
352 G4cout <<
"WARNING: Ionisation table for material " << material->
GetName() <<
" has " <<
353 theTable->size() <<
" oscillators" <<
G4endl;
354 G4cout <<
"Oscillator #" << index <<
" cannot be retrieved" <<
G4endl;
383 G4cout <<
"G4PenelopeOscillatorManager::GetOscillatorTableCompton() " <<
G4endl;
384 G4cout <<
"Impossible to create Compton oscillator table for " << mat->
GetName() <<
G4endl;
395 if (((
size_t)index) < theTable->size())
396 return (*theTable)[index];
399 G4cout <<
"WARNING: Compton table for material " << material->
GetName() <<
" has " <<
400 theTable->size() <<
" oscillators" <<
G4endl;
401 G4cout <<
"Oscillator #" << index <<
" cannot be retrieved" <<
G4endl;
448 std::vector<G4double> *StechiometricFactors =
new std::vector<G4double>;
450 for (
G4int i=0;i<nElements;i++)
453 G4double fraction = fractionVector[i];
454 G4double atomicWeigth = (*elementVector)[i]->GetAtomicMassAmu();
455 StechiometricFactors->push_back(fraction/atomicWeigth);
458 G4double MaxStechiometricFactor = 0.;
459 for (
G4int i=0;i<nElements;i++)
461 if ((*StechiometricFactors)[i] > MaxStechiometricFactor)
462 MaxStechiometricFactor = (*StechiometricFactors)[i];
464 if (MaxStechiometricFactor<1
e-16)
467 ed <<
"Problem with the mass composition of " << material->
GetName() <<
G4endl;
468 ed <<
"MaxStechiometricFactor = " << MaxStechiometricFactor <<
G4endl;
469 G4Exception(
"G4PenelopeOscillatorManager::BuildOscillatorTable()",
473 for (
G4int i=0;i<nElements;i++)
474 (*StechiometricFactors)[i] /= MaxStechiometricFactor;
478 for (
G4int i=0;i<nElements;i++)
479 theatomsPerMolecule += (*StechiometricFactors)[i];
486 for (
size_t i=0;i<StechiometricFactors->size();i++)
488 G4cout <<
"Element " << (*elementVector)[i]->GetSymbol() <<
" (Z = " <<
489 (*elementVector)[i]->GetZ() <<
") --> " <<
490 (*StechiometricFactors)[i] <<
" atoms/molecule " <<
G4endl;
495 for (
G4int i=0;i<nElements;i++)
497 G4int iZ = (
G4int) (*elementVector)[i]->GetZ();
498 totalZ += iZ * (*StechiometricFactors)[i];
499 totalMolecularWeight += (*elementVector)[i]->GetAtomicMassAmu() * (*StechiometricFactors)[i];
500 meanExcitationEnergy += iZ*std::log(meanAtomExcitationEnergy[iZ-1])*(*StechiometricFactors)[i];
507 std::pair<const G4Material*,G4int> theKey = std::make_pair(material,iZ);
511 meanExcitationEnergy =
G4Exp(meanExcitationEnergy/totalZ);
514 atomicMass->insert(std::make_pair(material,totalMolecularWeight));
521 G4cout <<
"Calculated mean excitation energy for " << material->
GetName() <<
522 " = " << meanExcitationEnergy/
eV <<
" eV" <<
G4endl;
525 std::vector<G4PenelopeOscillator> *helper =
new std::vector<G4PenelopeOscillator>;
536 helper->push_back(newOsc);
543 for (
G4int i=0;i<2000 && !finished;i++)
559 if (std::fabs(occup) > 0)
574 helper->push_back(newOscLocal);
577 G4double ff = (*helper)[0].GetOscillatorStrength();
578 ff += std::fabs(occup)*(*StechiometricFactors)[
k];
579 (*helper)[0].SetOscillatorStrength(ff);
589 delete StechiometricFactors;
594 std::sort(helper->begin(),helper->end());
597 static const G4double RydbergEnergy = 13.60569*
eV;
599 G4double conductionStrength = (*helper)[0].GetOscillatorStrength();
600 G4double plasmaEnergy = Omega*std::sqrt(conductionStrength/totalZ);
604 G4bool isAConductor =
false;
609 G4cout <<
"Estimated oscillator strenght and energy of plasmon: " <<
610 conductionStrength <<
" and " << plasmaEnergy/
eV <<
" eV" <<
G4endl;
613 if (conductionStrength < 0.01 || plasmaEnergy<1.0*
eV)
618 helper->erase(helper->begin());
626 G4double conductionStrengthCopy = conductionStrength;
628 for (
size_t i = 1; i<helper->size() && !quit ;i++)
630 G4double oscStre = (*helper)[i].GetOscillatorStrength();
632 if (oscStre < conductionStrengthCopy)
634 conductionStrengthCopy = conductionStrengthCopy-oscStre;
635 (*helper)[i].SetOscillatorStrength(0.);
641 (*helper)[i].SetOscillatorStrength(oscStre-conductionStrengthCopy);
642 if (std::fabs((*helper)[i].GetOscillatorStrength()) < 1
e-12)
644 conductionStrength += (*helper)[i].GetOscillatorStrength();
645 (*helper)[i].SetOscillatorStrength(0.);
652 (*helper)[0].SetOscillatorStrength(conductionStrength);
653 (*helper)[0].SetIonisationEnergy(0.);
654 (*helper)[0].SetResonanceEnergy(plasmaEnergy);
655 G4double hartree = 0.75/std::sqrt(3.0*
pi*
pi*moleculeDensity*
656 Bohr_radius*Bohr_radius*Bohr_radius*conductionStrength);
662 for (
size_t i=0;i<helper->size();i++)
664 sum += (*helper)[i].GetOscillatorStrength();
666 if (std::fabs(sum-totalZ) > (1
e-6*totalZ))
669 ed <<
"Inconsistent oscillator data for " << material->
GetName() <<
G4endl;
670 ed << sum <<
" " << totalZ <<
G4endl;
671 G4Exception(
"G4PenelopeOscillatorManager::BuildOscillatorTable()",
674 if (std::fabs(sum-totalZ) > (1
e-12*totalZ))
677 for (
size_t i=0;i<helper->size();i++)
679 G4double ff = (*helper)[i].GetOscillatorStrength()*fact;
680 (*helper)[i].SetOscillatorStrength(ff);
688 for (
size_t i=0;i<helper->size() && !
exit;i++)
690 if (std::fabs((*helper)[i].GetOscillatorStrength()) < 1
e-12)
692 helper->erase(helper->begin()+i);
700 if (helper->size() > 1)
702 G4double TST = totalZ*std::log(meanExcitationEnergy/
eV);
707 adjustmentFactor = (AALow+AAHigh)*0.5;
709 for (
size_t i=0;i<helper->size();i++)
711 if (i == 0 && isAConductor)
713 G4double resEne = (*helper)[i].GetResonanceEnergy();
714 sumLocal += (*helper)[i].GetOscillatorStrength()*std::log(resEne/
eV);
718 G4double ionEne = (*helper)[i].GetIonisationEnergy();
719 G4double oscStre = (*helper)[i].GetOscillatorStrength();
720 G4double WI2 = (adjustmentFactor*adjustmentFactor*ionEne*ionEne) +
721 2./3.*(oscStre/totalZ)*Omega*
Omega;
723 (*helper)[i].SetResonanceEnergy(resEne);
724 sumLocal += (*helper)[i].GetOscillatorStrength()*std::log(resEne/
eV);
728 AALow = adjustmentFactor;
730 AAHigh = adjustmentFactor;
732 G4cout <<
"Sternheimer's adjustment factor loops: " << AALow <<
" " << AAHigh <<
" " <<
733 adjustmentFactor <<
" " << TST <<
" " <<
735 }
while((AAHigh-AALow)>(1
e-14*adjustmentFactor));
739 G4double ionEne = (*helper)[0].GetIonisationEnergy();
740 (*helper)[0].SetIonisationEnergy(std::fabs(ionEne));
741 (*helper)[0].SetResonanceEnergy(meanExcitationEnergy);
745 G4cout <<
"Sternheimer's adjustment factor: " << adjustmentFactor <<
G4endl;
749 G4double xcheck = (*helper)[0].GetOscillatorStrength()*std::log((*helper)[0].GetResonanceEnergy());
750 G4double TST = (*helper)[0].GetOscillatorStrength();
751 for (
size_t i=1;i<helper->size();i++)
753 xcheck += (*helper)[i].GetOscillatorStrength()*std::log((*helper)[i].GetResonanceEnergy());
754 TST += (*helper)[i].GetOscillatorStrength();
756 if (std::fabs(TST-totalZ)>1
e-8*totalZ)
759 ed <<
"Inconsistent oscillator data " <<
G4endl;
760 ed << TST <<
" " << totalZ <<
G4endl;
761 G4Exception(
"G4PenelopeOscillatorManager::BuildOscillatorTable()",
764 xcheck =
G4Exp(xcheck/totalZ);
765 if (std::fabs(xcheck-meanExcitationEnergy) > 1
e-8*meanExcitationEnergy)
768 ed <<
"Error in Sterheimer factor calculation " <<
G4endl;
769 ed << xcheck/
eV <<
" " << meanExcitationEnergy/
eV <<
G4endl;
770 G4Exception(
"G4PenelopeOscillatorManager::BuildOscillatorTable()",
782 if (Z>Zmax) Zmax =
Z;
787 for (
size_t i=0;i<helper->size() && !found;i++)
790 G4int shID = (*helper)[i].GetParentShellID();
791 if (shID == 10 && Z == Zmax)
794 if ((*helper)[i].GetIonisationEnergy() > cutEnergy)
795 cutEnergy = (*helper)[i].GetIonisationEnergy();
800 G4double lowEnergyLimitForFluorescence = 250*
eV;
801 cutEnergy =
std::min(cutEnergy,lowEnergyLimitForFluorescence);
811 std::sort(helper->begin(),helper->end(),comparator);
814 for (
size_t i=0;i<helper->size();i++)
818 theTable->push_back(theOsc);
824 size_t Nost = theTable->size();
826 size_t firstIndex = (isAConductor) ? 1 : 0;
829 G4int removedLevels = 0;
834 if (Nost>firstIndex+1)
837 for (
size_t i=firstIndex;i<theTable->size()-1;i++)
840 G4int shellFlag = (*theTable)[i]->GetShellFlag();
841 G4double ionEne = (*theTable)[i]->GetIonisationEnergy();
842 G4double resEne = (*theTable)[i]->GetResonanceEnergy();
843 G4double resEnePlus1 = (*theTable)[i+1]->GetResonanceEnergy();
844 G4double oscStre = (*theTable)[i]->GetOscillatorStrength();
845 G4double oscStrePlus1 = (*theTable)[i+1]->GetOscillatorStrength();
847 if (ionEne>cutEnergy)
849 if (resEne<1.0*
eV || resEnePlus1<1.0*
eV)
851 if (resEnePlus1 > Rgroup*resEne)
856 oscStrePlus1*std::log(resEnePlus1))
857 /(oscStre+oscStrePlus1));
858 (*theTable)[i]->SetResonanceEnergy(newRes);
860 oscStrePlus1*(*theTable)[i+1]->GetIonisationEnergy())/
861 (oscStre+oscStrePlus1);
862 (*theTable)[i]->SetIonisationEnergy(newIon);
863 G4double newStre = oscStre+oscStrePlus1;
864 (*theTable)[i]->SetOscillatorStrength(newStre);
865 G4double newHartree = (oscStre*(*theTable)[i]->GetHartreeFactor()+
866 oscStrePlus1*(*theTable)[i+1]->GetHartreeFactor())/
867 (oscStre+oscStrePlus1);
868 (*theTable)[i]->SetHartreeFactor(newHartree);
869 if ((*theTable)[i]->GetParentZ() != (*theTable)[i+1]->GetParentZ())
870 (*theTable)[i]->SetParentZ(0.);
871 if (shellFlag < 10 || (*theTable)[i+1]->GetShellFlag() < 10)
873 G4int newFlag =
std::min(shellFlag,(*theTable)[i+1]->GetShellFlag());
874 (*theTable)[i]->SetShellFlag(newFlag);
877 (*theTable)[i]->SetShellFlag(30);
879 (*theTable)[i]->SetParentShellID((*theTable)[i]->GetShellFlag());
882 if (i<theTable->size()-2)
884 for (
size_t ii=i+1;ii<theTable->size()-1;ii++)
885 (*theTable)[ii] = (*theTable)[ii+1];
888 theTable->erase(theTable->begin()+theTable->size()-1);
895 Nost -= removedLevels;
898 if (Rgroup < 1.414213 || Nost > 64)
900 Rgroup = Rgroup*Rgroup;
904 if (nLoops > 100 && !removedLevels)
910 G4cout <<
"Final grouping factor for Ionisation: " << Rgroup <<
G4endl;
914 for (
size_t i=0;i<theTable->size();i++)
917 G4double ionEne = (*theTable)[i]->GetIonisationEnergy();
918 if (ionEne < 1
e-3*
eV)
920 G4double resEne = (*theTable)[i]->GetResonanceEnergy();
921 (*theTable)[i]->SetIonisationEnergy(0.*
eV);
922 (*theTable)[i]->SetCutoffRecoilResonantEnergy(resEne);
925 (*theTable)[i]->SetCutoffRecoilResonantEnergy(ionEne);
941 std::sort(helper->begin(),helper->end());
943 for (
size_t i=0;i<helper->size();i++)
947 theTableC->push_back(theOsc);
952 Nost = theTableC->size();
954 firstIndex = (isAConductor) ? 1 : 0;
961 if (Nost>firstIndex+1)
964 for (
size_t i=firstIndex;i<theTableC->size()-1;i++)
968 G4double ionEne = (*theTableC)[i]->GetIonisationEnergy();
969 G4double ionEnePlus1 = (*theTableC)[i+1]->GetIonisationEnergy();
970 G4double oscStre = (*theTableC)[i]->GetOscillatorStrength();
971 G4double oscStrePlus1 = (*theTableC)[i+1]->GetOscillatorStrength();
973 if (ionEne>cutEnergy)
975 if (ionEne<1.0*
eV || ionEnePlus1<1.0*
eV)
977 if (ionEnePlus1 > Rgroup*ionEne)
983 oscStrePlus1*ionEnePlus1)/
984 (oscStre+oscStrePlus1);
985 (*theTableC)[i]->SetIonisationEnergy(newIon);
986 G4double newStre = oscStre+oscStrePlus1;
987 (*theTableC)[i]->SetOscillatorStrength(newStre);
988 G4double newHartree = (oscStre*(*theTableC)[i]->GetHartreeFactor()+
989 oscStrePlus1*(*theTableC)[i+1]->GetHartreeFactor())/
990 (oscStre+oscStrePlus1);
991 (*theTableC)[i]->SetHartreeFactor(newHartree);
992 if ((*theTableC)[i]->GetParentZ() != (*theTableC)[i+1]->GetParentZ())
993 (*theTableC)[i]->SetParentZ(0.);
994 (*theTableC)[i]->SetShellFlag(30);
995 (*theTableC)[i]->SetParentShellID((*theTableC)[i]->GetShellFlag());
997 if (i<theTableC->size()-2)
999 for (
size_t ii=i+1;ii<theTableC->size()-1;ii++)
1000 (*theTableC)[ii] = (*theTableC)[ii+1];
1002 theTableC->erase(theTableC->begin()+theTableC->size()-1);
1009 Nost -= removedLevels;
1012 if (Rgroup < 2.0 || Nost > 64)
1014 Rgroup = Rgroup*Rgroup;
1018 if (nLoops > 100 && !removedLevels)
1025 G4cout <<
"Final grouping factor for Compton: " << Rgroup <<
G4endl;
1071 G4cout <<
"G4PenelopeOscillatorManager::ReadElementData()" <<
G4endl;
1074 char* path = std::getenv(
"G4LEDATA");
1077 G4String excep =
"G4PenelopeOscillatorManager - G4LEDATA environment variable not set!";
1078 G4Exception(
"G4PenelopeOscillatorManager::ReadElementData()",
1083 G4String pathFile = pathString +
"/penelope/pdatconf.p08";
1084 std::ifstream
file(pathFile);
1086 if (!file.is_open())
1088 G4String excep =
"G4PenelopeOscillatorManager - data file " + pathFile +
" not found!";
1089 G4Exception(
"G4PenelopeOscillatorManager::ReadElementData()",
1100 for (
G4int iline=0;iline<22;iline++)
1101 getline(file,theHeader);
1104 G4int shellCode = 0;
1106 G4int occupationNumber = 0;
1109 G4int shellCounter = 0;
1111 G4int numberOfShells = 0;
1113 for (
G4int i=0;!file.eof();i++)
1115 file >> Z >> shellCode >> shellId >> occupationNumber >> ionisationEnergy >> hartreeProfile;
1129 if (shellCounter<numberOfShells)
1136 elementData[3][i] = (bindingEnergy>100*
eV) ? bindingEnergy : ionisationEnergy*
eV;
1146 G4cout <<
"G4PenelopeOscillatorManager::ReadElementData(): Data file read" <<
G4endl;
1171 G4cout <<
"G4PenelopeOscillatorManager::GetMolecularExcitationEnergy() " <<
G4endl;
1172 G4cout <<
"Impossible to retrieve the excitation energy for " << mat->
GetName() <<
G4endl;
1195 G4cout <<
"G4PenelopeOscillatorManager::GetPlasmaEnergySquared() " <<
G4endl;
1220 G4cout <<
"G4PenelopeOscillatorManager::GetAtomsPerMolecule() " <<
G4endl;
1221 G4cout <<
"Impossible to retrieve the number of atoms per molecule for "
1235 std::pair<const G4Material*,G4int> theKey = std::make_pair(mat,Z);
1247 G4cout <<
"G4PenelopeOscillatorManager::GetAtomsPerMolecule() " <<
G4endl;
1248 G4cout <<
"Impossible to retrieve the number of atoms per molecule for Z = "