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

feat: Add immiscible multiphase flow package #3251

Open
wants to merge 87 commits into
base: develop
Choose a base branch
from

Conversation

CusiniM
Copy link
Collaborator

@CusiniM CusiniM commented Jul 30, 2024

Implementation of a multiphase immiscible solver for compressible fluids with viscous, gravity and capillary forces:

  • Included new ImmiscibleMultiphaseFlow solver and associated kernels (currently limited to two phases)
  • Standard and total mass formulations
  • Cell-centered Dirichlet and flux boundary conditions
  • Included new TwoPhaseFluid model for tabular data input
  • Direct and iterative linear solver compatibility
  • GPU compatibility
  • Set of input files with validation cases
  • Unit tests and documentation provided

@Ammara-14 Ammara-14 self-assigned this Jul 30, 2024
@ryar9534 ryar9534 self-assigned this Aug 1, 2024
Comment on lines 12 to 13
"program": "${userHome}/two-phase/GEOS/install-ubuntu22-debug/bin/geosx",
"args": ["-i", "/home/rpiazza/two-phase/GEOS/inputFiles/immiscibleMultiphaseFlow/immiscible_2phaseFlow_1d.xml", "-o", "${userHome}/geos-output"],
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Remove these changes.


real64 ImmiscibleMultiphaseFlow::setNextDt( const geos::real64 & currentDt, geos::DomainPartition & domain )
{
return PhysicsSolverBase::setNextDt( currentDt, domain );
Copy link
Contributor

Choose a reason for hiding this comment

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

TODO pressure and saturation change time step selector

Choose a reason for hiding this comment

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

Implemented new function:
real64 ImmiscibleMultiphaseFlow::setNextDtBasedOnStateChange(real64 const & currentDt, DomainPartition & domain)

real64 const dDens_dP = m_dDens_dPres[seri[ke]][sesri[ke]][sei[ke]][0][ip][Deriv::dP]; // dr/dP = dr1/dP1 || dr2/dP

// average density and derivatives
densMean[ip] += 0.5 * density; // rho = (rho1 + rho2) / 2
Copy link
Contributor

Choose a reason for hiding this comment

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

this treatment was recently modified, see #3337

Choose a reason for hiding this comment

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

New treatment implemented in kernel:
void computeFlux( localIndex const iconn, StackVariables & stack, FUNC && kernelOp = NoOpFunc{} ) const

Copy link
Contributor

Choose a reason for hiding this comment

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

sorry we had to revert that new treatment and make it an option, see #3467
somehow old treatment works much better for spe11 and it is not a good time to spoil it

Choose a reason for hiding this comment

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

We adapted the code to make it optional in the immiscible solver as well, using the parameter m_checkPhasePresenceInGravity

real64 dPresGrad_dTrans = 0.0;
real64 dGravHead_dTrans = 0.0;
real64 dCapGrad_dTrans = 0.0;
int signPotDiff[2] = {1, -1};
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 you need this sign thing

Choose a reason for hiding this comment

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

Keeping it for now. We can think of a more elegant implementation in the future.

Copy link
Contributor

Choose a reason for hiding this comment

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

i think it is just wrong, why no just this:

            presGrad[ip] += trans[ke] * pressure;
...
            dPresGrad_dP[ip][ke] += dTrans_dP[ke] * pressure;

?

Choose a reason for hiding this comment

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

If we understand correctly, it's because we need a pressure difference instead of a single pressure value:

Here presGrad = T * (P1-P2)
When we take the derivative with respect to the two pressures we will need: dPresGrad_dP = {dT/dP1 * (P1-P2) + T, dT/dP1 * (P1-P2) - T}. At the last line of code shown dPresGrad_dP = {T, -T} already.
So the second term on the right-hand side needs to be a (P1-P2), instead of just a single pressure. We used the signPotDiff variable to assist taking the difference of the 2 pressures.

Copy link
Contributor

Choose a reason for hiding this comment

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

i am still confused
the code is more like
presGrad = T1*P1 + T2*P2
right?
the rest should follow the same notation/logic
maybe @CusiniM or @ryar9534 can have a look and check if i am wrong

Choose a reason for hiding this comment

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

Someone else can check our understanding, but it's because in
presGrad[ip] += trans[ke] * pressure; // DPv = T (P1 - P2)
we are using the transmissibilities that come from the computeWeights (CellElementStencilTPFA.hpp) function like this:
weight[0][ke] = m_transMultiplier[iconn] * value * (ke == 0 ? 1 : -1);
So T2 = -T1

potGrad += capGrad[ip]; // DPhi = T (P1 - P2) - T rho g (z1 - z2) + T (-Pc1 + Pc2)
}

// compute upwinding tolerance
Copy link
Contributor

Choose a reason for hiding this comment

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

compositional is not doing that trick but ok to keep it here as long as it works fine

@paveltomin
Copy link
Contributor

Overall looks pretty good, just some minor things here and there, cleanup and remove commented code

Copy link
Contributor

@victorapm victorapm left a comment

Choose a reason for hiding this comment

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

I just looked at MGR changes, looks good!

explicit ImmiscibleMultiphaseFVM( arrayView1d< int const > const & numComponentsPerField )
: MGRStrategyBase( LvArray::integerConversion< HYPRE_Int >( numComponentsPerField[0] ) )
{
// Level 0: eliminate last density which corresponds to the volume constraint equation
Copy link
Contributor

Choose a reason for hiding this comment

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

These comments can be removed

@matteofrigo5
Copy link
Contributor

I'd remove the file host-configs/Stanford/ubuntu22.cmake before merging this branch into the develop branch.

@bd713 bd713 added the flag: requires rebaseline Requires rebaseline branch in integratedTests label Dec 12, 2024
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: requires rebaseline Requires rebaseline branch in integratedTests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants