-
-
Notifications
You must be signed in to change notification settings - Fork 6
Add package intro and an example in README #32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,69 @@ | ||
| # ModelOrderReduction.jl | ||
|
|
||
| [](https://github.com/SciML/ModelOrderReduction.jl/actions/workflows/CI.yml) | ||
| [](https://codecov.io/gh/SciML/ModelOrderReduction.jl) | ||
| [](https://github.com/SciML/SciMLStyle) | ||
| [](https://app.codecov.io/gh/SciML/ModelOrderReduction.jl/tree/main) | ||
| [](https://github.com/SciML/SciMLStyle) | ||
|
|
||
| ModelOrderReduction.jl is a package for automatically reducing the computational complexity | ||
| of mathematical models, while keeping expected fidelity within a controlled error bound. | ||
| These methods function a submodel with a projection | ||
| where solving the smaller model gives approximation information about the full model. | ||
| MOR.jl uses [ModelingToolkit.jl](https://github.com/SciML/ModelingToolkit.jl) | ||
| as a system description and automatically transforms equations | ||
| to the subform, defining the observables to automatically lazily reconstruct the full | ||
| model on-demand in a fast and stable form. | ||
|
|
||
| ## Example | ||
| #### Proper Orthogonal Decomposition and Discrete Empirical Interpolation Method (POD-DEIM) on the FitzHugh-Nagumo system | ||
| ```julia | ||
| using ModelingToolkit, MethodOfLines, DifferentialEquations, ModelOrderReduction | ||
|
|
||
| # firstly construct a ModelingToolkit.PDESystem for the FitzHugh-Nagumo model | ||
| @variables x t v(..) w(..) | ||
| Dx = Differential(x) | ||
| Dxx = Dx^2 | ||
| Dt = Differential(t) | ||
| const L = 1.0 | ||
| const ε = 0.015 | ||
| const b = 0.5 | ||
| const γ = 2.0 | ||
| const c = 0.05 | ||
| f(v) = v * (v - 0.1) * (1.0 - v) | ||
| i₀(t) = 50000.0t^3 * exp(-15.0t) | ||
| eqs = [ε * Dt(v(x, t)) ~ ε^2 * Dxx(v(x, t)) + f(v(x, t)) - w(x, t) + c, | ||
| Dt(w(x, t)) ~ b * v(x, t) - γ * w(x, t) + c] | ||
| bcs = [v(x, 0.0) ~ 0.0, w(x, 0) ~ 0.0, Dx(v(0, t)) ~ -i₀(t), Dx(v(L, t)) ~ 0.0] | ||
| domains = [x ∈ (0.0, L), t ∈ (0.0, 14.0)] | ||
| ivs = [x, t] | ||
| dvs = [v(x, t), w(x, t)] | ||
| pde_sys = PDESystem(eqs, bcs, domains, ivs, dvs; name = Symbol("FitzHugh-Nagumo")) | ||
|
|
||
| # transfer to a ModelingToolkit.ODESystem by automated discretization via MethodOfLines | ||
| N = 15 # equidistant discretization intervals | ||
| dx = (L - 0.0) / N | ||
| dxs = [x => dx] | ||
| discretization = MOLFiniteDifference(dxs, t) | ||
| ode_sys, tspan = symbolic_discretize(pde_sys, discretization) | ||
| simp_sys = structural_simplify(ode_sys) | ||
| ode_prob = ODEProblem(simp_sys, nothing, tspan) | ||
|
|
||
| # solve the full-order model to get snapshots | ||
| sol = solve(ode_prob, Tsit5()) | ||
| snapshot_simpsys = Array(sol.original_sol) | ||
|
|
||
| # set POD and DEIM dimensions | ||
| # apply POD-DEIM to obtain the reduced-order model | ||
| pod_dim = deim_dim = 5 | ||
| deim_sys = deim(simp_sys, snapshot_simpsys, pod_dim; deim_dim = deim_dim) | ||
| deim_prob = ODEProblem(deim_sys, nothing, tspan) | ||
| deim_sol = solve(deim_prob, Tsit5()) | ||
|
|
||
| # retrieve the approximate solution of the original full-order model | ||
| sol_deim_x = deim_sol[x] | ||
| sol_deim_v = deim_sol[v(x, t)] | ||
| sol_deim_w = deim_sol[w(x, t)] | ||
| ``` | ||
|
|
||
| The following figure shows the comparison of the solutions of the 32-dimension full-order model and the POD5-DEIM5 reduced-order model. | ||
|
|
||
|  | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Drop a plot into one of the issues and then use its link to end this with a nice plot.