3from .generate_flux_intflux
import compute_flux_coag_k0_kdv
6def coala_source_term_k0(nbins, massgrid, rhodust, rhodust_eps, tensor_tabflux_coag, v_dust):
8 Function to compute the source for coagulation and fragmentation in continuity equation for piecewise constant approximation (see Lombart et al., 2021)
9 Function for ballistic kernel with differential velocities dv
10 Used to evaluate the source term, then hydro code applies time solver
12 /!\ Only coagulation so far
16 nbins : scalar, type -> integer
18 massgrid : 1D array (dim = nbins+1), type -> float
19 grid of masses given borders value of mass bins
20 rhodust : 1D array (dim = nbins), type -> float
21 dust density for each grain size
22 rhodust_eps : scalar, type -> float
23 threshold value for rhodust
24 tensor_tabflux_coag : 3D array (dim = (nbins,nbins,nbins)), type -> float
25 array to evaluate coagulation flux
26 v_dust : 1D array (dim = (nbins)), type -> float
27 array of the dust velocities (could also be delta_v in monofluid since it is a delta)
31 S_coag : 1D array (dim = nbins), type -> float
32 Source term for dust coagulation in continuity equation
33 DG operator for piecewise constant approximation in each binls
39 for j
in range(nbins):
40 if rhodust[j] > rhodust_eps:
41 gij[j] = rhodust[j] / (massgrid[j + 1] - massgrid[j])
44 dv = np.zeros((nbins, nbins))
45 for i
in range(nbins):
46 for j
in range(nbins):
47 delta_v = v_dust[j] - v_dust[i]
48 dv[i, j] = np.sqrt(delta_v[0] ** 2 + delta_v[1] ** 2 + delta_v[2] ** 2)
51 flux = compute_flux_coag_k0_kdv(gij, tensor_tabflux_coag, dv)
53 S_coag = np.zeros(nbins)
55 S_coag[1:] = flux[:-1] - flux[1:]
62from scipy.special
import legendre
64from .generate_tabflux_tabintflux
import compute_coagtabflux_k0_numba
65from .utils_polynomials
import legendre_coeffs
68def coala_precalc_tabflux_coag(K0, nbins, Q, massgrid):
70 Function to iterate coagulation solver to reach the time ndthydro x dthydro
72 Function for ballistic kernel with differential velocities dv
74 DG scheme k=0, piecewise constant approximation
78 K0 : scalar, type -> float
79 constant value of the kernel function (used to adapt to code unit)
80 nbins : scalar, type -> integer
82 Q : scalar, type -> integer
83 number of points for Gauss-Legendre quadrature
84 massgrid : 1D array (dim = nbins+1), type -> float
85 grid of masses given borders value of mass bins
90 gij_init : 1D array (dim = nbins) or 2D array (dim = (nbins.kpol+1)), type -> float
91 initial components of g on the polynomial basis
92 gij : 1D array (dim = nbins) or 2D array (dim = (nbins.kpol+1)), type -> float
93 evolved components of g on the polynomial basis
94 time_coag : scalar, type -> float
95 final time ndthydro x dthydro
102 vecnodes, vecweights = np.polynomial.legendre.leggauss(Q)
105 mat_coeffs_leg = np.zeros((kpol + 1, kpol + 1))
106 mat_coeffs_leg = legendre_coeffs(kpol)
109 tensor_tabflux_coag = np.zeros((nbins, nbins, nbins))
111 compute_coagtabflux_k0_numba(
124 print(
"Tensor tabflux generated in %.5f s" % (finish - start))
126 return tensor_tabflux_coag