Пример #1
0
def test_coalescence():
    # TODO: np.random.RandomState in backend?

    # Arrange
    v_min = 4.186e-15
    v_max = 4.186e-12
    n_sd = 2**13
    steps = [0, 30, 60]
    X0 = 4 / 3 * 3.14 * 30.531e-6**3
    n_part = 2**23  # [m-3]
    dv = 1e6  # [m3]
    dt = 1  # [s]
    norm_factor = n_part * dv

    kernel = Golovin(b=1.5e3)  # [s-1]
    spectrum = Exponential(norm_factor=norm_factor, scale=X0)
    particles = Particles(n_sd=n_sd, dt=dt, backend=backend)
    particles.set_mesh_0d(dv=dv)
    particles.set_environment(Box, {})
    v, n = constant_multiplicity(n_sd, spectrum, (v_min, v_max))
    particles.create_state_0d(n=n, extensive={'volume': v}, intensive={})
    particles.add_dynamic(SDM, {"kernel": kernel})

    states = {}

    # Act
    for step in steps:
        particles.run(step - particles.n_steps)
        states[particles.n_steps] = copy.deepcopy(particles.state)

    # Assert
    x_max = 0
    for state in states.values():
        assert x_max < state.max('volume')
        x_max = state.max('volume')
Пример #2
0
def run(setup):
    particles = Particles(n_sd=setup.n_sd, dt=setup.dt, backend=setup.backend)
    particles.set_mesh_0d(setup.dv)
    particles.set_environment(Box, {})
    v, n = constant_multiplicity(setup.n_sd, setup.spectrum,
                                 (setup.x_min, setup.x_max))
    particles.create_state_0d(n=n, extensive={'volume': v}, intensive={})
    particles.add_dynamic(SDM, {"kernel": setup.kernel})

    states = {}
    for step in setup.steps:
        particles.run(step - particles.n_steps)
        # setup.check(runner.state, runner.n_steps) TODO???

    return states, particles.stats
Пример #3
0
def run(setup):
    particles_builder = ParticlesBuilder(n_sd=setup.n_sd,
                                         dt=setup.dt,
                                         backend=setup.backend)
    particles_builder.set_mesh_0d(setup.dv)
    particles_builder.set_environment(Box, {})
    v, n = constant_multiplicity(setup.n_sd, setup.spectrum,
                                 (setup.x_min, setup.x_max))
    particles_builder.create_state_0d(n=n,
                                      extensive={'volume': v},
                                      intensive={})
    particles_builder.register_dynamic(SDM, {"kernel": setup.kernel})
    particles = particles_builder.get_particles()

    states = {}
    for step in setup.steps:
        particles.run(step - particles.n_steps)
        setup.check(particles.state, particles.n_steps)
        states[particles.n_steps] = copy.deepcopy(particles.state)

    return states, particles.stats