Ticket #3935: ode_solver_patch.patch
| File ode_solver_patch.patch, 2.2 kB (added by jwmerrill, 5 months ago) |
|---|
-
a/sage/gsl/ode.pyx
old new 242 242 sage: f = T.interpolate_solution(i=2) 243 243 sage: plot(f,0,12).show() 244 244 sage: f = T.interpolate_solution() 245 sage: f(pi) # slightly random precision 246 0.53794722843358245 245 sage: f(pi) 246 0.5379... 247 248 The solver attributes may also be set up using arguments to ode_solver. The previous example can be rewritten as 249 250 sage: T = ode_solver(g_1,y_0=[0,1,1],scale_abs=[1e-4,1e-4,1e-5],error_rel=1e-4) 251 sage: T.ode_solve(t_span=[0,12],num_points=100) 252 sage: f = T.interpolate_solution() 253 sage: f(pi) 254 0.5379... 247 255 248 256 Unfortunately because python functions are used, this solver is slow on system that require many function evaluations. 249 257 It is possible to pass a compiled function by deriving from the class ode_sysem and overloading c_f and c_j with C functions that … … 284 292 def __init__(self,function=None,jacobian=None,h = 1e-2,error_abs=1e-10,error_rel=1e-10, a=False,a_dydt=False,scale_abs=False,algorithm="rkf45",y_0=None,t_span=None,params = []): 285 293 self.function = function 286 294 self.jacobian = jacobian 287 self.h =1e-2295 self.h = h 288 296 self.error_abs = error_abs 289 self.error_rel = error_ abs290 self.a = False291 self.a_dydt = False292 self.scale_abs =False293 self.algorithm = "rkf45"294 self.y_0 =None295 self.t_span = None296 self.params = []297 self.solution =[]297 self.error_rel = error_rel 298 self.a = a 299 self.a_dydt = a_dydt 300 self.scale_abs = scale_abs 301 self.algorithm = algorithm 302 self.y_0 = y_0 303 self.t_span = t_span 304 self.params = params 305 self.solution = [] 298 306 299 307 def __setattr__(self,name,value): 300 308 if(hasattr(self,'solution')):