Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
interface_coala_shamrock.py
1import numpy as np
2
3from .generate_flux_intflux import compute_flux_coag_k0_kdv
4
5
6def coala_source_term_k0(nbins, massgrid, rhodust, rhodust_eps, tensor_tabflux_coag, v_dust):
7 """
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
11
12 /!\ Only coagulation so far
13
14 Parameters
15 ----------
16 nbins : scalar, type -> integer
17 number of dust bins
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)
28
29 Returns
30 -------
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
34
35 """
36
37 # compute gij from rhodust for coala k=0
38 gij = 0.0
39 for j in range(nbins):
40 if rhodust[j] > rhodust_eps:
41 gij[j] = rhodust[j] / (massgrid[j + 1] - massgrid[j])
42
43 # dv_ij = v_dust_j - v_dust_i
44 dv = v_dust[None, :] - v_dust[:, None]
45
46 # copmute flux for all dust bins
47 flux = compute_flux_coag_k0_kdv(gij, tensor_tabflux_coag, dv)
48
49 S_coag = np.zeros(nbins)
50 S_coag[0] = -flux[0]
51 S_coag[1:] = flux[:-1] - flux[1:]
52
53 return S_coag