Sha256: 0e44d0de33c5a40695b7da9766dac70ca2ec56e89a5171364e157dcd5d009587

Contents?: true

Size: 742 Bytes

Versions: 22

Compression:

Stored size: 742 Bytes

Contents

#!/usr/bin/env ruby
require("gsl")
dim = 2
func = Proc.new { |t, y, dydt, mu|
  dydt[0] = y[1]
  dydt[1] = -y[0] - mu*y[1]*(y[0]*y[0] - 1.0)
}
step = GSL::Odeiv::Step.alloc(GSL::Odeiv::Step::RKF45, dim)
c = GSL::Odeiv::Control.y_new(1e-6, 0.0)
evolve = GSL::Odeiv::Evolve.alloc(dim)
sys = GSL::Odeiv::System.alloc(func, dim)
mu = 10.0
sys.set_params(mu)
t = 0.0; tend = 100.0
h = 1e-6
y = GSL::Vector[1.0, 0.0]
GSL::ieee_env_setup()

N = 1500
tt = GSL::Vector[N]
yt = GSL::Vector[N]
i = 0
while t < tend and i < N
  t, h, status = evolve.apply(c, step, sys, t, tend, h, y)
  tt[i] = t
  yt[i] = y[0]
  break if status != GSL::SUCCESS
  i += 1
end
yt.subvector(i).graph(tt.subvector(i), "-T X -C -g 3 -x 0 #{tt.max} -L '#{step.name}' -S 4")


Version data entries

22 entries across 22 versions & 4 rubygems

Version Path
gsl-2.1.0.3 examples/odeiv/odeiv.rb
gsl-2.1.0.2 examples/odeiv/odeiv.rb
gsl-2.1.0.1 examples/odeiv/odeiv.rb
gsl-2.1.0 examples/odeiv/odeiv.rb
gsl-1.16.0.6 examples/odeiv/odeiv.rb
rb-gsl-1.16.0.5 examples/odeiv/odeiv.rb
rb-gsl-1.16.0.4 examples/odeiv/odeiv.rb
rb-gsl-1.16.0.3 examples/odeiv/odeiv.rb
rb-gsl-1.16.0.3.rc1 examples/odeiv/odeiv.rb
gsl-nmatrix-1.15.3.2 examples/odeiv/odeiv.rb
gsl-nmatrix-1.15.3.1 examples/odeiv/odeiv.rb
rb-gsl-1.16.0.2 examples/odeiv/odeiv.rb
rb-gsl-1.16.0.1 examples/odeiv/odeiv.rb
rb-gsl-1.16.0 examples/odeiv/odeiv.rb
rb-gsl-1.15.3.2 examples/odeiv/odeiv.rb
rb-gsl-1.15.3.1 examples/odeiv/odeiv.rb
blackwinter-gsl-1.15.3.2 examples/odeiv/odeiv.rb
gsl-nmatrix-1.15.3.0 examples/odeiv/odeiv.rb
gsl-1.15.3 examples/odeiv/odeiv.rb
gsl-1.14.7 examples/odeiv/odeiv.rb