Cholla 3.0.1-dev
Cholla - Massively parallel hydro on GPUs
Loading...
Searching...
No Matches
chemistry_gpu.h
1#ifndef CHEMISTRY_GPU_H
2#define CHEMISTRY_GPU_H
3
4#include "../global/global.h"
5
6#define CHEM_TINY 1e-20
7
8// Define the type of a generic rate function.
9typedef Real (*Rate_Function_T)(Real, Real);
10
11// #define TEXTURES_UVB_INTERPOLATION
12
14 Real gamma;
15 Real density_conversion;
16 Real energy_conversion;
17 Real current_z;
18 Real runtime_chemistry_step;
19 Real H_fraction;
20
21 // Units system
22 Real a_value;
23 Real density_units;
24 Real length_units;
25 Real time_units;
26 Real velocity_units;
27 Real cooling_units;
28 Real reaction_units;
29 Real dens_number_conv;
30
31 // Cosmological parameters
32 Real H0;
33 Real Omega_M;
34 Real Omega_L;
35
36 // Interpolation tables for the rates
37 int N_Temp_bins;
38 Real Temp_start;
39 Real Temp_end;
40
41 Real *cool_ceHI_d;
42 Real *cool_ceHeI_d;
43 Real *cool_ceHeII_d;
44
45 Real *cool_ciHI_d;
46 Real *cool_ciHeI_d;
47 Real *cool_ciHeII_d;
48 Real *cool_ciHeIS_d;
49
50 Real *cool_reHII_d;
51 Real *cool_reHeII_1_d;
52 Real *cool_reHeII_2_d;
53 Real *cool_reHeIII_d;
54
55 Real *cool_brem_d;
56
57 Real cool_compton;
58
59 Real *k_coll_i_HI_d;
60 Real *k_coll_i_HeI_d;
61 Real *k_coll_i_HeII_d;
62 Real *k_coll_i_HI_HI_d;
63 Real *k_coll_i_HI_HeI_d;
64
65 Real *k_recomb_HII_d;
66 Real *k_recomb_HeII_d;
67 Real *k_recomb_HeIII_d;
68
69 int max_iter;
70
71 int n_uvb_rates_samples;
72 float *uvb_rates_redshift_d;
73 float *photo_ion_HI_rate_d;
74 float *photo_ion_HeI_rate_d;
75 float *photo_ion_HeII_rate_d;
76 float *photo_heat_HI_rate_d;
77 float *photo_heat_HeI_rate_d;
78 float *photo_heat_HeII_rate_d;
79
80 // inherit the temperature floor
81 // from Parameters
82 float temperature_floor;
83};
84
85#ifdef CHEMISTRY_GPU
86
87class Chem_GPU
88{
89 public:
90 int nx;
91 int ny;
92 int nz;
93
94 bool use_case_B_recombination;
95
96 Real scale_factor_UVB_on;
97
98 float *cosmo_params_h;
99 float *cosmo_params_d;
100
101 int n_uvb_rates_samples;
102 float *rates_z_h;
103 float *Heat_rates_HI_h;
104 float *Heat_rates_HeI_h;
105 float *Heat_rates_HeII_h;
106 float *Ion_rates_HI_h;
107 float *Ion_rates_HeI_h;
108 float *Ion_rates_HeII_h;
109
110 float *rates_z_d;
111 float *Heat_rates_HI_d;
112 float *Heat_rates_HeI_d;
113 float *Heat_rates_HeII_d;
114 float *Ion_rates_HI_d;
115 float *Ion_rates_HeI_d;
116 float *Ion_rates_HeII_d;
117
118 struct ChemistryHeader H;
119
120 struct Fields {
121 Real *temperature_h;
122 } Fields;
123
124 void Allocate_Array_GPU_Real(Real **array_dev, int size);
125 void Copy_Real_Array_to_Device(int size, Real *array_h, Real *array_d);
126 void Free_Array_GPU_Real(Real *array_dev);
127 void Allocate_Array_GPU_float(float **array_dev, int size);
128 void Copy_Float_Array_to_Device(int size, float *array_h, float *array_d);
129 void Free_Array_GPU_float(float *array_dev);
130
131 void Initialize(struct Parameters *P);
132
133 void Generate_Reaction_Rate_Table(Real **rate_table_array_d, Rate_Function_T rate_function, Real units);
134
135 void Initialize_Cooling_Rates();
136
137 void Initialize_Reaction_Rates();
138
139 void Initialize_UVB_Ionization_and_Heating_Rates(struct Parameters *P);
140
141 void Load_UVB_Ionization_and_Heating_Rates(struct Parameters *P);
142
143 void Copy_UVB_Rates_to_GPU();
144
145 void Reset();
146
147 #ifdef TEXTURES_UVB_INTERPOLATION
148 void Bind_GPU_Textures(int size, float *H_HI_h, float *H_HeI_h, float *H_HeII_h, float *I_HI_h, float *I_HeI_h,
149 float *I_HeII_h);
150 #endif
151};
152
158void Do_Chemistry_Update(Real *dev_conserved, int nx, int ny, int nz, int n_ghost, int n_fields, Real dt,
159 ChemistryHeader &Chem_H);
160
161#endif
162#endif
Definition chemistry_gpu.h:13
Definition global.h:217