DynamicGridsInteract.jl
DynamicGridsInteract.DynamicGridsInteract
— ModuleDynamicGridsInteract
DynamicGridsInteract provides web interfaces for visualising and interacting with simulations from DynamicGrids.jl, and for packages that build on it like Dispersal.jl.
The basic InteractOutput
works in the atom plot pane and Jupyter notebooks, and also serves as the core component of other outputs. A Mux.jl web server ServerOutput
and a Blink.jl electron app ElectronOutput
are also included.
To use:
using DynamicGrids, DynamicGridsInteract
output = InteractOutput(init;
ruleset=ruleset,
tspan=1:100,
store=false,
processor=ColorProcessor()
)
display(output)
Where init
is the initial array(s) for the simulation and ruleset is the Ruleset
to run in simulations.
To show the interface in the Atom plot pane, run display(output)
.
Interact
The interface provides control of the simulation using Interact.jl. It will automatically generate sliders for the parameters of the Ruleset
, even for user-defined rules.
To define range limits for sliders, use the @bounds
macro from FieldMetadata.jl on your struct
. Fields to be ignored can be marked with false
using the @flatten
macro, and descriptions for hover text use @description
.
DynamicGridsInteract.AbstractInteractOutput
— TypeAbstract supertype of Interact outputs including InteractOuput
and ElectronOutput
DynamicGridsInteract.ElectronOutput
— TypeElectronOutput(init, ruleset::Ruleset; kwargs...)
A html output using Interact.jl and an Electron window through Blink.jl ElectronOutput automatically generates sliders to control simulations in realtime. args and kwargs are passed to InteractOutput
.
Example
using Blink
ElectronOutput(init, ruleset; tspan=(1, 100))
Arguments
init
: initialisation array, orNamedTuple
of arraysruleset::Ruleset
: A DynamicGridsRuleset
Keyword arguments are passed to InteractOutput
.
DynamicGridsInteract.InteractOutput
— TypeInteractOutput(init; ruleset, fps=25.0, store=false,
processor=ColorProcessor(), minval=nothing, maxval=nothing,
extrainit=Dict())
An Output
for Atom/Juno and Jupyter notebooks, and the back-end for ElectronOutput
and ServerOutput
.
Arguments:
init
: initialisation Array or NamedTuple of arrays.
Keyword Arguments:
ruleset
: the ruleset to run in the interface simulations.tspan
:AbstractRange
timespan for the simulationfps::Real
: frames per second to display the simulationstore::Bool
: whether ot store the simulation frames for later use- `processor::GridProcessor
minval::Number
: minimum value to display in the simulationmaxval::Number
: maximum value to display in the simulation
DynamicGridsInteract.ServerOutput
— TypeServerOutput(frames, rulset, args...; port=8080, kwargs...)
A basic Mux.jl webserver, serving a InteractOutput
s to the web.
Unlike ElectronOutput, the parameter modifications are not written back to the original rulset, and the simulations are not stored. Each page load gets a identical initialised rulset.
Arguments
init
:AbstractArray
orNamedTuple
ofArray
ruleset::Models
: tuple of rulset wrapped in Models().
Keyword arguments
port
: port number to reach the server. ie localhost:8080kwargs
: keyword arguments to be passed toInteractOuput
.