PLUTO  4.4-patch2
radiation.h
Go to the documentation of this file.
1 /* ///////////////////////////////////////////////////////////////////// */
11 /* ///////////////////////////////////////////////////////////////////// */
12 
13 /* *************************************************
14  Define convenient and user-friendly
15  pointer labels for geometry setting
16  ************************************************* */
17 
18 #if GEOMETRY == CYLINDRICAL
19 
20  #define iFRR FR1
21  #define iFRZ FR2
22  #define iFRPHI FR3
23 
24 #elif GEOMETRY == POLAR
25 
26  #define iFRR FR1
27  #define iFRPHI FR2
28  #define iFRZ FR3
29 
30 #elif GEOMETRY == SPHERICAL
31 
32  #define iFRR FR1
33  #define iFRTH FR2
34  #define iFRPHI FR3
35 
36 #endif
37 
38 /* *************************************************
39  Radiation implicit method labels
40  ************************************************* */
41 
42  #define RADIATION_FIXEDPOINT_RAD 1
43  #define RADIATION_NEWTON_GAS 2
44  #define RADIATION_NEWTON_RAD 3
45  #define RADIATION_FIXEDPOINT_GAS 4
46 
47  #ifndef RADIATION_IMPL // Implicit method
48  #define RADIATION_IMPL RADIATION_FIXEDPOINT_RAD
49  #endif
50 
51  #ifndef RADIATION_NEQS // Size of the system solved in the implicit step
52  #define RADIATION_NEQS 4
53  #endif
54 
55 /* *************************************************
56  Constants used by the radiation module
57  ************************************************* */
58 
59  /*-- Implicit step constants --*/
60 
61  #ifndef RADIATION_MAXITER
62  #define RADIATION_MAXITER 200
63  #endif // Maximum number of iterations allowed for the radiation implicit step
64 
65  #ifndef RADIATION_ERROR
66  #define RADIATION_ERROR 1e-7 // Error used for convergence of the implicit step
67  #endif
68 
69  /*-- Minimum energy density set when it goes below 0 --*/
70 
71  #ifndef RADIATION_MIN_ERAD
72  #define RADIATION_MIN_ERAD 1e-16
73  #endif
74 
75 /* *************************************************
76  Additional options
77  ************************************************* */
78 
79  #ifndef RADIATION_IMEX_SSP2
80  #define RADIATION_IMEX_SSP2 NO
81  #endif /* Apply IMEX-SSP2(2,2,2) scheme [Pareschi, L., & Russo, G. 2005,
82  JSCom, 25, 129]. By default apply IMEX1 in [Melon Fuksman, J. D.,
83  & Mignone, A. 2019, ApJS, 242, 20] */
84 
85  #ifndef RADIATION_DIFF_LIMITING
86  #define RADIATION_DIFF_LIMITING NO
87  #endif /* Limit the radiation speeds in the diffusion limit following
88  Sadowski et al. MNRAS 429, 3533–3550 (2013) */
89 
90  #ifndef RADIATION_VAR_OPACITIES
91  #define RADIATION_VAR_OPACITIES NO
92  #endif /* Define opacity coefficients as functions of the primitive fields.
93  A function
94  UserDefOpacities (double *v, double *abs_op, double *scat_op)
95  must be defined in init.c */
96 
97  #ifndef RADIATION_FULL_CONVERGENCE
98  #define RADIATION_FULL_CONVERGENCE YES
99  #endif /* Require convergence of both radiation and RMHD */
100 
101 /* ********************************************************************* */
106 typedef struct RAD_DATA{
107  double dt;
108  int pos;
109  uint16_t * flag;
112  double ** pv;
113  double ** cv;
115  double * Ttot;
118  double * Rini;
122  double * Rprev;
126  double *u;
127  double u2;
128  double gamma;
129  double gamma2;
131  double exv;
136  double exv_prev;
141  char fill[20];
142 } Rad_data;
143 
144 
145 /* ---- Function prototyping ---- */
146 
147 int GaussianSolve (double **, double *, double *, int);
148 
149 void MaxRadSpeed (double **, double *, double *, int, int);
150 double LimitRadWaveVelocity (double **, double **, Grid *, int);
151 
152 void LimitRadFlux(double *);
153 void Rad_Speed (double **, double **, Grid *, uint16_t *,
154  double *, double *, int, int);
155 
156 double EddTensor (double *, int , int);
157 double Blackbody (double);
158 double GetTemperature (double, double);
159 int RadIterToPrim (double *, Rad_data *);
160 void RadFlux (const State *, int, int);
161 
162 void RadSourceFunction(double *, double *);
163 void AddRadSource1(Data_Arr, Data_Arr, RBox *, double);
164 void AddRadSource2(Data_Arr, Data_Arr, Data_Arr, RBox *, double, double);
165 
166 void RadFPMatrices (Rad_data *, double *, double **);
167 void RadNewtonMinusF(Rad_data *, double *, double *);
168 void RadNewtonJacobian (double *, double *, double **, Rad_data *);
169 
170 double RadErr (double *, double *, Rad_data *);
171 void RadStep (double **, double **, double **, int, int, uint16_t *, double);
172 void RadStep3D (Data_Arr, Data_Arr, Data_Arr, uint16_t ***, RBox *, double);
173 
174 Riemann_Solver *Rad_SetSolver (const char *);
175 
176 Riemann_Solver Rad_LF_Solver, Rad_HLL_Solver, Rad_HLLC_Solver ;
177 
178 #if RADIATION_VAR_OPACITIES == YES
179 void UserDefOpacities (double *, double *, double *);
180 #endif
181 
void Rad_LF_Solver(const Sweep *sweep, int beg, int end, double *cmax, Grid *grid)
Definition: rad_tvdlf.c:11
void RadSourceFunction(double *, double *)
Definition: rad_sourcef.c:3
double * Rini
Definition: radiation.h:118
void Rad_HLLC_Solver(const Sweep *sweep, int beg, int end, double *cmax, Grid *grid)
Definition: rad_hllc.c:30
uint16_t * flag
Definition: radiation.h:109
double * u
Definition: radiation.h:126
Definition: structs.h:124
double Blackbody(double)
Definition: rad_tools.c:15
double gamma2
Definition: radiation.h:129
double exv
Definition: radiation.h:131
double GetTemperature(double, double)
Definition: rad_tools.c:29
double gamma
Definition: radiation.h:128
void RadFPMatrices(Rad_data *, double *, double **)
Definition: rad_tools.c:44
void AddRadSource2(Data_Arr, Data_Arr, Data_Arr, RBox *, double, double)
Definition: rad_sourcef.c:110
double dt
Definition: radiation.h:107
Definition: structs.h:261
double exv_prev
Definition: radiation.h:136
int pos
Definition: radiation.h:108
Riemann_Solver * Rad_SetSolver(const char *)
Definition: rad_set_solver.c:14
int GaussianSolve(double **, double *, double *, int)
Definition: rad_tools.c:127
void AddRadSource1(Data_Arr, Data_Arr, RBox *, double)
Definition: rad_sourcef.c:72
Definition: radiation.h:106
double u2
Definition: radiation.h:127
double ** cv
Definition: radiation.h:113
Definition: structs.h:201
double ** pv
Definition: radiation.h:112
double * Rprev
Definition: radiation.h:122
double * Ttot
Definition: radiation.h:115
void Rad_HLL_Solver(const Sweep *sweep, int beg, int end, double *cmax, Grid *grid)
Definition: rad_hll.c:22