449 std::vector<G4double> *StechiometricFactors =
new std::vector<G4double>;
451 for (
G4int i=0;i<nElements;i++)
454 G4double fraction = fractionVector[i];
455 G4double atomicWeigth = (*elementVector)[i]->GetAtomicMassAmu();
456 StechiometricFactors->push_back(fraction/atomicWeigth);
459 G4double MaxStechiometricFactor = 0.;
460 for (
G4int i=0;i<nElements;i++)
462 if ((*StechiometricFactors)[i] > MaxStechiometricFactor)
463 MaxStechiometricFactor = (*StechiometricFactors)[i];
465 if (MaxStechiometricFactor<1
e-16)
468 ed <<
"Problem with the mass composition of " << material->
GetName() <<
G4endl;
469 ed <<
"MaxStechiometricFactor = " << MaxStechiometricFactor <<
G4endl;
470 G4Exception(
"G4PenelopeOscillatorManager::BuildOscillatorTable()",
474 for (
G4int i=0;i<nElements;i++)
475 (*StechiometricFactors)[i] /= MaxStechiometricFactor;
479 for (
G4int i=0;i<nElements;i++)
480 theatomsPerMolecule += (*StechiometricFactors)[i];
487 for (
size_t i=0;i<StechiometricFactors->size();i++)
489 G4cout <<
"Element " << (*elementVector)[i]->GetSymbol() <<
" (Z = " <<
490 (*elementVector)[i]->GetZ() <<
") --> " <<
491 (*StechiometricFactors)[i] <<
" atoms/molecule " <<
G4endl;
496 for (
G4int i=0;i<nElements;i++)
498 G4int iZ = (
G4int) (*elementVector)[i]->GetZ();
499 totalZ += iZ * (*StechiometricFactors)[i];
500 totalMolecularWeight += (*elementVector)[i]->GetAtomicMassAmu() * (*StechiometricFactors)[i];
501 meanExcitationEnergy += iZ*std::log(meanAtomExcitationEnergy[iZ-1])*(*StechiometricFactors)[i];
508 std::pair<const G4Material*,G4int> theKey = std::make_pair(material,iZ);
512 meanExcitationEnergy =
G4Exp(meanExcitationEnergy/totalZ);
515 atomicMass->insert(std::make_pair(material,totalMolecularWeight));
522 G4cout <<
"Calculated mean excitation energy for " << material->
GetName() <<
523 " = " << meanExcitationEnergy/
eV <<
" eV" <<
G4endl;
526 std::vector<G4PenelopeOscillator> *helper =
new std::vector<G4PenelopeOscillator>;
537 helper->push_back(newOsc);
540 for (
G4int k=0;k<nElements;k++)
542 G4double Z = (*elementVector)[k]->GetZ();
544 for (
G4int i=0;i<2000 && !finished;i++)
560 if (std::fabs(occup) > 0)
575 helper->push_back(newOscLocal);
578 G4double ff = (*helper)[0].GetOscillatorStrength();
579 ff += std::fabs(occup)*(*StechiometricFactors)[k];
580 (*helper)[0].SetOscillatorStrength(ff);
590 delete StechiometricFactors;
595 std::sort(helper->begin(),helper->end());
598 static const G4double RydbergEnergy = 13.60569*
eV;
600 G4double conductionStrength = (*helper)[0].GetOscillatorStrength();
601 G4double plasmaEnergy = Omega*std::sqrt(conductionStrength/totalZ);
605 G4bool isAConductor =
false;
610 G4cout <<
"Estimated oscillator strenght and energy of plasmon: " <<
611 conductionStrength <<
" and " << plasmaEnergy/
eV <<
" eV" <<
G4endl;
614 if (conductionStrength < 0.01 || plasmaEnergy<1.0*
eV)
619 helper->erase(helper->begin());
627 G4double conductionStrengthCopy = conductionStrength;
629 for (
size_t i = 1; i<helper->size() && !quit ;i++)
631 G4double oscStre = (*helper)[i].GetOscillatorStrength();
633 if (oscStre < conductionStrengthCopy)
635 conductionStrengthCopy = conductionStrengthCopy-oscStre;
636 (*helper)[i].SetOscillatorStrength(0.);
642 (*helper)[i].SetOscillatorStrength(oscStre-conductionStrengthCopy);
643 if (std::fabs((*helper)[i].GetOscillatorStrength()) < 1
e-12)
645 conductionStrength += (*helper)[i].GetOscillatorStrength();
646 (*helper)[i].SetOscillatorStrength(0.);
653 (*helper)[0].SetOscillatorStrength(conductionStrength);
654 (*helper)[0].SetIonisationEnergy(0.);
655 (*helper)[0].SetResonanceEnergy(plasmaEnergy);
656 G4double hartree = 0.75/std::sqrt(3.0*
pi*
pi*moleculeDensity*
663 for (
size_t i=0;i<helper->size();i++)
665 sum += (*helper)[i].GetOscillatorStrength();
667 if (std::fabs(sum-totalZ) > (1
e-6*totalZ))
670 ed <<
"Inconsistent oscillator data for " << material->
GetName() <<
G4endl;
671 ed << sum <<
" " << totalZ <<
G4endl;
672 G4Exception(
"G4PenelopeOscillatorManager::BuildOscillatorTable()",
675 if (std::fabs(sum-totalZ) > (1
e-12*totalZ))
678 for (
size_t i=0;i<helper->size();i++)
681 (*helper)[i].SetOscillatorStrength(ff);
686 for (
G4int k=0;k<nullOsc;k++)
689 for (
size_t i=0;i<helper->size() && !exit;i++)
691 if (std::fabs((*helper)[i].GetOscillatorStrength()) < 1
e-12)
693 helper->erase(helper->begin()+i);
701 if (helper->size() > 1)
703 G4double TST = totalZ*std::log(meanExcitationEnergy/
eV);
708 adjustmentFactor = (AALow+AAHigh)*0.5;
710 for (
size_t i=0;i<helper->size();i++)
712 if (i == 0 && isAConductor)
714 G4double resEne = (*helper)[i].GetResonanceEnergy();
715 sumLocal += (*helper)[i].GetOscillatorStrength()*std::log(resEne/
eV);
719 G4double ionEne = (*helper)[i].GetIonisationEnergy();
720 G4double oscStre = (*helper)[i].GetOscillatorStrength();
721 G4double WI2 = (adjustmentFactor*adjustmentFactor*ionEne*ionEne) +
722 2./3.*(oscStre/totalZ)*Omega*Omega;
724 (*helper)[i].SetResonanceEnergy(resEne);
725 sumLocal += (*helper)[i].GetOscillatorStrength()*std::log(resEne/
eV);
729 AALow = adjustmentFactor;
731 AAHigh = adjustmentFactor;
733 G4cout <<
"Sternheimer's adjustment factor loops: " << AALow <<
" " << AAHigh <<
" " <<
734 adjustmentFactor <<
" " << TST <<
" " <<
736 }
while((AAHigh-AALow)>(1
e-14*adjustmentFactor));
740 G4double ionEne = (*helper)[0].GetIonisationEnergy();
741 (*helper)[0].SetIonisationEnergy(std::fabs(ionEne));
742 (*helper)[0].SetResonanceEnergy(meanExcitationEnergy);
746 G4cout <<
"Sternheimer's adjustment factor: " << adjustmentFactor <<
G4endl;
750 G4double xcheck = (*helper)[0].GetOscillatorStrength()*std::log((*helper)[0].GetResonanceEnergy());
751 G4double TST = (*helper)[0].GetOscillatorStrength();
752 for (
size_t i=1;i<helper->size();i++)
754 xcheck += (*helper)[i].GetOscillatorStrength()*std::log((*helper)[i].GetResonanceEnergy());
755 TST += (*helper)[i].GetOscillatorStrength();
757 if (std::fabs(TST-totalZ)>1
e-8*totalZ)
760 ed <<
"Inconsistent oscillator data " <<
G4endl;
761 ed << TST <<
" " << totalZ <<
G4endl;
762 G4Exception(
"G4PenelopeOscillatorManager::BuildOscillatorTable()",
765 xcheck =
G4Exp(xcheck/totalZ);
766 if (std::fabs(xcheck-meanExcitationEnergy) > 1
e-8*meanExcitationEnergy)
769 ed <<
"Error in Sterheimer factor calculation " <<
G4endl;
770 ed << xcheck/
eV <<
" " << meanExcitationEnergy/
eV <<
G4endl;
771 G4Exception(
"G4PenelopeOscillatorManager::BuildOscillatorTable()",
780 for (
G4int k=0;k<nElements;k++)
782 G4double Z = (*elementVector)[k]->GetZ();
783 if (Z>Zmax) Zmax =
Z;
788 for (
size_t i=0;i<helper->size() && !found;i++)
790 G4double Z = (*helper)[i].GetParentZ();
791 G4int shID = (*helper)[i].GetParentShellID();
792 if (shID == 10 && Z == Zmax)
795 if ((*helper)[i].GetIonisationEnergy() > cutEnergy)
796 cutEnergy = (*helper)[i].GetIonisationEnergy();
801 G4double lowEnergyLimitForFluorescence = 250*
eV;
802 cutEnergy =
std::min(cutEnergy,lowEnergyLimitForFluorescence);
813 std::sort(helper->begin(),helper->end(),comparator);
816 for (
size_t i=0;i<helper->size();i++)
820 theTable->push_back(theOsc);
826 size_t Nost = theTable->size();
828 size_t firstIndex = (isAConductor) ? 1 : 0;
830 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;
907 G4cout <<
"Final grouping factor for Ionisation: " << Rgroup <<
G4endl;
911 for (
size_t i=0;i<theTable->size();i++)
914 G4double ionEne = (*theTable)[i]->GetIonisationEnergy();
915 if (ionEne < 1
e-3*
eV)
917 G4double resEne = (*theTable)[i]->GetResonanceEnergy();
918 (*theTable)[i]->SetIonisationEnergy(0.*
eV);
919 (*theTable)[i]->SetCutoffRecoilResonantEnergy(resEne);
922 (*theTable)[i]->SetCutoffRecoilResonantEnergy(ionEne);
938 std::sort(helper->begin(),helper->end());
940 for (
size_t i=0;i<helper->size();i++)
944 theTableC->push_back(theOsc);
949 Nost = theTableC->size();
951 firstIndex = (isAConductor) ? 1 : 0;
957 if (Nost>firstIndex+1)
960 for (
size_t i=firstIndex;i<theTableC->size()-1;i++)
964 G4double ionEne = (*theTableC)[i]->GetIonisationEnergy();
965 G4double ionEnePlus1 = (*theTableC)[i+1]->GetIonisationEnergy();
966 G4double oscStre = (*theTableC)[i]->GetOscillatorStrength();
967 G4double oscStrePlus1 = (*theTableC)[i+1]->GetOscillatorStrength();
969 if (ionEne>cutEnergy)
971 if (ionEne<1.0*
eV || ionEnePlus1<1.0*
eV)
973 if (ionEnePlus1 > Rgroup*ionEne)
979 oscStrePlus1*ionEnePlus1)/
980 (oscStre+oscStrePlus1);
981 (*theTableC)[i]->SetIonisationEnergy(newIon);
982 G4double newStre = oscStre+oscStrePlus1;
983 (*theTableC)[i]->SetOscillatorStrength(newStre);
984 G4double newHartree = (oscStre*(*theTableC)[i]->GetHartreeFactor()+
985 oscStrePlus1*(*theTableC)[i+1]->GetHartreeFactor())/
986 (oscStre+oscStrePlus1);
987 (*theTableC)[i]->SetHartreeFactor(newHartree);
988 if ((*theTableC)[i]->GetParentZ() != (*theTableC)[i+1]->GetParentZ())
989 (*theTableC)[i]->SetParentZ(0.);
990 (*theTableC)[i]->SetShellFlag(30);
991 (*theTableC)[i]->SetParentShellID((*theTableC)[i]->GetShellFlag());
993 if (i<theTableC->size()-2)
995 for (
size_t ii=i+1;ii<theTableC->size()-1;ii++)
996 (*theTableC)[ii] = (*theTableC)[ii+1];
998 theTableC->erase(theTableC->begin()+theTableC->size()-1);
1005 Nost -= removedLevels;
1008 if (Rgroup < 2.0 || Nost > 64)
1010 Rgroup = Rgroup*Rgroup;
1018 G4cout <<
"Final grouping factor for Compton: " << Rgroup <<
G4endl;
std::map< const G4Material *, G4double > * excitationEnergy
G4double elementData[5][2000]
std::vector< G4Element * > G4ElementVector
std::ostringstream G4ExceptionDescription
G4double GetTotNbOfAtomsPerVolume() const
const G4double * GetFractionVector() const
std::map< const G4Material *, G4PenelopeOscillatorTable * > * oscillatorStoreIonisation
void SetParentZ(G4double parZ)
void SetOscillatorStrength(G4double ostr)
std::map< const G4Material *, G4double > * plasmaSquared
G4GLOB_DLL std::ostream G4cout
void SetHartreeFactor(G4double hf)
std::map< const G4Material *, G4double > * atomicMass
void SetIonisationEnergy(G4double ie)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
std::map< const G4Material *, G4PenelopeOscillatorTable * > * oscillatorStoreCompton
void SetParentShellID(G4int psID)
G4double G4Exp(G4double initial_x)
Exponential Function double precision.
std::vector< G4PenelopeOscillator * > G4PenelopeOscillatorTable
size_t GetNumberOfElements() const
const G4ElementVector * GetElementVector() const
std::map< std::pair< const G4Material *, G4int >, G4double > * atomTablePerMolecule
void Dump(const G4Material *)
const G4String & GetName() const
std::map< const G4Material *, G4double > * atomicNumber
void SetShellFlag(G4int theflag)
std::map< const G4Material *, G4double > * atomsPerMolecule