Skip to content

Instantly share code, notes, and snippets.

@SergeStinckwich
Last active February 2, 2017 15:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SergeStinckwich/ad07cc4324bb75601e6f39896f49e21c to your computer and use it in GitHub Desktop.
Save SergeStinckwich/ad07cc4324bb75601e6f39896f49e21c to your computer and use it in GitHub Desktop.
Lorentz attractor with Polymath + Roassal viz
sigma := 10.0.
r := 28.0.
b := 8.0/3.0.
dt := 0.005.
system := ExplicitSystem
block:[:v :t | |dx dy dz x y z|
x := v at: 1. y := v at: 2. z := v at: 3.
dx := sigma * (y - x).
dy := r * x - y - (x * z).
dz := (-1 * b * z + (x * y)).
{dx. dy. dz}.
].
stepper := RungeKuttaStepper onSystem: system.
solver := (ExplicitSolver new) stepper: stepper; system: system; dt: dt.
state := #(10.0 10.0 10.0).
values := (0.0 to: 100.0 by: dt) collect:[:t |
state := stepper doStep: state time:t stepSize: dt].
b := RTGrapher new.
ds := RTData new.
ds dotShape ellipse size: 1; color: (Color blue).
ds points: values.
ds x: [:v | v at: 1]; y: [:v| v at: 2].
b add: ds.
b build.
b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment