Skip to content

Commit

Permalink
Fix Mistake on Bragg's Law
Browse files Browse the repository at this point in the history
It uses weight stoichiometries.
  • Loading branch information
Arucard1983 authored Jan 28, 2020
1 parent b36441e commit cd33ce6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/ReactionYield.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ Element::Element(ElementDatabase ThisElement, ZieglerParameters ThisZiegler, Ele
Sucess = true;
}


// Calculate the cross-section from the table of data
double Element::EvaluateSigma(double AtEnergy)
{
Expand Down Expand Up @@ -643,13 +644,32 @@ Vector ElementExtra::GetAllMass()
return results;
}

// Evaluate the weight stoichiometry ratio
double ElementExtra::GetWeightStoichiometry(int i)
{
double WeightStoichiometry = 0;
for(int k=0; k<this->GetCount(); k++)
{
WeightStoichiometry = WeightStoichiometry + this->Item(k).GetStoichiometry() * this->Item(k).GetAtomicMass();
}
if(std::abs(WeightStoichiometry)>0)
{
return this->Item(i).GetStoichiometry() * this->Item(i).GetAtomicMass() / WeightStoichiometry;
}
else
{
return 0;
}
}


// Evaluate the stopping power of all Elements, combined with the Bragg´s Law.
double ElementExtra::EvaluateBragg(double AtEnergy)
{
double StoppingPowerSum = 0;
for (int i=0; i<this->GetCount(); i++)
{
StoppingPowerSum = StoppingPowerSum + this->Item(i).EvaluateZiegler(AtEnergy) * this->Item(i).GetStoichiometry();
StoppingPowerSum = StoppingPowerSum + this->Item(i).EvaluateZiegler(AtEnergy) * this->GetWeightStoichiometry(i);
}
return StoppingPowerSum;
}
Expand Down
1 change: 1 addition & 0 deletions src/ReactionYield.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ int NumberParameters;
ElementExtra(){};
double GetTotalStoichiometry();
double GetTotalMass();
double GetWeightStoichiometry(int i);
double EvaluateCrossSection(int ElementID, double AtEnergy, double DeltaEnergy);
double GetEnergyMinimum(int ElementID){return this->Item(ElementID).GetEnergyMinimum();};
double GetEnergyMaximum(int ElementID){return this->Item(ElementID).GetEnergyMaximum();};
Expand Down

0 comments on commit cd33ce6

Please sign in to comment.