GADGET-4
cooling.h
Go to the documentation of this file.
1 /*******************************************************************************
2  * \copyright This file is part of the GADGET4 N-body/SPH code developed
3  * \copyright by Volker Springel. Copyright (C) 2014-2020 by Volker Springel
4  * \copyright (vspringel@mpa-garching.mpg.de) and all contributing authors.
5  *******************************************************************************/
6 
12 #ifndef COOLING_H
13 #define COOLING_H
14 
15 #ifdef COOLING
16 
17 #include "../data/simparticles.h"
18 #include "../mpi_utils/setcomm.h"
19 
20 class coolsfr : public setcomm
21 {
22  public:
23  coolsfr(MPI_Comm comm) : setcomm(comm) {}
24 
25  double AbundanceRatios(double u, double rho, double *ne_guess, double *nH0_pointer, double *nHeII_pointer);
26 
27  void InitCool(void);
28  void IonizeParams(void);
29 
30  void cooling_only(simparticles *Sp);
31 
32 #ifdef STARFORMATION
33  void sfr_create_star_particles(simparticles *Sp);
34 
35  void set_units_sfr(void);
36 
37  void cooling_and_starformation(simparticles *Sp);
38 
39  void init_clouds(void);
40 #endif
41 
42  private:
43 #define NCOOLTAB 2000
44 
45  /* data for gas state */
46  struct gas_state
47  {
48  double ne, necgs, nHcgs;
49  double bH0, bHep, bff, aHp, aHep, aHepp, ad, geH0, geHe0, geHep;
50  double gJH0ne, gJHe0ne, gJHepne;
51  double nH0, nHp, nHep, nHe0, nHepp;
52  double XH, yhelium;
53  double mhboltz;
54  double ethmin; /* minimum internal energy for neutral gas */
55  };
56 
57  /* tabulated rates */
58  struct rate_table
59  {
60  double BetaH0, BetaHep, Betaff;
61  double AlphaHp, AlphaHep, Alphad, AlphaHepp;
62  double GammaeH0, GammaeHe0, GammaeHep;
63  };
64 
65  /* photo-ionization/heating rate table */
66  struct photo_table
67  {
68  float variable; /* logz for UVB */
69  float gH0, gHe, gHep; /* photo-ionization rates */
70  float eH0, eHe, eHep; /* photo-heating rates */
71  };
72 
73  /* current interpolated photo-ionization/heating rates */
74  struct photo_current
75  {
76  char J_UV;
77  double gJH0, gJHep, gJHe0, epsH0, epsHep, epsHe0;
78  };
79 
80  /* cooling data */
81  struct do_cool_data
82  {
83  double u_old_input, rho_input, dt_input, ne_guess_input;
84  };
85 
86  gas_state GasState;
87  do_cool_data DoCoolData;
89  rate_table *RateT;
90  photo_table *PhotoTUVB;
91  photo_current pc;
93  double Tmin = 1.0;
94  double Tmax = 9.0;
95  double deltaT;
96  int NheattabUVB;
98 #ifdef COOLING
99  double DoCooling(double u_old, double rho, double dt, double *ne_guess, gas_state *gs, do_cool_data *DoCool);
100  double GetCoolingTime(double u_old, double rho, double *ne_guess, gas_state *gs, do_cool_data *DoCool);
101  void cool_sph_particle(simparticles *Sp, int i, gas_state *gs, do_cool_data *DoCool);
102 
103  void SetZeroIonization(void);
104 #endif
105 
106  void integrate_sfr(void);
107 
108  double CoolingRate(double logT, double rho, double *nelec, gas_state *gs, const do_cool_data *DoCool);
109  double CoolingRateFromU(double u, double rho, double *ne_guess, gas_state *gs, const do_cool_data *DoCool);
110  void find_abundances_and_rates(double logT, double rho, double *ne_guess, gas_state *gs, const do_cool_data *DoCool);
111  void IonizeParamsUVB(void);
112  void ReadIonizeParams(char *fname);
113 
114  double convert_u_to_temp(double u, double rho, double *ne_guess, gas_state *gs, const do_cool_data *DoCool);
115 
116  void MakeRateTable(void);
117 
118 #ifdef STARFORMATION
119  const int WriteMiscFiles = 1;
120 
121  void make_star(simparticles *Sp, int i, double prob, MyDouble mass_of_star, double *sum_mass_stars);
122  void spawn_star_from_sph_particle(simparticles *Sp, int igas, double birthtime, int istar, MyDouble mass_of_star);
123  void convert_sph_particle_into_star(simparticles *Sp, int i, double birthtime);
124 
125  int stars_spawned;
126  int tot_stars_spawned;
127  int stars_converted;
128  int tot_stars_converted;
129  int altogether_spawned;
130  int tot_altogether_spawned;
131  double cum_mass_stars = 0.0;
132 #endif
133 };
134 
135 #endif
136 #endif
float MyDouble
Definition: dtypes.h:87