Skip to content
Snippets Groups Projects
Commit 49885495 authored by Baptiste LENIAU's avatar Baptiste LENIAU
Browse files

Add GetMass and MeanMolarMass Function

git-svn-id: svn+ssh://svn.in2p3.fr/class@276 0e7d625b-0364-4367-a6be-d5be4a48d228
parent 39102793
No related branches found
No related tags found
No related merge requests found
......@@ -8,7 +8,7 @@
#include <fstream>
#include <string>
#include <algorithm>
#include "CLASSHeaders.hxx"
//________________________________________________________________________
//________________________________________________________________________
//
......@@ -451,6 +451,49 @@ IsotopicVector IsotopicVector::GetSpeciesComposition(int z) const
return IV;
}
//________________________________________________________________________
double IsotopicVector::GetTotalMass() const
{
double TotalMass = 0;
double AVOGADRO=6.02214129e23;
map<ZAI ,double >::iterator it;
map<ZAI ,double > isotopicquantity = GetIsotopicQuantity();
for( it = isotopicquantity.begin(); it != isotopicquantity.end(); it++)
{
ZAI zai = ((*it).first);
double MolarMass = zai.GetMass();
TotalMass += (*it).second/AVOGADRO * MolarMass ;
}
return TotalMass*1e-6;//in tons
}
//________________________________________________________________________
double IsotopicVector::MeanMolar() const
{
double MeanMolar = 0;
map<ZAI ,double >::iterator it;
map<ZAI ,double > isotopicquantity = GetIsotopicQuantity();
double NTot=0;
for( it = isotopicquantity.begin(); it != isotopicquantity.end(); it++)
NTot+= (*it).second ;
for( it = isotopicquantity.begin(); it != isotopicquantity.end(); it++)
{
ZAI zai = ((*it).first);
double MolarMass = zai.GetMass();
MeanMolar += (*it).second/NTot * MolarMass ;
}
return MeanMolar;
}
//________________________________________________________________________
vector<ZAI> IsotopicVector::GetZAIList() const
{
......
#include "ZAI.hxx"
#include "CLASSHeaders.hxx"
//const string DEFAULTDATABASE = "DecayBase.dat";
//________________________________________________________________________
......@@ -18,6 +20,7 @@ ZAI ZAI::operator=(ZAI IVa)
fZ = IVa.Z();
fA = IVa.A();
fI = IVa.I();
fMass = IVa.GetMass();
return *this;
}
......@@ -39,21 +42,20 @@ ZAI::~ZAI()
}
//________________________________________________________________________
ZAI::ZAI(int Z, int A, int I)
ZAI::ZAI(int Z, int A, int I,bool IsMassSet)
{
fZ=Z;
fA=A;
fI=I;
}
//________________________________________________________________________
double ZAI::GetMass()
{
return fMass;
}
if(!IsMassSet)
fMass=0;
//________________________________________________________________________
else
{
fMass=cZAIMass.GetMass(Z,A);
}
}
......@@ -29,7 +29,7 @@ ZAIMass::ZAIMass()
while (infile>>Z>>A>>Name>>MassUnity>>MassDec>>error)
{
double Masse=MassUnity+MassDec*1e-6;
fZAIMass.insert( pair< ZAI,double >( ZAI(Z,A,0), Masse ) );
fZAIMass.insert( pair< ZAI,double >( ZAI(Z,A,0,false), Masse ) );
}
infile.close();
......@@ -42,3 +42,15 @@ ZAIMass::~ZAIMass()
fZAIMass.clear();
}
double ZAIMass::GetMass(const int Z,const int A) const
{
map<ZAI,double> ZAIMasscpy = fZAIMass ;
map<ZAI,double>::iterator MassIT = ZAIMasscpy.find( ZAI(Z,A,0,false) );
if(MassIT==fZAIMass.end())
return A;
else
return MassIT->second;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment