```julia
using ModelingToolkit
using DifferentialEquations
using Plots
```

Let's try it out for the following system 
\begin{aligned}
    \dot{x} &= \sigma(x-y) \\ 
    \dot{y} &= x(\rho - z) - y  \\ 
    \dot{z} &= xy - \beta z
\end{aligned}


```julia
# set up variables/parameters
@variables t x(t) y(t) z(t) 
@parameters σ ρ β
D = Differential(t)


```




    (::Differential) (generic function with 2 methods)




```julia
@named lorenz = ODESystem([
    D(x) ~ σ*(y-x)
    D(y) ~ x*(ρ-z) - y 
    D(z) ~ x*y - β*z
])
```




\begin{align}
\frac{dx(t)}{dt} =& \sigma \left(  - x\left( t \right) + y\left( t \right) \right) \\
\frac{dy(t)}{dt} =&  - y\left( t \right) + \left( \rho - z\left( t \right) \right) x\left( t \right) \\
\frac{dz(t)}{dt} =& x\left( t \right) y\left( t \right) - \beta z\left( t \right)
\end{align}





```julia
prob = ODEProblem(
    structural_simplify(lorenz),
    [x=>1.0, y=>0.0, z=>0.0],
    (0.0,10.0),
    [σ => 10.0, ρ => 28.0, β => (8/3)],
    jac=true,
    sparse=true
)
```




    [36mODEProblem[0m with uType [36mVector{Float64}[0m and tType [36mFloat64[0m. In-place: [36mtrue[0m
    timespan: (0.0, 10.0)
    u0: 3-element Vector{Float64}:
     1.0
     0.0
     0.0




```julia
sol = solve(prob, jac=true, sparse=true)
```

    ┌ Warning: Warning: Unrecognized keyword arguments found. Future versions will error.
    │ The only allowed keyword arguments to `solve` are: 
    │ (:dense, :saveat, :save_idxs, :tstops, :d_discontinuities, :save_everystep, :save_on, :save_start, :save_end, :initialize_save, :adaptive, :abstol, :reltol, :dt, :dtmax, :dtmin, :force_dtmin, :internalnorm, :controller, :gamma, :beta1, :beta2, :qmax, :qmin, :qsteady_min, :qsteady_max, :qoldinit, :failfactor, :calck, :alias_u0, :maxiters, :callback, :isoutofdomain, :unstable_check, :verbose, :merge_callbacks, :progress, :progress_steps, :progress_name, :progress_message, :timeseries_errors, :dense_errors, :calculate_errors, :initializealg, :alg, :save_noise, :delta, :seed, :alg_hints, :kwargshandle, :trajectories, :batch_size, :sensealg, :advance_to_tstop, :stop_at_next_tstop)
    │ See https://diffeq.sciml.ai/stable/basics/common_solver_opts/ for more details.
    │ 
    │ Set kwargshandle=KeywordArgError for an error message and more details.
    │ Set kwargshandle=KeywordArgSilent to ignore this message.
    └ @ DiffEqBase /Users/jwaczak/.julia/packages/DiffEqBase/ziNGu/src/solve.jl:210





    retcode: Success
    Interpolation: specialized 4th order "free" interpolation, specialized 2nd order "free" stiffness-aware interpolation
    t: 104-element Vector{Float64}:
      0.0
      3.5678604836301404e-5
      0.0003924646531993154
      0.0032624087100077666
      0.009058076582749423
      0.016956470605311864
      0.027689959227781235
      0.04185635103821218
      0.060240410627700816
      0.0836854113984534
      0.11336499269451543
      0.14862181409827
      0.18703978025370946
      ⋮
      8.854893753966822
      8.965662134819611
      9.082539337396287
      9.181787148579398
      9.291289049504522
      9.389878163426545
      9.523325873771135
      9.626465957999306
      9.745734139492404
      9.839208473866107
      9.944480199643703
     10.0
    u: 104-element Vector{Vector{Float64}}:
     [1.0, 0.0, 0.0]
     [0.9996434557625105, 0.0009988049817849058, 1.781434788799189e-8]
     [0.9961045497425811, 0.010965399721242457, 2.1469553658389193e-6]
     [0.9693591550149778, 0.08977063252764937, 0.0001438019170127846]
     [0.924204355043198, 0.242289149116772, 0.0010461625397616113]
     [0.8800455796215916, 0.4387364900041282, 0.0034242599668253874]
     [0.8483309836977301, 0.6915629475762161, 0.008487624968655677]
     [0.8495036679850485, 1.0145426495980538, 0.018212090123888365]
     [0.9139069520070257, 1.4425599557988966, 0.03669382071284047]
     [1.0888638157267199, 2.0523265628455114, 0.07402573450924264]
     [1.4608626762755592, 3.020671976368475, 0.1600393550722158]
     [2.162723385463875, 4.6333636144497445, 0.3771173678677324]
     [3.3684642325435394, 7.267693727122864, 0.9363555414291386]
     ⋮
     [-6.9968578113892494, -8.631538424097723, 22.57196198224449]
     [-9.349101977343798, -11.618563410908104, 24.931236997749302]
     [-10.838065820890451, -10.548157021834754, 30.328493164265772]
     [-9.193938521582936, -6.611934055806503, 30.834764811501053]
     [-6.629016388347875, -4.985556722794793, 27.057897927863017]
     [-5.908799743077322, -6.08726579881099, 23.660819364085395]
     [-7.589659360414352, -9.768386562684622, 22.456309898947026]
     [-10.058660581140677, -12.222656629909856, 26.12768124980427]
     [-10.765377106558036, -9.405541368073447, 31.427518482454712]
     [-8.526541731383922, -5.663146666586879, 30.409866552495895]
     [-6.1435005430503065, -4.784021397971376, 26.201996560193862]
     [-5.695125623704, -5.433008824441513, 24.128635610927557]




```julia
plot(sol, vars=(x, y, z))
```




    

    




```julia

```

8635ae01a7e7ce4187df22b54bf5f2d8756650c5
ipynb
Jupyter Notebook
notebooks/Lorenz with MTK.ipynb
john-waczak/DataAssimilation.jl
2bb7cfe23405bc5d4cfb79da78e70da1e0b04ded
MIT
notebooks/Lorenz with MTK.ipynb
john-waczak/DataAssimilation.jl
2bb7cfe23405bc5d4cfb79da78e70da1e0b04ded
MIT
notebooks/Lorenz with MTK.ipynb
john-waczak/DataAssimilation.jl
2bb7cfe23405bc5d4cfb79da78e70da1e0b04ded
MIT
Qwen/Qwen-72B
1. YES
2. YES