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

Replaced user iterations of EqulibriumTransport actor with convergenc… #210

Merged
merged 18 commits into from
Feb 10, 2023

Conversation

adrianaghiozzi
Copy link
Contributor

…e criteria

Two changes were made:

  1. Moved SteadyStateCurrent actor to before prepare step in EquilibriumTransport workflow
  2. Replaced option of user-input number of iterations with a convergence criteria for EquilibriumTransport runs with CHEASE

…e criteria

Two changes were made:
1. Moved SteadyStateCurrent actor to before prepare step in EquilibriumTransport workflow
2. Replaced option of user-input number of iterations with a convergence criteria for EquilibriumTransport runs with CHEASE
@orso82
Copy link
Member

orso82 commented Feb 6, 2023

I do not understand why the CHEASE equilibrium solver should be treated any different from any other equilibrium solver.
Anything other than the @assert should be agnostic to the equilibrium solver used...

@adrianaghiozzi
Copy link
Contributor Author

I do not understand why the CHEASE equilibrium solver should be treated any different from any other equilibrium solver.
Anything other than the @assert should be agnostic to the equilibrium solver used...

The issue that we were trying to solve here is that when rescale_eq_to_ip is set to true, the rescaling isn't very accurate after just one iteration. By iterating multiple times with the rescale option forced to true, the j_tor profile gets closer and closer to the value of Ip. The reason it's specific to CHEASE is just because Solovev doesn't have the rescale_eq_to_ip option available, so it doesn't have the same convergence problem.

@orso82
Copy link
Member

orso82 commented Feb 6, 2023

If it does not have the same convergence problem, then your convergence criteria should be automatically satisfied and Solovev should only run once.

Removed duplicate code by allowing runs with Solovev to go through the same while loop as runs with CHEASE. Because Solovev loses current over successive iterations, forced runs with Solovev to only iterate once
Copy link
Member

@orso82 orso82 left a comment

Choose a reason for hiding this comment

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

Much better! but looking at it there are few things that we can improve on

@@ -57,18 +57,52 @@ function _step(actor::ActorEquilibriumTransport)
# Set j_ohmic to steady state
finalize(step(actor.actor_jt))

for iteration in 1:par.iterations
@assert act.ActorCHEASE.rescale_eq_to_ip "Running CHEASE with ActorEquilibriumTransport requires ActorCHEASE.rescale_eq_to_ip = true"
Copy link
Member

Choose a reason for hiding this comment

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

I am wondering if this @Assert is necessary, since we already do a act_chease = deepcopy(act.ActorCHEASE) we could then simply force act_chease.rescale_eq_to_ip = true. Is there any problem with that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I switched out the assert for an if statement that hard resets rescale_eq_to_ip to true if it gets false, but also gives the user a warning that it did so. I thought this made sense so that if someone did try setting it to false, they would know that it's actually running with true. Does that work?

avg_diff = sum(abs.(j_tor_after .- j_tor_before)) / length(j_tor_after)

if act.ActorEquilibrium.model == :Solovev
avg_diff = 0 # temporary fix to force Solovev to run exactly once
Copy link
Member

Choose a reason for hiding this comment

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

Hopefully this gets resolved with the MXH equilibrium 🤞

src/actors/compound_actors.jl Outdated Show resolved Hide resolved
src/actors/compound_actors.jl Outdated Show resolved Hide resolved
max_iter = 5
iter = 0
ip = dd.equilibrium.time_slice[].global_quantities.ip
conv_criteria = ip / 1e2
Copy link
Member

Choose a reason for hiding this comment

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

As discussed with @TimSlendebroek the convergence criterion should look at both the current and pressure profiles, taking their difference at the beginning and end of the loop.

adrianaghiozzi and others added 4 commits February 8, 2023 13:29
Changed convergence criteria to an error quantification of j_tor and pressure and also removed assert for CHEASE.rescale_eq_to_ip = false in favor of a warning
@orso82 orso82 merged commit 4b70a81 into master Feb 10, 2023
@orso82 orso82 deleted the eqtransport_convergence branch February 10, 2023 22:50
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