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

provide a simplified interface for users directly using ODEProblem and such #20

Closed
isaacsas opened this issue Dec 30, 2023 · 3 comments
Closed

Comments

@isaacsas
Copy link
Member

The current doc example shows how to use symbolic indexing when coming from MTK, but it would also be nice if users who directly construct SciML problems had a way to attach names (be they strings / symbols / etc) to indexes in sol.u and index with them.

I see https://github.com/SciML/SymbolicIndexingInterface.jl/blob/master/test/example_test.jl -- is there a possibility of providing a simple convenience function / macro that can do all this for a user who just wants to have a mapping from a variable and/or parameter name encoded in some way to an index in sol.u for use in solution indexing and plotting?

@AayushSabharwal
Copy link
Member

AayushSabharwal commented Jan 2, 2024

To add names to indexes in sol.u, they must be Symbols. This can be done using the SymbolCache in this library, by passing it as the sys to the relevant SciMLFunction. i.e.

function f(du, u, p, t)
    # ...
end
odefn = ODEFunction(f; sys = SymbolCache([:x, :y, :z], [:a, :b], :t))

If there are no e.g. parameter symbols, that field can be nothing or omitted entirely if there is no independent variable either. However, SymbolCaches without any independent variable will be assumed to be time-independent (is_time_dependent(sys) == false)

@isaacsas
Copy link
Member Author

isaacsas commented Jan 2, 2024

That's great, thanks for pointing that out! I will use that going forward. Once that is in the docs I think this issue can be closed.

@AayushSabharwal
Copy link
Member

This is now documented here

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

2 participants