XGC1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
sheath.hpp
Go to the documentation of this file.
1 #ifndef SHEATH_HPP
2 #define SHEATH_HPP
3 #include "push_controls.hpp"
4 #include "species.hpp"
5 #include "neutrals.hpp"
6 #include "heat_diagnostics.hpp"
7 
8 // Sheath particle struct to store particle info if using sheath mode 2
9 template<class Device>
11 
12  struct SheathVec {
13  double r;
14  double z;
15  double phi;
16  };
17 
18  // Constructor
19  SheathParticles(int n_ptl)
20  : widx(NoInit("widx"), n_ptl),
21  iphi(NoInit("iphi"), n_ptl),
22  en_para(NoInit("en_para"), n_ptl),
23  en_perp(NoInit("en_perp"), n_ptl),
24  ph_back("ph_back", n_ptl), // Init to 0
25  ph_out("ph_out", n_ptl) // Init to 0
26  {
27  // Set the particle values
28  Kokkos::deep_copy(widx, -1);
29  Kokkos::deep_copy(iphi, -1);
30  Kokkos::deep_copy(en_para, -1.0);
31  Kokkos::deep_copy(en_perp, -1.0);
32  }
33 
34  // Null constructor
36 
37  // Arrays of particle properties to track
38  View<int*,CLayout,Device> widx;
39  View<int*,CLayout,Device> iphi;
40  View<double*,CLayout,Device> en_para;
41  View<double*,CLayout,Device> en_perp;
42  View<SheathVec*,CLayout,Device> ph_back;
43  View<SheathVec*,CLayout,Device> ph_out;
44 };
45 
46 
47 // Sheath class
48 template<class Device>
49 class Sheath {
50  public:
51 
52  // Constructor
53  Sheath(const Grid<Device>& grid, const Simulation<Device>& sml);
54 
55  // Null constructor
56  Sheath(){}
57 
58  // Sheath variables
59  View<double**,CLayout,Device> pot;
60  View<double***,CLayout,Device> lost;
61  View<double***,CLayout,Device> ilost;
62 
63  // For sheath mode 2
64  View<double***,CLayout,Device> en_max;
65 
66  bool adjust;
67 
69 
70  KOKKOS_INLINE_FUNCTION void deposition_diagnostics_and_w1(const Species<Device> &species, const Grid<Device> &grid, const MagneticField<Device> &magnetic_field, const Neutrals<Device> &neutrals, const HeatDiagnostics<Device> &heat_diag, const SimdParticles &old_part,SimdParticles &part, const SimdVector2D& xff, const Simd<int>& iphi, const Simd<double>& en_para, const Simd<double>& en_perp, SimdPhase& new_phase, const Simd<int>& widx, const Simd<bool>& just_left_the_grid, bool update_lost, bool update_ilost, bool update_neutrals, bool update_heat_diag, Simd<double>& dw) const;
71 
72  KOKKOS_INLINE_FUNCTION void save_sheath_ptl_info(const PushControls &push_controls, const Species<Device> &species, const Grid<Device> &grid, int i_item, const SimdParticles &old_part,SimdParticles &part, const Simd<int>& iphi, const Simd<double>& en_para, const Simd<double>& en_perp, const SimdPhase& new_phase, const Simd<int>& widx, const Simd<bool>& just_left_the_grid) const;
73 
74  KOKKOS_INLINE_FUNCTION void sheath_calculation(const PushControls &push_controls, const Species<Device> &species, const Grid<Device> &grid, const MagneticField<Device> &magnetic_field, const Neutrals<Device> &neutrals, const HeatDiagnostics<Device> &heat_diag, int i_item, const SimdParticles &old_part,const Simd<bool>& not_in_triangle,SimdParticles &part,SimdGridWeights<Order::One, PIT_GLOBAL>& grid_wts_new, Simd<double>& dw) const;
75 
76  void write_checkpoint_files(const XGC_IO_Stream& stream) const;
77 
78  void reorder_sheath_pot(const Grid<DeviceType>& grid) const;
79 
80  void read_checkpoint_files(const Grid<DeviceType>& grid, const XGC_IO_Stream& stream, int version);
81 
82  void clear_device_views() const;
83 
84  void copy_pot_to_device() const;
85 
86  void setup_mode_2(int n_tmp);
87 
88  void deallocate_particles();
89 
90  void mode_1_copy_to_host() const;
91 
92  void mode_2_copy_to_host() const;
93 
94  void copy_lost_to_host() const;
95 };
96 
97 #include "sheath.tpp"
98 #endif
SheathParticles(int n_ptl)
Definition: sheath.hpp:19
Definition: heat_diagnostics.hpp:21
SheathParticles< Device > particles
Definition: sheath.hpp:68
Sheath()
Definition: sheath.hpp:56
void mode_2_copy_to_host() const
KOKKOS_INLINE_FUNCTION void save_sheath_ptl_info(const PushControls &push_controls, const Species< Device > &species, const Grid< Device > &grid, int i_item, const SimdParticles &old_part, SimdParticles &part, const Simd< int > &iphi, const Simd< double > &en_para, const Simd< double > &en_perp, const SimdPhase &new_phase, const Simd< int > &widx, const Simd< bool > &just_left_the_grid) const
Definition: sheath.tpp:69
View< int *, CLayout, Device > iphi
Track which phi segment the particle hit.
Definition: sheath.hpp:39
View< double *, CLayout, Device > en_para
Track parallel energy of sheath hit.
Definition: sheath.hpp:40
double phi
Definition: sheath.hpp:15
View< double *, CLayout, Device > en_perp
Track perpendicular energy of sheath hit.
Definition: sheath.hpp:41
View< double ***, CLayout, Device > ilost
Tracker of ions lost to the sheath.
Definition: sheath.hpp:61
void reorder_sheath_pot(const Grid< DeviceType > &grid) const
Definition: sml.hpp:8
Definition: grid_weights.hpp:47
View< double ***, CLayout, Device > lost
Tracker of particles lost to the sheath.
Definition: sheath.hpp:60
Definition: push_controls.hpp:9
bool adjust
Whether to adjust the sheath.
Definition: sheath.hpp:66
Definition: magnetic_field.hpp:12
void write_checkpoint_files(const XGC_IO_Stream &stream) const
double r
Definition: sheath.hpp:13
Definition: grid.hpp:21
void deallocate_particles()
Definition: sheath.hpp:10
void read_checkpoint_files(const Grid< DeviceType > &grid, const XGC_IO_Stream &stream, int version)
KOKKOS_INLINE_FUNCTION void deposition_diagnostics_and_w1(const Species< Device > &species, const Grid< Device > &grid, const MagneticField< Device > &magnetic_field, const Neutrals< Device > &neutrals, const HeatDiagnostics< Device > &heat_diag, const SimdParticles &old_part, SimdParticles &part, const SimdVector2D &xff, const Simd< int > &iphi, const Simd< double > &en_para, const Simd< double > &en_perp, SimdPhase &new_phase, const Simd< int > &widx, const Simd< bool > &just_left_the_grid, bool update_lost, bool update_ilost, bool update_neutrals, bool update_heat_diag, Simd< double > &dw) const
Definition: sheath.tpp:13
Definition: neutrals.hpp:9
View< int *, CLayout, Device > widx
Track which wall index the particle hit.
Definition: sheath.hpp:38
Definition: sheath.hpp:12
Definition: particles.hpp:61
Definition: xgc_io.hpp:24
void setup_mode_2(int n_tmp)
double z
Definition: sheath.hpp:14
void mode_1_copy_to_host() const
Definition: magnetic_field.F90:1
Definition: particles.hpp:17
View< double **, CLayout, Device > pot
Sheath potential.
Definition: sheath.hpp:59
void copy_lost_to_host() const
Definition: simd.hpp:139
void copy_pot_to_device() const
Definition: sheath.hpp:49
Definition: species.hpp:75
SheathParticles()
Definition: sheath.hpp:35
View< double ***, CLayout, Device > en_max
The most energetic particle that hit the wall in a given section.
Definition: sheath.hpp:64
void clear_device_views() const
View< SheathVec *, CLayout, Device > ph_out
Track location outside the grid.
Definition: sheath.hpp:43
Kokkos::ViewAllocateWithoutInitializing NoInit
Definition: space_settings.hpp:68
KOKKOS_INLINE_FUNCTION void sheath_calculation(const PushControls &push_controls, const Species< Device > &species, const Grid< Device > &grid, const MagneticField< Device > &magnetic_field, const Neutrals< Device > &neutrals, const HeatDiagnostics< Device > &heat_diag, int i_item, const SimdParticles &old_part, const Simd< bool > &not_in_triangle, SimdParticles &part, SimdGridWeights< Order::One, PIT_GLOBAL > &grid_wts_new, Simd< double > &dw) const
Definition: sheath.tpp:114
View< SheathVec *, CLayout, Device > ph_back
Track location where particle was returned to.
Definition: sheath.hpp:42