Class: Adaptive_Cash_Karp_RK45
- Inherits:
-
Cash_Karp_RK4
- Object
- Cash_Karp_RK4
- Adaptive_Cash_Karp_RK45
- Includes:
- AdaptiveIntegrator
- Defined in:
- lib/integrator/rkqs.rb
Constant Summary collapse
- SAFETY =
0.9
- PGROW =
-0.2
- PSHRNK =
-0.25
- ERRCON =
1.89e-4
Constants included from AdaptiveIntegrator
AdaptiveIntegrator::MAXSTP, AdaptiveIntegrator::TINY
Constants inherited from Cash_Karp_RK4
Cash_Karp_RK4::A2, Cash_Karp_RK4::A3, Cash_Karp_RK4::A4, Cash_Karp_RK4::A5, Cash_Karp_RK4::A6, Cash_Karp_RK4::B21, Cash_Karp_RK4::B31, Cash_Karp_RK4::B32, Cash_Karp_RK4::B41, Cash_Karp_RK4::B42, Cash_Karp_RK4::B43, Cash_Karp_RK4::B51, Cash_Karp_RK4::B52, Cash_Karp_RK4::B53, Cash_Karp_RK4::B54, Cash_Karp_RK4::B61, Cash_Karp_RK4::B62, Cash_Karp_RK4::B63, Cash_Karp_RK4::B64, Cash_Karp_RK4::B65, Cash_Karp_RK4::C1, Cash_Karp_RK4::C3, Cash_Karp_RK4::C4, Cash_Karp_RK4::C6, Cash_Karp_RK4::DC1, Cash_Karp_RK4::DC3, Cash_Karp_RK4::DC4, Cash_Karp_RK4::DC5, Cash_Karp_RK4::DC6
Instance Method Summary collapse
Methods included from AdaptiveIntegrator
Methods included from Integrator
#Integrator_initialize, #integrate, #set_max_samples
Methods inherited from Cash_Karp_RK4
#initialize, #integrate_fixed_step
Constructor Details
This class inherits a constructor from Cash_Karp_RK4
Instance Method Details
#integrate_ad_step(y, dydx, x, htry, eps, yscal, derivs) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/integrator/rkqs.rb', line 23 def integrate_ad_step(y, dydx, x, htry, eps, yscal, derivs) h = htry while(true) do ytemp, yerr = integrate_fixed_step(y, dydx, x, h, derivs) errmax = yerr.collect2(yscal) { |err, scal| (err/scal).abs }.max errmax /= eps break if errmax <= 1.0 htemp = SAFETY * h * (errmax ** PSHRNK) h = h >= 0.0 ? [htemp, 0.1 * h].max : [htemp, 0.1 * h].min xnew = x + h raise "Step underflow!" if xnew == x end if errmax > ERRCON hnext = SAFETY * h * (errmax ** PGROW) else hnext = 5 * h end hdid = h x += h y = ytemp [x, y, hdid, hnext] end |