5from scipy.special
import eval_legendre
7from .generate_flux_intflux
import *
9from .utils_polynomials
import *
13def compute_CFL_coag_k0(eps, nbins, massgrid, gij, tensor_tabflux_coag):
15 Function to compute coagulation CFL for DG scheme k=0 piecewise constant approximation
17 CFL formulation from Filbet & Laurencot 2004, dt <= mean_g * dm/dF
21 eps : scalar, type -> float
22 minimum value for mass distribution approximation gij
23 nbins : scalar, type -> integer
25 massgrid : 1D array (dim = nbins+1), type -> float
26 grid of masses given borders value of mass bins
27 gij : 1D array (dim = nbins), type -> float
28 components of g on the polynomial basis
29 tensor_tabflux_coag : 3D array (dim = (nbins,nbins,nbins)), type -> float
30 array to evaluate coagulation flux
35 CFL_k0 : scalar, type -> float
36 CFL restriction for coagulation
40 tabdflux = np.zeros(nbins)
41 tabdtCFL = np.zeros(nbins)
43 flux = compute_flux_coag_k0(gij, tensor_tabflux_coag)
45 if np.array_equal(flux, np.zeros(nbins)):
51 tabdtCFL[0] = np.abs(gij[0] * (massgrid[1] - massgrid[0]) / (tabdflux[0]))
53 for j
in range(1, nbins):
54 hj = massgrid[j + 1] - massgrid[j]
55 tabdflux[j] = flux[j] - flux[j - 1]
58 tabdtCFL[j] = np.abs(gij[j] * hj / tabdflux[j])
62 CFL_k0 = np.min(tabdtCFL)
66 print(
"hj = ", massgrid[1:] - massgrid[:nbins])
67 print(
"tabdtCFL = ", tabdtCFL)
68 print(
"CFL_k0 = ", CFL_k0)
69 print(
"issue in CFL coagulation")
75def L_func_coag_k0(nbins, massgrid, gij, tensor_tabflux_coag):
77 Function to compute the DG operator L for piecewise constant approximation (see Lombart et al., 2021)
78 It is used for the time solver
82 nbins : scalar, type -> integer
84 massgrid : 1D array (dim = nbins+1), type -> float
85 grid of masses given borders value of mass bins
86 gij : 1D array (dim = nbins), type -> float
87 components of g on the polynomial basis
88 tensor_tabflux_coag : 3D array (dim = (nbins,nbins,nbins)), type -> float
89 array to evaluate coagulation flux
94 Lk0 : 1D array (dim = nbins), type -> float
95 DG operator for piecewise constant approximation in each bin
99 flux = compute_flux_coag_k0(gij, tensor_tabflux_coag)
101 Lk0 = np.zeros(nbins)
102 Lk0[0] = -flux[0] / (massgrid[1] - massgrid[0])
103 Lk0[1:] = -(flux[1:] - flux[0 : nbins - 1]) / (massgrid[2:] - massgrid[1:nbins])
108def solver_coag_k0(eps, nbins, massgrid, gij, tensor_tabflux_coag, dt):
110 Function to compute SSPRK order 3 time solver with piecewise constant approximation
111 See Zhang & Shu 2010 and Lombart et al., 2021
116 eps : scalar, type -> float
117 minimum value for mass distribution approximation gij
118 nbins : scalar, type -> integer
120 massgrid : 1D array (dim = nbins+1), type -> float
121 grid of masses given borders value of mass bins
122 gij : 1D array (dim = nbins), type -> float
123 components of g on the polynomial basis
124 tensor_tabflux_coag : 3D array (dim = (nbins,nbins,nbins)), type -> float
125 array to evaluate coagulation flux
126 dt : scalar, type -> float
132 gijnew : 1D array (dim = nbins), type -> float
133 evolved components of g on the polynomial basis after 1 timestep
139 Lk0 = L_func_coag_k0(nbins, massgrid, gij, tensor_tabflux_coag)
141 gij1 = gij + dt * Lk0
144 if len(gij1[gij1 < 0.0]) > 0:
146 print(
"dt*Lk0 = ", dt * Lk0)
147 print(
"gij1 = ", gij1)
150 gij1[gij1 < eps] = eps
152 Lk0_1 = L_func_coag_k0(nbins, massgrid, gij1, tensor_tabflux_coag)
154 gij2 = 3.0 * gij / 4.0 + (gij1 + dt * Lk0_1) / 4.0
157 if len(gij2[gij2 < 0.0]) > 0:
159 print(
"dt*Lk0_1 = ", dt * Lk0_1)
160 print(
"gij2 = ", gij2)
163 gij2[gij2 < eps] = eps
166 Lk0_2 = L_func_coag_k0(nbins, massgrid, gij2, tensor_tabflux_coag)
168 gijnew = gij / 3.0 + 2.0 * (gij2 + dt * Lk0_2) / 3.0
171 if len(gijnew[gijnew < 0.0]) > 0:
173 print(
"dt*Lk0_2 = ", dt * Lk0_2)
174 print(
"gijnew = ", gijnew)
177 gijnew[gijnew < eps] = eps
183def compute_CFL_coag_k0_kdv(eps, nbins, massgrid, gij, tensor_tabflux_coag, dv):
185 Function to compute coagulation CFL for DG scheme k=0 piecewise constant approximation.
187 Function for ballistic kernel with differential velocities dv
189 CFL formulation from Filbet & Laurencot 2004, dt <= mean_g * dm/dF
193 eps : scalar, type -> float
194 minimum value for mass distribution approximation gij
195 nbins : scalar, type -> integer
197 massgrid : 1D array (dim = nbins+1), type -> float
198 grid of masses given borders value of mass bins
199 gij : 1D array (dim = nbins), type -> float
200 components of g on the polynomial basis
201 tensor_tabflux_coag : 3D array (dim = (nbins,nbins,nbins)), type -> float
202 array to evaluate coagulation flux
203 dv : 2D array (dim = (nbins,nbins)), type -> float
204 array of the differential velocity between grains
209 CFL_k0 : scalar, type -> float
210 CFL restriction for coagulation
214 tabdflux = np.zeros(nbins)
215 tabdtCFL = np.zeros(nbins)
217 flux = compute_flux_coag_k0_kdv(gij, tensor_tabflux_coag, dv)
219 if np.array_equal(flux, np.zeros(nbins)):
224 tabdflux[0] = flux[0]
225 tabdtCFL[0] = np.abs(gij[0] * (massgrid[1] - massgrid[0]) / (tabdflux[0]))
227 for j
in range(1, nbins):
228 hj = massgrid[j + 1] - massgrid[j]
229 tabdflux[j] = flux[j] - flux[j - 1]
232 tabdtCFL[j] = np.abs(gij[j] * hj / tabdflux[j])
239 CFL_k0 = np.min(tabdtCFL)
243 print(
"hj = ", massgrid[1:] - massgrid[:nbins])
244 print(
"tabdtCFL = ", tabdtCFL)
245 print(
"CFL_k0 = ", CFL_k0)
246 print(
"issue in CFL coagulation")
253def L_func_coag_k0_kdv(nbins, massgrid, gij, tensor_tabflux_coag, dv):
255 Function to compute the DG operator L for piecewise constant approximation (see Lombart et al., 2021)
256 Function for ballistic kernel with differential velocities dv
257 It is used for the time solver
261 nbins : scalar, type -> integer
263 massgrid : 1D array (dim = nbins+1), type -> float
264 grid of masses given borders value of mass bins
265 gij : 1D array (dim = nbins), type -> float
266 components of g on the polynomial basis
267 tensor_tabflux_coag : 3D array (dim = (nbins,nbins,nbins)), type -> float
268 array to evaluate coagulation flux
269 dv : 2D array (dim = (nbins,nbins)), type -> float
270 array of the differential velocity between grains
275 Lk0 : 1D array (dim = nbins), type -> float
276 DG operator for piecewise constant approximation in each bin
280 flux = compute_flux_coag_k0_kdv(gij, tensor_tabflux_coag, dv)
282 Lk0 = np.zeros(nbins)
283 Lk0[0] = -flux[0] / (massgrid[1] - massgrid[0])
284 Lk0[1:] = -(flux[1:] - flux[0 : nbins - 1]) / (massgrid[2:] - massgrid[1:nbins])
290def solver_coag_k0_kdv(eps, nbins, massgrid, gij, tensor_tabflux_coag, dv, dt):
292 Function to compute SSPRK order 3 time solver with piecewise constant approximation
293 Function for ballistic kernel with differential velocities dv
294 See Zhang & Shu 2010 and Lombart et al., 2021
299 eps : scalar, type -> float
300 minimum value for mass distribution approximation gij
301 nbins : scalar, type -> integer
303 massgrid : 1D array (dim = nbins+1), type -> float
304 grid of masses given borders value of mass bins
305 gij : 1D array (dim = nbins), type -> float
306 components of g on the polynomial basis
307 tensor_tabflux_coag : 3D array (dim = (nbins,nbins,nbins)), type -> float
308 array to evaluate coagulation flux
309 dv : 2D array (dim = (nbins,nbins)), type -> float
310 array of the differential velocity between grains
311 dt : scalar, type -> float
317 gijnew : 1D array (dim = nbins), type -> float
318 evolved components of g on the polynomial basis after 1 timestep
324 Lk0 = L_func_coag_k0_kdv(nbins, massgrid, gij, tensor_tabflux_coag, dv)
326 gij1 = gij + dt * Lk0
329 if len(gij1[gij1 < 0.0]) > 0:
331 print(
"dt*Lk0 = ", dt * Lk0)
332 print(
"gij1 = ", gij1)
335 gij1[gij1 < eps] = eps
337 Lk0_1 = L_func_coag_k0_kdv(nbins, massgrid, gij1, tensor_tabflux_coag, dv)
339 gij2 = 3.0 * gij / 4.0 + (gij1 + dt * Lk0_1) / 4.0
342 if len(gij2[gij2 < 0.0]) > 0:
344 print(
"dt*Lk0_1 = ", dt * Lk0_1)
345 print(
"gij2 = ", gij2)
348 gij2[gij2 < eps] = eps
351 Lk0_2 = L_func_coag_k0_kdv(nbins, massgrid, gij2, tensor_tabflux_coag, dv)
353 gijnew = gij / 3.0 + 2.0 * (gij2 + dt * Lk0_2) / 3.0
356 if len(gijnew[gijnew < 0.0]) > 0:
358 print(
"dt*Lk0_2 = ", dt * Lk0_2)
359 print(
"gijnew = ", gijnew)
362 gijnew[gijnew < eps] = eps
367def compute_CFL_coag(eps, nbins, kpol, massgrid, gij, tensor_tabflux_coag):
369 Function to compute coagulation CFL for DG scheme k>0 piecewise polynomial approximation
371 CFL formulation from Filbet & Laurencot 2004, dt <= mean_g * dm/dF
375 eps : scalar, type -> float
376 minimum value for mass distribution approximation gij
377 nbins : scalar, type -> integer
379 kpol : scalar, type -> integer
380 degree of polynomials for approximation
381 massgrid : 1D array (dim = nbins+1), type -> float
382 grid of masses given borders value of mass bins
383 gij : 2D array (dim = (nbins,kpol+1)), type -> float
384 components of g on the polynomial basis
385 tensor_tabflux_coag : 5D array (dim = (nbins,nbins,nbins,kpol+1,kpol+1)), type -> float
386 array to evaluate coagulation flux
391 CFL : scalar, type -> float
392 CFL restriction for coagulation
396 tabdflux = np.zeros(nbins)
397 tabdtCFL = np.zeros(nbins)
399 flux = compute_flux_coag(gij, tensor_tabflux_coag)
401 if np.array_equal(flux, np.zeros(nbins)):
406 tabdflux[0] = flux[0]
407 tabdtCFL[0] = np.abs(gij[0, 0] * (massgrid[1] - massgrid[0]) / (tabdflux[0]))
409 for j
in range(1, nbins):
410 hj = massgrid[j + 1] - massgrid[j]
411 tabdflux[j] = flux[j] - flux[j - 1]
414 tabdtCFL[j] = np.abs(gij[j, 0] * hj / tabdflux[j])
418 CFL = np.min(tabdtCFL)
421 print(
"gij[:,0]=", gij[:, 0])
422 print(
"hj = ", massgrid[1:] - massgrid[: nbins + 1])
423 print(
"tabdtCFL = ", tabdtCFL)
425 print(
"issue in CFL")
431def L_func_coag(nbins, kpol, massgrid, gij, tensor_tabflux_coag, tensor_tabintflux_coag):
433 Function to compute the DG operator L for piecewise polynomial approximation (see Lombart et al., 2021)
434 It is used for the time solver
438 nbins : scalar, type -> integer
440 kpol : scalar, type -> integer
441 degree of polynomials for approximation
442 massgrid : 1D array (dim = nbins+1), type -> float
443 grid of masses given borders value of mass bins
444 gij : 2D array (dim = (nbins,kpol+1)), type -> float
445 components of g on the polynomial basis
446 tensor_tabflux_coag : 5D array (dim = (nbins,nbins,nbins,kpol+1,kpol+1)), type -> float
447 array to evaluate coagulation flux
448 tensor_tabintflux_coag : 6D array (dim = (nbins,kpol+1,nbins,nbins,kpol+1,kpol+1)), type -> float
449 array to evaluate the term including the integral of coagulation flux
454 Lk : 2D array (dim = (nbins,kpol+1)), type -> float
455 DG operator for piecewise polynomials approximation in each bin
459 flux = compute_flux_coag(gij, tensor_tabflux_coag)
460 intflux = compute_intflux_coag(gij, tensor_tabintflux_coag)
462 mat_intflux = intflux.reshape(nbins, kpol + 1)
464 LegPright = eval_legendre(range(kpol + 1), 1.0)
465 flux_right = np.outer(flux, LegPright)
467 flux_left = np.zeros((nbins, kpol + 1))
468 LegPleft = eval_legendre(range(kpol + 1), -1.0)
469 flux_left[1:, :] = np.outer(flux[0 : nbins - 1], LegPleft)
471 mat_coeff_norm = np.outer(
472 2.0 / (massgrid[1:] - massgrid[0:nbins]), 1.0 / coeff_norm_leg(np.arange(kpol + 1))
475 Lk = mat_coeff_norm * (mat_intflux - (flux_right - flux_left))
481 eps, nbins, kpol, massgrid, massbins, gij, tensor_tabflux_coag, tensor_tabintflux_coag, dt
484 Function to compute SSPRK order 3 time solver with piecewise polynomial approximation
485 See Zhang & Shu 2010 and Lombart et al., 2021
490 eps : scalar, type -> float
491 minimum value for mass distribution approximation gij
492 nbins : scalar, type -> integer
494 kpol : scalar, type -> integer
495 degree of polynomials for approximation
496 massgrid : 1D array (dim = nbins+1), type -> float
497 grid of masses given borders value of mass bins
498 massbins : 1D array (dim = nbins), type -> float
499 arithmetic mean value of massgrid for each mass bins
500 gij : 2D array (dim = (nbins,kpol+1)), type -> float
501 components of g on the polynomial basis
502 tensor_tabflux_coag : 5D array (dim = (nbins,nbins,nbins,kpol+1,kpol+1)), type -> float
503 array to evaluate coagulation flux
504 tensor_tabintflux_coag : 6D array (dim = (nbins,kpol+1,nbins,nbins,kpol+1,kpol+1)), type -> float
505 array to evaluate the term including the integral of coagulation flux
506 dt : scalar, type -> float
512 gijnew : 2D array (dim = (nbins,kpol+1)), type -> float
513 evolved components of g on the polynomial basis after 1 timestep
519 Lk = L_func_coag(nbins, kpol, massgrid, gij, tensor_tabflux_coag, tensor_tabintflux_coag)
524 tabgamma = gammafunction(eps, nbins, kpol, massgrid, massbins, gij1)
525 gij1[:, 1:] = tabgamma.reshape(nbins, 1) * gij1[:, 1:]
528 if gij1[:, 0][gij1[:, 0] < 0.0].any():
530 print(
"dt*Lk = ", dt * Lk)
531 print(
"gij1 = ", gij1)
534 gij1[:, 1:][gij1[:, 0] < eps] = 0.0
535 gij1[:, 0][gij1[:, 0] < eps] = eps
537 Lk_1 = L_func_coag(nbins, kpol, massgrid, gij1, tensor_tabflux_coag, tensor_tabintflux_coag)
539 gij2 = 3.0 * gij / 4.0 + (gij1 + dt * Lk_1) / 4.0
542 tabgamma = gammafunction(eps, nbins, kpol, massgrid, massbins, gij2)
543 gij2[:, 1:] = tabgamma.reshape(nbins, 1) * gij2[:, 1:]
547 if gij2[:, 0][gij2[:, 0] < 0.0].any():
549 print(
"dt*Lk_1 = ", dt * Lk_1)
550 print(
"gij2 = ", gij2)
553 gij2[:, 1:][gij2[:, 0] < eps] = 0.0
554 gij2[:, 0][gij2[:, 0] < eps] = eps
557 Lk_2 = L_func_coag(nbins, kpol, massgrid, gij2, tensor_tabflux_coag, tensor_tabintflux_coag)
559 gijnew = gij / 3.0 + 2.0 * (gij2 + dt * Lk_2) / 3.0
562 tabgamma = gammafunction(eps, nbins, kpol, massgrid, massbins, gijnew)
563 gijnew[:, 1:] = tabgamma.reshape(nbins, 1) * gijnew[:, 1:]
567 if gijnew[:, 0][gijnew[:, 0] < 0.0].any():
569 print(
"dt*Lk_1 = ", dt * Lk_1)
570 print(
"gijnew = ", gijnew)
573 gijnew[:, 1:][gijnew[:, 0] < eps] = 0.0
574 gijnew[:, 0][gijnew[:, 0] < eps] = eps
580def compute_CFL_coag_kdv(eps, nbins, kpol, massgrid, gij, tensor_tabflux_coag, dv):
582 Function to compute coagulation CFL for DG scheme k>0 piecewise polynomial approximation
583 Function for ballistic kernel with differential velocities dv
584 CFL formulation from Filbet & Laurencot 2004, dt <= mean_g * dm/dF
588 eps : scalar, type -> float
589 minimum value for mass distribution approximation gij
590 nbins : scalar, type -> integer
592 kpol : scalar, type -> integer
593 degree of polynomials for approximation
594 massgrid : 1D array (dim = nbins+1), type -> float
595 grid of masses given borders value of mass bins
596 gij : 2D array (dim = (nbins,kpol+1)), type -> float
597 components of g on the polynomial basis
598 tensor_tabflux_coag : 5D array (dim = (nbins,nbins,nbins,kpol+1,kpol+1)), type -> float
599 array to evaluate coagulation flux
600 dv : 2D array (dim = (nbins,nbins)), type -> float
601 array of the differential velocity between grains
606 CFL : scalar, type -> float
607 CFL restriction for coagulation
610 tabdflux = np.zeros(nbins)
611 tabdtCFL = np.zeros(nbins)
613 flux = compute_flux_coag_kdv(gij, tensor_tabflux_coag, dv)
615 if np.array_equal(flux, np.zeros(nbins)):
620 tabdflux[0] = flux[0]
621 tabdtCFL[0] = np.abs(gij[0, 0] * (massgrid[1] - massgrid[0]) / (tabdflux[0]))
623 for j
in range(1, nbins):
624 hj = massgrid[j + 1] - massgrid[j]
625 tabdflux[j] = flux[j] - flux[j - 1]
628 tabdtCFL[j] = np.abs(gij[j, 0] * hj / tabdflux[j])
632 CFL = np.min(tabdtCFL)
635 print(
"gij[:,0]=", gij[:, 0])
636 print(
"hj = ", massgrid[1:] - massgrid[: nbins + 1])
637 print(
"tabdtCFL = ", tabdtCFL)
639 print(
"issue in CFL")
646def L_func_coag_kdv(nbins, kpol, massgrid, gij, tensor_tabflux_coag, tensor_tabintflux_coag, dv):
648 Function to compute the DG operator L for piecewise polynomial approximation (see Lombart et al., 2021)
649 Function for ballistic kernel with differential velocities dv
650 It is used for the time solver
654 nbins : scalar, type -> integer
656 kpol : scalar, type -> integer
657 degree of polynomials for approximation
658 massgrid : 1D array (dim = nbins+1), type -> float
659 grid of masses given borders value of mass bins
660 gij : 2D array (dim = (nbins,kpol+1)), type -> float
661 components of g on the polynomial basis
662 tensor_tabflux_coag : 5D array (dim = (nbins,nbins,nbins,kpol+1,kpol+1)), type -> float
663 array to evaluate coagulation flux
664 tensor_tabintflux_coag : 6D array (dim = (nbins,kpol+1,nbins,nbins,kpol+1,kpol+1)), type -> float
665 array to evaluate the term including the integral of coagulation flux
666 dv : 2D array (dim = (nbins,nbins)), type -> float
667 array of the differential velocity between grains
671 Lk : 2D array (dim = (nbins,kpol+1)), type -> float
672 DG operator for piecewise polynomials approximation in each bin
676 flux = compute_flux_coag_kdv(gij, tensor_tabflux_coag, dv)
677 intflux = compute_intflux_coag_kdv(gij, tensor_tabintflux_coag, dv)
679 mat_intflux = intflux.reshape(nbins, kpol + 1)
681 LegPright = eval_legendre(range(kpol + 1), 1.0)
682 flux_right = np.outer(flux, LegPright)
684 flux_left = np.zeros((nbins, kpol + 1))
685 LegPleft = eval_legendre(range(kpol + 1), -1.0)
686 flux_left[1:, :] = np.outer(flux[0 : nbins - 1], LegPleft)
688 mat_coeff_norm = np.outer(
689 2.0 / (massgrid[1:] - massgrid[0:nbins]), 1.0 / coeff_norm_leg(np.arange(kpol + 1))
692 Lk = mat_coeff_norm * (mat_intflux - (flux_right - flux_left))
699 eps, nbins, kpol, massgrid, massbins, gij, tensor_tabflux_coag, tensor_tabintflux_coag, dv, dt
702 Function to compute SSPRK order 3 time solver with piecewise constant approximation
703 Function for ballistic kernel with differential velocities dv
704 See Zhang & Shu 2010 and Lombart et al., 2021
709 eps : scalar, type -> float
710 minimum value for mass distribution approximation gij
711 nbins : scalar, type -> integer
713 kpol : scalar, type -> integer
714 degree of polynomials for approximation
715 massgrid : 1D array (dim = nbins+1), type -> float
716 grid of masses given borders value of mass bins
717 massbins : 1D array (dim = nbins), type -> float
718 arithmetic mean value of massgrid for each mass bins
719 gij : 2D array (dim = (nbins,kpol+1)), type -> float
720 components of g on the polynomial basis
721 tensor_tabflux_coag : 5D array (dim = (nbins,nbins,nbins,kpol+1,kpol+1)), type -> float
722 array to evaluate coagulation flux
723 tensor_tabintflux_coag : 6D array (dim = (nbins,kpol+1,nbins,nbins,kpol+1,kpol+1)), type -> float
724 array to evaluate the term including the integral of coagulation flux
725 dv : 2D array (dim = (nbins,nbins)), type -> float
726 array of the differential velocity between grains
727 dt : scalar, type -> float
733 gijnew : 2D array (dim = (nbins,kpol+1)), type -> float
734 evolved components of g on the polynomial basis after 1 timestep
740 Lk = L_func_coag_kdv(
741 nbins, kpol, massgrid, gij, tensor_tabflux_coag, tensor_tabintflux_coag, dv
747 tabgamma = gammafunction(eps, nbins, kpol, massgrid, massbins, gij1)
748 gij1[:, 1:] = tabgamma.reshape(nbins, 1) * gij1[:, 1:]
751 if gij1[:, 0][gij1[:, 0] < 0.0].any():
753 print(
"dt*Lk = ", dt * Lk)
754 print(
"gij1 = ", gij1)
755 print(
"Negative value ")
758 gij1[:, 1:][gij1[:, 0] < eps] = 0.0
759 gij1[:, 0][gij1[:, 0] < eps] = eps
761 Lk_1 = L_func_coag_kdv(
762 nbins, kpol, massgrid, gij1, tensor_tabflux_coag, tensor_tabintflux_coag, dv
765 gij2 = 3.0 * gij / 4.0 + (gij1 + dt * Lk_1) / 4.0
768 tabgamma = gammafunction(eps, nbins, kpol, massgrid, massbins, gij2)
769 gij2[:, 1:] = tabgamma.reshape(nbins, 1) * gij2[:, 1:]
773 if gij2[:, 0][gij2[:, 0] < 0.0].any():
775 print(
"dt*Lk_1 = ", dt * Lk_1)
776 print(
"gij2 = ", gij2)
777 print(
"Negative value ")
780 gij2[:, 1:][gij2[:, 0] < eps] = 0.0
781 gij2[:, 0][gij2[:, 0] < eps] = eps
784 Lk_2 = L_func_coag_kdv(
785 nbins, kpol, massgrid, gij2, tensor_tabflux_coag, tensor_tabintflux_coag, dv
788 gijnew = gij / 3.0 + 2.0 * (gij2 + dt * Lk_2) / 3.0
791 tabgamma = gammafunction(eps, nbins, kpol, massgrid, massbins, gijnew)
792 gijnew[:, 1:] = tabgamma.reshape(nbins, 1) * gijnew[:, 1:]
796 if gijnew[:, 0][gijnew[:, 0] < 0.0].any():
798 print(
"dt*Lk_1 = ", dt * Lk_1)
799 print(
"gijnew = ", gijnew)
800 print(
"Negative value ")
803 gijnew[:, 1:][gijnew[:, 0] < eps] = 0.0
804 gijnew[:, 0][gijnew[:, 0] < eps] = eps