Buckets:
| import odespy | |
| import numpy as np | |
| import decay_mod | |
| import sys | |
| #import matplotlib.pyplot as plt | |
| import scitools.std as plt | |
| def f(u, t): | |
| return -a*u | |
| def exact_solution(t): | |
| return I*np.exp(-a*t) | |
| I = 1; a = 2; T = 5 | |
| tol = float(sys.argv[1]) | |
| solver = odespy.DormandPrince(f, atol=tol, rtol=0.1*tol) | |
| Nt = 1 # just one step - let the scheme find its intermediate points | |
| t_mesh = np.linspace(0, T, Nt+1) | |
| t_fine = np.linspace(0, T, 10001) | |
| solver.set_initial_condition(I) | |
| u, t = solver.solve(t_mesh) | |
| # u and t will only consist of [I, u^Nt] and [0,T] | |
| # solver.u_all and solver.t_all contains all computed points | |
| plt.plot(solver.t_all, solver.u_all, 'ko') | |
| plt.hold('on') | |
| plt.plot(t_fine, exact_solution(t_fine), 'b-') | |
| plt.legend(['tol=%.0E' % tol, 'exact']) | |
| plt.savefig('tmp_odespy_adaptive.png') | |
| plt.show() | |
Xet Storage Details
- Size:
- 812 Bytes
- Xet hash:
- ca1686c96fc8156a977f489dff9f067a470c3b53eb935f898ef53ffa68a02259
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.