Skip to content

New opening tutorial #874

@ChrisRackauckas

Description

@ChrisRackauckas

We want a longer opening tutorial that progresses like:

  • Defines and solves a simple ODE
  • Adds some output observables?
  • Adds some connections?

I kind of think @pbouffard's example is something nice to show off:

using ModelingToolkit, OrdinaryDiffEq

@parameters t a
@variables x(t) f(t)
D = Differential(t)

function decay(;name)
  eqs = [
    D(x) ~ -a*x + f
  ]
  ODESystem(eqs, name=name)
end

@named decay1 = decay()
@named decay2 = decay()

@named connected = ODESystem([
  decay2.f ~ decay1.x
  D(decay1.f) ~ 0
], t, systems=[decay1, decay2])

reduced_system = structural_simplify(connected)

x0 = [
  decay1.x => 1.0
  decay1.f => 0.0
  decay2.x => 1.0
]
p = [
  decay1.a => 0.1
  decay2.a => 0.2
]

prob = ODEProblem(reduced_system, x0, (0.0, 20.0), p)
sol = solve(prob, Tsit5())

as something that is useful to show too, since forcing functions and using another system to complete a system is a standard practice that should be demonstrated.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions