Skip to content

fix: thermal prod well inflow der #4024

Open
tjb-ltk wants to merge 7 commits intodevelopfrom
fix/byer3/thermalWell
Open

fix: thermal prod well inflow der #4024
tjb-ltk wants to merge 7 commits intodevelopfrom
fix/byer3/thermalWell

Conversation

@tjb-ltk
Copy link
Copy Markdown
Contributor

@tjb-ltk tjb-ltk commented Apr 9, 2026

Fix to thermal well inflow derivatives.

@tjb-ltk tjb-ltk self-assigned this Apr 9, 2026
@tjb-ltk tjb-ltk added the ci: run CUDA builds Allows to triggers (costly) CUDA jobs label Apr 9, 2026
@tjb-ltk tjb-ltk requested a review from rrsettgast as a code owner April 9, 2026 19:09
@tjb-ltk tjb-ltk added the ci: run integrated tests Allows to run the integrated tests in GEOS CI label Apr 9, 2026
@tjb-ltk tjb-ltk added flag: no rebaseline Does not require rebaseline ci: run code coverage enables running of the code coverage CI jobs labels Apr 9, 2026
@tjb-ltk tjb-ltk changed the title thermal prod well inflow der fix fix: thermal prod well inflow der Apr 9, 2026
@tjb-ltk tjb-ltk marked this pull request as draft April 9, 2026 22:30
@tjb-ltk tjb-ltk marked this pull request as ready for review April 14, 2026 22:15
// and sum contributions to each component's perforation rate
for( integer ip = 0; ip < NP; ++ip )
{
// skip the rest of the calculation if the phase is absent
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The isothermal case does quite a bit of this calculation as well. Can we unify it somewhere perhaps?


dDens[CP_Deriv::dP] = m_dResPhaseDens[er][esr][ei][0][ip][Deriv::dP];
if constexpr ( IS_THERMAL )
{
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think all these temperature derivatives are not used here and are recalculated in the thermal version.

m_dEnergyPerfFlux[iperf][TAG::WELL][CP_Deriv::dC+jc] += phaseFlux * dProp_dC[jc];
dMult[CP_Deriv::dC+jc] += m_wellElemPhaseVolFrac[iwelem][iphase] * m_wellElemPhaseDensity[iwelem][0][iphase] * dProp_dC[jc]
+ m_wellElemPhaseEnthalpy[iwelem][0][iphase] * m_wellElemPhaseVolFrac[iwelem][iphase] * dProp_dD[jc]
+ m_wellElemPhaseEnthalpy[iwelem][0][iphase] * m_wellElemPhaseDensity[iwelem][0][iphase] * m_dWellElemPhaseVolFrac[iwelem][iphase][Deriv::dC+jc];
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
+ m_wellElemPhaseEnthalpy[iwelem][0][iphase] * m_wellElemPhaseDensity[iwelem][0][iphase] * m_dWellElemPhaseVolFrac[iwelem][iphase][Deriv::dC+jc];
+ m_wellElemPhaseEnthalpy[iwelem][0][iphase] * m_wellElemPhaseDensity[iwelem][0][iphase] * dProp_dF[jc];

Looks to me like dProp_dF is unused.

{
real64 dMult[CP_Deriv::nDer]{};
real64 totalEnthalpy=0;
dMult[CP_Deriv::dP] = 0;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
dMult[CP_Deriv::dP] = 0;

dMult[CP_Deriv::nDer]{}; should normally initialise to zero. Otherwise we have to initialise everything including dT and dC.

m_wellElemPhaseEnthalpy[iwelem][0][iphase] * m_wellElemPhaseVolFrac[iwelem][iphase] * m_dWellElemPhaseDensity[iwelem][0][iphase][Deriv::dT];
real64 dProp_dC[numComp]{};
applyChainRule( NC,
m_dWellElemCompFrac_dCompDens[iwelem],
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Instead of having these chain rules within the loop. Can't we calculate the dC derivative and then do the chain rule after summing over the loop. It would remove a few flops in the loop and the dProp allocations.

discretization="fluidTPFA"
temperature="368.15"
useMass="1"
useMass="0"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm guessing the removal of thermal here is for debugging?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci: run code coverage enables running of the code coverage CI jobs ci: run CUDA builds Allows to triggers (costly) CUDA jobs ci: run integrated tests Allows to run the integrated tests in GEOS CI flag: no rebaseline Does not require rebaseline flag: ready for review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants