[ANN] SystemsOfSystems.jl, a simulation engine

Hi all. I’d like to announce a new package for simulating models that contain models that contain models, etc., where the models can have both continuous and discrete parts. I needed a system like this to work with modular components of control systems, and it has been working well for the teams I work with, so I hope it can be useful to the broader community.

As a teaser, here is an extremely simple, one-model simulation:

using SystemsOfSystems

constants = (;
    mass = 1.,
    kp = 8., # Proportional gain for the controller
    kd = 4., # Derivative gain for the controller
)

history = simulate(
    constants; # Any arbitrary thing we want to pass to init_fcn
    t = (0, 5), # Any collection of times from start to end
    init_fcn = (t, constants, seed) -> ModelDescription(;
        constants = constants, # We'll keep our mass and gains as constants.
        continuous_states = (; # We'll add fields for position and velocity.
            position = 0.,
            velocity = 0.,
        ),
        discrete_states = (; # We'll add a field for the actuation force.
            actuation = 0.,
        ),
        schedules = (;
            control_schedule = RegularSchedule(0.1), # Triggers at 10Hz
        ),
    ),
    rates_fcn = (t, model) -> RatesOutput(;
        rates = (; # The derivative of each continuous state
            position = model.velocity,
            velocity = model.actuation / model.mass
        ),
    ),
    updates_fcn = (t, model) -> on_triggering(model.control_schedule, t) do
        UpdatesOutput(;
            updates = (; # How each discrete state updates this sample
                actuation = model.kp * (1 - model.position) - model.kd * model.velocity,
            ),
        )
    end,
)

And now, history["/"]["position"] contains the time series of the position variable of the root model. We could plot it, etc.

Here is the GitHub page with a bit more on the above simple example.

Here is the documentation. The control system example is essentially a walkthrough.

This is not as amazingly full-featured as DifferentialEquations nor as broad in its ambition as ModelingToolkit, but for the work I do, this lives at the sweet spot of features I need, flexibility, expressiveness, simplicity, and speed. If you’re looking for hybrid continuous and discrete simulation of systems of systems, it might be worth a try.

2 Likes