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

Fix dual type promotion in remake with dummy derivatives #3337

Merged
merged 4 commits into from
Jan 18, 2025

Conversation

hersle
Copy link
Contributor

@hersle hersle commented Jan 17, 2025

This seems to fix the minimal example in #3336.

I am still having problems with a slightly more complicated example, though.

Copy link
Member

@ChrisRackauckas ChrisRackauckas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is at least a reasonable thing to do.

@ChrisRackauckas
Copy link
Member

Actually no, this can be unsafe. Instead of generating a new variable (which might not match the other if metadata is applied), you'd want to do it the transform the same way the initialization problem does it.

https://github.com/SciML/ModelingToolkit.jl/blob/master/src/systems/nonlinear/initializesystem.jl#L51

Though I am a bit confused, u0map is already processed right there?

@hersle
Copy link
Contributor Author

hersle commented Jan 17, 2025

What does the schedule.dummy_sub do differently? Preserve any variable metadata?

@ChrisRackauckas
Copy link
Member

It's grabbing the variable itself that already exists, rather than making a new one. The new one is a new symbol which is not guaranteed to match the actual dummy derivative.

@hersle
Copy link
Contributor Author

hersle commented Jan 17, 2025

Ok, thanks. Is this better?

@hersle
Copy link
Contributor Author

hersle commented Jan 17, 2025

Though I am a bit confused, u0map is already processed right there?

But yes, it is probably better to do this higher up in the call hierarchy, in case other functions also depend on the dummy derivative substitution being performed? Where would that be?

@hersle hersle force-pushed the fix_remake_dummy_derivative branch from b2449bf to 60e4723 Compare January 17, 2025 18:54
@ChrisRackauckas ChrisRackauckas merged commit 8668cde into SciML:master Jan 18, 2025
34 of 42 checks passed
AayushSabharwal added a commit to AayushSabharwal/ModelingToolkit.jl that referenced this pull request Jan 24, 2025
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.

2 participants