Skip to content

Propagate kwargs through update_coefficients! #125

@gaurav-arya

Description

@gaurav-arya

In some rare cases, an operator depends on more state than just u, p, and t. For example, the W operator in OrdinaryDiffEq depends on dtgamma.

If kwargs could be propagated through update_coefficients!, we'd be able to take advantage of the recursive infrastructure in these cases too. The call might look something like update_coefficients!(W, u, p, t; dtgamma): operators which do not use dtgamma 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 requires dtgamma (or contains an operator that does), it could not be used as a regular SciMLOperator 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:

  • Recursively propagate kwargs in update_coefficients! for ComposedOperator's, etc.
  • User-provided update_func signatures which do not catch kwargs should be detected and modified to catch kwargs (and not use them), so that the usual use case of update_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 the W 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions