26 template<
class Device>
30 Kokkos::View<double*,Kokkos::LayoutRight,Device>
v;
45 KOKKOS_INLINE_FUNCTION
double interp(
double x)
const{
47 xn=max(min(xn,
double(
n)),0.0);
50 double wp=1.0-(xn-double(ip));
51 return v(ip)*wp+
v(ip+1)*(1.0-wp);
54 KOKKOS_INLINE_FUNCTION
double dinterp(
double x)
const{
56 xn=max(min(xn,
double(
n)),0.0);
64 template<
class Device>
81 return sv[1]*tanh((
inx[0]-psi)*
sv[2]) + sv[0];
83 return sv[0]*psi+
sv[1];
85 if(abs(psi/b_field.
equil.xpt_psi)<1.0e-3) psi = 1.0e-3*b_field.
equil.xpt_psi;
86 double tmp2=
sv[2]*(
inx[0]-sqrt(
inx[0]*psi));
87 double tmp3=exp(tmp2);
88 double tmp4=exp(-tmp2);
90 return sv[1]*((1+tmp2*
sv[3])*tmp3-tmp4)/(tmp3+tmp4) +
sv[0];
93 return lin.interp(psi);
102 Profile(
double* inx_in,
double* iny_in,
double* sv_in,
double p_min_in,
double p_max_in,
int shape_int,
double* v_in )
106 for (
int i=0; i<5; i++)
inx[i]=inx_in[i];
107 for (
int i=0; i<4; i++)
iny[i]=iny_in[i];
108 for (
int i=0; i<6; i++)
sv[i]=sv_in[i];
113 }
else if(shape_int==1){
115 }
else if(shape_int==2){
117 }
else if(shape_int==5){
119 }
else if(shape_int==-1){
123 printf(
"invalid shape number in eq_ftn_setup: %d",shape_int);
132 for (
int i=0; i<5; i++)
inx[i]=0.0;
133 for (
int i=0; i<4; i++)
iny[i]=0.0;
134 for (
int i=0; i<6; i++)
sv[i]=0.0;
136 sv[1] = val_at_zero_psi;
145 for (
int i=0; i<5; i++)
inx[i]=0.0;
146 for (
int i=0; i<4; i++)
iny[i]=0.0;
147 for (
int i=0; i<6; i++)
sv[i]=0.0;
169 v_in[i] = 1.0+i/(ftn_lin_n-1.0);
179 bool is_in_rgn12 = b_field.
equil.is_in_region_1_or_2(r,z,psi_in);
180 if(is_in_rgn12 && (psi_in<=b_field.
outpsi)){
182 }
else if(is_in_rgn12 && (psi_in>b_field.
outpsi)){
187 double psi=b_field.
outpsi;
189 double tmp3=tmp2*(1.0-b_field.
equil.out_decay_factor);
190 return tmp3*exp(-abs(psi_in-psi)/b_field.
equil.out_decay_width)+b_field.
equil.out_decay_factor*tmp2;
191 }
else if(!is_in_rgn12 && z<b_field.
equil.xpt_z){
193 double psi=b_field.
equil.xpt_psi;
195 double tmp3=tmp2*(1.0-b_field.
equil.priv_flux_decay_factor);
196 return tmp3*exp(-abs(psi_in-psi)/b_field.
equil.priv_flux_decay_width)+b_field.
equil.priv_flux_decay_factor*tmp2;
197 }
else if(!is_in_rgn12 && z>b_field.
equil.xpt2_z && b_field.
equil.set_xpt2){
199 double psi=b_field.
equil.xpt2_psi;
201 double tmp3=tmp2*(1.0-b_field.
equil.priv_flux_decay_factor);
202 return tmp3*exp(-abs(psi_in-psi)/b_field.
equil.priv_flux_decay_width)+b_field.
equil.priv_flux_decay_factor*tmp2;
205 double psi=b_field.
equil.xpt_psi;
216 if(!b_field.
equil.is_in_region_1_or_2(r,z,psi_in) || (psi_in>b_field.
outpsi)){
223 double tmp2 = 1.0/cosh((
inx[0]-psi_in)*
sv[2]);
224 return -sv[2]*sv[1]*tmp2*tmp2;
228 double tmp2=
sv[2]*(
inx[0]-sqrt(
inx[0]*psi_in));
229 double tmp3=exp(tmp2);
231 if(abs(psi_in/b_field.
equil.xpt_psi)<1.0e-3){
234 return -
inx[0]*
sv[1]*
sv[2]*tmp3*tmp3*(4.0+
sv[3]*(1.0+tmp3*tmp3+2.0*tmp2))
235 /(2.0*(1.0+tmp3*tmp3)*(1.0+tmp3*tmp3)*(sqrt(
inx[0]*psi_in)));
239 return lin.dinterp(psi_in);
void array_deep_copy(T *array, const Kokkos::View< T *, Kokkos::LayoutRight, Device > &view)
Definition: array_deep_copy.hpp:11
const int ftn_lin_n
Definition: profile.hpp:23
double p_del
Definition: profile.hpp:29
KOKKOS_INLINE_FUNCTION double slope(const MagneticField< DeviceType > &b_field, double psi_in, double r, double z) const
Definition: profile.hpp:211
KOKKOS_INLINE_FUNCTION double interp(double x) const
Definition: profile.hpp:45
Shape shape
Definition: profile.hpp:66
Definition: profile.hpp:11
Definition: magnetic_field.hpp:9
Profile(double *inx_in, double *iny_in, double *sv_in, double p_min_in, double p_max_in, int shape_int, double *v_in)
Definition: profile.hpp:102
Definition: profile.hpp:12
double p_min
Definition: profile.hpp:70
int n
Definition: profile.hpp:28
CustomLinShape< Device > lin
Definition: profile.hpp:74
CustomLinShape(double p_min_in, double p_max_in, double *v_in)
Definition: profile.hpp:34
Definition: profile.hpp:15
double inx[5]
Definition: profile.hpp:67
Definition: profile.hpp:14
double outpsi
Boundary condition used in a few spots.
Definition: magnetic_field.hpp:26
KOKKOS_INLINE_FUNCTION double value_at_coords(const MagneticField< DeviceType > &b_field, double psi, double r, double z) const
Definition: profile.hpp:77
Definition: profile.hpp:17
KOKKOS_INLINE_FUNCTION double dinterp(double x) const
Definition: profile.hpp:54
Definition: profile.hpp:13
Definition: profile.hpp:16
Profile()
Definition: profile.hpp:175
double p_min
Definition: profile.hpp:29
double iny[4]
Definition: profile.hpp:68
CustomLinShape()
Definition: profile.hpp:43
Equilibrium< Device > equil
The object containing information about the magnetic equilibrium.
Definition: magnetic_field.hpp:32
Shape
Definition: profile.hpp:9
Profile(double val_at_zero_psi, double slope)
Definition: profile.hpp:129
Definition: profile.hpp:18
KOKKOS_INLINE_FUNCTION double value(const MagneticField< DeviceType > &b_field, double psi_in, double r, double z) const
Definition: profile.hpp:178
Definition: profile.hpp:27
Profile(Shape shape_in)
Definition: profile.hpp:140
Definition: profile.hpp:10
Kokkos::View< double *, Kokkos::LayoutRight, Device > v
Definition: profile.hpp:30
double sv[6]
Definition: profile.hpp:69
double p_max
Definition: profile.hpp:71
Definition: profile.hpp:65