Exemplo n.º 1
0
    def test_analytic_solution_underflow(x):
        # Arrange
        formulae = Formulae()
        b = 1.5e3
        x_0 = formulae.trivia.volume(radius=30.531e-6)
        N_0 = 2 ** 23
        sut = Golovin(b)

        # Act
        value = sut.analytic_solution(x=x, t=1200, x_0=x_0, N_0=N_0)

        # Assert
        assert np.all(np.isfinite(value))
Exemplo n.º 2
0
def test_coalescence_2_sd(backend):
    # Arrange
    s = Settings()
    s.kernel = Golovin(b=1.5e12)
    s.formulae.seed = 0
    steps = [0, 200]
    s.n_sd = 2

    builder = Builder(n_sd=s.n_sd, backend=backend, formulae=s.formulae)
    builder.set_environment(Box(dt=s.dt, dv=s.dv))
    attributes = {}
    attributes['volume'], attributes['n'] = ConstantMultiplicity(s.spectrum).sample(s.n_sd)
    builder.add_dynamic(Coalescence(s.kernel))
    core = builder.build(attributes)

    volumes = {}

    # Act
    for step in steps:
        core.run(step - core.n_steps)
        volumes[core.n_steps] = core.particles['volume'].to_ndarray()

    # Assert
    x_max = 0
    for volume in volumes.values():
        assert x_max < np.amax(volume)
        x_max = np.amax(volume)
    print(core.particles['n'].to_ndarray())
    assert core.particles.SD_num == 1
Exemplo n.º 3
0
 def __init__(self):
     self.formulae = Formulae()
     self.n_sd = 2**13
     self.n_part = 2**23 / si.metre**3
     self.X0 = self.formulae.trivia.volume(radius=30.531 * si.micrometres)
     self.dv = 1e6 * si.metres**3
     self.norm_factor = self.n_part * self.dv
     self.rho = 1000 * si.kilogram / si.metre**3
     self.dt = 1 * si.seconds
     self.adaptive = False
     self.seed = 44
     self._steps = [0, 1200, 2400, 3600]
     self.kernel = Golovin(b=1.5e3 / si.second)
     self.spectrum = spectra.Exponential(norm_factor=self.norm_factor,
                                         scale=self.X0)
     self.radius_bins_edges = np.logspace(np.log10(10 * si.um),
                                          np.log10(5e3 * si.um),
                                          num=128,
                                          endpoint=True)
Exemplo n.º 4
0
def test_coalescence(backend, croupier, adaptive):
    if backend == ThrustRTC and croupier == 'local':  # TODO #358
        return
    if backend == ThrustRTC and adaptive and croupier == 'global':  # TODO #329
        return
    # Arrange
    formulae = Formulae(seed=256)
    n_sd = 2**14
    steps = [0, 100, 200]
    X0 = formulae.trivia.volume(radius=30.531e-6)
    n_part = 2**23 / si.metre**3
    dv = 1e6 * si.metres**3
    dt = 1 * si.seconds
    norm_factor = n_part * dv
    rho = 1000 * si.kilogram / si.metre**3

    kernel = Golovin(b=1.5e3)  # [s-1]
    spectrum = Exponential(norm_factor=norm_factor, scale=X0)
    builder = Builder(n_sd=n_sd, backend=backend(formulae=formulae))
    builder.set_environment(Box(dt=dt, dv=dv))
    attributes = {}
    attributes['volume'], attributes['n'] = ConstantMultiplicity(
        spectrum).sample(n_sd)
    builder.add_dynamic(
        Coalescence(kernel, croupier=croupier, adaptive=adaptive))
    particulator = builder.build(attributes)

    volumes = {}

    # Act
    for step in steps:
        particulator.run(step - particulator.n_steps)
        check(n_part, dv, n_sd, rho, particulator.attributes, step)
        volumes[particulator.
                n_steps] = particulator.attributes['volume'].to_ndarray()

    # Assert
    x_max = 0
    for volume in volumes.values():
        assert x_max < np.amax(volume)
        x_max = np.amax(volume)