Repository navigation
DEIM - #19
DEIM#19
Conversation
Codecov Report
@@ Coverage Diff @@
## main #19 +/- ##
===========================================
+ Coverage 81.94% 92.96% +11.02%
===========================================
Files 3 5 +2
Lines 72 199 +127
===========================================
+ Hits 59 185 +126
- Misses 13 14 +1
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
|
Very nice, I like it a lot. We should soon talk a little bit about how to expose these functionalities to a user and create an overarching interface that supports common workflows but also can accommodate generic reduction techniques. |
|
@ChrisRackauckas @FHoltorf This PR is ready. |
FHoltorf
left a comment
There was a problem hiding this comment.
No further comments. Looks great!
| dxs = [x => dx] | ||
| order = 2 | ||
| discretization = MOLFiniteDifference(dxs, t; approx_order = order) | ||
| ode_sys, tspan = symbolic_discretize(pde_sys, discretization) |
There was a problem hiding this comment.
Note that this might break in a future version, hopefully soon. Not your fault though @bowenszhu , we should make an issue to track it though.
There was a problem hiding this comment.
@YingboMa we should add (symbolic) time span to the system types so this can be supported better. It would also make modelingtoolkitize and reconstruction more automatic.
|
|
||
| Variables in `vars` must be unique. | ||
| """ | ||
| function linear_terms(exprs::AbstractVector, vars) |
There was a problem hiding this comment.
Yes, definitely in Symbolics. There's a function called linear_expansion.
There was a problem hiding this comment.
This function extracts 1. coefficients of linear terms, 2. constant terms and 3. remaining nonlinear terms to facilitate the DEIM algorithm, which is different from Symbolics.linear_expansion.
For example,
using Symbolics, ModelOrderReduction
@variables x y
exprs = [2x - 4y + 5 + (x + 1)^3 + sin(x)
8x + 7]
l, c, n = ModelOrderReduction.linear_terms(exprs, [x, y])gives
julia> l
2×2 SparseArrays.SparseMatrixCSC{Float64, Int64} with 3 stored entries:
2.0 -4.0
8.0 ⋅
julia> c
2-element Vector{Num}:
5
7
julia> n
2-element Vector{Num}:
(1 + x)^3 + sin(x)
0However, Symbolics.linear_expansion doesn't return what is needed in DEIM:
using Symbolics
@variables x y
exprs = [2x - 4y + 5 + (x + 1)^3 + sin(x)
8x + 7]
Symbolics.linear_expansion(exprs, [x, y])result: (Num[#undef #undef; #undef #undef], Num[#undef, #undef], false)
There was a problem hiding this comment.
Open an issue on Symbolics.jl about potentially changing linear_expansion to what's needed/used here.
There was a problem hiding this comment.
|
Awesome work! I left a few comments for something to clean up before merging. Overall this looks really good though. |
|
I think I'm basically good here. Try |
|
🎉 |
resolve #12