Repository navigation
Restore pT equilibrium when pTg relaxation uses up a phase #2052
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
Open
aliencaocao
wants to merge
3
commits into
MFlowCode:master
Choose a base branch
from
aliencaocao:fix/phase-depletion-equilibrium
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+678
−651
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -59,6 +59,7 @@ contains | |
| real(wp) :: rhoe, dynE, rhos !< total internal energy, kinetic energy, and total entropy | ||
| real(wp) :: rho, rM, m1, m2, MCT !< total density, total reacting mass, individual reacting masses | ||
| real(wp) :: TvF !< total volume fraction | ||
| logical :: ptg_conv !< pTg Newton solver converged | ||
|
|
||
| #:if not MFC_CASE_OPTIMIZATION and USING_AMD | ||
| real(wp), dimension(3) :: p_infpT, sk, hk, gk, ek, rhok | ||
|
|
@@ -79,7 +80,7 @@ contains | |
| ! starting equilibrium solver | ||
|
|
||
| $:GPU_PARALLEL_LOOP(collapse=3, private='[i, j, k, l, p_infpT, sk, hk, gk, ek, rhok, pS, TS, rhoe, dynE, rhos, rho, rM, & | ||
| & m1, m2, MCT, TvF]') | ||
| & m1, m2, MCT, TvF, ptg_conv]') | ||
| do j = 0, m | ||
| do k = 0, n | ||
| do l = 0, p | ||
|
|
@@ -135,7 +136,10 @@ contains | |
| q_cons_vf(lp + eqn_idx%cont%beg - 1)%sf(j, k, l) = m1 | ||
| q_cons_vf(vp + eqn_idx%cont%beg - 1)%sf(j, k, l) = m2 | ||
|
|
||
| call s_infinite_ptg_relaxation_k(j, k, l, pS, rhoe, q_cons_vf, TS) | ||
| call s_infinite_ptg_relaxation_k(j, k, l, pS, rhoe, q_cons_vf, TS, ptg_conv) | ||
|
|
||
| ! Unconverged pTg; solve pT equilibrium again for the final masses | ||
| if (.not. ptg_conv) call s_infinite_pt_relaxation_k(j, k, l, 2, pS, p_infpT, q_cons_vf, rhoe, TS) | ||
| end if | ||
|
|
||
| ! Calculations AFTER equilibrium | ||
|
|
@@ -332,7 +336,7 @@ contains | |
| !! rhoe-relative branch). Every step is projected onto the physical bounds 0 <= ml <= mT, pS > pmin. This converges in a handful | ||
| !! of iterations with a bounded, uniform count (no GPU warp divergence), unlike the former fixed 1e-3 underrelaxation that | ||
| !! stalled far from the root. | ||
| subroutine s_infinite_ptg_relaxation_k(j, k, l, pS, rhoe, q_cons_vf, TS) | ||
| subroutine s_infinite_ptg_relaxation_k(j, k, l, pS, rhoe, q_cons_vf, TS, ptg_conv) | ||
|
|
||
| $:GPU_ROUTINE(function_name='s_infinite_ptg_relaxation_k', parallelism='[seq]', cray_noinline=True) | ||
|
|
||
|
|
@@ -341,6 +345,7 @@ contains | |
| real(wp), intent(in) :: rhoe | ||
| type(scalar_field), dimension(sys_size), intent(inout) :: q_cons_vf | ||
| real(wp), intent(inout) :: TS | ||
| logical, intent(out) :: ptg_conv | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this not an optional? |
||
| real(wp), dimension(2, 2) :: Jac, InvJac | ||
| real(wp), dimension(2) :: R2D, R2D_try, DeltamP | ||
| real(wp) :: mCP, mCPD, mCVGP, mCVGP2, mQ | ||
|
|
@@ -368,7 +373,8 @@ contains | |
|
|
||
| do ns = 1, max_iter | ||
| ! converged on the absolute residual, or on the rhoe-relative residual (multiply form, rhoe > 0) | ||
| if ((resnorm <= ptgalpha_eps) .or. (resnorm <= (ptgalpha_eps/1.e6_wp)*rhoe)) exit | ||
| ptg_conv = (resnorm <= ptgalpha_eps) .or. (resnorm <= (ptgalpha_eps/1.e6_wp)*rhoe) | ||
| if (ptg_conv .or. (ns == max_iter)) exit | ||
|
|
||
| ! 2x2 Jacobian of (Gibbs equality, energy) with respect to (ml, pS) at the current state | ||
| dFdT = -(cvs(lp)*isentrope_n(lp) - cvs(vp)*isentrope_n(vp))*log(TS) - (qvps(lp) - qvps(vp)) + cvs(lp)*(isentrope_n(lp) & | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prove this gives the right results, what are the costs if it does? tradeoffs?