XGC1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
loop_voltage.hpp
Go to the documentation of this file.
1 #ifndef LOOP_VOLTAGE_HPP
2 #define LOOP_VOLTAGE_HPP
3 
4 #include "grid.hpp"
5 #include "globals.hpp"
6 
7 
21 template<class Device,PhiInterpType PIT>
22 KOKKOS_INLINE_FUNCTION void add_loop_voltage(const PushControls& push_controls, const Grid<Device>& grid, const MagneticField<Device>& magnetic_field, const GridFieldPack<Device,PIT>& gfpack, const Species<Device>& species, const SimdParticles& part, const Simd<double>& B_mag, const Simd<double>& psi, SimdVector& efield, SimdGridWeights<Order::One, PIT>& grid_wts){
23 
25 
26 //#ifdef XGC1
27 // // Must use non-field-following coordinates
28 // SimdGridWeights<Order::One, PhiInterpType::None> grid_wts_no_ff;
29 // grid.get_grid_weights(magnetic_field, part.ph.v(), grid_wts_no_ff);
30 // gfpack.loop_voltage.gather(grid,grid_wts_no_ff,loop_voltage)
31 //#else
32  gfpack.loop_voltage.gather(grid,grid_wts,part.ph.phi,loop_voltage);
33 //#endif
34 
35  for (int i_simd = 0; i_simd<SIMD_SIZE; i_simd++){
36  double cmrhoB = species.c_m*part.ph.rho[i_simd]*B_mag[i_simd];
37  double f0_T_ev = species.eq_temp.value(magnetic_field, psi[i_simd],part.ph.r[i_simd],part.ph.z[i_simd]);
38 
39  // Add loop voltage if particle is within specified psi range and isn't beyond the energy threshold
40  constexpr double LOOP_VOLTAGE_HIGH_E_LIMIT_FACTOR = 16.0;
41  bool loop_voltage_on = (psi[i_simd]<push_controls.loop_voltage_psimax) &&
42  (magnetic_field.is_in_region_1_or_2(part.ph.r[i_simd],part.ph.z[i_simd],psi[i_simd])) &&
43  ((part.ct.mu[i_simd]*2.0*B_mag[i_simd] + cmrhoB*cmrhoB*species.mass)*J_2_EV<(LOOP_VOLTAGE_HIGH_E_LIMIT_FACTOR*f0_T_ev));
44  //if(loop_voltage_on) efield.phi[i_simd] += push_controls.loop_voltage/(TWOPI*part.ph.r[i_simd]);
45  if(loop_voltage_on) efield.phi[i_simd] += loop_voltage[i_simd]/(TWOPI*part.ph.r[i_simd]);
46  }
47 }
48 
49 #endif
Definition: simd.hpp:149
GridField< Device, VarType::Scalar, PIT, TorType::OnePlane, KinType::DriftKin > loop_voltage
Definition: grid_field_pack.hpp:91
KOKKOS_INLINE_FUNCTION void add_loop_voltage(const PushControls &push_controls, const Grid< Device > &grid, const MagneticField< Device > &magnetic_field, const GridFieldPack< Device, PIT > &gfpack, const Species< Device > &species, const SimdParticles &part, const Simd< double > &B_mag, const Simd< double > &psi, SimdVector &efield, SimdGridWeights< Order::One, PIT > &grid_wts)
Definition: loop_voltage.hpp:22
double c_m
c/m
Definition: species.hpp:86
Definition: grid_weights.hpp:73
Definition: push_controls.hpp:9
Definition: magnetic_field.hpp:14
double loop_voltage_psimax
Definition: push_controls.hpp:24
Definition: grid.hpp:21
Definition: grid_field_pack.hpp:21
Simd< double > rho
Definition: particles.hpp:21
constexpr double J_2_EV
Conversion rate J to ev.
Definition: constants.hpp:6
double mass
Particle mass.
Definition: species.hpp:83
Simd< double > r
Definition: particles.hpp:18
SimdPhase ph
Definition: particles.hpp:62
Simd< double > phi
Definition: simd.hpp:152
Definition: particles.hpp:61
Simd< double > z
Definition: particles.hpp:19
Simd< double > phi
Definition: particles.hpp:20
Definition: magnetic_field.F90:1
SimdConstants ct
Definition: particles.hpp:63
Definition: species.hpp:75
KOKKOS_INLINE_FUNCTION bool is_in_region_1_or_2(double r, double z, double psi) const
Definition: magnetic_field.tpp:72
Eq::Profile< Device > eq_temp
Definition: species.hpp:131
Simd< double > mu
Definition: particles.hpp:52
constexpr double TWOPI
Definition: constants.hpp:9