(define-values (struct:simulation-environment
simulation-environment-constructor
simulation-environment?
simulation-environment-field-ref
set-simulation-environment-field!)
(make-struct-type 'simulation-environment #f 22 0))
(define simulation-environment-running?
(make-struct-field-accessor
simulation-environment-field-ref 0 'running?))
(define set-simulation-environment-running?!
(make-struct-field-mutator
set-simulation-environment-field! 0 'running?))
(define simulation-environment-time
(make-struct-field-accessor
simulation-environment-field-ref 1 'time))
(define set-simulation-environment-time!
(make-struct-field-mutator
set-simulation-environment-field! 1 'time))
(define simulation-environment-now-event-list
(make-struct-field-accessor
simulation-environment-field-ref 2 'now-event-list))
(define set-simulation-environment-now-event-list!
(make-struct-field-mutator
set-simulation-environment-field! 2 'now-event-list))
(define simulation-environment-future-event-list
(make-struct-field-accessor
simulation-environment-field-ref 3 'future-event-list))
(define set-simulation-environment-future-event-list!
(make-struct-field-mutator
set-simulation-environment-field! 3 'future-event-list))
(define simulation-environment-loop-next
(make-struct-field-accessor
simulation-environment-field-ref 4 'loop-next))
(define set-simulation-environment-loop-next!
(make-struct-field-mutator
set-simulation-environment-field! 4 'loop-next))
(define simulation-environment-loop-exit
(make-struct-field-accessor
simulation-environment-field-ref 5 'loop-exit))
(define set-simulation-environment-loop-exit!
(make-struct-field-mutator
set-simulation-environment-field! 5 'loop-exit))
(define simulation-environment-event
(make-struct-field-accessor
simulation-environment-field-ref 6 'event))
(define set-simulation-environment-event!
(make-struct-field-mutator
set-simulation-environment-field! 6 'event))
(define simulation-environment-process
(make-struct-field-accessor
simulation-environment-field-ref 7 'process))
(define set-simulation-environment-process!
(make-struct-field-mutator
set-simulation-environment-field! 7 'process))
(define simulation-environment-parent
(make-struct-field-accessor
simulation-environment-field-ref 8 'parent))
(define set-simulation-environment-parent!
(make-struct-field-mutator
set-simulation-environment-field! 8 'parent))
(define simulation-environment-children
(make-struct-field-accessor
simulation-environment-field-ref 9 'children))
(define set-simulation-environment-children!
(make-struct-field-mutator
set-simulation-environment-field! 9 'children))
(define simulation-environment-continuous-event-list
(make-struct-field-accessor
simulation-environment-field-ref 10 'continuous-event-list))
(define set-simulation-environment-continuous-event-list!
(make-struct-field-mutator
set-simulation-environment-field! 10 'continuous-event-list))
(define simulation-environment-evolve
(make-struct-field-accessor
simulation-environment-field-ref 11 'evolve))
(define set-simulation-environment-evolve!
(make-struct-field-mutator
set-simulation-environment-field! 11 'evolve))
(define simulation-environment-control
(make-struct-field-accessor
simulation-environment-field-ref 12 'control))
(define set-simulation-environment-control!
(make-struct-field-mutator
set-simulation-environment-field! 12 'control))
(define simulation-environment-step-type
(make-struct-field-accessor
simulation-environment-field-ref 13 'step-type))
(define set-simulation-environment-step-type!
(make-struct-field-mutator
set-simulation-environment-field! 13 'step-type))
(define simulation-environment-step
(make-struct-field-accessor
simulation-environment-field-ref 14 'step))
(define set-simulation-environment-step!
(make-struct-field-mutator
set-simulation-environment-field! 14 'step))
(define simulation-environment-system
(make-struct-field-accessor
simulation-environment-field-ref 15 'system))
(define set-simulation-environment-system!
(make-struct-field-mutator
set-simulation-environment-field! 15 'system))
(define simulation-environment-step-size
(make-struct-field-accessor
simulation-environment-field-ref 16 'step-size))
(define set-simulation-environment-step-size!
(make-struct-field-mutator
set-simulation-environment-field! 16 'step-size))
(define simulation-environment-dimension
(make-struct-field-accessor
simulation-environment-field-ref 17 'dimension))
(define set-simulation-environment-dimension!
(make-struct-field-mutator
set-simulation-environment-field! 17 'dimension))
(define simulation-environment-y
(make-struct-field-accessor
simulation-environment-field-ref 18 'y))
(define set-simulation-environment-y!
(make-struct-field-mutator
set-simulation-environment-field! 18 'y))
(define simulation-environment-dydt
(make-struct-field-accessor
simulation-environment-field-ref 19 'dydt))
(define set-simulation-environment-dydt!
(make-struct-field-mutator
set-simulation-environment-field! 19 'dydt))
(define simulation-environment-state-changed?
(make-struct-field-accessor
simulation-environment-field-ref 20 'state-changed?))
(define set-simulation-environment-state-changed?!
(make-struct-field-mutator
set-simulation-environment-field! 20 'state-changed?))
(define simulation-environment-max-step-size
(make-struct-field-accessor
simulation-environment-field-ref 21 'max-step-size))
(define set-simulation-environment-max-step-size!
(make-struct-field-mutator
set-simulation-environment-field! 21 'max-step-size))
(define make-simulation-environment
(case-lambda
((parent)
(let ((simulation-environment
(simulation-environment-constructor
#f 0.0 (make-event-list) (make-event-list) #f #f #f #f parent '() (make-event-list) #f (control-y-new 1.0e-6 0.0) rkf45-ode-type #f #f 1.0e-6 0 #f #f #t +inf.0))) (if parent
(begin
(set-simulation-environment-children!
parent
(cons simulation-environment
(simulation-environment-children parent)))
(set-simulation-environment-running?!
simulation-environment
(simulation-environment-running? parent))
(set-simulation-environment-time!
simulation-environment
(simulation-environment-time parent))))
simulation-environment))
(()
(make-simulation-environment #f))))
(define default-simulation-environment
(make-simulation-environment))
(define current-simulation-environment
(make-parameter default-simulation-environment
(lambda (x)
(if (not (simulation-environment? x))
(raise-type-error 'current-simulation-environment
"simulation-environment" x))
x)))
(define current-simulation-running?
(case-lambda
(()
(simulation-environment-running?
(current-simulation-environment)))
((running?)
(set-simulation-environment-running?!
(current-simulation-environment) running?))))
(define current-simulation-time
(case-lambda
(()
(simulation-environment-time
(current-simulation-environment)))
((time)
(set-simulation-environment-time!
(current-simulation-environment) time))))
(define current-simulation-now-event-list
(case-lambda
(()
(simulation-environment-now-event-list
(current-simulation-environment)))
((now-event-list)
(set-simulation-environment-now-event-list!
(current-simulation-environment) now-event-list))))
(define current-simulation-future-event-list
(case-lambda
(()
(simulation-environment-future-event-list
(current-simulation-environment)))
((future-event-list)
(set-simulation-environment-future-event-list!
(current-simulation-environment) future-event-list))))
(define current-simulation-loop-next
(case-lambda
(()
(simulation-environment-loop-next
(current-simulation-environment)))
((loop-next)
(set-simulation-environment-loop-next!
(current-simulation-environment) loop-next))))
(define current-simulation-loop-exit
(case-lambda
(()
(simulation-environment-loop-exit
(current-simulation-environment)))
((loop-exit)
(set-simulation-environment-loop-exit!
(current-simulation-environment) loop-exit))))
(define current-simulation-event
(case-lambda
(()
(simulation-environment-event
(current-simulation-environment)))
((event)
(set-simulation-environment-event!
(current-simulation-environment) event))))
(define current-simulation-process
(case-lambda
(()
(simulation-environment-process
(current-simulation-environment)))
((process)
(set-simulation-environment-process!
(current-simulation-environment) process))))
(define current-simulation-parent
(case-lambda
(()
(simulation-environment-parent
(current-simulation-environment)))
((parent)
(set-simulation-environment-parent!
(current-simulation-environment) parent))))
(define current-simulation-children
(case-lambda
(()
(simulation-environment-children
(current-simulation-environment)))
((children)
(set-simulation-environment-children!
(current-simulation-environment) children))))
(define current-simulation-continuous-event-list
(case-lambda
(()
(simulation-environment-continuous-event-list
(current-simulation-environment)))
((variables)
(set-simulation-environment-continuous-event-list!
(current-simulation-environment) variables))))
(define current-simulation-evolve
(case-lambda
(()
(simulation-environment-evolve
(current-simulation-environment)))
((evolve)
(set-simulation-environment-evolve!
(current-simulation-environment) evolve))))
(define current-simulation-control
(case-lambda
(()
(simulation-environment-control
(current-simulation-environment)))
((control)
(set-simulation-environment-control!
(current-simulation-environment) control))))
(define current-simulation-step-type
(case-lambda
(()
(simulation-environment-step-type
(current-simulation-environment)))
((step-type)
(set-simulation-environment-step-type!
(current-simulation-environment) step-type))))
(define current-simulation-step
(case-lambda
(()
(simulation-environment-step
(current-simulation-environment)))
((step)
(set-simulation-environment-step!
(current-simulation-environment) step))))
(define current-simulation-system
(case-lambda
(()
(simulation-environment-system
(current-simulation-environment)))
((system)
(set-simulation-environment-system!
(current-simulation-environment) system))))
(define current-simulation-step-size
(case-lambda
(()
(simulation-environment-step-size
(current-simulation-environment)))
((step-size)
(set-simulation-environment-step-size!
(current-simulation-environment) step-size))))
(define current-simulation-dimension
(case-lambda
(()
(simulation-environment-dimension
(current-simulation-environment)))
((dimension)
(set-simulation-environment-dimension!
(current-simulation-environment) dimension))))
(define current-simulation-y
(case-lambda
(()
(simulation-environment-y
(current-simulation-environment)))
((y)
(set-simulation-environment-y!
(current-simulation-environment) y))))
(define current-simulation-dydt
(case-lambda
(()
(simulation-environment-dydt
(current-simulation-environment)))
((dydt)
(set-simulation-environment-dydt!
(current-simulation-environment) dydt))))
(define current-simulation-state-changed?
(case-lambda
(()
(simulation-environment-state-changed?
(current-simulation-environment)))
((state-changed?)
(set-simulation-environment-state-changed?!
(current-simulation-environment) state-changed?))))
(define current-simulation-max-step-size
(case-lambda
(()
(simulation-environment-max-step-size
(current-simulation-environment)))
((max-step-size)
(set-simulation-environment-max-step-size!
(current-simulation-environment) max-step-size))))
(define-syntax with-simulation-environment
(syntax-rules ()
((with-simulation-environment simulation-environment
body ...)
(parameterize ((current-simulation-environment
simulation-environment))
body ...))))
(define-syntax with-new-simulation-environment
(syntax-rules ()
((with-new-simulation-environment
body ...)
(parameterize ((current-simulation-environment
(make-simulation-environment)))
body ...))))