Пример #1
0
def test_just_do_it(scheme):
    # Arrange
    setup = Setup()
    setup.condensation_scheme = scheme
    simulation = Simulation(setup)

    # Act
    output = simulation.run()
Пример #2
0
def test_just_do_it(scheme, coord):  #, enable_particle_temperatures):
    # Arrange
    Setup.total_time = 15 * si.minute
    setup = Setup()
    setup.coord = coord
    #setup.enable_particle_temperatures = enable_particle_temperatures
    if scheme == 'BDF':
        setup.dt_max = setup.total_time

    simulation = Simulation(setup)
    if scheme == 'BDF':
        bdf.patch_particles(simulation.particles, setup.coord)

    # Act
    output = simulation.run()
Пример #3
0
def test_displacement(plot=False):
    # Arrange
    setup = Setup(n_sd=0)
    simulation = Simulation(setup)

    # Act
    output = simulation.run()

    # Plot
    if plot:
        plt.plot(output["t"], output["S"])
        plt.grid()
        plt.show()

    # Assert
    assert np.argmin(output["z"]) == 0
    assert output["z"][0] == setup.z0
    np.testing.assert_approx_equal(output["z"][-1], 1000)
    np.testing.assert_approx_equal(np.amax(output["z"]), 1200)
    assert signal.argrelextrema(np.array(output["z"]), np.greater)[0].shape[0] == 10
    assert signal.argrelextrema(np.array(output["z"]), np.less)[0].shape[0] == 10
Пример #4
0
def test_just_do_it(scheme, coord, adaptive,
                    enable_particle_temperatures):  # Arrange
    if scheme == 'BDF' and not adaptive:
        return
    if scheme == 'BDF' and coord == 'volume':
        return

    # Setup.total_time = 15 * si.minute
    setup = Setup(dt_output=10 * si.second)
    setup.coord = coord
    setup.adaptive = adaptive
    setup.enable_particle_temperatures = enable_particle_temperatures
    if scheme == 'BDF':
        setup.dt_max = setup.dt_output
    elif not adaptive:
        setup.dt_max = 1 * si.second

    simulation = Simulation(setup)
    if scheme == 'BDF':
        bdf.patch_particles(simulation.particles, setup.coord)

    # Act
    output = simulation.run()
    r = np.array(output['r']).T * si.metres
    n = setup.n / (setup.mass_of_dry_air * si.kilogram)

    # Assert
    condition = (r > 1 * si.micrometre)
    NTOT = n_tot(n, condition)
    N1 = NTOT[:int(1 / 3 * len(NTOT))]
    N2 = NTOT[int(1 / 3 * len(NTOT)):int(2 / 3 * len(NTOT))]
    N3 = NTOT[int(2 / 3 * len(NTOT)):]

    n_unit = 1 / si.microgram
    assert min(N1) == 0.0 * n_unit
    assert .63 * n_unit < max(N1) < .68 * n_unit
    assert .14 * n_unit < min(N2) < .15 * n_unit
    assert .3 * n_unit < max(N2) < .37 * n_unit
    assert .08 * n_unit < min(N3) < .083 * n_unit
    assert .27 * n_unit < max(N3) < .4 * n_unit