1 #include "flame/constants.h"
2 #include "flame/moment.h"
3 #include "flame/moment_sup.h"
4 #include "flame/chg_stripper.h"
6 #define sqr(x) ((x)*(x))
7 #define cube(x) ((x)*(x)*(x))
10 double Gaussian(
double in,
const double Q_ave,
const double d)
13 return 1e0/sqrt(2e0*M_PI)/d*exp(-0.5e0*sqr(in-Q_ave)/sqr(d));
18 void StripperCharge(
const double beta,
double &Q_ave,
double &d)
23 Q_ave1 = Stripper_IonProton*(1e0-exp(-83.275*(beta/pow(Stripper_IonProton, 0.447))));
24 Q_ave = Q_ave1*(1e0-exp(-12.905+0.2124*Stripper_IonProton-0.00122*sqr(Stripper_IonProton)));
25 Y = Q_ave1/Stripper_IonProton;
26 d = sqrt(Q_ave1*(0.07535+0.19*Y-0.2654*sqr(Y)));
31 void ChargeStripper(
const double beta,
const std::vector<double>& ChgState, std::vector<double>& chargeAmount_Baron)
36 StripperCharge(beta, Q_ave, d);
37 for (k = 0; k < ChgState.size(); k++)
38 chargeAmount_Baron.push_back(Gaussian(ChgState[k]*Stripper_IonMass, Q_ave, d));
43 void Stripper_Propagate_ref(
Particle &ref)
47 ref.
IonZ = Stripper_IonZ;
52 ref.
IonEk = (ref.
IonEk-Stripper_Para[2])*Stripper_E0Para[1] + Stripper_E0Para[0];
57 void Stripper_GetMat(
const Config &conf,
61 double tmptotCharge, Fy_abs_recomb, Ek_recomb, stdEkFoilVariation, ZpAfStr, growthRate;
62 double stdXYp, XpAfStr, growthRateXp, YpAfStr, growthRateYp, s;
65 MomentState::matrix_t tmpmat;
66 std::vector<double> chargeAmount_Baron;
75 tmpmat = boost::numeric::ublas::zero_matrix<double>(PS_Dim);
76 for (k = 0; k < ST.
size(); k++) {
77 const double Q = ST.real[k].IonQ;
79 Fy_abs_recomb += Q*StatePtr->real[k].phis;
80 Ek_recomb += Q*StatePtr->real[k].IonEk;
82 Q*(StatePtr->moment1[k]+outer_prod(StatePtr->moment0[k]-ST.moment0_env, StatePtr->moment0[k]-ST.moment0_env));
85 Fy_abs_recomb /= tmptotCharge;
86 Ek_recomb /= tmptotCharge;
89 Ek_recomb = (Ek_recomb-Stripper_Para[2])*Stripper_E0Para[1] + Stripper_E0Para[0];
90 tmpmat /= tmptotCharge;
93 stdEkFoilVariation = sqrt(1e0/3e0)*Stripper_Para[1]/100e0*Stripper_Para[0]*Stripper_E0Para[2];
94 ZpAfStr = tmpmat(5, 5) + sqr(Stripper_E1Para) + sqr(stdEkFoilVariation);
95 growthRate = sqrt(ZpAfStr/tmpmat(5, 5));
97 for (k = 0; k < 6; k++) {
98 tmpmat(k, 5) = tmpmat(k, 5)*growthRate;
100 tmpmat(5, k) = tmpmat(5, k)*growthRate;
104 stdXYp = sqrt(Stripper_upara/sqr(Stripper_lambda))*1e-3;
105 XpAfStr = tmpmat(1, 1) + sqr(stdXYp);
106 growthRateXp = sqrt(XpAfStr/tmpmat(1, 1));
107 YpAfStr = tmpmat(3, 3) + sqr(stdXYp);
108 growthRateYp = sqrt(YpAfStr/tmpmat(3, 3));
110 for (k = 0; k < 6; k++) {
111 tmpmat(k, 1) = tmpmat(k, 1)*growthRateXp;
113 tmpmat(1, k) = tmpmat(1, k)*growthRateXp;
114 tmpmat(k, 3) = tmpmat(k, 3)*growthRateYp;
115 tmpmat(3, k) = tmpmat(3, k)*growthRateYp;
119 const std::vector<double>& ChgState = conf.
get<std::vector<double> >(
"IonChargeStates");
120 const std::vector<double>& NChg = conf.
get<std::vector<double> >(
"NCharge");
122 assert(NChg.size()==n);
126 Stripper_Propagate_ref(ref);
131 ST.moment0.resize(n);
132 ST.moment1.resize(n);
139 ChargeStripper(StatePtr->real[0].beta, ChgState, chargeAmount_Baron);
141 for (k = 0; k < n; k++) {
142 StatePtr->real[k].IonZ = ChgState[k];
143 StatePtr->real[k].IonQ = chargeAmount_Baron[k];
144 StatePtr->real[k].IonEs = ref.IonEs;
145 StatePtr->real[k].IonEk = Ek_recomb;
146 StatePtr->real[k].recalc();
147 StatePtr->real[k].phis = Fy_abs_recomb;
148 StatePtr->moment0[k] = ST.moment0_env;
149 StatePtr->moment1[k] = tmpmat;
155 void ElementStripper::advance(
StateBase &s)
162 Stripper_GetMat(conf(), ST);
double IonEk
Kinetic energy.
The abstract base class for all simulation state objects.
Associative configuration container.
double pos
absolute longitudinal position at end of Element
size_t size() const
of charge states
detail::RT< T >::type get(const std::string &name) const