Exemple #1
0
def test_simul_already_ended(heat_model):
    x, dx = np.linspace(0, 10, 50, retstep=True, endpoint=False)
    T = np.cos(x * 2 * np.pi / 10)
    initial_fields = heat_model.fields_template(x=x, T=T)
    parameters = dict(periodic=True, k=1)

    simul = Simulation(heat_model, initial_fields, parameters,
                       dt=1, tol=1E-1, tmax=10)
    simul.run()
    simul.run()
Exemple #2
0
def test_simul_pprocess(heat_model):
    x, dx = np.linspace(0, 10, 50, retstep=True, endpoint=False)
    T = np.cos(x * 2 * np.pi / 10)
    initial_fields = heat_model.fields_template(x=x, T=T)
    parameters = dict(periodic=True, k=1)

    simul = Simulation(heat_model, initial_fields, parameters,
                       dt=1, tol=1E-1, tmax=10)

    def compute_grad(simul):
        simul.fields["grad"] = np.gradient(simul.fields["T"].values)
        return simul

    simul.add_post_process("grad", compute_grad)
    simul.run()
    simul.remove_post_process("grad")
    assert simul.post_processes == []