OPAL (Object Oriented Parallel Accelerator Library)  2024.1
OPAL
BeamStrippingPhysics.h
Go to the documentation of this file.
1 //
2 // Class BeamStrippingPhysics
3 // Defines the physical processes of residual gas
4 // interactions and Lorentz stripping
5 //
6 // Copyright (c) 2018 - 2021, Pedro Calvo, CIEMAT, Spain
7 // All rights reserved
8 //
9 // Implemented as part of the PhD thesis
10 // "Optimizing the radioisotope production of the novel AMIT
11 // superconducting weak focusing cyclotron"
12 //
13 // This file is part of OPAL.
14 //
15 // OPAL is free software: you can redistribute it and/or modify
16 // it under the terms of the GNU General Public License as published by
17 // the Free Software Foundation, either version 3 of the License, or
18 // (at your option) any later version.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with OPAL. If not, see <https://www.gnu.org/licenses/>.
22 //
23 #ifndef BEAMSTRIPPINGPHYSICS_H
24 #define BEAMSTRIPPINGPHYSICS_H
25 
26 #include "AbsBeamline/Component.h"
28 #include "Algorithms/Vektor.h"
30 
31 #include <gsl/gsl_math.h>
32 #include <gsl/gsl_rng.h>
33 
34 #include <memory>
35 #include <string>
36 #include <utility>
37 
38 template <class T, unsigned Dim>
39 class PartBunchBase;
40 
41 class LossDataSink;
42 class Inform;
43 class Cyclotron;
44 class Vacuum;
45 
47 
48 public:
49  BeamStrippingPhysics(const std::string& name, ElementBase* element);
51 
52  void setCyclotron(Cyclotron* cycl) { cycl_m = cycl; };
53 
54  virtual void apply(PartBunchBase<double, 3>* bunch,
55  const std::pair<Vector_t, double>& boundingSphere) override;
56 
57  virtual const std::string getType() const override;
58  virtual void print(Inform& msg) override;
59  virtual bool stillActive() override;
60 
61  virtual double getTime() override;
62  virtual std::string getName() override;
63  virtual size_t getParticlesInMat() override;
64  virtual unsigned getRediffused() override;
65  virtual unsigned int getNumEntered() override;
66 
68 
69 private:
70 
71  void computeCrossSection(double energy);
72 
73  double computeCrossSectionNakai(double energy, double energyThreshold, int& i);
74 
75  double computeCrossSectionTabata(double energy, double energyThreshold,
76  double a1, double a2, double a3,
77  double a4, double a5, double a6);
78 
79  double computeCrossSectionChebyshev(double energy, double energyMin, double energyMax);
80 
81  double computeCrossSectionBohr(double energy, int zTarget, double massInAmu);
82 
83  bool evalGasStripping(double& deltas);
84  bool evalLorentzStripping(double& gamma, double& eField);
85 
86  void getSecondaryParticles(PartBunchBase<double, 3>* bunch, size_t& i, bool pdead_LS);
87 
89 
91  Vector_t& /*P*/,
92  const double /*deltat*/,
93  bool /*includeFluctuations*/) const override {
94  return false;
95  }
96 
97  void gatherStatistics();
98 
100 
103 
104  gsl_rng* r_m;
105 
106  double T_m; // s
107  double dT_m; // s
108  double mass_m; // GeV/c2
109  double pressure_m; // mbar
110  double temperature_m; // K
111 
112  std::unique_ptr<LossDataSink> lossDs_m;
113 
115  double nCSA_m;
116  double nCSB_m;
117  double nCSC_m;
118  double nCSTotal_m;
119 
124 
125  static const double csCoefSingle_Hminus[3][9];
126  static const double csCoefDouble_Hminus[3][9];
127  static const double csCoefSingle_Hplus[3][9];
128  static const double csCoefDouble_Hplus[3][9];
129  static const double csCoefSingleLoss_H[3][9];
130  static const double csCoefSingleCapt_H[3][9];
131 
132  static const double csCoefSingle_Hplus_Tabata[10];
133  static const double csCoefHminusProduction_H_Tabata[13];
134  static const double csCoefProtonProduction_H_Tabata[9];
135  static const double csCoefProtonProduction_H2plus_Tabata[11];
136  static const double csCoefH3plusProduction_H2plus_Tabata[7];
137 
138  static const double csCoefSingle_Hminus_Chebyshev[11];
139  static const double csCoefDouble_Hminus_Chebyshev[11];
140  static const double csCoefSingle_Hplus_Chebyshev[11];
141  static const double csCoefDouble_Hplus_Chebyshev[11];
144  static const double energyRangeH2plusinH2[2];
145  static double a_m[9];
146  static double b_m[3][9];
147 };
148 
149 
150 inline
152  return T_m;
153 }
154 
155 inline
157  return (element_ref_m->getName() + "_" + name_m);
158 }
159 
160 inline
162  return totalPartsInMat_m;
163 }
164 
165 inline
167  return rediffusedStat_m;
168 }
169 
170 inline
172  return bunchToMatStat_m;
173 }
174 
175 inline
177  return totalPartsInMat_m != 0;
178 }
179 
180 inline
181 const std::string BeamStrippingPhysics::getType() const {
182  return "BeamStrippingPhysics";
183 }
184 
185 #endif //BEAMSTRIPPINGPHYSICS_H
double computeCrossSectionTabata(double energy, double energyThreshold, double a1, double a2, double a3, double a4, double a5, double a6)
virtual void print(Inform &msg) override
virtual void apply(PartBunchBase< double, 3 > *bunch, const std::pair< Vector_t, double > &boundingSphere) override
bool evalLorentzStripping(double &gamma, double &eField)
double computeCrossSectionBohr(double energy, int zTarget, double massInAmu)
static const double csCoefProtonProduction_H_Tabata[9]
void doPhysics(PartBunchBase< double, 3 > *bunch)
virtual const std::string getType() const override
static const double csCoefSingleLoss_H[3][9]
virtual std::string getName() override
void computeCrossSection(double energy)
static const double energyRangeH2plusinH2[2]
double nCSA_m
macroscopic cross sections
virtual double getTime() override
virtual unsigned int getNumEntered() override
static const double csCoefSingle_Hminus_Chebyshev[11]
virtual bool stillActive() override
Definition: Vacuum.h:61
virtual const std::string & getName() const
Get element name.
static const double csCoefDouble_Hplus[3][9]
static const double csCoefDouble_Hminus[3][9]
static const double csCoefDouble_Hplus_Chebyshev[11]
void getSecondaryParticles(PartBunchBase< double, 3 > *bunch, size_t &i, bool pdead_LS)
void transformToSecondary(PartBunchBase< double, 3 > *bunch, size_t &i, ParticleType type)
Definition: Inform.h:42
virtual size_t getParticlesInMat() override
static const double csCoefProtonProduction_H2plus_Tabata[11]
static const double csCoefH3plusProduction_H2plus_Tabata[7]
static double b_m[3][9]
static const double csCoefHydrogenProduction_H2plus_Chebyshev[11]
bool computeEnergyLoss(PartBunchBase< double, 3 > *, Vector_t &, const double, bool) const override
static const double csCoefSingleCapt_H[3][9]
const std::string name
virtual unsigned getRediffused() override
ParticleType
std::unique_ptr< LossDataSink > lossDs_m
static const double csCoefHminusProduction_H_Tabata[13]
bool evalGasStripping(double &deltas)
static const double csCoefSingle_Hplus_Chebyshev[11]
static const double csCoefSingle_Hplus_Tabata[10]
static const double csCoefDouble_Hminus_Chebyshev[11]
BeamStrippingPhysics(const std::string &name, ElementBase *element)
static const double csCoefSingle_Hplus[3][9]
SDDS1 &description type
Definition: test.stat:4
void setCyclotron(Cyclotron *cycl)
double computeCrossSectionChebyshev(double energy, double energyMin, double energyMax)
static const double csCoefProtonProduction_H2plus_Chebyshev[11]
static const double csCoefSingle_Hminus[3][9]
double computeCrossSectionNakai(double energy, double energyThreshold, int &i)