3from .solver_DG
import *
6def compute_coag_k0(eps, coeff_CFL, nbins, massgrid, gij, tensor_tabflux_coag, dthydro):
8 Function to compute coagulation solver for 1 hydro time-step
10 DG scheme k=0, piecewise constant approximation
14 eps : scalar, type -> float
15 minimum value for mass distribution approximation gij
16 coeff_CFL : scalar, type -> float
17 timestep coefficient for stability of the SSPRK order 3 scheme
18 nbins : scalar, type -> integer
20 massgrid : 1D array (dim = nbins+1), type -> float
21 grid of masses given borders value of mass bins
22 gij : 1D array (dim = nbins), type -> float
23 components of g on the polynomial basis
24 tensor_tabflux_coag : 3D array (dim = (nbins,nbins,nbins)), type -> float
25 array to evaluate coagulation flux
26 dthydro : scalar, type -> float
27 hydro timestep, used as timestep to reach for coagulation process
32 gij : 1D array (dim = nbins), type -> float
33 evolved components of g on the polynomial basis after 1 hydro timestep
34 nsub : scalar, type -> integer
35 number of subcycling coagulation timestep to reach dthydro
36 ndt : scalar, type -> integer
37 number of hydro timestep, when coagulation CFL > dthydro
45 dtCFLsub = compute_CFL_coag_k0(eps, nbins, massgrid, gij, tensor_tabflux_coag)
46 dtCFLsub = coeff_CFL * dtCFLsub
50 dt = min(dtCFLsub, dthydro)
55 while dtsub < dthydro
and dthydro - dtsub > dtCFLsub:
60 gij = solver_coag_k0(eps, nbins, massgrid, gij, tensor_tabflux_coag, dtCFLsub)
62 dtCFLsub = compute_CFL_coag_k0(eps, nbins, massgrid, gij, tensor_tabflux_coag)
63 dtCFLsub = coeff_CFL * dtCFLsub
69 dtlast = dthydro - dtsub
72 gij = solver_coag_k0(eps, nbins, massgrid, gij, tensor_tabflux_coag, dtlast)
78 gij = solver_coag_k0(eps, nbins, massgrid, gij, tensor_tabflux_coag, dt)
83def compute_coag_k0_kdv(eps, coeff_CFL, nbins, massgrid, gij, tensor_tabflux_coag, dv, dthydro):
85 Function to compute coagulation solver for 1 hydro time-step
87 DG scheme k=0, piecewise constant approximation
89 Function for ballistic kernel with differential velocities dv
93 eps : scalar, type -> float
94 minimum value for mass distribution approximation gij
95 coeff_CFL : scalar, type -> float
96 timestep coefficient for stability of the SSPRK order 3 scheme
97 nbins : scalar, type -> integer
99 massgrid : 1D array (dim = nbins+1), type -> float
100 grid of masses given borders value of mass bins
101 gij : 1D array (dim = nbins), type -> float
102 components of g on the polynomial basis
103 tensor_tabflux_coag : 3D array (dim = (nbins,nbins,nbins)), type -> float
104 array to evaluate coagulation flux
105 dv : 2D array (dim = (nbins,nbins)), type -> float
106 array of the differential velocity between grains
107 dthydro : scalar, type -> float
108 hydro timestep, used as timestep to reach for coagulation process
113 gij : 1D array (dim = nbins), type -> float
114 evolved components of g on the polynomial basis after 1 hydro timestep
115 nsub : scalar, type -> integer
116 number of subcycling coagulation timestep to reach dthydro
117 ndt : scalar, type -> integer
118 number of hydro timestep, when coagulation CFL > dthydro
126 dtCFLsub = compute_CFL_coag_k0_kdv(eps, nbins, massgrid, gij, tensor_tabflux_coag, dv)
127 dtCFLsub = coeff_CFL * dtCFLsub
131 dt = min(dtCFLsub, dthydro)
136 while dtsub < dthydro
and dthydro - dtsub > dtCFLsub:
141 gij = solver_coag_k0_kdv(eps, nbins, massgrid, gij, tensor_tabflux_coag, dv, dtCFLsub)
143 dtCFLsub = compute_CFL_coag_k0_kdv(eps, nbins, massgrid, gij, tensor_tabflux_coag, dv)
144 dtCFLsub = coeff_CFL * dtCFLsub
149 dtlast = dthydro - dtsub
152 gij = solver_coag_k0_kdv(eps, nbins, massgrid, gij, tensor_tabflux_coag, dv, dtlast)
158 gij = solver_coag_k0_kdv(eps, nbins, massgrid, gij, tensor_tabflux_coag, dv, dt)
160 return gij, nsub, ndt
172 tensor_tabintflux_coag,
176 Function to compute coagulation solver for 1 hydro time-step
178 DG scheme k>0, piecewise polynomial (order k) approximation
182 eps : scalar, type -> float
183 minimum value for mass distribution approximation gij
184 coeff_CFL : scalar, type -> float
185 timestep coefficient for stability of the SSPRK order 3 scheme
186 nbins : scalar, type -> integer
188 kpol : scalar, type -> integer
189 degree of polynomials for approximation
190 massgrid : 1D array (dim = nbins+1), type -> float
191 grid of masses given borders value of mass bins
192 massbins : 1D array (dim = nbins), type -> float
193 arithmetic mean of massgrid
194 gij : 2D array (dim = (nbins,kpol+1)), type -> float
195 components of g on the polynomial basis
196 tensor_tabflux_coag : 5D array (dim = (nbins,nbins,nbins,kpol+1,kpol+1)), type -> float
197 array to evaluate coagulation flux
198 tensor_tabintflux_coag : 6D array (dim = (nbins,kpol+1,nbins,nbins,kpol+1,kpol+1)), type -> float
199 array to evaluate term including the integral of the coagulation flux
200 dthydro : scalar, type -> float
201 hydro timestep, used as timestep to reach for coagulation process
206 gij : 2D array (dim = (nbins,kpol+1)), type -> float
207 evolve components of g on the polynomial basis after 1 hydro timestep
208 nsub : scalar, type -> integer
209 number of subcycling coagulation timestep to reach dthydro
210 ndt : scalar, type -> integer
211 number of hydro timestep, when coagulation CFL > dthydro
219 dtCFLsub = compute_CFL_coag(eps, nbins, kpol, massgrid, gij, tensor_tabflux_coag)
220 dtCFLsub = coeff_CFL * dtCFLsub
224 dt = min(dtCFLsub, dthydro)
229 while dtsub < dthydro
and dthydro - dtsub > dtCFLsub:
242 tensor_tabintflux_coag,
246 dtCFLsub = compute_CFL_coag(eps, nbins, kpol, massgrid, gij, tensor_tabflux_coag)
247 dtCFLsub = coeff_CFL * dtCFLsub
251 dtlast = dthydro - dtsub
262 tensor_tabintflux_coag,
278 tensor_tabintflux_coag,
282 return gij, nsub, ndt
294 tensor_tabintflux_coag,
299 Function to compute coagulation solver for 1 hydro time-step
301 DG scheme k>0, piecewise polynomial (order k) approximation
303 Function for ballistic kernel with differential velocities dv
307 eps : scalar, type -> float
308 minimum value for mass distribution approximation gij
309 coeff_CFL : scalar, type -> float
310 timestep coefficient for stability of the SSPRK order 3 scheme
311 nbins : scalar, type -> integer
313 kpol : scalar, type -> integer
314 degree of polynomials for approximation
315 massgrid : 1D array (dim = nbins+1), type -> float
316 grid of masses given borders value of mass bins
317 massbins : 1D array (dim = nbins), type -> float
318 arithmetic mean of massgrid
319 gij : 2D array (dim = (nbins,kpol+1)), type -> float
320 components of g on the polynomial basis
321 tensor_tabflux_coag : 5D array (dim = (nbins,nbins,nbins,kpol+1,kpol+1)), type -> float
322 array to evaluate coagulation flux
323 tensor_tabintflux_coag : 6D array (dim = (nbins,kpol+1,nbins,nbins,kpol+1,kpol+1)), type -> float
324 array to evaluate term including the integral of the coagulation flux
325 dv : 2D array (dim = (nbins,nbins)), type -> float
326 array of the differential velocity between grains
327 dthydro : scalar, type -> float
328 hydro timestep, used as timestep to reach for coagulation process
333 gij : 2D array (dim = (nbins,kpol+1)), type -> float
334 evolve components of g on the polynomial basis after 1 hydro timestep
335 nsub : scalar, type -> integer
336 number of subcycling coagulation timestep to reach dthydro
337 ndt : scalar, type -> integer
338 number of hydro timestep, when coagulation CFL > dthydro
346 dtCFLsub = compute_CFL_coag_kdv(eps, nbins, kpol, massgrid, gij, tensor_tabflux_coag, dv)
347 dtCFLsub = coeff_CFL * dtCFLsub
351 dt = min(dtCFLsub, dthydro)
356 while dtsub < dthydro
and dthydro - dtsub > dtCFLsub:
361 gij = solver_coag_kdv(
369 tensor_tabintflux_coag,
374 dtCFLsub = compute_CFL_coag_kdv(
375 eps, nbins, kpol, massgrid, gij, tensor_tabflux_coag, dv
377 dtCFLsub = coeff_CFL * dtCFLsub
381 dtlast = dthydro - dtsub
384 gij = solver_coag_kdv(
392 tensor_tabintflux_coag,
401 gij = solver_coag_kdv(
409 tensor_tabintflux_coag,
414 return gij, nsub, ndt