|
1 | 1 | # ModelOrderReduction.jl
|
2 | 2 |
|
3 | 3 | [](https://github.com/SciML/ModelOrderReduction.jl/actions/workflows/CI.yml)
|
4 |
| -[](https://codecov.io/gh/SciML/ModelOrderReduction.jl) |
5 |
| -[](https://github.com/SciML/SciMLStyle) |
| 4 | +[](https://app.codecov.io/gh/SciML/ModelOrderReduction.jl/tree/main) |
| 5 | +[](https://github.com/SciML/SciMLStyle) |
| 6 | + |
| 7 | +ModelOrderReduction.jl is a package for automatically reducing the computational complexity |
| 8 | +of mathematical models, while keeping expected fidelity within a controlled error bound. |
| 9 | +These methods function a submodel with a projection |
| 10 | +where solving the smaller model gives approximation information about the full model. |
| 11 | +MOR.jl uses [ModelingToolkit.jl](https://github.com/SciML/ModelingToolkit.jl) |
| 12 | +as a system description and automatically transforms equations |
| 13 | +to the subform, defining the observables to automatically lazily reconstruct the full |
| 14 | +model on-demand in a fast and stable form. |
| 15 | + |
| 16 | +## Example |
| 17 | +#### Proper Orthogonal Decomposition and Discrete Empirical Interpolation Method (POD-DEIM) on the FitzHugh-Nagumo system |
| 18 | +```julia |
| 19 | +using ModelingToolkit, MethodOfLines, DifferentialEquations, ModelOrderReduction |
| 20 | + |
| 21 | +# firstly construct a ModelingToolkit.PDESystem for the FitzHugh-Nagumo model |
| 22 | +@variables x t v(..) w(..) |
| 23 | +Dx = Differential(x) |
| 24 | +Dxx = Dx^2 |
| 25 | +Dt = Differential(t) |
| 26 | +const L = 1.0 |
| 27 | +const ε = 0.015 |
| 28 | +const b = 0.5 |
| 29 | +const γ = 2.0 |
| 30 | +const c = 0.05 |
| 31 | +f(v) = v * (v - 0.1) * (1.0 - v) |
| 32 | +i₀(t) = 50000.0t^3 * exp(-15.0t) |
| 33 | +eqs = [ε * Dt(v(x, t)) ~ ε^2 * Dxx(v(x, t)) + f(v(x, t)) - w(x, t) + c, |
| 34 | + Dt(w(x, t)) ~ b * v(x, t) - γ * w(x, t) + c] |
| 35 | +bcs = [v(x, 0.0) ~ 0.0, w(x, 0) ~ 0.0, Dx(v(0, t)) ~ -i₀(t), Dx(v(L, t)) ~ 0.0] |
| 36 | +domains = [x ∈ (0.0, L), t ∈ (0.0, 14.0)] |
| 37 | +ivs = [x, t] |
| 38 | +dvs = [v(x, t), w(x, t)] |
| 39 | +pde_sys = PDESystem(eqs, bcs, domains, ivs, dvs; name = Symbol("FitzHugh-Nagumo")) |
| 40 | + |
| 41 | +# transfer to a ModelingToolkit.ODESystem by automated discretization via MethodOfLines |
| 42 | +N = 15 # equidistant discretization intervals |
| 43 | +dx = (L - 0.0) / N |
| 44 | +dxs = [x => dx] |
| 45 | +discretization = MOLFiniteDifference(dxs, t) |
| 46 | +ode_sys, tspan = symbolic_discretize(pde_sys, discretization) |
| 47 | +simp_sys = structural_simplify(ode_sys) |
| 48 | +ode_prob = ODEProblem(simp_sys, nothing, tspan) |
| 49 | + |
| 50 | +# solve the full-order model to get snapshots |
| 51 | +sol = solve(ode_prob, Tsit5()) |
| 52 | +snapshot_simpsys = Array(sol.original_sol) |
| 53 | + |
| 54 | +# set POD and DEIM dimensions |
| 55 | +# apply POD-DEIM to obtain the reduced-order model |
| 56 | +pod_dim = deim_dim = 5 |
| 57 | +deim_sys = deim(simp_sys, snapshot_simpsys, pod_dim; deim_dim = deim_dim) |
| 58 | +deim_prob = ODEProblem(deim_sys, nothing, tspan) |
| 59 | +deim_sol = solve(deim_prob, Tsit5()) |
| 60 | + |
| 61 | +# retrieve the approximate solution of the original full-order model |
| 62 | +sol_deim_x = deim_sol[x] |
| 63 | +sol_deim_v = deim_sol[v(x, t)] |
| 64 | +sol_deim_w = deim_sol[w(x, t)] |
| 65 | +``` |
| 66 | + |
| 67 | +The following figure shows the comparison of the solutions of the 32-dimension full-order model and the POD5-DEIM5 reduced-order model. |
| 68 | + |
| 69 | + |
0 commit comments