Sha256: 54d5d4029a73355adcf73a0ac89b31faa69b315d56ac6fd869573d0f62811c35
Contents?: true
Size: 875 Bytes
Versions: 22
Compression:
Stored size: 875 Bytes
Contents
#!/usr/bin/env ruby require("gsl") dim = 3 roesller = Proc.new { |t, v, dvdt, params| a = params[0]; b = params[1]; c = params[2] x = v[0]; y = v[1]; z = v[2] dvdt[0] = - y - z dvdt[1] = x + a*y dvdt[2] = b*x - (c - x)*z } a = 0.344 b = 0.4 c = 4.5 solver = GSL::Odeiv::Solver.alloc(GSL::Odeiv::Step::RKF45, [1e-6, 0.0], roesller, dim) solver.set_params(a, b, c) t = 0.0; tend = 100.0 h = 1e-6 v = GSL::Vector.alloc(1, 0, 0) GSL::ieee_env_setup() IO.popen("gnuplot -persist", "w") do |io| io.print("set title 'Roesller equation'\n") io.print("set xlabel 'X'\n") io.print("set ylabel 'Y'\n") io.print("set zlabel 'Z'\n") io.printf("splot '-' u 2:3:4 w l\n") while t < tend t, h, status = solver.apply(t, tend, h, v) io.printf("%e %e %e %e\n", t, v[0], v[1], v[2]) break if status != GSL::SUCCESS end io.printf("e\n") io.flush end
Version data entries
22 entries across 22 versions & 4 rubygems