40 #include <boost/math/special_functions/chebyshev.hpp>
44 virtual ~InsideTester() {}
46 virtual double getPressure(
const Vector_t&
R) = 0;
49 struct BeamStrippingInsideTester:
public InsideTester {
50 explicit BeamStrippingInsideTester(
ElementBase* el) {
51 vac_m =
static_cast<Vacuum*
>(el);
53 virtual bool checkHit(
const Vector_t&
R) {
57 return vac_m->checkPressure(
R(0),
R(1));
85 const gsl_rng_type*
T;
89 unsigned long mySeed = tv.tv_sec + tv.tv_usec;
91 r_m = gsl_rng_alloc (
T);
92 gsl_rng_set(
r_m, mySeed);
114 "BeamStrippingPhysics::apply",
116 " is not supported for residual stripping interactions!");
138 InsideTester* tester;
142 for (
size_t i = 0; i < bunch->
getLocalNum(); ++i) {
143 if ( (bunch->
Bin[i] != -1) && (tester->checkHit(bunch->
R[i]))) {
145 bool pdead_GS =
false;
146 bool pdead_LS =
false;
153 double beta =
std::sqrt(1.0 - 1.0 / (gamma * gamma));
161 double bField = 0.1 *
std::sqrt(extB[0]*extB[0] + extB[1]*extB[1] + extB[2]*extB[2]);
162 double eField = gamma * beta *
Physics::c * bField;
166 if (pdead_GS ==
true || pdead_LS ==
true) {
168 bunch->
R[i], bunch->
P[i],
170 bunch->
Q[i], bunch->
M[i]));
175 <<
" is deleted by beam stripping" <<
endl;
180 <<
": Total number of particles after beam stripping = "
191 size_t& i,
double energy) {
198 double energyThreshold = 0.0;
211 double molecularDensity[3] = {};
217 double energyMin = 0.0, energyMax = 0.0;
218 double csA = 0.0, csB = 0.0, csC = 0.0, csTotal = 0.0;
226 for (
int i = 0; i < 9; ++i)
233 for (
int i = 0; i < 9; ++i)
243 for (
int i = 0; i < 9; ++i)
250 for (
int i = 0; i < 9; ++i)
321 for (
int i = 0; i < 9; ++i)
334 for (
int i = 0; i < 9; ++i)
348 csTotal = csA + csB + csC;
350 nCSA = csA * 1E-4 * molecularDensity[0];
351 nCSB = csB * 1E-4 * molecularDensity[0];
352 nCSC = csC * 1E-4 * molecularDensity[0];
353 nCSTotal = csTotal * 1E-4 * molecularDensity[0];
359 int zTarget[3] = {7, 8, 18};
360 static const double fMolarFraction[3] = {0.78084, 0.20947, 0.00934};
361 double csSingle[3], csDouble[3], csTotal[3];
362 double nCSSingle[3], nCSDouble[3], nCS[3];
363 double nCSSingleSum = 0.0;
364 double nCSDoubleSum = 0.0;
365 double nCSTotalSum = 0.0;
367 for (
int i = 0; i < 3; ++i) {
373 for (
int j = 0; j < 8; ++j)
379 for (
int j = 0; j < 8; ++j)
386 for (
int j = 0; j < 8; ++j)
393 for (
int j = 0; j < 8; ++j)
395 if (
b_m[i][7] != 0) {
405 for (
int j = 0; j < 8; ++j)
411 for (
int j = 0; j < 8; ++j)
413 if (
b_m[i][7] != 0) {
429 csTotal[i] = csSingle[i] + csDouble[i];
430 nCSSingle[i] = csSingle[i] * 1E-4 * molecularDensity[i];
431 nCSDouble[i] = csDouble[i] * 1E-4 * molecularDensity[i];
432 nCS[i] = csTotal[i] * 1E-4 * molecularDensity[i];
434 nCSSingleSum += nCSSingle[i];
435 nCSDoubleSum += nCSDouble[i];
436 nCSTotalSum += nCS[i];
458 if (energy <= energyThreshold) {
462 const double sigma_0 = 1E-16;
464 double effectiveEnergy = energy - energyThreshold;
465 double f1 = sigma_0 *
b_m[i][0] *
std::pow((effectiveEnergy/E_R),
b_m[i][1]);
466 if (
b_m[i][2] != 0.0 &&
b_m[i][3] != 0.0) {
484 double a1,
double a2,
double a3,
485 double a4,
double a5,
double a6) {
486 if (energy <= energyThreshold) {
489 const double sigma_0 = 1E-16;
491 double effectiveEnergy = energy - energyThreshold;
493 if (a3 != 0.0 && a4 != 0.0) {
494 sigma = f1 / (1 +
std::pow((effectiveEnergy/a3),(a2+a4)) +
std::pow((effectiveEnergy/a5),(a2+a6)));
496 sigma = f1 / (1 +
std::pow((effectiveEnergy/a5),(a2+a6)));
511 if (energy <= energyMin || energy >= energyMax) {
515 double aT[8] = {0.0};
517 for (
int i = 0; i < 8; ++i) {
518 aT[i] = (
a_m[i+1] * boost::math::chebyshev_t(i+1, x));
534 double energyAmu = energy / massInAmu;
535 if (energyAmu <= 1E3 || energyAmu >= 1E5) {
539 double mass =
mass_m * 1e6;
543 double z = (zTarget + zTarget*zTarget);
554 double xi = gsl_rng_uniform(
r_m);
567 double xi = gsl_rng_uniform(
r_m);
572 const double p = 0.0126;
573 const double s0 = 0.783;
575 const double k0 =
std::sqrt(2 * me * eps0)/hbar;
578 double tau = (4 * me * zT)/(s0 *
n *
n * hbar * (1+p)*(1+p) * (1-1/(2*k0*zT))) *
std::exp(4*k0*zT/3);
585 size_t& i,
bool pdead_LS) {
586 double r = gsl_rng_uniform(
r_m);
593 if (pdead_LS ==
true) {
670 "Tracking secondary particles from incident "
671 "ParticleType::DEUTERON is not implemented");
683 <<
" is transformed to proton" <<
endl;
692 <<
" is transformed to neutral hydrogen" <<
endl;
701 <<
" is transformed to negative hydrogen ion" <<
endl;
710 <<
" is transformed to H3+" <<
endl;
730 {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},
731 {-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},
732 {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}
735 {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},
736 {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},
737 {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}
740 {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},
741 {-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},
742 {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}
745 {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},
746 {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},
747 {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}
750 {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},
751 {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},
752 {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}
755 {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},
756 {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},
757 {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}
762 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
765 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
768 2.0E-02, 2.53E-04, 1.728E+00, 2.164E+00, 7.74E-01, 1.639E+00, 1.43E+01, 0, 0
771 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
774 0.00E+00, 6.05E+00, -5.247E-01, 4.088E-03, 2.872E+00, 7.3E-03, 6.99E+00
777 2.3, 1.7E+07, -73.1505813599, -1.7569509745, -2.0016760826, -0.1902804971, 0.0171353221, 0.1270833164, -0.1523126215, 0, 0
780 1.00E+03, 1.00E+07, -79.0158996582, -2.1025185585, -1.2407282591, 0.174798578, 0.1062489152, -0.0004342734, -0.0465673618, 0, 0
783 2.6E+00, 4.00E+06, -82.5164, -6.70755, -6.10977, -2.6281, 0.709759, 0.639033, 0.10298, 0.26124, -0.263817
786 200, 1.00E+06, -95.8165, -7.17049, -7.48288, -1.93034, 0.761153, 0.556689, -0.0542859, -0.270184, -0.0147
789 2.00E+03, 1.00E+05, -70.670173645, -0.632612288, -0.6065212488, -0.0915143117, -0.0121710282, 0.0168179292, 0.0104796877, 0, 0
792 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.
double dot(const Vector3D &lhs, const Vector3D &rhs)
Vector dot product.
Inform & endl(Inform &inf)
Inform & level4(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_h3p
The H3+ 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.
ParticleAttrib< int > Bin
std::string getPTypeString()
size_t getLocalNum() const
ParticleAttrib< double > M
size_t getTotalNum() const
ParticleAttrib< Vector_t > P
ParticleAttrib< ParticleType > PType
ParticleAttrib< ParticleOrigin > POrigin
ParticleAttrib< double > Q
ParticleType getPType() const
virtual bool apply(const size_t &id, const double &t, Vector_t &E, Vector_t &B)
ResidualGas getResidualGas() const
double getTemperature() const
int checkPoint(const double &x, const double &y, const double &z)
virtual bool getStop() const
static const double csCoefProtonProduction_H_Tabata[9]
double computeCrossSectionNakai(double energy, double energyThreshold, int &i)
static const double csCoefProtonProduction_H2plus_Tabata[11]
double nCSA
macroscopic cross sections
static const double csCoefProtonProduction_H2plus_Chebyshev[11]
static const double csCoefDouble_Hminus[3][9]
virtual std::string getName()
static const double csCoefSingle_Hminus[3][9]
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 transformToHydrogen(PartBunchBase< double, 3 > *bunch, size_t &i)
void doPhysics(PartBunchBase< double, 3 > *bunch)
static const double csCoefHminusProduction_H_Tabata[13]
double computeCrossSectionBohr(double energy, int zTarget, double massInAmu)
static const double csCoefSingleCapt_H[3][9]
static const double csCoefDouble_Hplus_Chebyshev[11]
virtual void apply(PartBunchBase< double, 3 > *bunch, const std::pair< Vector_t, double > &boundingSphere)
static const double csCoefSingle_Hplus[3][9]
void transformToH3plus(PartBunchBase< double, 3 > *bunch, size_t &i)
void transformToHminus(PartBunchBase< double, 3 > *bunch, size_t &i)
static const double csCoefSingleLoss_H[3][9]
static const double csCoefSingle_Hplus_Chebyshev[11]
virtual bool stillActive()
virtual void print(Inform &msg)
void computeCrossSection(PartBunchBase< double, 3 > *bunch, size_t &i, double energy)
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)
void transformToProton(PartBunchBase< double, 3 > *bunch, size_t &i)
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]
ElementBase * element_ref_m
ElementBase * getElement()
virtual bool checkHit(const Vector_t &R)=0
Vektor< double, 3 > Vector_t