-
-
Notifications
You must be signed in to change notification settings - Fork 6
DEIM #19
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
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. |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@xtalax this is an interface break.
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Yes, definitely in Symbolics. There's a function called linear_expansion
.
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.
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)
0
However, 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Open an issue on Symbolics.jl about potentially changing linear_expansion
to what's needed/used here.
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.
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