Exemplo n.º 1
0
def test_multi_timestep(plot=False):
    # Arrange
    setup = Setup()
    setup.n_steps = 20
    setup.outfreq = 1

    for key in setup.processes.keys():
        setup.processes[key] = False
    setup.processes["condensation"] = True
    setup.processes["fluid advection"] = True

    storage = DummyStorage()
    simulation = Simulation(setup, storage)
    simulation.reinit()

    # Act
    simulation.run()

    # Plot
    if plot:
        levels = np.arange(setup.grid[1])
        for step, datum in storage.profiles.items():
            pyplot.plot(datum["qv"], levels, label=str(step))
        pyplot.legend()
        pyplot.show()

    # Assert
    for step in range(len(storage.profiles) - 1):
        next = storage.profiles[step + 1]["qv"]
        prev = storage.profiles[step]["qv"]
        eps = 1e-5
        assert ((prev + eps) >= next).all()
Exemplo n.º 2
0
def test_export():
    # Arrange
    setup = Setup()
    setup.n_steps = 1
    setup.outfreq = 1

    storage = Storage()
    simulator = Simulation(setup, storage)
    sut = netCDF(storage, setup, simulator)
    controller = DummyController()

    simulator.reinit()
    simulator.run(controller)

    # Act
    sut.run(controller=controller)