-
-
Notifications
You must be signed in to change notification settings - Fork 10
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
Propagate kwargs
through update_coefficients!
#125
Comments
that is easy to implement. @ChrisRackauckas thoughts on the design change? and do we have any updates on the sciml parameter interface? SciML/DifferentialEquations.jl#881 |
@ChrisRackauckas thoughts? |
Personally I'm in favor of something like this to easily support cases where the state isn't easily shoehorned into
The idea would be that if the user provides |
An easier alternative would be to not allow arbitrary This makes it easier to do the automatic handling than with (The fundamental problem is I don't think this extra info can be put into either u, p, or t, because all three have a pre-fixed meaning based on the problem definition.) |
Just remembered - this won't be necessary. For the |
"simple update rule for gamma" -- can you elaborate? Do you mean you'll manually update it, separately from running update coefficients? The issue I see is that if you run update_coefficients on the WOperator, and it'll recurse onto the ScalarOperator gamma, but gamma needs the dtgamma to update. |
gamma = ScalarOperator(0.0, update_func = (dtold, u, p, t) -> integrator.dt)
W = 1/gamma * M + J
update_coefficients!(W, u, p, t) |
So |
^that should work for now. Though your point is valid. FEniCS has a mature UFL which just lets you say |
something like gamma = ScalarOperator(0.0, update_func = (oldval, u, p, t) -> 1/integrator.dt))
W = 1/gamma * M + J
integrator.dt = dtnew
# option 1 - use update_coefficients!
W(du, u, p, t)
# option 2 - override update_coefficients!
update_coefficients!(W, u, p, t)
set!(gamma, 1/integrator.dt)
mul!(du, W, u) and then we can write |
Right, that works. I still feel like |
Implemented a prototype at #143, let me know your thoughts! |
hold off on implementation till we get some input from Chris. after all it has to fit with the rest of the ecosystem |
@ChrisRackauckas can you also bump version? thanks |
In some rare cases, an operator depends on more state than just
u
,p
, andt
. For example, theW
operator inOrdinaryDiffEq
depends ondtgamma
.If
kwargs
could be propagated throughupdate_coefficients!
, we'd be able to take advantage of the recursive infrastructure in these cases too. The call might look something likeupdate_coefficients!(W, u, p, t; dtgamma)
: operators which do not usedtgamma
would just ignore the extra info, while an operator which would like to use it catches it and uses it. Of course, if an operator requiresdtgamma
(or contains an operator that does), it could not be used as a regularSciMLOperator
for the usual use cases, but it wouldn't make sense for that to be possible in any case if the operator needs extra state.For this to work, it seems like all that would be needed to be done is:
kwargs
inupdate_coefficients!
forComposedOperator
's, etc.update_func
signatures which do not catchkwargs
should be detected and modified to catchkwargs
(and not use them), so that the usual use case ofupdate_coefficients!
still works seamlessly. (Something like https://stackoverflow.com/a/42579941?)In general, something like this just seems like good design: while the positional args
u, p, t
capture 99% of use cases, there are definitely cases (like theW
operator) which could naturally be expressed as a SciMLOperator if we just allowed an extra state dependence. Happy to take a stab at this if it's deemed a good idea.The text was updated successfully, but these errors were encountered: