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

perform_step! refactor for Rosenbrock #2320

Closed
wants to merge 0 commits into from

Conversation

ParamThakkar123
Copy link
Contributor

@ParamThakkar123 ParamThakkar123 commented Aug 8, 2024

Checklist

  • Appropriate tests were added
  • Any code changes were done in a way that does not break public API
  • All documentation related to code changes were updated
  • The new code follows the
    contributor guidelines, in particular the SciML Style Guide and
    COLPRAC.
  • Any new documentation only uses public API

Additional context

Add any other context about the problem here.
#233

@ParamThakkar123
Copy link
Contributor Author

@oscardssmith All the methods should be combined into one single perform_step this way right ??

@ParamThakkar123
Copy link
Contributor Author

Or are there certain methods which should be kept together ??

@ChrisRackauckas
Copy link
Member

You'll want to combine all of the caches too, just using arrays of arrays in the caches instead of different variables for each k for example

@ParamThakkar123
Copy link
Contributor Author

@ChrisRackauckas I think the recent merge caused an error here

@ChrisRackauckas
Copy link
Member

what do you mean?

@ParamThakkar123
Copy link
Contributor Author

I ran the tests some time ago and all the errors pointed to OrdinaryDiffEqRosenbrock.jl even though I made no changes there

@ParamThakkar123
Copy link
Contributor Author

image

@ChrisRackauckas
Copy link
Member

did you rebase?

@ParamThakkar123
Copy link
Contributor Author

no

@ParamThakkar123
Copy link
Contributor Author

I will do that

@ParamThakkar123
Copy link
Contributor Author

@ChrisRackauckas Can you please review the changes to see if whatever I have done so far is correct and on track ?? If any changes are needed I will make those.

@ChrisRackauckas
Copy link
Member

This is still all written out. It should turn into loops over arrays.

@ParamThakkar123
Copy link
Contributor Author

ParamThakkar123 commented Aug 10, 2024

@ChrisRackauckas I made a recent change to Rodas23WCache and Rodas3PCache. Is this how it should be done ?? Just to confirm

@ChrisRackauckas
Copy link
Member

This isn't quite right. See ExplicitRK

@ParamThakkar123
Copy link
Contributor Author

This isn't quite right. See ExplicitRK

I went through the explicitrk code and understood how this should be done. I will make the changes

else
linsolve_tmp = du + dtd3 * dT + mass_matrix * (dtC31 * k1 + dtC32 * k2)
end
for i in 2:eachindex(A)
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this is right since eachindex of a Matrix will loop over the scalars. I think you want for i in 2:size(A, 2)

Copy link
Contributor

Choose a reason for hiding this comment

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

you also probably want an @assert that size(A,1)==size(A,2)==length(k) so the compiler can know that all the sizes match up.

@ParamThakkar123
Copy link
Contributor Author

@ChrisRackauckas @oscardssmith if we change all the perform_step! implementations to have just RosenbrockCache and RosenbrockConstantCache then would we need the others ?? Or Just one perform_step! for RosenbrockCache and one perform_step! for RosenbrockConstantCache would suffice ??

@oscardssmith
Copy link
Contributor

Or Just one perform_step! for RosenbrockCache and one perform_step! for RosenbrockConstantCache would suffice ??

Exactly. That's the point of the refactor.

@ParamThakkar123
Copy link
Contributor Author

Ok got it.

@ChrisRackauckas
Copy link
Member

It's not passing tests so it can't merge?

@ParamThakkar123
Copy link
Contributor Author

Yes. I need to work on fixing the Symbolics module error that's occuring in this

@ParamThakkar123
Copy link
Contributor Author

image
this one

@ChrisRackauckas
Copy link
Member

That's unrelated. Don't worry about it.

Your actual error is that you deleted the overloads required to make Rosenbrock23 work. Rebase this.

@ParamThakkar123
Copy link
Contributor Author

okay

@ParamThakkar123
Copy link
Contributor Author

image

@ChrisRackauckas How can this be dealt with ? There is some method call error here

@oscardssmith
Copy link
Contributor

You need to be using https://github.com/SciML/PreallocationTools.jl somewhere to make the caches autodiff compatible.

@ChrisRackauckas
Copy link
Member

That's done in build_jac_config.

@ParamThakkar123
Copy link
Contributor Author

You need to be using https://github.com/SciML/PreallocationTools.jl somewhere to make the caches autodiff compatible.

For the error I mentioned in the message above??

@ParamThakkar123
Copy link
Contributor Author

That's done in build_jac_config.

There's a function build_jac_config in the derivative_wrappers.jl file with AutoDiff

@ParamThakkar123
Copy link
Contributor Author

@ChrisRackauckas Should I be importing build_jac_config from derivateive_wrappers.jl. It doesn't seem to use it

@ParamThakkar123
Copy link
Contributor Author

ParamThakkar123 commented Aug 21, 2024

@ChrisRackauckas @oscardssmith just needed some guidance on the current failures that occur in tests. I tried to figure this out but finding it a bit hard to get where things are wrong

@ParamThakkar123
Copy link
Contributor Author

@ChrisRackauckas can you please review the errors here ?? I will fix those.

@ParamThakkar123
Copy link
Contributor Author

Okay. will try to figure things out and fix them. i will try to get this done today.

@@ -1,13 +1,49 @@
abstract type RosenbrockMutableCache <: OrdinaryDiffEqMutableCache end
abstract type RosenbrockConstantCache <: OrdinaryDiffEqConstantCache end
Copy link
Member

Choose a reason for hiding this comment

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

why was this deleted?

@@ -1,13 +1,49 @@
abstract type RosenbrockMutableCache <: OrdinaryDiffEqMutableCache end
abstract type RosenbrockConstantCache <: OrdinaryDiffEqConstantCache end

# Fake values since non-FSAL
Copy link
Member

Choose a reason for hiding this comment

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

why was this deleted?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually I wanted to club the constant caches into a single RosenbrockConstantCache and the names were conflicting. So I decided to keep one.

Rosenbrock5Cache(u, uprev, dense1, dense2, dense3, du, du1, du2, k1, k2, k3, k4,
k5, k6, k7, k8,
grad_config = build_grad_config(alg, f, tf, dus[2], t)
jac_config = build_jac_config(alg, f, uf, dus[2], uprev, u, tmp, dus[3])
Copy link
Member

Choose a reason for hiding this comment

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

why was this changed to 2 and 3?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

actually dus had three variables du, du1, and du2 so I kept them in single vector as [du, du1, du2] according to Julia's 1-based indexing du1 would be dus[2] so I went that way


# Calculate the final results for k
for j in 1:3
tmp = sum(eval(Symbol("h$j$i")) * ks[i] for i in 1:8)
Copy link
Member

Choose a reason for hiding this comment

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

no eval allowed. it should probably be an array anyways.

@ChrisRackauckas
Copy link
Member

Lots of comments. You really need to fix the merge commit before trying to continue. You cannot just delete all changes that have happened, that's going to cause test failures. There is a naming overlap with one of the new abstract types, you'll want to actually handle that and not just revert it.

@ParamThakkar123
Copy link
Contributor Author

Lots of comments. You really need to fix the merge commit before trying to continue. You cannot just delete all changes that have happened, that's going to cause test failures. There is a naming overlap with one of the new abstract types, you'll want to actually handle that and not just revert it.

Okay. Will keep that in mind. working towards that. Sorry for the mistakes made

@ChrisRackauckas
Copy link
Member

I highly recommend moving this PR to a branch so you can keep a clean master. This was causing you issues before, and now it's interfering with the other PR. Generally, don't open PRs from your fork's master.

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