Esempio n. 1
0
                            index=0,
                            analytical_solution=ho_solution,
                            dt=dt,
                            maxt=maxt)
graphs.plot_compare_methods(ho, (0, 1),
                            index=0,
                            analytical_solution=ho_solution,
                            integrators=[
                                ode.euler_2, ode.runge_kutta_4,
                                symplectic.verlet,
                                symplectic.euler_1_modified_x
                            ],
                            dt=dt,
                            maxt=maxt)
graphs.plot_compare_steps(ho, (0, 1),
                          ode.euler_1,
                          analytical_solution=ho_solution,
                          maxt=maxt)

symplectic.plot_energy(ho, (0, 1), energy_function=ho_energy, dt=dt, maxt=maxt)
symplectic.plot_energy(
    ho, (0, 1),
    energy_function=ho_energy,
    dt=dt,
    maxt=maxt,
    integrators=[ode.euler_2, ode.runge_kutta_4, symplectic.verlet])

graphs.plot_cummulative_error(ho, (0, 1),
                              ho_solution,
                              index=0,
                              integrators=[
                                  ode.euler_1, ode.euler_2, ode.runge_kutta_4,
Esempio n. 2
0
import numpy as np

import ode
import graphs

def relaxation(y, t):
    """ Derivatives for the relaxation system """
    return -y


def analytical_solution(t):
    return np.exp(-t)


graphs.plot_compare_methods(relaxation, 1, analytical_solution=analytical_solution, dt=0.5)
graphs.plot_compare_steps(relaxation, 1, ode.euler_1, analytical_solution=analytical_solution)
graphs.plot_compare_steps(relaxation, 1, ode.euler_2, analytical_solution=analytical_solution)
graphs.plot_compare_steps(relaxation, 1, ode.runge_kutta_4, analytical_solution=analytical_solution)
graphs.plot_cummulative_error(relaxation, 1, analytical_solution)
Esempio n. 3
0
maxt = 20

graphs.plot_compare_methods(exp, (1, -1),
                            index=0,
                            analytical_solution=exp_solution,
                            dt=dt,
                            maxt=maxt)
graphs.plot_compare_methods(exp, (1, -1),
                            index=0,
                            analytical_solution=exp_solution,
                            integrators=[
                                ode.euler_1, ode.euler_2, ode.runge_kutta_4,
                                symplectic.verlet,
                                symplectic.euler_1_modified_x
                            ],
                            dt=dt,
                            maxt=maxt)
graphs.plot_compare_steps(exp, (1, -1),
                          ode.euler_1,
                          analytical_solution=exp_solution,
                          maxt=maxt)
graphs.plot_compare_steps(exp, (1, -1),
                          ode.euler_2,
                          analytical_solution=exp_solution,
                          maxt=maxt)

graphs.plot_compare_steps(exp, (1, -1),
                          symplectic.verlet,
                          analytical_solution=exp_solution,
                          maxt=maxt)