FIX: Make minimizer state more internally consistent #410
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR moves
advance_state
to be the last step in the minimization loop.The main reason to make this change is that we want the chemical potentials that we get from
solve_state
to be consistent with the current site fractions, phase amounts, and state variables when we check for convergence, change phases, and return a solution. Right now, we apply the corrections to site fractions, phase amounts, and state variables after solving for the chemical potentials with the current values, so they are effectively one step ahead of the chemical potentials.This fixes #372 as the driving forces should now always be zero in
change_phases
, as the chemical potentials are now consistent with the current site fractions.Summary of changes:
advance_state
to something non-zero to avoid divide by zero cases.ALLOWED_DELTA_Y = 1e-09
seems to be the charged species test.