1
0
Fork 0
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:
Gordon McCann 2022-12-01 09:39:02 -05:00
parent 629690a6f9
commit 671cda3c0f
3 changed files with 21 additions and 2 deletions

View File

@ -1,3 +1,8 @@
/*
* Simple energy loss integrators for forward and reverse cases.
*
* Dec 2022, Gordon McCann
*/
#include "catima/gwm_integrators.h"
namespace catima {
@ -34,6 +39,10 @@ namespace catima {
{
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
{
e_step = dedx(proj, mat, c)*x_step*A_recip;

View File

@ -1,3 +1,8 @@
/*
* Simple energy loss integrators for forward and reverse cases.
*
* Dec 2022, Gordon McCann
*/
#ifndef 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);
}
#endif
#endif

View File

@ -1,3 +1,8 @@
/*
* Testing for gwm_integrators
*
* Dec 2022, Gordon McCann
*/
#include "catima/gwm_integrators.h"
#include "catima/nucdata.h"
#include <iostream>
@ -14,4 +19,4 @@ int main()
result = catima::reverse_integrate_energyloss(p1, mat1);
std::cout<<"Reverse Energy loss (MeV): "<<result<<" Initial energy: "<<p1.T<<std::endl;
}
}