Module: Integrator
- Included in:
- AdaptiveIntegrator, Cash_Karp_RK4
- Defined in:
- lib/integrator/version.rb,
lib/integrator.rb
Overview
:nodoc:
Defined Under Namespace
Modules: VERSION
Instance Method Summary collapse
-
#integrate(y0, t_start, t_end, derivs, step_start = 0.1, step_min = 0.0001, epsilon = 0.01) ⇒ Object
Integrate from time t_start to t_end, starting from initial value y0.
- #Integrator_initialize ⇒ Object
-
#set_max_samples(num_max, min_x_save = 0.01) ⇒ Object
Set sample logging.
Instance Method Details
#integrate(y0, t_start, t_end, derivs, step_start = 0.1, step_min = 0.0001, epsilon = 0.01) ⇒ Object
Integrate from time t_start to t_end, starting from initial value y0. Use the ‘derivs’ proc to evaluate derivatives at a given point. Start by taking a step of size step_start, take steps no smaller than step_min, and attempt to keep the error per step down to a maximum of epsilon.
54 55 56 57 58 59 60 61 |
# File 'lib/integrator.rb', line 54 def integrate(y0, t_start, t_end, derivs, step_start = 0.1, step_min = 0.0001, epsilon = 0.01) raise "y0 must be a vector!" unless y0.kind_of?(Vector) raise "Must give derivative proc!" unless derivs.kind_of?(Proc) adaptive_integrate(y0, t_start, t_end, epsilon, step_start, step_min, derivs) end |
#Integrator_initialize ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/integrator.rb', line 15 def Integrator_initialize() @kmax = 0 # Max steps to save @dxsav = 0.01 # Minimum step size to save data @xp = nil # Array to save X coords @yp = nil # Array to save Y vectors # Stats from most recent integrate call @nok = 0 @nbad = 0 @count = 0 end |
#set_max_samples(num_max, min_x_save = 0.01) ⇒ Object
Set sample logging. Num_max is the maximum number of samples to log, and min_x_save is the minimum distance between x samples to bother to log.
41 42 43 44 45 46 |
# File 'lib/integrator.rb', line 41 def set_max_samples(num_max, min_x_save = 0.01) @kmax = num_max @xp = [] @yp = [] @dxsav = min_x_save end |