lorenz.parareal package
Submodules
lorenz.parareal.parareal module
- lorenz.parareal.parareal.compute_sol_k(fin, X0_k_j)[source]
Compute the solution at the current iteration and do a gather.
- Parameters
fin (numpy.ndarray) – Fine solution on the current process at the current iteration.
X0_k_j (numpy.ndarray) – Initial point on the current process at the current iteration.
- Returns
Ndarray with the number of values of solution for each process and the entire solution between t0 and T.
- Return type
tuple
- lorenz.parareal.parareal.parareal_method(X0_t0, t0, T, prob, fct_res, fct_write, dt_G, dt_F, gamma=None, write_csv=True)[source]
Parareal method.
- Parameters
X0_t0 (list) – Initial point.
t0 (float) – Starting time.
T (float) – Finish time.
prob (function) – Function which represent the ODE.
fct_res (function) – Function which represent the integrator.
fct_write (function) – Function which write the solution in csv files.
dt_G (float) – Coarse time step.
dt_F (float) – Time step.
gamma (tuple, optional) – System parameters. Defaults to None.
write_csv (bool, optional) – Boolean to true if we want to write the solutions in a csv file. Defaults to True.
- Returns
Solution at the last iteration.
- Return type
numpy.ndarray
lorenz.parareal.plot_sol module
- lorenz.parareal.plot_sol.plot_3D(solution, X0)[source]
Plot in 3 dimension the solution and the initial point
- Parameters
solution (numpy.ndarray) – Exact solution.
X0 (numpy.ndarray) – Initial point of the system.
- lorenz.parareal.plot_sol.plot_all(var, n, nom_sol_ex, nom_sol, nom_pts)[source]
Read the exact solution, calculated solution and initial points. Plot them all.
- Parameters
var (str) – Variable.
n (int) – Position of the variable (between 0 and dimension).
nom_sol_ex (str) – Name of the csv file where the exaction solution is.
nom_sol (str) – Name of the csv file where the calculated solution is.
nom_pts (str) – Name of the csv file where the initial points are.
- Returns
Discretisation time between t0 and T for the exact solution, exact solution, discretisation time between t0 and T for the calculated solution, calculated solution (only the variable concerned), number of iteration (until the solution converge), times for the initial poins, number of value of the solution for each process and initial points for each process and each iteration.
- Return type
tuple
- lorenz.parareal.plot_sol.plot_sol(entree, t_rk4, sol_rk4, t, sol, nb_iter, times, pt0)[source]
Plot the solution of the parareal method for each iteration.
- Parameters
entree (str) – Variable.
t_rk4 (list) – Discretisation time between t0 and T for the exact solution.
sol_rk4 (numpy.ndarray) – Exact solution.
t (list) – Discretisation time between t0 and T for the calculated solution.
sol (numpy.ndarray) – Calculated solution.
nb_iter (int) – Number of iteration (until the solution converge).
times (list) – Times used to the system resolution.
pt0 (numpy.ndarray) – Initial points for each process and each iteration.
- lorenz.parareal.plot_sol.read_init_pt(file_name, dim)[source]
Read the file “file_name” where are the initial points for each iteration.
- Parameters
file_name (str) – Name of the csv file where the initial points are.
dim (int) – System dimension.
- Returns
Times for the initial poins, number of value of the solution for each process and initial points for each process and each iteration.
- Return type
tuple
- lorenz.parareal.plot_sol.read_sol(file_name)[source]
Read the file “file_name” where is the calculated solution.
- Parameters
file_name (str) – Name of the csv file where the calculated solution is.
- Returns
Discretisation time between t0 and T for the calculated solution and calculated solution.
- Return type
tuple
lorenz.parareal.utils module
- lorenz.parareal.utils.E_j_k(j, k, nb_pts, solx, solx_exacte, x0)[source]
Compute the value of the convergence property for j and k.
- Parameters
j (int) – Processus (between 0 and P-1).
k (int) – Iteration (between 0 and nb_iter-1)
nb_pts (list) – Number of value of the solution for each process.
solx (numpy.ndarray) – Calculated solution for each iteration.
solx_exacte (numpy.ndarray) – Exact solution.
x0 (numpy.ndarray) – Initial point for each iteration.
- Returns
Two terms of the convergence property.
- Return type
tuple
- lorenz.parareal.utils.RK4(X0, dt, t0, T, fct, gamma=None)[source]
Runge Kutta order 4 method.
- Parameters
X0 (list) – Initial point of the system.
dt (float) – Time step.
t0 (float) – Starting time.
T (float) – Finish time.
fct (function) – Function which represent the ODE.
gamma (tuple, optional) – System parameters. Defaults to None.
- Returns
Solution calculated by the method.
- Return type
numpy.ndarray
- lorenz.parareal.utils.compute_time(t0, T, dt_G, P)[source]
Compute time used to the system resolution.
- Parameters
t0 (float) – Starting time.
T (float) – Finish time.
dt_G (float) – Coarse time step.
P (int) – Number of interval (= number of processes).
- Returns
Times used to the system resolution.
- Return type
list
- lorenz.parareal.utils.csv_files_lorenz(t0, T, dt_F, times, nb_tj, nb_iter, solution, init_pts, reshape_size, fct, fct_res, gamma=None)[source]
Create and write in the csv files for the Lorenz system.
- Parameters
t0 (float) – Starting time.
T (float) – Finish time.
dt_F (float) – Time step.
times (list) – Times used to the system resolution.
nb_tj (numpy.ndarray) – Number of value of the solution for each process.
nb_iter (int) – Number of iteration (until the solution converge).
solution (numpy.ndarray) – Solution for each iteration.
init_pts (numpy.ndarray) – Init points for each iteration.
reshape_size (int) – Dimension of the system.
fct (function) – Function which represent the ODE.
fct_res (function) – Function which represent the integrator.
gamma (tuple, optional) – System parameters. Defaults to None.
- lorenz.parareal.utils.csv_files_oscillator(t0, T, dt_F, times, nb_tj, nb_iter, solution, init_pts, reshape_size, fct, fct_res, gamma=None)[source]
Create and write in the csv files for the Lorenz system.
- Parameters
t0 (float) – Starting time.
T (float) – Finish time.
dt_F (float) – Time step.
times (list) – Times used to the system resolution.
nb_tj (numpy.ndarray) – Number of value of the solution for each process.
nb_iter (int) – Number of iteration (until the solution converge).
solution (numpy.ndarray) – Solution for each iteration.
init_pts (numpy.ndarray) – Init points for each iteration.
reshape_size (int) – Dimension of the system.
fct (function) – Function which represent the ODE.
fct_res (function) – Function which represent the integrator.
gamma (tuple, optional) – System parameters. Defaults to None.
- lorenz.parareal.utils.cvg(t_ex, solx_exacte, t, solx, nb_iter, times, nb_pts, x0)[source]
Calculate for each process and each iteration the value of the convergence property. Plot the value maximum on process for each iteration and the coarse time step power k (the iteration).
- Parameters
t_ex (list) – Discretisation time between t0 and T for the exact solution. Can be different of the one used for the method (if the time step is different).
solx_exacte (numpy.ndarray) – Exact solution.
t (list) – Discretisation time between t0 and T for the calculated solution.
solx (numpy.ndarray) – Calculated solution for each iteration.
nb_iter (int) – Number of iteration (until the solution converge).
times (list) – Times used to the system resolution.
nb_pts (list) – Number of value of the solution for each process.
x0 (numpy.ndarray) – Initial point for each iteration.
- lorenz.parareal.utils.delete_old_files_lorenz()[source]
Delete old csv files created for the lorenz system.
- lorenz.parareal.utils.delete_olf_files_oscillator()[source]
Delete old csv files created for the oscillator.
- lorenz.parareal.utils.erreur(solx, solx_exacte)[source]
Compute the error between two solutions.
- Parameters
solx (numpy.ndarray) – Calculated solution.
solx_exacte (numpy.ndarray) – Exact solution.
- Returns
The error between the exact and calculated solutions.
- Return type
float
- lorenz.parareal.utils.sol_converge(x0_k, x0_knext, eps=1e-15)[source]
Check if initial points converge.
- Parameters
x0_k (numpy.ndarray) – Initial points at the previous time.
x0_knext (numpy.ndarray) – Initial points at the current time.
eps (float, optional) – Error tolerance. Defaults to 1e-15.
- Returns
Boolean to true if the initial points converge.
- Return type
bool