Skip to content

[WIP] Differential Equation Function Transformations #141 #1073

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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

SteffenPL
Copy link

@SteffenPL SteffenPL commented Jun 23, 2021

For #141
I'm not quite done yet, but I wanted to ask for feedback to check that the direction is alright.

For example, the change of variables z = exp(x) looks currently like this:

eqs = [D(x) ~ α*x]
u0 = [x => 1.0]
sys = ODESystem(eqs; defaults=u0)

@variables z(t)
forward_subs  = [exp(x) => z]
backward_subs = [x => log(z)]
new_sys = changeofvariables(sys, forward_subs, backward_subs)
@test equations(new_sys)[1] == (D(z) ~ α*z*log(z))

Since there is not symbolic way (AFAIK) to get the inverse of general nonlinear functions, one has to
provide both: the forward and backward substitution (forward_subs and backward_subs).

In the test file, I also added a Riccati ODE and a 3D linear transformation as examples.

Details:

  • If sys.defaults exists, then those will be transformed as well.
  • The substituted variables become observables.
  • Transformation can depend on time. (For transformation of initial data defaults, one needs to provide t0)
  • It only works for first-order ODEs

Questions:

  • Is the function interface ok? I picked this form, since it looks mathematically correct. I use expressions instead of Functions because everything else is also symbolic.

Things I will add for final PR/known bugs:

  • support cases where length(forward_subs) < length(states(sys)), i.e. keep old state variables.
  • add proper doc string once the interface is fixed.
  • support for SDEs

Optional ideas:

  • compute forward/backward substitution automatically if possible (but I don't know where to get inveres from). One could use inverse function theorem, but then the transformed ODEs are ugly/too complex.
  • allow to pass known invariants, to cover cases like Riccati equations better.

@ChrisRackauckas
Copy link
Member

Since there is not symbolic way (AFAIK) to get the inverse of general nonlinear functions, one has to
provide both: the forward and backward substitution (forward_subs and backward_subs).

I think that's fine for now.

@EricTulowetzke
Copy link

@ChrisRackauckas and @SteffenPL are we wanting to get this PR finished? Do either of have issues with me picking this up? I'm looking for a good first issue to get my feet wet.

@ChrisRackauckas
Copy link
Member

It's gone stale. Feel free to take this on yourself either using this as a starting point or from scratch.

@SteffenPL
Copy link
Author

SteffenPL commented Aug 14, 2023

Hi, sorry for my inactivity. It wasn't really my focus for a while. I can work on it in the next week. Initially an issue in symbolics (with some simplify not working) was halting this PR, but the issue should be resolved now. I can try to work on it again/or at least help if you want to push another PR.

@SteffenPL
Copy link
Author

SteffenPL commented Aug 14, 2023

Maybe to add more details. The main reason why I didn't ask for merging was that SDEs and DAEs were not supported at the time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants