38#include <boost/math/special_functions/chebyshev.hpp>
50 vac_m =
static_cast<Vacuum*
>(el);
53 return vac_m->checkPoint(
R);
81 const gsl_rng_type*
T;
85 unsigned long mySeed = tv.tv_sec + tv.tv_usec;
87 r_m = gsl_rng_alloc (
T);
88 gsl_rng_set(
r_m, mySeed);
99 const std::pair<Vector_t, double>& ) {
109 "BeamStrippingPhysics::apply",
111 " is not supported for residual stripping interactions!");
119 "Unsupported element type");
154 for (
size_t i = 0; i < bunch->
getLocalNum(); ++i) {
161 bool pdead_GS =
false;
162 bool pdead_LS =
false;
169 double beta =
std::sqrt(1.0 - 1.0 / (gamma * gamma));
179 double eField = gamma * beta *
Physics::c * bField;
183 if (pdead_GS ==
true || pdead_LS ==
true) {
187 bunch->
Q[i], bunch->
M[i]));
192 <<
" is deleted by beam stripping interactions" <<
endl;
208 double energyThreshold = 0.0;
221 double molecularDensity[3] = {};
227 double energyMin = 0.0, energyMax = 0.0;
228 double csA = 0.0, csB = 0.0, csC = 0.0, csTotal = 0.0;
236 for (
int i = 0; i < 9; ++i)
243 for (
int i = 0; i < 9; ++i)
253 for (
int i = 0; i < 9; ++i)
260 for (
int i = 0; i < 9; ++i)
331 for (
int i = 0; i < 9; ++i)
344 for (
int i = 0; i < 9; ++i)
358 csTotal = csA + csB + csC;
369 int zTarget[3] = {7, 8, 18};
370 static const double fMolarFraction[3] = {0.78084, 0.20947, 0.00934};
371 double csSingle[3], csDouble[3], csTotal[3];
372 double nCSSingle[3], nCSDouble[3], nCS[3];
373 double nCSSingleSum = 0.0;
374 double nCSDoubleSum = 0.0;
375 double nCSTotalSum = 0.0;
377 for (
int i = 0; i < 3; ++i) {
383 for (
int j = 0; j < 8; ++j)
389 for (
int j = 0; j < 8; ++j)
396 for (
int j = 0; j < 8; ++j)
403 for (
int j = 0; j < 8; ++j)
405 if (
b_m[i][7] != 0) {
415 for (
int j = 0; j < 8; ++j)
421 for (
int j = 0; j < 8; ++j)
423 if (
b_m[i][7] != 0) {
439 csTotal[i] = csSingle[i] + csDouble[i];
444 nCSSingleSum += nCSSingle[i];
445 nCSDoubleSum += nCSDouble[i];
446 nCSTotalSum += nCS[i];
468 if (energy <= energyThreshold) {
472 const double sigma_0 = 1E-16;
474 double effectiveEnergy = energy - energyThreshold;
475 double f1 = sigma_0 *
b_m[i][0] *
std::pow((effectiveEnergy / E_R),
b_m[i][1]);
476 if (
b_m[i][2] != 0.0 &&
b_m[i][3] != 0.0) {
477 sigma = f1 / (1 +
std::pow((effectiveEnergy /
b_m[i][2]), (
b_m[i][1] +
b_m[i][3]))
480 sigma = f1 / (1 +
std::pow((effectiveEnergy /
b_m[i][4]), (
b_m[i][1] +
b_m[i][5])));
494 double a1,
double a2,
double a3,
495 double a4,
double a5,
double a6) {
496 if (energy <= energyThreshold) {
499 const double sigma_0 = 1E-16;
501 double effectiveEnergy = energy - energyThreshold;
503 if (a3 != 0.0 && a4 != 0.0) {
504 sigma = f1 / (1 +
std::pow((effectiveEnergy / a3), (a2 + a4)) +
std::pow((effectiveEnergy / a5), (a2 + a6)));
506 sigma = f1 / (1 +
std::pow((effectiveEnergy / a5), (a2 + a6)));
521 if (energy <= energyMin || energy >= energyMax) {
525 double aT[8] = {0.0};
527 for (
int i = 0; i < 8; ++i) {
528 aT[i] = (
a_m[i+1] * boost::math::chebyshev_t(i+1, x));
544 double energyAmu = energy / massInAmu;
545 if (energyAmu <= 1E3 || energyAmu >= 1E5) {
554 double z = (zTarget + zTarget*zTarget);
565 double xi = gsl_rng_uniform(
r_m);
578 double xi = gsl_rng_uniform(
r_m);
583 const double p = 0.0126;
584 const double s0 = 0.783;
586 const double k0 =
std::sqrt(2 * me * eps0)/hbar;
589 double tau = (4 * me * zT)/(s0 *
n *
n * hbar * (1+p)*(1+p) * (1-1/(2*k0*zT))) *
std::exp(4*k0*zT/3);
596 size_t& i,
bool pdead_LS) {
597 double r = gsl_rng_uniform(
r_m);
602 if (pdead_LS ==
true) {
679 "Tracking secondary particles from incident "
680 "ParticleType::DEUTERON is not implemented");
702 <<
"\n"<<
"--- BeamStrippingPhysics ---\n"
703 <<
"Name: " <<
name_m <<
" - "
716 constexpr unsigned short numItems = 3;
721 allreduce(&(partStatistics[0]), numItems, std::plus<unsigned int>());
736 {7.50E-04, 4.38E+02, 7.28E-01, 8.40E-01, 2.82E-01, 4.10E+01, 1.37E+00, 0.00E+00, 0.00E+00},
737 {-2.00E-04, 3.45E+02, 4.80E-01, 5.30E-02, 8.40E-02, 1.00E+01, 9.67E-01, 0.00E+00, 0.00E+00},
738 {1.70E-3, 2.47E+01, 3.36E-01, 7.00E+01, 5.00E-01, 9.90E+01, 7.80E-01, 0.00E+00, 0.00E+00}
741 {1.40E-02, 1.77E+00, 4.80E-01, 0.00E+00, 0.00E+00, 1.52E+02, 1.52E+00, 0.00E+00, 0.00E+00},
742 {1.30E-02, 1.90E+00, 6.20E-01, 0.00E+00, 0.00E+00, 5.20E+01, 9.93E-01, 0.00E+00, 0.00E+00},
743 {1.50E-02, 1.97E+00, 8.90E-01, 0.00E+00, 0.00E+00, 5.10E+01, 9.37E-01, 0.00E+00, 0.00E+00}
746 {2.00E-03, 1.93E+03, 1.64E+00, 1.98E+00, 6.69E-01, 2.19E+01, 4.15E+00, 3.23E-04, 1.00E+01},
747 {-1.50E-03, 3.86E+05, 1.60E+00, 6.93E-02, 3.28E-01, 7.86E+00, 3.92E+00, 3.20E-04, 1.00E+01},
748 {2.18E-03, 1.61E+04, 2.12E+00, 1.16E+00, 4.44E-01, 1.39E+01, 4.07E+00, 2.99E-04, 1.45E+01}
751 {2.90E-02, 2.90E-01, 1.50E+00, 1.39E+01, 1.65E+00, 3.94E+01, 5.79E+00, 0.00E+00, 0.00E+00},
752 {2.20E-02, 2.64E-01, 1.50E+00, 1.40E+01, 1.70E+00, 4.00E+01, 5.80E+00, 0.00E+00, 0.00E+00},
753 {2.90E-02, 1.40E-01, 1.87E+00, 2.40E+01, 1.60E+00, 3.37E+01, 4.93E+00, 4.50E-01, 2.00E-01}
756 {1.36E-02, 2.59E+03, 1.78E+00, 2.69E-01, -3.52E-01, 5.60E+00, 8.99E-01, 0.00E+00, 0.00E+00},
757 {1.36E-02, 3.29E+03, 1.85E+00, 2.89E-01, -2.72E-01, 8.20E+00, 1.09E+00, 0.00E+00, 0.00E+00},
758 {1.36E-02, 1.16E+12, 7.40E+00, 5.36E-01, -5.42E-01, 1.23E+00, 7.26E-01, 0.00E+00, 0.00E+00}
761 {1.48E-02, 1.15E+00, 1.18E+00, 1.15E+01, 1.19E+00, 3.88E+01, 3.38E+00, 1.00E-01, 2.82E-02},
762 {1.13E-02, 3.26E+00, 1.02E+00, 2.99E+00, 4.50E-01, 1.90E+01, 3.42E+00, 0.00E+00, 0.00E+00},
763 {1.50E-02, 1.24E+03, 3.38E+00, 2.46E+00, 5.20E-01, 7.00E+00, 2.56E+00, 9.10E-02, 1.95E-02}
768 2.50E-03, 2.12E+02, 1.721E+00, 6.70E-04, 3.239E-01, 4.34E-03, 1.296E+00, 1.42E-01, 9.34E+00, 2.997E+00
771 2.1E-02, 9.73E-03, 2.38E+00, 1.39E-02, -5.51E-01, 7.7E-02, 2.12E+00, 1.97E-06, 2.051E+00, 5.5E+00, 6.62E-01, 2.02E+01, 3.62E+00
774 2.0E-02, 2.53E-04, 1.728E+00, 2.164E+00, 7.74E-01, 1.639E+00, 1.43E+01, 0, 0
777 5.0E-03, 6.34E+01, 1.78E+00, 1.38E-03, 4.06E-01, 1.63E-01, 3.27E-01, 1.554E+01, 3.903E+00, 1.735, 1.02E+01
780 0.00E+00, 6.05E+00, -5.247E-01, 4.088E-03, 2.872E+00, 7.3E-03, 6.99E+00
783 2.3, 1.7E+07, -73.1505813599, -1.7569509745, -2.0016760826, -0.1902804971, 0.0171353221, 0.1270833164, -0.1523126215, 0, 0
786 1.00E+03, 1.00E+07, -79.0158996582, -2.1025185585, -1.2407282591, 0.174798578, 0.1062489152, -0.0004342734, -0.0465673618, 0, 0
789 2.6E+00, 4.00E+06, -82.5164, -6.70755, -6.10977, -2.6281, 0.709759, 0.639033, 0.10298, 0.26124, -0.263817
792 200, 1.00E+06, -95.8165, -7.17049, -7.48288, -1.93034, 0.761153, 0.556689, -0.0542859, -0.270184, -0.0147
795 2.00E+03, 1.00E+05, -70.670173645, -0.632612288, -0.6065212488, -0.0915143117, -0.0121710282, 0.0168179292, 0.0104796877, 0, 0
798 1.50E+03, 1.00E+07, -74.9261474609, -2.1944284439, -0.8558337688, 0.0421306863, 0.2162267119, 0.0921146944, -0.0893079266, 0, 0
Tps< T > log(const Tps< T > &x)
Natural logarithm.
Tps< T > pow(const Tps< T > &x, int y)
Integer power.
Tps< T > exp(const Tps< T > &x)
Exponential.
Tps< T > sqrt(const Tps< T > &x)
Square root.
void allreduce(const T *input, T *output, int count, Op op)
Inform & level2(Inform &inf)
Inform & level4(Inform &inf)
Inform & endl(Inform &inf)
constexpr double kB
Boltzman's constant in eV/K.
constexpr double amu
The atomic mass unit energy equivalent in GeV.
constexpr double a0
Bohr radius in m.
constexpr double h_bar
The reduced Planck constant in GeVs.
constexpr double m_p
The proton rest mass in GeV.
constexpr double m_h2p
The H2+ rest mass in GeV.
constexpr double q_e
The elementary charge in As.
constexpr double m_e
The electron rest mass in GeV.
constexpr double m_hm
The H- rest mass in GeV.
constexpr double E_ryd
Rydberg's energy (Rydberg's constant times hc) in GeV.
constexpr double m_h
The hydrogen atom rest mass in GeV.
constexpr double c
The velocity of light in m/s.
constexpr double pi
The value of.
double getKineticEnergy(Vector_t p, double mass)
double getGamma(Vector_t p)
std::string toStringWithThousandSep(T value, char sep='\'')
boost::function< boost::tuple< double, bool >(arguments_t)> type
ParticleAttrib< int > Bin
size_t getLocalNum() const
ParticleAttrib< double > M
ParticleAttrib< Vector_t > P
ParticleAttrib< ParticleType > PType
ParticleAttrib< ParticleOrigin > POrigin
ParticleAttrib< double > Q
ParticleType getPType() const
static OpalData * getInstance()
virtual bool apply(const size_t &id, const double &t, Vector_t &E, Vector_t &B)
virtual const std::string & getName() const
Get element name.
virtual ElementType getType() const =0
Get element type std::string.
ResidualGas getResidualGas() const
double checkPressure(const Vector_t &R)
double getTemperature() const
std::string getResidualGasName()
static std::string getParticleTypeString(const ParticleType &type)
static double getParticleMass(const ParticleType &type)
static double getParticleChargeInCoulomb(const ParticleType &type)
static const double csCoefProtonProduction_H_Tabata[9]
double computeCrossSectionNakai(double energy, double energyThreshold, int &i)
static const double csCoefProtonProduction_H2plus_Tabata[11]
unsigned totalPartsInMat_m
static const double csCoefProtonProduction_H2plus_Chebyshev[11]
static const double csCoefDouble_Hminus[3][9]
static const double csCoefSingle_Hminus[3][9]
virtual void apply(PartBunchBase< double, 3 > *bunch, const std::pair< Vector_t, double > &boundingSphere) override
void getSecondaryParticles(PartBunchBase< double, 3 > *bunch, size_t &i, bool pdead_LS)
double computeCrossSectionChebyshev(double energy, double energyMin, double energyMax)
static const double csCoefSingle_Hminus_Chebyshev[11]
static const double energyRangeH2plusinH2[2]
static const double csCoefSingle_Hplus_Tabata[10]
void doPhysics(PartBunchBase< double, 3 > *bunch)
static const double csCoefHminusProduction_H_Tabata[13]
double computeCrossSectionBohr(double energy, int zTarget, double massInAmu)
virtual void print(Inform &msg) override
static const double csCoefSingleCapt_H[3][9]
double nCSA_m
macroscopic cross sections
static const double csCoefDouble_Hplus_Chebyshev[11]
void computeCrossSection(double energy)
virtual std::string getName() override
static const double csCoefSingle_Hplus[3][9]
void transformToSecondary(PartBunchBase< double, 3 > *bunch, size_t &i, ParticleType type)
static const double csCoefSingleLoss_H[3][9]
static const double csCoefSingle_Hplus_Chebyshev[11]
unsigned rediffusedStat_m
BeamStrippingPhysics(const std::string &name, ElementBase *element)
double computeCrossSectionTabata(double energy, double energyThreshold, double a1, double a2, double a3, double a4, double a5, double a6)
bool evalLorentzStripping(double &gamma, double &eField)
std::unique_ptr< LossDataSink > lossDs_m
bool evalGasStripping(double &deltas)
static const double csCoefHydrogenProduction_H2plus_Chebyshev[11]
static const double csCoefH3plusProduction_H2plus_Tabata[7]
static const double csCoefDouble_Hminus_Chebyshev[11]
unsigned stoppedPartStat_m
static const double csCoefDouble_Hplus[3][9]
virtual bool checkHit(const Vector_t &R)=0
std::unique_ptr< InsideTester > hitTester_m
ElementBase * element_ref_m
std::ios_base::fmtflags FmtFlags_t
Vektor< double, 3 > Vector_t