loom
39 строк · 909.0 Байт
1// Encapsulating the model file into the LorenzSystem type.
2// This way you can create many objects from one model.
3import "diff/LorenzSystem.diff" type LorenzSystem
4
5// Model object initialization
6LorenzSystem ls = {
7sigma : 10.0,
8b : 8.0/3,
9R : 28.0,
10x : 10.0,
11y : 1.0,
12z : 1.0,
13}
14
15// Charting module
16import "Chart" chart = {title : "Lorenz System"}
17
18// Delayed execution
19finally chart.show()
20
21// Simulation execution module
22import "Scene" scene = {
23// Initializing simulation data
24t : 0.0,
25tk : 50.0,
26dt : 0.01,
27// Lambda with a closure as a callback function
28callback : func [chart : var, ls] ()
29{
30call chart.addPoint("x-y projection", ls.x, ls.y)
31call chart.addPoint("x-z projection", ls.x, ls.z)
32},
33callback_interval : 100,
34// Populating an array of scene objects
35actors : [ls],
36}
37
38// Run simulation
39run scene
40