Exemplo n.º 1
0
    def test_fig10():
        # Arrange
        simulation = Simulation(Setup("cosine"),
                                Options(infinite_gauge=True, n_iters=2))

        # Act
        simulation.run()
        psiT = simulation.state

        # Assert
        assert -.1 < np.amin(psiT) < 0
        assert 1.75 < np.amax(psiT) < 1.9
Exemplo n.º 2
0
    def test_fig11():
        # Arrange
        simulation = Simulation(Setup("rect"),
                                Options(infinite_gauge=True, n_iters=2))

        # Act
        simulation.run()
        psiT = simulation.state

        # Assert
        assert -1.9 < np.amin(psiT) < 2
        assert 4 < np.amax(psiT) < 4.2
Exemplo n.º 3
0
    def test_fig11(dtype: np.floating):
        # Arrange
        simulation = Simulation(Setup("rect"), Options(infinite_gauge=True, n_iters=2, dtype=dtype))

        # Act
        simulation.run()
        psiT = simulation.state

        # Assert
        assert psiT.dtype == dtype
        assert -1.9 < np.amin(psiT) < 2
        assert 4 < np.amax(psiT) < 4.2
Exemplo n.º 4
0
    def test_fig10(dtype: np.floating):
        # Arrange
        simulation = Simulation(Setup("cosine"), Options(infinite_gauge=True, n_iters=2, dtype=dtype))

        # Act
        simulation.run()
        psiT = simulation.state

        # Assert
        assert psiT.dtype == dtype
        assert -.1 < np.amin(psiT) < 0
        assert 1.75 < np.amax(psiT) < 1.9
Exemplo n.º 5
0
    def test_fig12(dtype: np.floating):
        # Arrange
        simulation = Simulation(Setup("rect"), Options(n_iters=2, infinite_gauge=True, flux_corrected_transport=True, dtype=dtype))

        # Act
        simulation.run()
        psiT = simulation.state

        # Assert
        assert psiT.dtype == dtype
        assert np.amin(psiT) >= 2
        assert np.amax(psiT) <= 4
        assert np.amax(psiT) > 3
Exemplo n.º 6
0
    def test_fig3():
        # Arrange
        simulation = Simulation(Setup("cosine"), Options(n_iters=1))
        psi0 = simulation.state

        # Act
        simulation.run()
        psiT = simulation.state

        # Assert
        epsilon = 1e-20
        assert np.amin(psi0) == 0
        assert np.amax(psi0) == 2
        assert 0 < np.amin(psiT) < epsilon
        assert .45 < np.amax(psiT) < .5
Exemplo n.º 7
0
    def test_fig4(dtype: np.floating):
        # Arrange
        simulation = Simulation(Setup("cosine"), Options(n_iters=2, dtype=dtype))
        psi0 = simulation.state

        # Act
        simulation.run()
        psiT = simulation.state

        # Assert
        epsilon = 1e-20
        assert psiT.dtype == dtype
        assert np.amin(psi0) == 0
        assert np.amax(psi0) == 2
        assert 0 < np.amin(psiT) < epsilon
        assert 1.3 < np.amax(psiT) < 1.4
Exemplo n.º 8
0
def test_timing_1d(benchmark, options):
    simulation = Simulation(Setup("cosine"), options)
    psi0 = simulation.stepper.curr.get().copy()

    def set_psi():
        simulation.stepper.curr.get()[:] = psi0

    benchmark.pedantic(simulation.run, {},
                       setup=set_psi,
                       warmup_rounds=1,
                       rounds=3)

    print(np.amin(simulation.state), np.amax(simulation.state))
    if not options.infinite_gauge:
        assert np.amin(simulation.state) >= 0