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

Factoring hysteresis model out of TableRelativePermeabilityHysteresis #2207

Open
wants to merge 51 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
87d210e
save commit before refactoring
jafranc Nov 10, 2022
4e937e1
factor out Killough Parameters to be used by TableHysteresis
jafranc Nov 11, 2022
81a85cc
Adding TableCapillaryPressureHysteresis class
jafranc Nov 12, 2022
162b899
adding phaseVolTrapped to CapillaryBase + inheritance
jafranc Nov 16, 2022
b4456bf
adding Hysteresis capillary table
jafranc Nov 16, 2022
fa48972
few correction/missing parts
Nov 17, 2022
35988c4
uncrustify + some corrections
Nov 19, 2022
4e4956c
addding save converged state for capillary model
Nov 30, 2022
67a3cf7
adding headers and minor fixes
Nov 30, 2022
505d475
adding a test for capillary hysteresis
Nov 30, 2022
3da2cd5
adapt test for hyst relperm
Nov 30, 2022
a016798
uncrustify
Nov 30, 2022
c4c592e
uncrustified + bounded F ratio
Nov 30, 2022
6701749
added a Logic error
Dec 2, 2022
21f6a3b
add flags logic and correct 2phase
Dec 2, 2022
3da4473
flags as cell-wise fields
Dec 5, 2022
f766c68
adding a test case
Dec 5, 2022
63a086b
clean capillaryPCHyst + fix few filename convention
Dec 9, 2022
cc01813
init KilloughHysteresis obj through relpermClass + usage of 3-points …
Dec 9, 2022
c5ae8cd
start revising unitest
Dec 9, 2022
53e89f5
cleaning up interfaces
jafranc Dec 9, 2022
ea74141
Merge branch 'develop' into jafranc/refactor/relpermHysteresis
Dec 13, 2022
7ce9a1b
clean up post-merge
Dec 13, 2022
1b60f12
fix trapped fraction
Dec 13, 2022
1540d0d
make KilloughHysteresis a simple helpers class
Dec 14, 2022
fcf366b
reorderd messed ratio
Dec 14, 2022
5067990
some more comments and uncrustify
Dec 14, 2022
32a366d
Residual clean up from branching f766c68
Jan 24, 2023
d60e095
Clean and made KilloughHysteresis static
Jan 25, 2023
6e52e30
discard wip-test
Jan 25, 2023
04fdd27
Merge branch 'develop' into jafranc/refactor/relpermHysteresis
Jan 25, 2023
3a8b75d
post-merge/ fix minPhaseFraction getters
Jan 25, 2023
a01db8c
uncrustify
Jan 25, 2023
71ba079
Merge branch 'develop' into jafranc/refactor/relpermHysteresis
jafranc Feb 27, 2023
2fd8bca
correcting GPU and compile issue for CI
jafranc Feb 28, 2023
4c37c18
restoring original namespacing
Mar 1, 2023
9bb24bb
fixing dataRepository::details and geosx::details clash
Mar 1, 2023
d3cc4b4
fixing missing marked HOST_DEVICE
Mar 1, 2023
9f12e94
moving defs and inlining for GPU support
jafranc Mar 2, 2023
8172f34
adress Francois's comments
Apr 11, 2023
5c45a8f
Merge branch 'develop' into jafranc/refactor/relpermHysteresis
Apr 11, 2023
dd9c747
indentation and m_isWetting as mem var
Apr 11, 2023
deba706
Merge branch 'develop' into jafranc/refactor/relpermHysteresis
francoishamon Jul 7, 2023
de8b09d
added doxygen
francoishamon Jul 7, 2023
d7cd842
fixed unit test
francoishamon Jul 7, 2023
820dbac
first bugfixes
francoishamon Jul 7, 2023
ac5edaa
fixed bug
francoishamon Jul 10, 2023
825e571
Merge branch 'develop' into jafranc/refactor/relpermHysteresis
francoishamon Jul 21, 2023
992deac
updated integratedTests submodule
francoishamon Jul 21, 2023
b681100
fixed erroneous warning message
francoishamon Jul 24, 2023
fdbfbd1
bugfixes and checks
francoishamon Jul 25, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/coreComponents/common/Logger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,7 @@ struct InputError : public std::runtime_error
{}
};


/**
* @brief Exception class used for special control flow.
*/
Expand Down
14 changes: 8 additions & 6 deletions src/coreComponents/constitutive/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@ set( constitutive_headers
ConstitutivePassThruHandler.hpp
ExponentialRelation.hpp
NullModel.hpp
KilloughHysteresis.hpp
capillaryPressure/BrooksCoreyCapillaryPressure.hpp
capillaryPressure/CapillaryPressureBase.hpp
capillaryPressure/CapillaryPressureFields.hpp
capillaryPressure/JFunctionCapillaryPressure.hpp
capillaryPressure/TableCapillaryPressure.hpp
capillaryPressure/TableCapillaryPressureHelpers.hpp
capillaryPressure/VanGenuchtenCapillaryPressure.hpp
capillaryPressure/capillaryPressureSelector.hpp
capillaryPressure/layouts.hpp
capillaryPressure/CapillaryPressureSelector.hpp
capillaryPressure/Layouts.hpp
contact/ContactBase.hpp
contact/CoulombContact.hpp
contact/ContactSelector.hpp
Expand Down Expand Up @@ -51,7 +52,7 @@ set( constitutive_headers
fluid/PVTFunctions/CO2Enthalpy.hpp
fluid/PVTFunctions/CO2EOSSolver.hpp
fluid/PVTFunctions/PureWaterProperties.hpp
fluid/PVTFunctions/WaterDensity.hpp
fluid/PVTFunctions/WaterDensity.hpp
fluid/ParticleFluid.hpp
fluid/ParticleFluidBase.hpp
fluid/ProppantSlurryFluid.hpp
Expand All @@ -77,7 +78,7 @@ set( constitutive_headers
permeability/PermeabilityFields.hpp
permeability/ProppantPermeability.hpp
permeability/SlipDependentPermeability.hpp
permeability/WillisRichardsPermeability.hpp
permeability/WillisRichardsPermeability.hpp
relativePermeability/RelpermDriver.hpp
relativePermeability/RelpermDriverRunTest.hpp
relativePermeability/BrooksCoreyBakerRelativePermeability.hpp
Expand All @@ -89,7 +90,7 @@ set( constitutive_headers
relativePermeability/TableRelativePermeabilityHelpers.hpp
relativePermeability/TableRelativePermeabilityHysteresis.hpp
relativePermeability/VanGenuchtenBakerRelativePermeability.hpp
relativePermeability/layouts.hpp
relativePermeability/Layouts.hpp
relativePermeability/RelativePermeabilitySelector.hpp
solid/CompressibleSolid.hpp
solid/ProppantSolid.hpp
Expand Down Expand Up @@ -142,6 +143,7 @@ set( constitutive_sources
ConstitutiveBase.cpp
ConstitutiveManager.cpp
NullModel.cpp
KilloughHysteresis.cpp
capillaryPressure/BrooksCoreyCapillaryPressure.cpp
capillaryPressure/CapillaryPressureBase.cpp
capillaryPressure/JFunctionCapillaryPressure.cpp
Expand Down Expand Up @@ -180,7 +182,7 @@ set( constitutive_sources
fluid/PVTFunctions/CO2Enthalpy.cpp
fluid/PVTFunctions/CO2EOSSolver.cpp
fluid/PVTFunctions/PureWaterProperties.cpp
fluid/PVTFunctions/WaterDensity.cpp
fluid/PVTFunctions/WaterDensity.cpp
fluid/ParticleFluid.cpp
fluid/ParticleFluidBase.cpp
fluid/ProppantSlurryFluid.cpp
Expand Down
59 changes: 59 additions & 0 deletions src/coreComponents/constitutive/KilloughHysteresis.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* ------------------------------------------------------------------------------------------------------------
francoishamon marked this conversation as resolved.
Show resolved Hide resolved
* SPDX-License-Identifier: LGPL-2.1-only
*
* Copyright (c) 2018-2020 Lawrence Livermore National Security LLC
* Copyright (c) 2018-2020 The Board of Trustees of the Leland Stanford Junior University
* Copyright (c) 2018-2020 TotalEnergies
* Copyright (c) 2019- GEOSX Contributors
* All rights reserved
*
* See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details.
* ------------------------------------------------------------------------------------------------------------
*/

/***
* @file KilloughHysteresis.cpp
francoishamon marked this conversation as resolved.
Show resolved Hide resolved
*/

#include "KilloughHysteresis.hpp"


namespace geosx
{

using namespace dataRepository;

namespace constitutive
{


void KilloughHysteresis::postProcessInput( real64 const & jerauldParam_a, real64 const & jerauldParam_b,
real64 const & killoughCurvatureParamRelPerm )
{
GEOSX_THROW_IF( jerauldParam_a < 0,
GEOSX_FMT( "{}: the parameter {} must be positive",
catalogName(),
viewKeyStruct::jerauldParameterAString() ),
InputError );

GEOSX_THROW_IF( jerauldParam_b < 0,
GEOSX_FMT( "{}: the paramater {} must be postitive",
catalogName(),
viewKeyStruct::jerauldParameterBString() ),
InputError );

GEOSX_THROW_IF( killoughCurvatureParamRelPerm < 0,
GEOSX_FMT( "{}: the paramater {} must be postitive",
catalogName(),
viewKeyStruct::killoughCurvatureParameterString() ),
InputError );

}





}//end namespace
}//end namespace
235 changes: 235 additions & 0 deletions src/coreComponents/constitutive/KilloughHysteresis.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,235 @@
/*
* ------------------------------------------------------------------------------------------------------------
* SPDX-License-Identifier: LGPL-2.1-only
*
* Copyright (c) 2018-2020 Lawrence Livermore National Security LLC
* Copyright (c) 2018-2020 The Board of Trustees of the Leland Stanford Junior University
* Copyright (c) 2018-2020 TotalEnergies
* Copyright (c) 2019- GEOSX Contributors
* All rights reserved
*
* See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details.
* ------------------------------------------------------------------------------------------------------------
*/

/**
* @file TableRelativePermeabilityHysteresis.hpp
*/
francoishamon marked this conversation as resolved.
Show resolved Hide resolved

#ifndef GEOSX_KILLOUGHHYSTERESIS_HPP
#define GEOSX_KILLOUGHHYSTERESIS_HPP

#include "relativePermeability/Layouts.hpp"
#include "capillaryPressure/Layouts.hpp"

#include "constitutive/ConstitutiveBase.hpp"
#include "functions/TableFunction.hpp"


namespace geosx
{

namespace constitutive
{

/***
* @brief KilloughHysteresis is designed to hold Killough hystereis model parameters and
* be in charge of all compuration related to this model (trapped Saturation,Land Coefficient?)
francoishamon marked this conversation as resolved.
Show resolved Hide resolved
*/



//should be up to constitutiveBase or some new SCALConstitutiveBase but for now let's POC on relativePermeabilityBase
francoishamon marked this conversation as resolved.
Show resolved Hide resolved
class KilloughHysteresis
{
public:

static constexpr real64 minScriMinusScrd = 1e-12;
francoishamon marked this conversation as resolved.
Show resolved Hide resolved
/// To avoid frequent changes from drainage to imbibition and vice versa, we use this buffer
static constexpr real64 flowReversalBuffer = 1e-12;

struct PhaseWettability
{
enum : integer
{
WETTING = 0,
NONWETTING = 1
};
};

/**
* @brief struct to represent hysteresis curves (relperm or capillary pressure)
* whether they are wetting or non wetting, storing key point as pairs of
* saturations and value, being either the relperm value (S,kr) or capillary pressure value (S,pc).
francoishamon marked this conversation as resolved.
Show resolved Hide resolved
* this way we can tell wetting curve from non wetting by the ordering of drainage/imbibition key values.
* Indeed if imbibition comes at lower saturation than drainage then it is wetting curve, on the opposite
* if drainage comes before imbibition this is a non-wetting hysteresis. This is completed by an opposite
* point that is either the connate wetting saturation Swc or the maximum non wetting saturation Sgmax.
* @param oppositeBoundPhaseVolFraction represents either Swc or Sgmax depending if a wetting curve or nonwetting is described
* @param imbibitionExtremaPhaseVolFraction represents in wetting case the imibibition max and in non-wetting the imbibition residual
* @param drainageExtremaPhaseVolFraction represents in wetting case the drainage max and in non-wetting the drainage residual
* @param oppositeBoundSCALValue represents the associate relperm or capillary pressure value
* @param imbibitionExtremaSCALValue represents the associate relperm or capillary pressure value
* @param drainageExtremaSCALValue represents the associate relperm or capillary pressure value
*/
struct HysteresisCurve
{
real64 oppositeBoundPhaseVolFraction = -1.;
real64 imbibitionExtremaPhaseVolFraction = -1.;
real64 drainageExtremaPhaseVolFraction = -1.;

real64 oppositeBoundSCALValue = -1.;
real64 imbibitionExtremaSCALValue = -1.;
real64 drainageExtremaSCALValue = -1.;
francoishamon marked this conversation as resolved.
Show resolved Hide resolved

HysteresisCurve() = default;

HysteresisCurve( std::pair< real64, real64 > const & opp, std::pair< real64, real64 > const & imbE, std::pair< real64, real64 > const & drainE )
{
setPoints( opp, imbE, drainE );
}

void setPoints( std::pair< real64, real64 > const & opp, std::pair< real64, real64 > const & imbE, std::pair< real64, real64 > const & drainE )
{
oppositeBoundPhaseVolFraction = opp.first;
imbibitionExtremaPhaseVolFraction = imbE.first;
drainageExtremaPhaseVolFraction = drainE.first;

oppositeBoundSCALValue = opp.second;
imbibitionExtremaSCALValue = imbE.second;
drainageExtremaSCALValue = drainE.second;
}
francoishamon marked this conversation as resolved.
Show resolved Hide resolved

GEOSX_HOST_DEVICE
inline bool isWetting() const
{
return ((drainageExtremaPhaseVolFraction > oppositeBoundPhaseVolFraction) ? PhaseWettability::WETTING : PhaseWettability::NONWETTING) == PhaseWettability::WETTING;
}
francoishamon marked this conversation as resolved.
Show resolved Hide resolved


bool isZero() const
{
return (oppositeBoundPhaseVolFraction <= 0.0) && (imbibitionExtremaPhaseVolFraction <= 0.0) && (drainageExtremaPhaseVolFraction <= 0.0);
francoishamon marked this conversation as resolved.
Show resolved Hide resolved
}

};

// void setRelPermParameters( real64 const & jerauldA, real64 const & jerauldB, real64 const & relpermCurv );
francoishamon marked this conversation as resolved.
Show resolved Hide resolved

static std::string catalogName() { return "KilloughHysteresis"; }

static void postProcessInput( real64 const & jerauldParam_a, real64 const & jerauldParam_b,
real64 const & killoughCurvatureParamRelPerm );

GEOSX_HOST_DEVICE
static void computeLandCoefficient( HysteresisCurve const & hcruve, real64 & landParam );
francoishamon marked this conversation as resolved.
Show resolved Hide resolved
/**
* @brief Function computing the trapped critical phase volume fraction
* @param[in] hcurve the hysteresis curve to be used and dispatched on
* @param[in] Shy the max historical phase volume fraction
* @param[in] landParam Land trapping parameter
* @param[in] jerauldParam_a jerauld expononent
* @param[in] jerauldParam_b jerauld expononent
* @param[out] Scrt the trapped critical phase volume fraction
*/
GEOSX_HOST_DEVICE
static void computeTrappedCriticalPhaseVolFraction( HysteresisCurve const & hcurve,
real64 const & Shy,
real64 const & landParam,
real64 const & jerauldParam_a,
real64 const & jerauldParam_b,
real64 & Scrt );

struct viewKeyStruct
{
static constexpr char const * jerauldParameterAString() { return "jerauldParameterA"; }
static constexpr char const * jerauldParameterBString() { return "jerauldParameterB"; }

static constexpr char const * killoughCurvatureParameterString() { return "killoughCurvatureParameter"; }
};

};

GEOSX_HOST_DEVICE
inline void KilloughHysteresis::computeLandCoefficient( KilloughHysteresis::HysteresisCurve const & hcurve,
real64 & landParam )
francoishamon marked this conversation as resolved.
Show resolved Hide resolved
{

// Note: for simplicity, the notations are taken from IX documentation (although this breaks our phaseVolFrac naming convention)

// Step 1: Land parameter for the wetting phase
if( hcurve.isWetting() )
{
real64 const Scrd = hcurve.oppositeBoundPhaseVolFraction;
real64 const Smxd = hcurve.drainageExtremaPhaseVolFraction;
real64 const Smxi = hcurve.imbibitionExtremaPhaseVolFraction;
real64 const Swc = Scrd;
GEOSX_ERROR_IF( (Smxi - Smxd) > 0,
GEOSX_FMT( "{}: For wetting phase hysteresis, imbibition end-point saturation Smxi( {} ) must be smaller than the drainage saturation end-point Smxd( {} ).\n"
"Crossing relative permeability curves.\n",
catalogName(),
Smxi,
Smxd ));

landParam = ( Smxd - Swc ) / LvArray::math::max( KilloughHysteresis::minScriMinusScrd, ( Smxd - Smxi ) ) - 1.0;
}
else
// Step 2: Land parameter for the non-wetting phase

{
real64 const Smx = hcurve.oppositeBoundPhaseVolFraction;
real64 const Scrd = hcurve.drainageExtremaPhaseVolFraction;
real64 const Scri = hcurve.imbibitionExtremaPhaseVolFraction;
GEOSX_ERROR_IF( (Scrd - Scri) > 0,
GEOSX_FMT( "{}: For non-wetting phase hysteresis, drainage trapped saturation Scrd( {} ) must be smaller than the imbibition saturation Scri( {} ).\n"
"Crossing relative permeability curves.\n",
catalogName(),
Scrd,
Scri ));

landParam = ( Smx - Scrd ) / LvArray::math::max( KilloughHysteresis::minScriMinusScrd, ( Scri - Scrd ) ) - 1.0;
}
}

GEOSX_HOST_DEVICE
inline void
KilloughHysteresis::
computeTrappedCriticalPhaseVolFraction( HysteresisCurve const & hcurve,
real64 const & Shy,
real64 const & landParam,
real64 const & jerauldParam_a,
real64 const & jerauldParam_b,
real64 & Scrt )
{

if( hcurve.isWetting())
{
//unpack values
real64 const Smxd = hcurve.drainageExtremaPhaseVolFraction;
real64 const Swc = hcurve.oppositeBoundPhaseVolFraction;

real64 const A = 1 + jerauldParam_a * (Shy - Swc);
real64 const numerator = Shy - Smxd;
real64 const denom = A + landParam * pow((Smxd - Shy) / (Smxd - Swc), 1 + jerauldParam_b / landParam );
Scrt = Smxd + numerator / denom;
}
else
{
//unpack values
real64 const Scrd = hcurve.drainageExtremaPhaseVolFraction;
real64 const Smx = hcurve.oppositeBoundPhaseVolFraction;

real64 const A = 1 + jerauldParam_a * (Smx - Shy);
real64 const numerator = Shy - Scrd;
real64 const denom = A + landParam * pow((Shy - Scrd) / (Smx - Scrd), 1 + jerauldParam_b / landParam );
Scrt = LvArray::math::max( 0.0,
Scrd + numerator / denom ); // trapped critical saturation from equation 2.162
}

}

}

}

#endif //GEOSX_KILLOUGHHYSTERESIS_HPP
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

#include "common/DataLayouts.hpp"
#include "constitutive/ConstitutiveBase.hpp"
#include "constitutive/capillaryPressure/layouts.hpp"
#include "constitutive/capillaryPressure/Layouts.hpp"
#include "common/GEOS_RAJA_Interface.hpp"

namespace geosx
Expand Down
francoishamon marked this conversation as resolved.
Show resolved Hide resolved
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#ifndef GEOSX_CONSTITUTIVE_CAPILLARYPRESSURE_CAPILLARYPRESSUREFIELDS_HPP_
#define GEOSX_CONSTITUTIVE_CAPILLARYPRESSURE_CAPILLARYPRESSUREFIELDS_HPP_

#include "constitutive/capillaryPressure/layouts.hpp"
#include "constitutive/capillaryPressure/Layouts.hpp"
#include "mesh/MeshFields.hpp"

namespace geosx
Expand Down
Loading