(define-values (struct:simulation-environment
simulation-environment-constructor
simulation-environment?
simulation-environment-field-ref
set-simulation-environment-field!)
(make-struct-type 'simulation-environment #f 23 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 simulation-environment-monitor
(make-struct-field-accessor
simulation-environment-field-ref 22 'monitor))
(define set-simulation-environment-monitor!
(make-struct-field-mutator
set-simulation-environment-field! 22 'monitor))
(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 #f )))
(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-syntax current-simulation-running?
(syntax-rules ()
((current-simulation-running?)
(simulation-environment-running?
(current-simulation-environment)))
((current-simulation-running? running?)
(set-simulation-environment-running?!
(current-simulation-environment) running?))))
(define-syntax current-simulation-time
(syntax-rules ()
((current-simulation-time)
(simulation-environment-time
(current-simulation-environment)))
((current-simulation-time time)
(set-simulation-environment-time!
(current-simulation-environment) time))))
(define-syntax current-simulation-now-event-list
(syntax-rules ()
((current-simulation-now-event-list)
(simulation-environment-now-event-list
(current-simulation-environment)))
((current-simulation-now-event-list now-event-list)
(set-simulation-environment-now-event-list!
(current-simulation-environment) now-event-list))))
(define-syntax current-simulation-future-event-list
(syntax-rules ()
((current-simulation-future-event-list)
(simulation-environment-future-event-list
(current-simulation-environment)))
((current-simulation-future-event-list future-event-list)
(set-simulation-environment-future-event-list!
(current-simulation-environment) future-event-list))))
(define-syntax current-simulation-loop-next
(syntax-rules ()
((current-simulation-loop-next)
(simulation-environment-loop-next
(current-simulation-environment)))
((current-simulation-loop-next loop-next)
(set-simulation-environment-loop-next!
(current-simulation-environment) loop-next))))
(define-syntax current-simulation-loop-exit
(syntax-rules ()
((current-simulation-loop-exit)
(simulation-environment-loop-exit
(current-simulation-environment)))
((current-simulation-loop-exit loop-exit)
(set-simulation-environment-loop-exit!
(current-simulation-environment) loop-exit))))
(define-syntax current-simulation-event
(syntax-rules ()
((current-simulation-event)
(simulation-environment-event
(current-simulation-environment)))
((current-simulation-event event)
(set-simulation-environment-event!
(current-simulation-environment) event))))
(define-syntax current-simulation-process
(syntax-rules ()
((current-simulation-process)
(simulation-environment-process
(current-simulation-environment)))
((current-simulation-process process)
(set-simulation-environment-process!
(current-simulation-environment) process))))
(define-syntax current-simulation-parent
(syntax-rules ()
((current-simulation-parent)
(simulation-environment-parent
(current-simulation-environment)))
((current-simulation-parent parent)
(set-simulation-environment-parent!
(current-simulation-environment) parent))))
(define-syntax current-simulation-children
(syntax-rules ()
((current-simulation-children)
(simulation-environment-children
(current-simulation-environment)))
((current-simulation-children children)
(set-simulation-environment-children!
(current-simulation-environment) children))))
(define-syntax current-simulation-continuous-event-list
(syntax-rules ()
((current-simulation-continuous-event-list)
(simulation-environment-continuous-event-list
(current-simulation-environment)))
((current-simulation-continuous-event-list continuous-event-list)
(set-simulation-environment-continuous-event-list!
(current-simulation-environment) continuous-event-list))))
(define-syntax current-simulation-evolve
(syntax-rules ()
((current-simulation-evolve)
(simulation-environment-evolve
(current-simulation-environment)))
((current-simulation-evolve evolve)
(set-simulation-environment-evolve!
(current-simulation-environment) evolve))))
(define-syntax current-simulation-control
(syntax-rules ()
((current-simulation-control)
(simulation-environment-control
(current-simulation-environment)))
((current-simulation-control control)
(set-simulation-environment-control!
(current-simulation-environment) control))))
(define-syntax current-simulation-step-type
(syntax-rules ()
((current-simulation-step-type)
(simulation-environment-step-type
(current-simulation-environment)))
((current-simulation-step-type step-type)
(set-simulation-environment-step-type!
(current-simulation-environment) step-type))))
(define-syntax current-simulation-step
(syntax-rules ()
((current-simulation-step)
(simulation-environment-step
(current-simulation-environment)))
((current-simulation-step step)
(set-simulation-environment-step!
(current-simulation-environment) step))))
(define-syntax current-simulation-system
(syntax-rules ()
((current-simulation-system)
(simulation-environment-system
(current-simulation-environment)))
((current-simulation-system system)
(set-simulation-environment-system!
(current-simulation-environment) system))))
(define-syntax current-simulation-step-size
(syntax-rules ()
((current-simulation-step-size)
(simulation-environment-step-size
(current-simulation-environment)))
((current-simulation-step-size step-size)
(set-simulation-environment-step-size!
(current-simulation-environment) step-size))))
(define-syntax current-simulation-dimension
(syntax-rules ()
((current-simulation-dimension)
(simulation-environment-dimension
(current-simulation-environment)))
((current-simulation-dimension dimension)
(set-simulation-environment-dimension!
(current-simulation-environment) dimension))))
(define-syntax current-simulation-y
(syntax-rules ()
((current-simulation-y)
(simulation-environment-y
(current-simulation-environment)))
((current-simulation-y y)
(set-simulation-environment-y!
(current-simulation-environment) y))))
(define-syntax current-simulation-dydt
(syntax-rules ()
((current-simulation-dydt)
(simulation-environment-dydt
(current-simulation-environment)))
((current-simulation-dydt dydt)
(set-simulation-environment-dydt!
(current-simulation-environment) dydt))))
(define-syntax current-simulation-state-changed?
(syntax-rules ()
((current-simulation-state-changed?)
(simulation-environment-state-changed?
(current-simulation-environment)))
((current-simulation-state-changed? state-changed?)
(set-simulation-environment-state-changed?!
(current-simulation-environment) state-changed?))))
(define-syntax current-simulation-max-step-size
(syntax-rules ()
((current-simulation-max-step-size)
(simulation-environment-max-step-size
(current-simulation-environment)))
((current-simulation-max-step-size max-step-size)
(set-simulation-environment-max-step-size!
(current-simulation-environment) max-step-size))))
(define-syntax current-simulation-monitor
(syntax-rules ()
((current-simulation-monitor)
(simulation-environment-monitor
(current-simulation-environment)))
((current-simulation-monitor monitor)
(set-simulation-environment-monitor!
(current-simulation-environment) monitor))))
(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 ...))))