diff --git a/docs/Project.toml b/docs/Project.toml index 0ad1c10e9b..1838bfb8e4 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -58,7 +58,7 @@ Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d" Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f" [compat] -AdvancedHMC = "0.6, 0.7" +AdvancedHMC = "0.8" BenchmarkTools = "1" CSV = "0.10" CUDA = "5" @@ -70,24 +70,24 @@ DiffEqGPU = "3" DifferentialEquations = "7" Distributions = "0.25" Documenter = "1" -DomainSets = "0.6, 0.7" -Flux = "0.13, 0.14, 0.15, 0.16" +DomainSets = "0.7" +Flux = "0.16" ForwardDiff = "0.10, 1" IncompleteLU = "0.2" Integrals = "4" LineSearches = "7" -LinearSolve = "2, 3" +LinearSolve = "3" Lux = "1" LuxCUDA = "0.3" LuxCore = "1" -MCMCChains = "6" +MCMCChains = "7" Measurements = "2" MethodOfLines = "0.11" -ModelingToolkit = "9.9" -ModelingToolkitNeuralNets = "1" -MultiDocumenter = "0.7, 0.8" +ModelingToolkit = "10" +ModelingToolkitNeuralNets = "2" +MultiDocumenter = "0.8" NeuralPDE = "5.15" -NonlinearSolve = "3, 4" +NonlinearSolve = "4" Optimization = "4" OptimizationBBO = "0.4" OptimizationMOI = "0.5" @@ -109,4 +109,4 @@ SymbolicIndexingInterface = "0.3" SymbolicRegression = "1" Symbolics = "6" Unitful = "1" -Zygote = "0.6, 0.7" +Zygote = "0.7" diff --git a/docs/src/getting_started/find_root.md b/docs/src/getting_started/find_root.md index 606035f06d..61ef28a0da 100644 --- a/docs/src/getting_started/find_root.md +++ b/docs/src/getting_started/find_root.md @@ -40,7 +40,7 @@ With the parameter values ``\sigma = 10.0``, ``\rho = 26.0``, ``\beta = 8/3``. # Import the packages import ModelingToolkit as MTK import NonlinearSolve as NLS -import ModelingToolkit: @variables, @parameters, @mtkbuild +import ModelingToolkit: @variables, @parameters, @mtkcompile, mtkcompile # Define the nonlinear system @variables x=1.0 y=0.0 z=0.0 @@ -49,7 +49,7 @@ import ModelingToolkit: @variables, @parameters, @mtkbuild eqs = [0 ~ σ * (y - x), 0 ~ x * (ρ - z) - y, 0 ~ x * y - β * z] -@mtkbuild ns = MTK.NonlinearSystem(eqs, [x, y, z], [σ, ρ, β]) +@mtkcompile ns = MTK.NonlinearSystem(eqs, [x, y, z], [σ, ρ, β]) # Convert the symbolic system into a numerical system prob = NLS.NonlinearProblem(ns, []) @@ -83,7 +83,7 @@ Now we're ready. Let's load in these packages: # Import the packages import ModelingToolkit as MTK import NonlinearSolve as NLS -import ModelingToolkit: @variables, @parameters, @mtkbuild +import ModelingToolkit: @variables, @parameters, @mtkcompile, mtkcompile ``` ### Step 2: Define the Nonlinear System @@ -126,7 +126,7 @@ Finally, we bring these pieces together, the equation along with its states and define our `NonlinearSystem`: ```@example first_rootfind -@mtkbuild ns = MTK.NonlinearSystem(eqs, [x, y, z], [σ, ρ, β]) +@mtkcompile ns = MTK.NonlinearSystem(eqs, [x, y, z], [σ, ρ, β]) ``` ### Step 3: Convert the Symbolic Problem to a Numerical Problem diff --git a/docs/src/getting_started/first_simulation.md b/docs/src/getting_started/first_simulation.md index 9cd0f77be6..0f6be19edf 100644 --- a/docs/src/getting_started/first_simulation.md +++ b/docs/src/getting_started/first_simulation.md @@ -53,7 +53,7 @@ import DifferentialEquations as DE import ModelingToolkit as MTK import Plots import ModelingToolkit: t_nounits as t, D_nounits as D, - @variables, @parameters, @named, @mtkbuild + @variables, @parameters, @named, @mtkcompile, mtkcompile # Define our state variables: state(t) = initial condition @variables x(t)=1 y(t)=1 z(t) @@ -67,7 +67,7 @@ eqs = [D(x) ~ α * x - β * x * y z ~ x + y] # Bring these pieces together into an ODESystem with independent variable t -@mtkbuild sys = MTK.ODESystem(eqs, t) +@mtkcompile sys = MTK.ODESystem(eqs, t) # Convert from a symbolic to a numerical problem to simulate tspan = (0.0, 10.0) @@ -106,7 +106,7 @@ Now we're ready. Let's load in these packages: import DifferentialEquations as DE import ModelingToolkit as MTK import Plots -import ModelingToolkit: t_nounits as t, D_nounits as D, @variables, @parameters, @named, @mtkbuild +import ModelingToolkit: t_nounits as t, D_nounits as D, @variables, @parameters, @named, @mtkcompile, mtkcompile ``` ### Step 2: Define our ODE Equations @@ -170,7 +170,7 @@ to represent an `ODESystem` with the following: ```@example first_sim # Bring these pieces together into an ODESystem with independent variable t -@mtkbuild sys = MTK.ODESystem(eqs, t) +@mtkcompile sys = MTK.ODESystem(eqs, t) ``` Notice that in our equations we have an algebraic equation `z ~ x + y`. This is not a @@ -274,7 +274,7 @@ D = MTK.Differential(t) eqs = [D(🐰) ~ α * 🐰 - β * 🐰 * 🐺, D(🐺) ~ -γ * 🐺 + δ * 🐰 * 🐺] -@mtkbuild sys = MTK.ODESystem(eqs, t) +@mtkcompile sys = MTK.ODESystem(eqs, t) prob = DE.ODEProblem(sys, [], (0.0, 10.0)) sol = DE.solve(prob) ``` diff --git a/docs/src/showcase/bayesian_neural_ode.md b/docs/src/showcase/bayesian_neural_ode.md index 0f5661efdb..590441d486 100644 --- a/docs/src/showcase/bayesian_neural_ode.md +++ b/docs/src/showcase/bayesian_neural_ode.md @@ -119,10 +119,10 @@ We use the NUTS sampler with an acceptance ratio of δ= 0.45 in this example. In We sample using 500 warmup samples and 500 posterior samples. ```@example bnode -integrator = AdvancedHMC.Leapfrog(AdvancedHMC.find_good_stepsize(h, p)) +integrator = AdvancedHMC.Leapfrog(AdvancedHMC.find_good_stepsize(h, Array(p))) kernel = AdvancedHMC.HMCKernel(AdvancedHMC.Trajectory{AdvancedHMC.MultinomialTS}(integrator, AdvancedHMC.GeneralisedNoUTurn())) adaptor = AdvancedHMC.StanHMCAdaptor(AdvancedHMC.MassMatrixAdaptor(metric), AdvancedHMC.StepSizeAdaptor(0.45, integrator)) -samples, stats = AdvancedHMC.sample(h, kernel, p, 500, adaptor, 500; progress = true) +samples, stats = AdvancedHMC.sample(h, kernel, Array(p), 500, adaptor, 500; progress = true) ``` ## Step 5: Plot diagnostics diff --git a/docs/src/showcase/brusselator.md b/docs/src/showcase/brusselator.md index edae2c2bad..b4eb43de33 100644 --- a/docs/src/showcase/brusselator.md +++ b/docs/src/showcase/brusselator.md @@ -73,7 +73,7 @@ import MethodOfLines import OrdinaryDiffEq as ODE import LinearSolve as LS import DomainSets -using ModelingToolkit: @parameters, @variables, Differential, Interval, PDESystem +using ModelingToolkit: @named, @parameters, @variables, Differential, Interval, PDESystem @parameters x y t @variables u(..) v(..) diff --git a/docs/src/showcase/optimal_data_gathering_for_missing_physics.md b/docs/src/showcase/optimal_data_gathering_for_missing_physics.md index f6d0c3355a..c363ad5b7e 100644 --- a/docs/src/showcase/optimal_data_gathering_for_missing_physics.md +++ b/docs/src/showcase/optimal_data_gathering_for_missing_physics.md @@ -11,7 +11,7 @@ To this end, we will rely on the following packages: using Random; Random.seed!(984519674645) using StableRNGs; rng = StableRNG(845652695) import ModelingToolkit as MTK -import ModelingToolkit: t_nounits as t, D_nounits as D +import ModelingToolkit: t_nounits as t, D_nounits as D, @mtkcompile, mtkcompile import ModelingToolkitNeuralNets import OrdinaryDiffEqRosenbrock as ODE import SymbolicIndexingInterface @@ -145,11 +145,11 @@ We also add some noise to the simulated data, to make it more realistic: ```@example DoE optimization_state = zeros(15) optimization_initial = optimization_state[1] # HACK CAN'T GET THIS TO WORK WITHOUT SEPARATE SCALAR -@mtkbuild true_bioreactor = TrueBioreactor() +@mtkcompile true_bioreactor = TrueBioreactor() prob = ODE.ODEProblem(true_bioreactor, [], (0.0, 15.0), [], tstops = 0:15, save_everystep=false) sol = ODE.solve(prob, ODE.Rodas5P()) -@mtkbuild ude_bioreactor = UDEBioreactor() +@mtkcompile ude_bioreactor = UDEBioreactor() ude_prob = ODE.ODEProblem(ude_bioreactor, [], (0.0, 15.0), [], tstops = 0:15, save_everystep=false) ude_sol = ODE.solve(ude_prob, ODE.Rodas5P()) @@ -283,7 +283,7 @@ function get_probs_and_caches(model_structures) μ ~ model_structures[i](C_s) end end - @mtkbuild plausible_bioreactor = PlausibleBioreactor() + @mtkcompile plausible_bioreactor = PlausibleBioreactor() plausible_prob = ODE.ODEProblem(plausible_bioreactor, [], (0.0, 15.0), [], tstops=0:15, saveat=0:15) probs_plausible[i] = plausible_prob @@ -401,10 +401,10 @@ This causes the two aforementioned groups in the model structures to be easily d We now gather a second dataset and perform the same exercise. ```@example DoE -@mtkbuild true_bioreactor2 = TrueBioreactor() +@mtkcompile true_bioreactor2 = TrueBioreactor() prob2 = ODE.ODEProblem(true_bioreactor2, [], (0.0, 15.0), [], tstops=0:15, save_everystep=false) sol2 = ODE.solve(prob2, ODE.Rodas5P()) -@mtkbuild ude_bioreactor2 = UDEBioreactor() +@mtkcompile ude_bioreactor2 = UDEBioreactor() ude_prob2 = ODE.ODEProblem(ude_bioreactor2, [], (0.0, 15.0), [ude_bioreactor2.Q_in => optimization_initial], tstops=0:15, save_everystep=false) ude_sol2 = ODE.solve(ude_prob2, ODE.Rodas5P()) plot(ude_sol2[3,:]) @@ -516,10 +516,10 @@ After the staircase reaches the maximal control value, a zero control is used. Some model structures decrease more rapidly in substrate concentration than others. ```@example DoE -@mtkbuild true_bioreactor3 = TrueBioreactor() +@mtkcompile true_bioreactor3 = TrueBioreactor() prob3 = ODE.ODEProblem(true_bioreactor3, [], (0.0, 15.0), [], tstops=0:15, save_everystep=false) sol3 = ODE.solve(prob3, ODE.Rodas5P()) -@mtkbuild ude_bioreactor3 = UDEBioreactor() +@mtkcompile ude_bioreactor3 = UDEBioreactor() ude_prob3 = ODE.ODEProblem(ude_bioreactor3, [], (0.0, 15.0), tstops=0:15, save_everystep=false) x0 = reduce(vcat, getindex.((default_values(ude_bioreactor3),), tunable_parameters(ude_bioreactor3)))