8def compute_flux_coag_k0(gij, tensor_tabflux_coag):
10 Function to compute the approximation of the coagulation flux with DG scheme k=0
11 Flux defined at the right boundary of mass bins, i.e. flux[j] ~ F(m_{j+1/2})
15 gij : 1D array (dim = nbins), type -> float
16 components of g on the polynomial basis
17 tensor_tabflux_coag : 3D array (dim = (nbins,nbins,nbins)), type -> float
18 array to evaluate coagulation flux
23 flux : 1D array (dim = nbins), type -> float
24 approximation of the coagulation flux at each bin
30 flux = np.einsum(
"jlm,l,m->j", tensor_tabflux_coag, gij, gij)
35def compute_flux_coag_k0_kdv(gij, tensor_tabflux_coag, dv):
37 Function to compute the approximation of the coagulation flux with DG scheme k=0
38 Flux defined at the right boundary of mass bins, i.e. flux[j] ~ F(m_{j+1/2})
39 Function for ballistic kernel with differential velocities dv
43 gij : 1D array (dim = nbins), type -> float
44 components of g on the polynomial basis
45 tensor_tabflux_coag : 3D array (dim = (nbins,nbins,nbins)), type -> float
46 array to evaluate coagulation flux
47 dv : 2D array (dim = (nbins,nbins)), type -> float
48 array of the differential velocity between grains
53 flux : 1D array (dim = nbins), type -> float
54 approximation of the coagulation flux at each bin
60 flux = np.einsum(
"jlm,lm,l,m->j", tensor_tabflux_coag, dv, gij, gij)
65def compute_flux_coag(gij, tensor_tabflux_coag):
67 Function to compute the approximation of the coagulation flux with DG scheme k>0
68 Flux defined at the right boundary of mass bins, i.e. flux[j] ~ F(m_{j+1/2})
72 gij : 2D array (dim = (nbins,kpol+1)), type -> float
73 components of g on the polynomial basis
74 tensor_tabflux_coag : 5D array (dim = (nbins,nbins,nbins,kpol+1,kpol+1)), type -> float
75 array to evaluate coagulation flux
80 flux : 1D array (dim = nbins), type -> float
81 approximation of the coagulation flux at each bin
90 arr_gij = np.einsum(
"ac,bd->abcd", gij, gij)
92 [np.sum(tensor_tabflux_coag[j, :, :, :, :] * arr_gij)
for j
in range(len(gij[:, 0]))]
98def compute_flux_coag_kdv(gij, tensor_tabflux_coag, dv):
100 Function to compute the approximation of the coagulation flux with DG scheme k>0
101 Flux defined at the right boundary of mass bins, i.e. flux[j] ~ F(m_{j+1/2})
102 Function for ballistic kernel with differential velocities dv
106 gij : 2D array (dim = (nbins,kpol+1)), type -> float
107 components of g on the polynomial basis
108 tensor_tabflux_coag : 5D array (dim = (nbins,nbins,nbins,kpol+1,kpol+1)), type -> float
109 array to evaluate coagulation flux
110 dv : 2D array (dim = (nbins,nbins)), type -> float
111 array of the differential velocity between grains
116 flux : 1D array (dim = nbins), type -> float
117 approximation of the coagulation flux at each bin
129 nbins = len(gij[:, 0])
130 kpol = len(gij[0, :]) - 1
131 arr_gij_dv = np.zeros((nbins, nbins, kpol + 1, kpol + 1))
132 for lp
in range(nbins):
133 for l
in range(nbins):
134 for ip
in range(kpol + 1):
135 for i
in range(kpol + 1):
136 arr_gij_dv[lp, l, ip, i] = gij[lp, ip] * gij[l, i] * dv[lp, l]
139 [np.sum(tensor_tabflux_coag[j, :, :, :, :] * arr_gij_dv)
for j
in range(len(gij[:, 0]))]
145def compute_intflux_coag(gij, tensor_tabintflux_coag):
147 Function to compute the approximation of the term including the integral of coagulation flux with DG scheme k>0
151 gij : 2D array (dim = (nbins,kpol+1)), type -> float
152 components of g on the polynomial basis
153 tensor_tabintflux_coag : 6D array (dim = (nbins,kpol+1,nbins,nbins,kpol+1,kpol+1)), type -> float
154 array to evaluate the term including the intgegral of the coagulation flux
159 intflux : 2D array (dim = (nbins,kpol+1)), type -> float
160 approximation of the term including the integral of coagulation flux at each bin
164 arr_gij = np.einsum(
"ac,bd->abcd", gij, gij)
166 nbins = len(gij[:, 0])
167 dim_kpol = len(gij[0, :])
168 intflux = np.zeros((nbins, dim_kpol))
169 for j
in range(nbins):
170 for k
in range(1, dim_kpol):
171 intflux[j, k] = np.sum(tensor_tabintflux_coag[j, k, :, :, :, :] * arr_gij)
176def compute_intflux_coag_kdv(gij, tensor_tabintflux_coag, dv):
178 Function to compute the approximation of the term including the integral of coagulation flux with DG scheme k>0
179 Function for ballistic kernel with differential velocities dv
183 gij : 2D array (dim = (nbins,kpol+1)), type -> float
184 components of g on the polynomial basis
185 tensor_tabintflux_coag : 6D array (dim = (nbins,kpol+1,nbins,nbins,kpol+1,kpol+1)), type -> float
186 array to evaluate the term including the integral of the coagulation flux
187 dv : 2D array (dim = (nbins,nbins)), type -> float
188 array of the differential velocity between grains
192 intflux : 2D array (dim = (nbins,kpol+1)), type -> float
193 approximation of the term including the integral of coagulation flux at each bin
197 arr_gij_dv = np.einsum(
"ac,bd,ab->abcd", gij, gij, dv)
199 nbins = len(gij[:, 0])
200 dim_kpol = len(gij[0, :])
201 intflux = np.zeros((nbins, dim_kpol))
202 for j
in range(nbins):
203 for k
in range(1, dim_kpol):
204 intflux[j, k] = np.sum(tensor_tabintflux_coag[j, k, :, :, :, :] * arr_gij_dv)
214def compute_flux_frag_k0(gij, tensor_tabflux_coag, tensor_tabflux_frag_T1, tensor_tabflux_frag_T2):
216 Function to compute the approximation of the fragmentation flux with DG scheme k=0, for simple collision kernels
218 Frag flux is calculated from the expression (similar to coag) dg/dt + dF/dm = 0
219 -> frag flux is defined from small to large masses
220 -> frag flux is defined on the right boundary of bin j, i.e. flux(j) ~ F(m_{j+1/2})
224 gij : 1D array (dim = nbins), type -> float
225 components of g on the polynomial basis
226 tensor_tabflux_coag : 3D array (dim = (nbins,nbins,nbins)), type -> float
227 array to evaluate coagulation term in the fragmentation flux
228 tensor_tabflux_frag_T1 : 3D array (dim = (nbins,nbins,nbins)), type -> float
229 array to evaluate the term 1 for fragmentation flux
230 tensor_tabflux_frag_T2 : 3D array (dim = (nbins,nbins,nbins)), type -> float
231 array to evaluate the term 2 for fragmentation flux
236 flux : 1D array (dim = nbins), type -> float
237 approximation of the fragmentation flux at each bin
244 np.einsum(
"jlm,l,m->j", tensor_tabflux_coag, gij, gij)
245 - np.einsum(
"jlm,l,m->j", tensor_tabflux_frag_T1, gij, gij)
246 - np.einsum(
"jlm,l,m->j", tensor_tabflux_frag_T2, gij, gij)
252def compute_flux_frag_k0_kdv(
253 gij, tensor_tabflux_coag, tensor_tabflux_frag_T1, tensor_tabflux_frag_T2, dv
256 Function to compute the approximation of the coagulation flux with DG scheme k=0, for physical collision kernel
258 Frag flux is calculated from the expression (similar to coag) dg/dt + dF/dm = 0
259 -> frag flux is defined from small to large masses
260 -> frag flux is defined on the right boundary of bin j, i.e. flux(j) ~ F(m_{j+1/2})
262 Function for ballistic kernel with differential velocities dv
266 gij : 1D array (dim = nbins), type -> float
267 components of g on the polynomial basis
268 tensor_tabflux_coag : 3D array (dim = (nbins,nbins,nbins)), type -> float
269 array to evaluate coagulation flux
270 tensor_tabflux_frag_T1 : 3D array (dim = (nbins,nbins,nbins)), type -> float
271 array to evaluate the term 1 for fragmentation flux
272 tensor_tabflux_frag_T2 : 3D array (dim = (nbins,nbins,nbins)), type -> float
273 array to evaluate the term 2 for fragmentation flux
274 dv : 2D array (dim = (nbins,nbins)), type -> float
275 array of the differential velocity between grains
280 flux : 1D array (dim = nbins), type -> float
281 approximation of the fragmentation flux at each bin
288 np.einsum(
"jlm,lm,l,m->j", tensor_tabflux_coag, dv, gij, gij)
289 - np.einsum(
"jlm,lm,l,m->j", tensor_tabflux_frag_T1, dv, gij, gij)
290 - np.einsum(
"jlm,lm,l,m->j", tensor_tabflux_frag_T2, dv, gij, gij)
299def compute_flux_coag_frag_k0_kdv(
302 tensor_tabflux_frag_T1,
303 tensor_tabflux_frag_T2,
309 Function to compute the approximation of the coagulation flux with DG scheme k=0, for physical collision kernel
311 Frag flux is calculated from the expression (similar to coag) dg/dt + dF/dm = 0
312 -> frag flux is defined from small to large masses
313 -> frag flux is defined on the right boundary of bin j, i.e. flux(j) ~ F(m_{j+1/2})
315 Function for ballistic kernel with differential velocities dv
319 gij : 1D array (dim = nbins), type -> float
320 components of g on the polynomial basis
321 tensor_tabflux_coag : 3D array (dim = (nbins,nbins,nbins)), type -> float
322 array to evaluate coagulation flux
323 tensor_tabflux_frag_T1 : 3D array (dim = (nbins,nbins,nbins)), type -> float
324 array to evaluate the term 1 for fragmentation flux
325 tensor_tabflux_frag_T2 : 3D array (dim = (nbins,nbins,nbins)), type -> float
326 array to evaluate the term 2 for fragmentation flux
327 dv : 2D array (dim = (nbins,nbins)), type -> float
328 array of the differential velocity between grains
329 proba_coag : 2D array (dim = (nbins,nbins)), type -> float
330 probability to have coagulation (depending on v_frag and dv)
331 proba_frag : 2D array (dim = (nbins,nbins)), type -> float
332 probability to have fragmentation (depending on v_frag and dv)
337 flux : 1D array (dim = nbins), type -> float
338 approximation of the fragmentation flux at each bin
344 dv_coag = proba_coag * dv
345 dv_frag = proba_frag * dv
348 np.einsum(
"jlm,lm,l,m->j", tensor_tabflux_coag, dv_coag + dv_frag, gij, gij)
349 - np.einsum(
"jlm,lm,l,m->j", tensor_tabflux_frag_T1, dv_frag, gij, gij)
350 - np.einsum(
"jlm,lm,l,m->j", tensor_tabflux_frag_T2, dv_frag, gij, gij)