mirror of
https://github.com/gwm17/catima.git
synced 2024-11-22 10:18:50 -05:00
Fix bug in integrator where occasionally step past 0 energy when stopping in material
This commit is contained in:
parent
629690a6f9
commit
671cda3c0f
|
@ -1,3 +1,8 @@
|
||||||
|
/*
|
||||||
|
* Simple energy loss integrators for forward and reverse cases.
|
||||||
|
*
|
||||||
|
* Dec 2022, Gordon McCann
|
||||||
|
*/
|
||||||
#include "catima/gwm_integrators.h"
|
#include "catima/gwm_integrators.h"
|
||||||
|
|
||||||
namespace catima {
|
namespace catima {
|
||||||
|
@ -34,6 +39,10 @@ namespace catima {
|
||||||
{
|
{
|
||||||
return e_in*proj.A;
|
return e_in*proj.A;
|
||||||
}
|
}
|
||||||
|
else if (e_final > 0.0)
|
||||||
|
{
|
||||||
|
return e_in * proj.A; //In case an integration step takes us below 0
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
e_step = dedx(proj, mat, c)*x_step*A_recip;
|
e_step = dedx(proj, mat, c)*x_step*A_recip;
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
/*
|
||||||
|
* Simple energy loss integrators for forward and reverse cases.
|
||||||
|
*
|
||||||
|
* Dec 2022, Gordon McCann
|
||||||
|
*/
|
||||||
#ifndef GWM_INTEGRATORS_H
|
#ifndef GWM_INTEGRATORS_H
|
||||||
#define GWM_INTEGRATORS_H
|
#define GWM_INTEGRATORS_H
|
||||||
|
|
||||||
|
@ -10,4 +15,4 @@ namespace catima {
|
||||||
double reverse_integrate_energyloss(Projectile& proj, const Material& mat, const Config& c=default_config);
|
double reverse_integrate_energyloss(Projectile& proj, const Material& mat, const Config& c=default_config);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
/*
|
||||||
|
* Testing for gwm_integrators
|
||||||
|
*
|
||||||
|
* Dec 2022, Gordon McCann
|
||||||
|
*/
|
||||||
#include "catima/gwm_integrators.h"
|
#include "catima/gwm_integrators.h"
|
||||||
#include "catima/nucdata.h"
|
#include "catima/nucdata.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
@ -14,4 +19,4 @@ int main()
|
||||||
result = catima::reverse_integrate_energyloss(p1, mat1);
|
result = catima::reverse_integrate_energyloss(p1, mat1);
|
||||||
std::cout<<"Reverse Energy loss (MeV): "<<result<<" Initial energy: "<<p1.T<<std::endl;
|
std::cout<<"Reverse Energy loss (MeV): "<<result<<" Initial energy: "<<p1.T<<std::endl;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user