Skip to content
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

RFC: time-dependent operator macro #129

Open
aryavorskiy opened this issue Aug 5, 2023 · 2 comments
Open

RFC: time-dependent operator macro #129

aryavorskiy opened this issue Aug 5, 2023 · 2 comments

Comments

@aryavorskiy
Copy link
Contributor

Currently the only time-dependent operator type present in the library is TimeDependentSum, which is actually a lazy sum with time-dependent coefficients. While certainly useful, it might be a bit hard and unintuitive to use in code. My proposal is the following:

  • Write a macro that will create time-dependent operators in a convenient manner like A = @timedependent t -> (B * t + C * (1 - t)) ⊗ D(t - 2). It does approximately the following:
    • All +, *, top-level calls are turned into lazy operators.
    • dense, sparse e. g. calls are left untouched
    • All other calls are checked for time-dependent operators like D(t - 2). If the call is a time-dependent operator, we create a CompositeTimeDependentOperator with t -> t - 2 as a time parameter. If it is an ordinary function, we treat it as a number (because in context of this macro we expect an operator or a number, nothing else)

Also maybe this architecture should support parameters other than time (e. g. magnetic field?).
Hope you find this idea useful.

@Krastanov
Copy link
Collaborator

This can be quite valuable. My main worry if we go in this direction would be diverging too much from SciMLOperators https://docs.sciml.ai/SciMLOperators/stable/

@amilsted
Copy link
Collaborator

amilsted commented Aug 25, 2023

This is an interesting idea! I think it could be compatible with a SciMLOperators approach to time-dependent operators. Seems like a layer on top of all that? By the way, even as things are, it should be possible to make lazy sums and products of time-dependent operators and have them behave properly. They won't be AbstractTimeDependentOperators themselves, but they should respond to set_time! properly and work when used in schroedinger_dynamic and co.

You can't currently have LazyTensors of time-dependent stuff, however.

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

No branches or pull requests

3 participants