PySDM_examples.Bieli_et_al_2022.simulation

 1import PySDM.products.size_spectral.arbitrary_moment as am
 2from PySDM.backends import CPU
 3from PySDM.builder import Builder
 4from PySDM.dynamics import Collision
 5from PySDM.environments import Box
 6from PySDM.initialisation.sampling.spectral_sampling import ConstantMultiplicity
 7
 8
 9def make_core(settings, coal_eff):
10    backend = CPU
11
12    builder = Builder(
13        n_sd=settings.n_sd,
14        backend=backend(settings.formulae),
15        environment=Box(dv=settings.dv, dt=settings.dt),
16    )
17    builder.particulator.environment["rhod"] = 1.0
18    attributes = {}
19    attributes["volume"], attributes["multiplicity"] = ConstantMultiplicity(
20        settings.spectrum
21    ).sample(settings.n_sd)
22    collision = Collision(
23        collision_kernel=settings.kernel,
24        coalescence_efficiency=coal_eff,
25        breakup_efficiency=settings.break_eff,
26        fragmentation_function=settings.fragmentation,
27        adaptive=settings.adaptive,
28    )
29    builder.add_dynamic(collision)
30    common_args = {
31        "attr": "volume",
32        "attr_unit": "m^3",
33        "skip_division_by_m0": True,
34        "skip_division_by_dv": True,
35    }
36    products = tuple(
37        am.make_arbitrary_moment_product(rank=rank, **common_args)(name=f"M{rank}")
38        for rank in range(3)
39    )
40    return builder.build(attributes, products)
def make_core(settings, coal_eff):
10def make_core(settings, coal_eff):
11    backend = CPU
12
13    builder = Builder(
14        n_sd=settings.n_sd,
15        backend=backend(settings.formulae),
16        environment=Box(dv=settings.dv, dt=settings.dt),
17    )
18    builder.particulator.environment["rhod"] = 1.0
19    attributes = {}
20    attributes["volume"], attributes["multiplicity"] = ConstantMultiplicity(
21        settings.spectrum
22    ).sample(settings.n_sd)
23    collision = Collision(
24        collision_kernel=settings.kernel,
25        coalescence_efficiency=coal_eff,
26        breakup_efficiency=settings.break_eff,
27        fragmentation_function=settings.fragmentation,
28        adaptive=settings.adaptive,
29    )
30    builder.add_dynamic(collision)
31    common_args = {
32        "attr": "volume",
33        "attr_unit": "m^3",
34        "skip_division_by_m0": True,
35        "skip_division_by_dv": True,
36    }
37    products = tuple(
38        am.make_arbitrary_moment_product(rank=rank, **common_args)(name=f"M{rank}")
39        for rank in range(3)
40    )
41    return builder.build(attributes, products)