33 #include "opm/material/fluidsystems/blackoilpvt/NullOilPvt.hpp" 35 #include <opm/common/ErrorMacros.hpp> 36 #include <opm/common/TimingMacros.hpp> 37 #include <opm/common/utility/VectorWithDefaultAllocator.hpp> 38 #include <opm/common/utility/gpuDecorators.hpp> 49 #include <opm/material/fluidsystems/PhaseUsageInfo.hpp> 56 #include <string_view> 57 #include <type_traits> 71 template <
class Scalar,
class IndexTraits = BlackOilDefaultFluidSystemIndices,
72 template<
typename>
typename Storage = VectorWithDefaultAllocator>
82 using GasPvt = std::conditional_t<std::is_same_v<Storage<Scalar>, VectorWithDefaultAllocator<Scalar>>,
85 using OilPvt = std::conditional_t<std::is_same_v<Storage<Scalar>, VectorWithDefaultAllocator<Scalar>>,
88 using WaterPvt = std::conditional_t<std::is_same_v<Storage<Scalar>, VectorWithDefaultAllocator<Scalar>>,
91 using IndexTraitsType = IndexTraits;
93 #ifdef COMPILING_STATIC_FLUID_SYSTEM 94 template <
class EvaluationT>
98 using Evaluation = EvaluationT;
101 explicit ParameterCache(
unsigned regionIdx = 0)
102 : regionIdx_(regionIdx)
113 template <
class OtherCache>
114 void assignPersistentData(
const OtherCache& other)
116 regionIdx_ = other.regionIndex();
126 unsigned regionIndex()
const 127 {
return regionIdx_; }
136 void setRegionIndex(
unsigned val)
137 { regionIdx_ = val; }
146 template<
class EvaluationT>
147 using ParameterCache =
150 Storage>::template ParameterCache<EvaluationT>;
153 #ifndef COMPILING_STATIC_FLUID_SYSTEM 159 template<
template<
typename>
typename StorageT>
163 , reservoirTemperature_(other.reservoirTemperature_)
164 , gasPvt_(other.gasPvt_)
165 , oilPvt_(other.oilPvt_)
166 , waterPvt_(other.waterPvt_)
167 , enableDissolvedGas_(other.enableDissolvedGas_)
168 , enableDissolvedGasInWater_(other.enableDissolvedGasInWater_)
169 , enableVaporizedOil_(other.enableVaporizedOil_)
170 , enableVaporizedWater_(other.enableVaporizedWater_)
171 , enableDiffusion_(other.enableDiffusion_)
172 , referenceDensity_(StorageT<typename decltype(referenceDensity_)::value_type>(other.referenceDensity_))
173 , molarMass_(StorageT<typename decltype(molarMass_)::value_type>(other.molarMass_))
174 , diffusionCoefficients_(StorageT<typename decltype(diffusionCoefficients_)::value_type>(other.diffusionCoefficients_))
175 , phaseUsageInfo_(other.phaseUsageInfo_)
176 , isInitialized_(other.isInitialized_)
177 , useSaturatedTables_(other.useSaturatedTables_)
178 , enthalpy_eq_energy_(other.enthalpy_eq_energy_)
183 Scalar _surfaceTemperature_,
184 Scalar _reservoirTemperature_,
185 const GasPvt& _gasPvt_,
186 const OilPvt& _oilPvt_,
187 const WaterPvt& _waterPvt_,
188 bool _enableDissolvedGas_,
189 bool _enableDissolvedGasInWater_,
190 bool _enableVaporizedOil_,
191 bool _enableVaporizedWater_,
192 bool _enableConstantRs_,
193 bool _enableDiffusion_,
194 Storage<std::array<Scalar, 3>>&& _referenceDensity_,
195 Storage<std::array<Scalar, 3>>&& _molarMass_,
196 Storage<std::array<Scalar, 3 * 3>>&& _diffusionCoefficients_,
198 bool _isInitialized_,
199 bool _useSaturatedTables_,
200 bool _enthalpy_eq_energy_)
203 , reservoirTemperature_(_reservoirTemperature_)
206 , waterPvt_(_waterPvt_)
207 , enableDissolvedGas_(_enableDissolvedGas_)
208 , enableDissolvedGasInWater_(_enableDissolvedGasInWater_)
209 , enableVaporizedOil_(_enableVaporizedOil_)
210 , enableVaporizedWater_(_enableVaporizedWater_)
211 , enableConstantRs_(_enableConstantRs_)
212 , enableDiffusion_(_enableDiffusion_)
213 , referenceDensity_(
std::move(_referenceDensity_))
214 , molarMass_(
std::move(_molarMass_))
215 , diffusionCoefficients_(
std::move(_diffusionCoefficients_))
216 , phaseUsageInfo_(_phaseUsageInfo_)
217 , isInitialized_(_isInitialized_)
218 , useSaturatedTables_(_useSaturatedTables_)
219 , enthalpy_eq_energy_(_enthalpy_eq_energy_)
224 template <
class ScalarT,
class IndexTraitsT>
225 friend FLUIDSYSTEM_CLASSNAME<ScalarT, IndexTraitsT, gpuistl::GpuBuffer>
226 gpuistl::copy_to_gpu(
const FLUIDSYSTEM_CLASSNAME<ScalarT, IndexTraitsT>& oldFluidSystem);
228 template <
class ScalarT,
class IndexTraitsT>
229 friend FLUIDSYSTEM_CLASSNAME<ScalarT, IndexTraitsT, gpuistl::GpuView>
230 gpuistl::make_view(FLUIDSYSTEM_CLASSNAME<ScalarT, IndexTraitsT, gpuistl::GpuBuffer>& oldFluidSystem);
233 #endif // COMPILING_STATIC_FLUID_SYSTEM 235 #ifdef COMPILING_STATIC_FLUID_SYSTEM 243 template<
template<
typename>
typename StorageT = VectorWithDefaultAllocator>
244 static FLUIDSYSTEM_CLASSNAME_NONSTATIC<Scalar, IndexTraits, StorageT>& getNonStaticInstance()
246 static FLUIDSYSTEM_CLASSNAME_NONSTATIC<Scalar, IndexTraits, StorageT> instance{FLUIDSYSTEM_CLASSNAME<Scalar, IndexTraits, Storage>()};
253 instance = FLUIDSYSTEM_CLASSNAME_NONSTATIC<Scalar, IndexTraits, StorageT>(
254 FLUIDSYSTEM_CLASSNAME<Scalar, IndexTraits, Storage>());
266 STATIC_OR_NOTHING
void initFromState(
const EclipseState& eclState,
const Schedule& schedule);
276 STATIC_OR_NOTHING
void initBegin(std::size_t numPvtRegions);
285 { enableDissolvedGas_ = yesno; }
294 { enableVaporizedOil_ = yesno; }
303 { enableVaporizedWater_ = yesno; }
312 { enableDissolvedGasInWater_ = yesno; }
321 { enableConstantRs_ = yesno; }
329 { enableDiffusion_ = yesno; }
337 { useSaturatedTables_ = yesno; }
342 STATIC_OR_DEVICE
void setGasPvt(std::shared_ptr<GasPvt> pvtObj)
343 { gasPvt_ = *pvtObj; }
348 STATIC_OR_DEVICE
void setOilPvt(std::shared_ptr<OilPvt> pvtObj)
349 { oilPvt_ = *pvtObj; }
354 STATIC_OR_DEVICE
void setWaterPvt(std::shared_ptr<WaterPvt> pvtObj)
355 { waterPvt_ = *pvtObj; }
357 STATIC_OR_DEVICE
void setVapPars(
const Scalar par1,
const Scalar par2)
359 if (gasPvt_.isActive()) {
360 gasPvt_.setVapPars(par1, par2);
362 if (oilPvt_.isActive()) {
363 oilPvt_.setVapPars(par1, par2);
365 if (waterPvt_.isActive()) {
366 waterPvt_.setVapPars(par1, par2);
386 STATIC_OR_DEVICE
void initEnd();
388 STATIC_OR_DEVICE
bool isInitialized() NOTHING_OR_CONST
389 {
return isInitialized_; }
396 static constexpr
unsigned numPhases = IndexTraits::numPhases;
412 STATIC_OR_NOTHING std::string_view
phaseName(
unsigned phaseIdx) NOTHING_OR_CONST;
415 STATIC_OR_DEVICE
bool isLiquid(
unsigned phaseIdx) NOTHING_OR_CONST
439 {
return phaseUsageInfo_; }
443 {
return phaseUsageInfo_.numActivePhases(); }
448 return phaseUsageInfo_.phaseIsActive(phaseIdx);
458 STATIC_OR_NOTHING std::string_view
componentName(
unsigned compIdx) NOTHING_OR_CONST;
461 STATIC_OR_DEVICE
Scalar molarMass(
unsigned compIdx,
unsigned regionIdx = 0) NOTHING_OR_CONST
462 {
return molarMass_[regionIdx][compIdx]; }
490 {
return molarMass_.size(); }
499 {
return enableDissolvedGas_; }
509 {
return enableDissolvedGasInWater_; }
518 {
return enableVaporizedOil_; }
527 {
return enableVaporizedWater_; }
533 {
return enableConstantRs_; }
541 {
return enableDiffusion_; }
549 {
return useSaturatedTables_; }
557 {
return referenceDensity_[regionIdx][phaseIdx]; }
563 template <
class Flu
idState,
class LhsEval =
typename Flu
idState::ValueType,
class ParamCacheEval = LhsEval>
564 STATIC_OR_DEVICE LhsEval
density(
const FluidState& fluidState,
565 const ParameterCache<ParamCacheEval>& paramCache,
566 unsigned phaseIdx) NOTHING_OR_CONST
567 {
return density<FluidState, LhsEval>(fluidState, phaseIdx, paramCache.regionIndex()); }
570 template <
class Flu
idState,
class LhsEval =
typename Flu
idState::ValueType,
class ParamCacheEval = LhsEval>
572 const ParameterCache<ParamCacheEval>& paramCache,
574 unsigned compIdx) NOTHING_OR_CONST
576 return fugacityCoefficient<FluidState, LhsEval>(fluidState,
579 paramCache.regionIndex());
583 template <
class Flu
idState,
class LhsEval =
typename Flu
idState::ValueType,
class ParamCacheEval = LhsEval>
584 STATIC_OR_DEVICE LhsEval
viscosity(
const FluidState& fluidState,
585 const ParameterCache<ParamCacheEval>& paramCache,
586 unsigned phaseIdx) NOTHING_OR_CONST
587 {
return viscosity<FluidState, LhsEval>(fluidState, phaseIdx, paramCache.regionIndex()); }
590 template <
class Flu
idState,
class LhsEval =
typename Flu
idState::ValueType,
class ParamCacheEval = LhsEval>
591 STATIC_OR_DEVICE LhsEval
enthalpy(
const FluidState& fluidState,
592 const ParameterCache<ParamCacheEval>& paramCache,
594 {
return enthalpy<FluidState, LhsEval>(fluidState, phaseIdx, paramCache.regionIndex()); }
596 template <
class Flu
idState,
class LhsEval =
typename Flu
idState::ValueType,
class ParamCacheEval = LhsEval>
597 STATIC_OR_DEVICE LhsEval internalEnergy(
const FluidState& fluidState,
598 const ParameterCache<ParamCacheEval>& paramCache,
599 unsigned phaseIdx) NOTHING_OR_CONST
600 {
return internalEnergy<FluidState, LhsEval>(fluidState, phaseIdx, paramCache.regionIndex()); }
607 template <
class Flu
idState,
class LhsEval =
typename Flu
idState::ValueType>
608 STATIC_OR_DEVICE LhsEval
density(
const FluidState& fluidState,
610 unsigned regionIdx) NOTHING_OR_CONST
615 const LhsEval& p = decay<LhsEval>(fluidState.pressure(phaseIdx));
616 const LhsEval& T = decay<LhsEval>(fluidState.temperature(phaseIdx));
617 const LhsEval& saltConcentration = BlackOil::template getSaltConcentration_<FluidState, LhsEval>(fluidState, regionIdx);
623 const LhsEval& Rs = oilPvt_.saturatedGasDissolutionFactor(regionIdx, T, p);
624 const LhsEval& bo = oilPvt_.inverseFormationVolumeFactor(regionIdx, T, p, Rs);
633 const LhsEval& Rs = BlackOil::template getRs_<ThisType, FluidState, LhsEval>(fluidState, regionIdx);
634 const LhsEval& bo = oilPvt_.inverseFormationVolumeFactor(regionIdx, T, p, Rs);
642 const LhsEval Rs(0.0);
643 const auto& bo = oilPvt_.inverseFormationVolumeFactor(regionIdx, T, p, Rs);
651 const LhsEval& Rv = BlackOil::template getRv_<ThisType, FluidState, LhsEval>(fluidState, regionIdx);
652 const LhsEval& Rvw = BlackOil::template getRvw_<ThisType, FluidState, LhsEval>(fluidState, regionIdx);
653 const LhsEval& bg = gasPvt_.inverseFormationVolumeFactor(regionIdx, T, p, Rv, Rvw);
662 const LhsEval Rvw(0.0);
663 const LhsEval& Rv = BlackOil::template getRv_<ThisType, FluidState, LhsEval>(fluidState, regionIdx);
664 const LhsEval& bg = gasPvt_.inverseFormationVolumeFactor(regionIdx, T, p, Rv, Rvw);
672 const LhsEval Rv(0.0);
673 const LhsEval& Rvw = BlackOil::template getRvw_<ThisType, FluidState, LhsEval>(fluidState, regionIdx);
674 const LhsEval& bg = gasPvt_.inverseFormationVolumeFactor(regionIdx, T, p, Rv, Rvw);
682 const LhsEval Rv(0.0);
683 const LhsEval Rvw(0.0);
684 const auto& bg = gasPvt_.inverseFormationVolumeFactor(regionIdx, T, p, Rv, Rvw);
691 const LhsEval& Rsw =BlackOil::template getRsw_<ThisType, FluidState, LhsEval>(fluidState, regionIdx);
692 const LhsEval& bw = waterPvt_.inverseFormationVolumeFactor(regionIdx, T, p, Rsw, saltConcentration);
697 const LhsEval Rsw(0.0);
700 * waterPvt_.inverseFormationVolumeFactor(regionIdx, T, p, Rsw, saltConcentration);
703 OPM_THROW(std::logic_error,
"Unhandled phase index " + std::to_string(phaseIdx));
715 template <
class Flu
idState,
class LhsEval =
typename Flu
idState::ValueType>
718 unsigned regionIdx) NOTHING_OR_CONST
723 const auto& p = fluidState.pressure(phaseIdx);
724 const auto& T = fluidState.temperature(phaseIdx);
730 const LhsEval& Rs = oilPvt_.saturatedGasDissolutionFactor(regionIdx, T, p);
731 const LhsEval& bo = oilPvt_.inverseFormationVolumeFactor(regionIdx, T, p, Rs);
740 const LhsEval& Rs = saturatedDissolutionFactor<FluidState, LhsEval>(fluidState,
oilPhaseIdx, regionIdx);
741 const LhsEval& bo = oilPvt_.inverseFormationVolumeFactor(regionIdx, T, p, Rs);
749 const LhsEval Rs(0.0);
750 const LhsEval& bo = oilPvt_.inverseFormationVolumeFactor(regionIdx, T, p, Rs);
757 const LhsEval& Rv = saturatedDissolutionFactor<FluidState, LhsEval>(fluidState,
gasPhaseIdx, regionIdx);
758 const LhsEval& Rvw = saturatedVaporizationFactor<FluidState, LhsEval>(fluidState,
gasPhaseIdx, regionIdx);
759 const LhsEval& bg = gasPvt_.inverseFormationVolumeFactor(regionIdx, T, p, Rv, Rvw);
769 const LhsEval Rvw(0.0);
770 const LhsEval& Rv = saturatedDissolutionFactor<FluidState, LhsEval>(fluidState,
gasPhaseIdx, regionIdx);
771 const LhsEval& bg = gasPvt_.inverseFormationVolumeFactor(regionIdx, T, p, Rv, Rvw);
780 const LhsEval Rv(0.0);
781 const LhsEval& Rvw = saturatedVaporizationFactor<FluidState, LhsEval>(fluidState,
gasPhaseIdx, regionIdx);
782 const LhsEval& bg = gasPvt_.inverseFormationVolumeFactor(regionIdx, T, p, Rv, Rvw);
790 const LhsEval Rv(0.0);
791 const LhsEval Rvw(0.0);
792 const LhsEval& bg = gasPvt_.inverseFormationVolumeFactor(regionIdx, T, p, Rv, Rvw);
802 const auto& saltConcentration = decay<LhsEval>(fluidState.saltConcentration());
803 const LhsEval& Rsw = saturatedDissolutionFactor<FluidState, LhsEval>(fluidState,
waterPhaseIdx, regionIdx);
804 const LhsEval& bw = waterPvt_.inverseFormationVolumeFactor(regionIdx, T, p, Rsw, saltConcentration);
811 *inverseFormationVolumeFactor<FluidState, LhsEval>(fluidState,
waterPhaseIdx, regionIdx);
815 OPM_THROW(std::logic_error,
"Unhandled phase index " + std::to_string(phaseIdx));
826 template <
class Flu
idState,
class LhsEval =
typename Flu
idState::ValueType>
829 unsigned regionIdx) NOTHING_OR_CONST
835 const auto& p = decay<LhsEval>(fluidState.pressure(phaseIdx));
836 const auto& T = decay<LhsEval>(fluidState.temperature(phaseIdx));
841 const auto& Rs = BlackOil::template getRs_<ThisType, FluidState, LhsEval>(fluidState, regionIdx);
843 && Rs >= (1.0 - 1e-10)*oilPvt_.saturatedGasDissolutionFactor(regionIdx, scalarValue(T), scalarValue(p)))
845 return oilPvt_.saturatedInverseFormationVolumeFactor(regionIdx, T, p);
847 return oilPvt_.inverseFormationVolumeFactor(regionIdx, T, p, Rs);
851 const LhsEval Rs(0.0);
852 return oilPvt_.inverseFormationVolumeFactor(regionIdx, T, p, Rs);
856 const auto& Rvw = BlackOil::template getRvw_<ThisType, FluidState, LhsEval>(fluidState, regionIdx);
857 const auto& Rv = BlackOil::template getRv_<ThisType, FluidState, LhsEval>(fluidState, regionIdx);
859 && Rvw >= (1.0 - 1e-10)*gasPvt_.saturatedWaterVaporizationFactor(regionIdx, scalarValue(T), scalarValue(p))
861 && Rv >= (1.0 - 1e-10)*gasPvt_.saturatedOilVaporizationFactor(regionIdx, scalarValue(T), scalarValue(p)))
863 return gasPvt_.saturatedInverseFormationVolumeFactor(regionIdx, T, p);
865 return gasPvt_.inverseFormationVolumeFactor(regionIdx, T, p, Rv, Rvw);
870 const auto& Rv = BlackOil::template getRv_<ThisType, FluidState, LhsEval>(fluidState, regionIdx);
872 && Rv >= (1.0 - 1e-10)*gasPvt_.saturatedOilVaporizationFactor(regionIdx, scalarValue(T), scalarValue(p)))
874 return gasPvt_.saturatedInverseFormationVolumeFactor(regionIdx, T, p);
876 const LhsEval Rvw(0.0);
877 return gasPvt_.inverseFormationVolumeFactor(regionIdx, T, p, Rv, Rvw);
882 const auto& Rvw = BlackOil::template getRvw_<ThisType, FluidState, LhsEval>(fluidState, regionIdx);
884 && Rvw >= (1.0 - 1e-10)*gasPvt_.saturatedWaterVaporizationFactor(regionIdx, scalarValue(T), scalarValue(p)))
886 return gasPvt_.saturatedInverseFormationVolumeFactor(regionIdx, T, p);
888 const LhsEval Rv(0.0);
889 return gasPvt_.inverseFormationVolumeFactor(regionIdx, T, p, Rv, Rvw);
893 const LhsEval Rv(0.0);
894 const LhsEval Rvw(0.0);
895 return gasPvt_.inverseFormationVolumeFactor(regionIdx, T, p, Rv, Rvw);
899 const auto& saltConcentration = BlackOil::template getSaltConcentration_<FluidState, LhsEval>(fluidState, regionIdx);
901 const auto& Rsw = BlackOil::template getRsw_<ThisType, FluidState, LhsEval>(fluidState, regionIdx);
903 && Rsw >= (1.0 - 1e-10)*waterPvt_.saturatedGasDissolutionFactor(regionIdx, scalarValue(T), scalarValue(p), scalarValue(saltConcentration)))
905 return waterPvt_.saturatedInverseFormationVolumeFactor(regionIdx, T, p, saltConcentration);
907 return waterPvt_.inverseFormationVolumeFactor(regionIdx, T, p, Rsw, saltConcentration);
910 const LhsEval Rsw(0.0);
911 return waterPvt_.inverseFormationVolumeFactor(regionIdx, T, p, Rsw, saltConcentration);
913 default: OPM_THROW(std::logic_error,
"Unhandled phase index " + std::to_string(phaseIdx));
917 template <
class Flu
idState,
class LhsEval =
typename Flu
idState::ValueType>
918 STATIC_OR_DEVICE std::pair<LhsEval, LhsEval>
919 inverseFormationVolumeFactorAndViscosity(
const FluidState& fluidState,
921 unsigned regionIdx) NOTHING_OR_CONST
925 return oilPvt_.inverseFormationVolumeFactorAndViscosity(fluidState, regionIdx);
927 return gasPvt_.inverseFormationVolumeFactorAndViscosity(fluidState, regionIdx);
929 return waterPvt_.inverseFormationVolumeFactorAndViscosity(fluidState, regionIdx);
931 OPM_THROW(std::logic_error,
"Unhandled phase index " + std::to_string(phaseIdx));
944 template <
class Flu
idState,
class LhsEval =
typename Flu
idState::ValueType>
947 unsigned regionIdx) NOTHING_OR_CONST
953 const auto& p = decay<LhsEval>(fluidState.pressure(phaseIdx));
954 const auto& T = decay<LhsEval>(fluidState.temperature(phaseIdx));
955 const auto& saltConcentration = BlackOil::template getSaltConcentration_<FluidState, LhsEval>(fluidState, regionIdx);
958 case oilPhaseIdx:
return oilPvt_.saturatedInverseFormationVolumeFactor(regionIdx, T, p);
959 case gasPhaseIdx:
return gasPvt_.saturatedInverseFormationVolumeFactor(regionIdx, T, p);
960 case waterPhaseIdx:
return waterPvt_.saturatedInverseFormationVolumeFactor(regionIdx, T, p, saltConcentration);
961 default: OPM_THROW(std::logic_error,
"Unhandled phase index " + std::to_string(phaseIdx));
966 template <
class Flu
idState,
class LhsEval =
typename Flu
idState::ValueType>
970 unsigned regionIdx) NOTHING_OR_CONST
976 const auto& p = decay<LhsEval>(fluidState.pressure(phaseIdx));
977 const auto& T = decay<LhsEval>(fluidState.temperature(phaseIdx));
982 const LhsEval phi_oO = 20e3/p;
985 constexpr
const Scalar phi_gG = 1.0;
989 const LhsEval phi_wW = 30e3/p;
1007 const auto& R_vSat = gasPvt_.saturatedOilVaporizationFactor(regionIdx, T, p);
1011 const auto& R_sSat = oilPvt_.saturatedGasDissolutionFactor(regionIdx, T, p);
1014 const auto& x_oOSat = 1.0 - x_oGSat;
1016 const auto& p_o = decay<LhsEval>(fluidState.pressure(
oilPhaseIdx));
1017 const auto& p_g = decay<LhsEval>(fluidState.pressure(
gasPhaseIdx));
1019 return phi_oO*p_o*x_oOSat / (p_g*x_gOSat);
1027 throw std::logic_error(
"Invalid component index "+std::to_string(compIdx));
1043 const auto& R_vSat = gasPvt_.saturatedOilVaporizationFactor(regionIdx, T, p);
1046 const auto& x_gGSat = 1.0 - x_gOSat;
1048 const auto& R_sSat = oilPvt_.saturatedGasDissolutionFactor(regionIdx, T, p);
1052 const auto& p_o = decay<LhsEval>(fluidState.pressure(
oilPhaseIdx));
1053 const auto& p_g = decay<LhsEval>(fluidState.pressure(
gasPhaseIdx));
1055 return phi_gG*p_g*x_gGSat / (p_o*x_oGSat);
1062 throw std::logic_error(
"Invalid component index "+std::to_string(compIdx));
1077 throw std::logic_error(
"Invalid component index "+std::to_string(compIdx));
1081 throw std::logic_error(
"Invalid phase index "+std::to_string(phaseIdx));
1084 OPM_THROW(std::logic_error,
"Unhandled phase or component index");
1088 template <
class Flu
idState,
class LhsEval =
typename Flu
idState::ValueType>
1089 STATIC_OR_DEVICE LhsEval
viscosity(
const FluidState& fluidState,
1091 unsigned regionIdx) NOTHING_OR_CONST
1093 OPM_TIMEBLOCK_LOCAL(
viscosity, Subsystem::PvtProps);
1097 const LhsEval& p = decay<LhsEval>(fluidState.pressure(phaseIdx));
1098 const LhsEval& T = decay<LhsEval>(fluidState.temperature(phaseIdx));
1103 const auto& Rs = BlackOil::template getRs_<ThisType, FluidState, LhsEval>(fluidState, regionIdx);
1105 && Rs >= (1.0 - 1e-10)*oilPvt_.saturatedGasDissolutionFactor(regionIdx, scalarValue(T), scalarValue(p)))
1107 return oilPvt_.saturatedViscosity(regionIdx, T, p);
1109 return oilPvt_.viscosity(regionIdx, T, p, Rs);
1113 const LhsEval Rs(0.0);
1114 return oilPvt_.viscosity(regionIdx, T, p, Rs);
1119 const auto& Rvw = BlackOil::template getRvw_<ThisType, FluidState, LhsEval>(fluidState, regionIdx);
1120 const auto& Rv = BlackOil::template getRv_<ThisType, FluidState, LhsEval>(fluidState, regionIdx);
1122 && Rvw >= (1.0 - 1e-10)*gasPvt_.saturatedWaterVaporizationFactor(regionIdx, scalarValue(T), scalarValue(p))
1124 && Rv >= (1.0 - 1e-10)*gasPvt_.saturatedOilVaporizationFactor(regionIdx, scalarValue(T), scalarValue(p)))
1126 return gasPvt_.saturatedViscosity(regionIdx, T, p);
1128 return gasPvt_.viscosity(regionIdx, T, p, Rv, Rvw);
1132 const auto& Rv = BlackOil::template getRv_<ThisType, FluidState, LhsEval>(fluidState, regionIdx);
1134 && Rv >= (1.0 - 1e-10)*gasPvt_.saturatedOilVaporizationFactor(regionIdx, scalarValue(T), scalarValue(p)))
1136 return gasPvt_.saturatedViscosity(regionIdx, T, p);
1138 const LhsEval Rvw(0.0);
1139 return gasPvt_.viscosity(regionIdx, T, p, Rv, Rvw);
1143 const auto& Rvw = BlackOil::template getRvw_<ThisType, FluidState, LhsEval>(fluidState, regionIdx);
1145 && Rvw >= (1.0 - 1e-10)*gasPvt_.saturatedWaterVaporizationFactor(regionIdx, scalarValue(T), scalarValue(p)))
1147 return gasPvt_.saturatedViscosity(regionIdx, T, p);
1149 const LhsEval Rv(0.0);
1150 return gasPvt_.viscosity(regionIdx, T, p, Rv, Rvw);
1154 const LhsEval Rv(0.0);
1155 const LhsEval Rvw(0.0);
1156 return gasPvt_.viscosity(regionIdx, T, p, Rv, Rvw);
1161 const LhsEval& saltConcentration = BlackOil::template getSaltConcentration_<FluidState, LhsEval>(fluidState, regionIdx);
1163 const auto& Rsw = BlackOil::template getRsw_<ThisType, FluidState, LhsEval>(fluidState, regionIdx);
1165 && Rsw >= (1.0 - 1e-10)*waterPvt_.saturatedGasDissolutionFactor(regionIdx, scalarValue(T), scalarValue(p), scalarValue(saltConcentration)))
1167 return waterPvt_.saturatedViscosity(regionIdx, T, p, saltConcentration);
1169 return waterPvt_.viscosity(regionIdx, T, p, Rsw, saltConcentration);
1172 const LhsEval Rsw(0.0);
1173 return waterPvt_.viscosity(regionIdx, T, p, Rsw, saltConcentration);
1177 OPM_THROW(std::logic_error,
"Unhandled phase index "+std::to_string(phaseIdx));
1180 template <
class Flu
idState,
class LhsEval =
typename Flu
idState::ValueType>
1181 STATIC_OR_DEVICE LhsEval internalEnergy(
const FluidState& fluidState,
1182 const unsigned phaseIdx,
1183 const unsigned regionIdx) NOTHING_OR_CONST
1185 const auto p = decay<LhsEval>(fluidState.pressure(phaseIdx));
1186 const auto T = decay<LhsEval>(fluidState.temperature(phaseIdx));
1190 if (!oilPvt_.mixingEnergy()) {
1191 return oilPvt_.internalEnergy
1193 BlackOil::template getRs_<ThisType, FluidState, LhsEval>(fluidState, regionIdx));
1198 if (!waterPvt_.mixingEnergy()) {
1199 return waterPvt_.internalEnergy
1201 BlackOil::template getRsw_<ThisType, FluidState, LhsEval>(fluidState, regionIdx),
1202 BlackOil::template getSaltConcentration_<FluidState, LhsEval>(fluidState, regionIdx));
1207 if (!gasPvt_.mixingEnergy()) {
1208 return gasPvt_.internalEnergy
1210 BlackOil::template getRv_<ThisType, FluidState, LhsEval>(fluidState, regionIdx),
1211 BlackOil::template getRvw_<ThisType, FluidState, LhsEval>(fluidState, regionIdx));
1216 OPM_THROW(std::logic_error,
1217 "Phase index " + std::to_string(phaseIdx) +
1218 " does not support internal energy");
1221 return internalMixingTotalEnergy<FluidState,LhsEval>(fluidState, phaseIdx, regionIdx)
1222 / density<FluidState,LhsEval>(fluidState, phaseIdx, regionIdx);
1226 template <
class Flu
idState,
class LhsEval =
typename Flu
idState::ValueType>
1227 STATIC_OR_DEVICE LhsEval internalMixingTotalEnergy(
const FluidState& fluidState,
1229 unsigned regionIdx) NOTHING_OR_CONST
1233 const LhsEval& p = decay<LhsEval>(fluidState.pressure(phaseIdx));
1234 const LhsEval& T = decay<LhsEval>(fluidState.temperature(phaseIdx));
1235 const LhsEval& saltConcentration = BlackOil::template getSaltConcentration_<FluidState, LhsEval>(fluidState, regionIdx);
1239 auto oilEnergy = oilPvt_.internalEnergy(regionIdx, T, p,
1240 BlackOil::template getRs_<ThisType, FluidState, LhsEval>(fluidState, regionIdx));
1241 assert(oilPvt_.mixingEnergy());
1245 const LhsEval& Rs = BlackOil::template getRs_<ThisType, FluidState, LhsEval>(fluidState, regionIdx);
1246 const LhsEval& bo = oilPvt_.inverseFormationVolumeFactor(regionIdx, T, p, Rs);
1247 const auto& gasEnergy =
1248 gasPvt_.internalEnergy(regionIdx, T, p,
1249 BlackOil::template getRv_<ThisType, FluidState, LhsEval>(fluidState, regionIdx),
1250 BlackOil::template getRvw_<ThisType, FluidState, LhsEval>(fluidState, regionIdx));
1251 const auto hVapG = gasPvt_.hVap(regionIdx);
1258 const LhsEval Rs(0.0);
1259 const auto& bo = oilPvt_.inverseFormationVolumeFactor(regionIdx, T, p, Rs);
1265 const auto& gasEnergy =
1266 gasPvt_.internalEnergy(regionIdx, T, p,
1267 BlackOil::template getRv_<ThisType, FluidState, LhsEval>(fluidState, regionIdx),
1268 BlackOil::template getRvw_<ThisType, FluidState, LhsEval>(fluidState, regionIdx));
1269 assert(gasPvt_.mixingEnergy());
1271 const auto& oilEnergy =
1272 oilPvt_.internalEnergy(regionIdx, T, p,
1273 BlackOil::template getRs_<ThisType, FluidState, LhsEval>(fluidState, regionIdx));
1274 const auto waterEnergy =
1275 waterPvt_.internalEnergy(regionIdx, T, p,
1276 BlackOil::template getRsw_<ThisType, FluidState, LhsEval>(fluidState, regionIdx),
1277 BlackOil::template getSaltConcentration_<FluidState, LhsEval>(fluidState, regionIdx));
1279 const LhsEval& Rv = BlackOil::template getRv_<ThisType, FluidState, LhsEval>(fluidState, regionIdx);
1280 const LhsEval& Rvw = BlackOil::template getRvw_<ThisType, FluidState, LhsEval>(fluidState, regionIdx);
1281 const LhsEval& bg = gasPvt_.inverseFormationVolumeFactor(regionIdx, T, p, Rv, Rvw);
1282 const auto hVapO = oilPvt_.hVap(regionIdx);
1283 const auto hVapW = waterPvt_.hVap(regionIdx);
1290 const auto& oilEnergy =
1291 oilPvt_.internalEnergy(regionIdx, T, p,
1292 BlackOil::template getRs_<ThisType, FluidState, LhsEval>(fluidState, regionIdx));
1294 const LhsEval Rvw(0.0);
1295 const LhsEval& Rv = BlackOil::template getRv_<ThisType, FluidState, LhsEval>(fluidState, regionIdx);
1296 const LhsEval& bg = gasPvt_.inverseFormationVolumeFactor(regionIdx, T, p, Rv, Rvw);
1297 const auto hVapO = oilPvt_.hVap(regionIdx);
1304 const LhsEval Rv(0.0);
1305 const LhsEval& Rvw = BlackOil::template getRvw_<ThisType, FluidState, LhsEval>(fluidState, regionIdx);
1306 const LhsEval& bg = gasPvt_.inverseFormationVolumeFactor(regionIdx, T, p, Rv, Rvw);
1307 const auto waterEnergy =
1308 waterPvt_.internalEnergy(regionIdx, T, p,
1309 BlackOil::template getRsw_<ThisType, FluidState, LhsEval>(fluidState, regionIdx),
1310 BlackOil::template getSaltConcentration_<FluidState, LhsEval>(fluidState, regionIdx));
1311 const auto hVapW = waterPvt_.hVap(regionIdx);
1318 const LhsEval Rv(0.0);
1319 const LhsEval Rvw(0.0);
1320 const auto& bg = gasPvt_.inverseFormationVolumeFactor(regionIdx, T, p, Rv, Rvw);
1325 const auto waterEnergy =
1326 waterPvt_.internalEnergy(regionIdx, T, p,
1327 BlackOil::template getRsw_<ThisType, FluidState, LhsEval>(fluidState, regionIdx),
1328 BlackOil::template getSaltConcentration_<FluidState, LhsEval>(fluidState, regionIdx));
1329 assert(waterPvt_.mixingEnergy());
1331 const auto& gasEnergy =
1332 gasPvt_.internalEnergy(regionIdx, T, p,
1333 BlackOil::template getRv_<ThisType, FluidState, LhsEval>(fluidState, regionIdx),
1334 BlackOil::template getRvw_<ThisType, FluidState, LhsEval>(fluidState, regionIdx));
1336 const LhsEval& Rsw = saturatedDissolutionFactor<FluidState, LhsEval>(fluidState,
waterPhaseIdx, regionIdx);
1337 const LhsEval& bw = waterPvt_.inverseFormationVolumeFactor(regionIdx, T, p, Rsw, saltConcentration);
1342 const LhsEval Rsw(0.0);
1345 * waterPvt_.inverseFormationVolumeFactor(regionIdx, T, p, Rsw, saltConcentration);
1347 OPM_THROW(std::logic_error,
"Unhandled phase index " + std::to_string(phaseIdx));
1353 template <
class Flu
idState,
class LhsEval =
typename Flu
idState::ValueType>
1354 STATIC_OR_DEVICE LhsEval
enthalpy(
const FluidState& fluidState,
1356 unsigned regionIdx) NOTHING_OR_CONST
1359 const auto& p = decay<LhsEval>(fluidState.pressure(phaseIdx));
1360 auto energy = internalEnergy<FluidState, LhsEval>(fluidState, phaseIdx, regionIdx);
1361 if(!enthalpy_eq_energy_){
1363 energy += p/density<FluidState, LhsEval>(fluidState, phaseIdx, regionIdx);
1374 template <
class Flu
idState,
class LhsEval =
typename Flu
idState::ValueType>
1377 unsigned regionIdx) NOTHING_OR_CONST
1382 const auto& p = decay<LhsEval>(fluidState.pressure(phaseIdx));
1383 const auto& T = decay<LhsEval>(fluidState.temperature(phaseIdx));
1384 const auto& saltConcentration = decay<LhsEval>(fluidState.saltConcentration());
1388 case gasPhaseIdx:
return gasPvt_.saturatedWaterVaporizationFactor(regionIdx, T, p, saltConcentration);
1391 OPM_THROW(std::logic_error,
"Unhandled phase index " + std::to_string(phaseIdx));
1401 template <
class Flu
idState,
class LhsEval =
typename Flu
idState::ValueType>
1405 const LhsEval& maxOilSaturation) NOTHING_OR_CONST
1411 const auto& p = decay<LhsEval>(fluidState.pressure(phaseIdx));
1412 const auto& T = decay<LhsEval>(fluidState.temperature(phaseIdx));
1416 case oilPhaseIdx:
return oilPvt_.saturatedGasDissolutionFactor(regionIdx, T, p, So, maxOilSaturation);
1417 case gasPhaseIdx:
return gasPvt_.saturatedOilVaporizationFactor(regionIdx, T, p, So, maxOilSaturation);
1418 case waterPhaseIdx:
return waterPvt_.saturatedGasDissolutionFactor(regionIdx, T, p,
1419 BlackOil::template getSaltConcentration_<FluidState, LhsEval>(fluidState, regionIdx));
1420 default: OPM_THROW(std::logic_error,
"Unhandled phase index " + std::to_string(phaseIdx));
1432 template <
class Flu
idState,
class LhsEval =
typename Flu
idState::ValueType>
1435 unsigned regionIdx) NOTHING_OR_CONST
1441 const auto& p = decay<LhsEval>(fluidState.pressure(phaseIdx));
1442 const auto& T = decay<LhsEval>(fluidState.temperature(phaseIdx));
1445 case oilPhaseIdx:
return oilPvt_.saturatedGasDissolutionFactor(regionIdx, T, p);
1446 case gasPhaseIdx:
return gasPvt_.saturatedOilVaporizationFactor(regionIdx, T, p);
1447 case waterPhaseIdx:
return waterPvt_.saturatedGasDissolutionFactor(regionIdx, T, p,
1448 BlackOil::template getSaltConcentration_<FluidState, LhsEval>(fluidState, regionIdx));
1450 OPM_THROW(std::logic_error,
"Unhandled phase index " + std::to_string(phaseIdx));
1457 template <
class Flu
idState,
class LhsEval =
typename Flu
idState::ValueType>
1459 unsigned regionIdx) NOTHING_OR_CONST
1468 template <
class Flu
idState,
class LhsEval =
typename Flu
idState::ValueType>
1470 unsigned regionIdx) NOTHING_OR_CONST
1485 template <
class Flu
idState,
class LhsEval =
typename Flu
idState::ValueType>
1488 unsigned regionIdx) NOTHING_OR_CONST
1493 const auto& T = decay<LhsEval>(fluidState.temperature(phaseIdx));
1496 case oilPhaseIdx:
return oilPvt_.saturationPressure(regionIdx, T, BlackOil::template getRs_<ThisType, FluidState, LhsEval>(fluidState, regionIdx));
1497 case gasPhaseIdx:
return gasPvt_.saturationPressure(regionIdx, T, BlackOil::template getRv_<ThisType, FluidState, LhsEval>(fluidState, regionIdx));
1498 case waterPhaseIdx:
return waterPvt_.saturationPressure(regionIdx, T,
1499 BlackOil::template getRsw_<ThisType, FluidState, LhsEval>(fluidState, regionIdx),
1500 BlackOil::template getSaltConcentration_<FluidState, LhsEval>(fluidState, regionIdx));
1501 default: OPM_THROW(std::logic_error,
"Unhandled phase index " + std::to_string(phaseIdx));
1512 template <
class LhsEval>
1513 STATIC_OR_DEVICE LhsEval
convertXoGToRs(
const LhsEval& XoG,
unsigned regionIdx) NOTHING_OR_CONST
1518 return XoG/(1.0 - XoG)*(rho_oRef/rho_gRef);
1525 template <
class LhsEval>
1526 STATIC_OR_DEVICE LhsEval
convertXwGToRsw(
const LhsEval& XwG,
unsigned regionIdx) NOTHING_OR_CONST
1531 return XwG/(1.0 - XwG)*(rho_wRef/rho_gRef);
1538 template <
class LhsEval>
1539 STATIC_OR_DEVICE LhsEval
convertXgOToRv(
const LhsEval& XgO,
unsigned regionIdx) NOTHING_OR_CONST
1544 return XgO/(1.0 - XgO)*(rho_gRef/rho_oRef);
1551 template <
class LhsEval>
1552 STATIC_OR_DEVICE LhsEval
convertXgWToRvw(
const LhsEval& XgW,
unsigned regionIdx) NOTHING_OR_CONST
1557 return XgW/(1.0 - XgW)*(rho_gRef/rho_wRef);
1565 template <
class LhsEval>
1566 STATIC_OR_DEVICE LhsEval
convertRsToXoG(
const LhsEval& Rs,
unsigned regionIdx) NOTHING_OR_CONST
1571 const LhsEval& rho_oG = Rs*rho_gRef;
1572 return rho_oG/(rho_oRef + rho_oG);
1579 template <
class LhsEval>
1580 STATIC_OR_DEVICE LhsEval
convertRswToXwG(
const LhsEval& Rsw,
unsigned regionIdx) NOTHING_OR_CONST
1585 const LhsEval& rho_wG = Rsw*rho_gRef;
1586 return rho_wG/(rho_wRef + rho_wG);
1593 template <
class LhsEval>
1594 STATIC_OR_DEVICE LhsEval
convertRvToXgO(
const LhsEval& Rv,
unsigned regionIdx) NOTHING_OR_CONST
1599 const LhsEval& rho_gO = Rv*rho_oRef;
1600 return rho_gO/(rho_gRef + rho_gO);
1607 template <
class LhsEval>
1608 STATIC_OR_DEVICE LhsEval
convertRvwToXgW(
const LhsEval& Rvw,
unsigned regionIdx) NOTHING_OR_CONST
1613 const LhsEval& rho_gW = Rvw*rho_wRef;
1614 return rho_gW/(rho_gRef + rho_gW);
1620 template <
class LhsEval>
1621 STATIC_OR_DEVICE LhsEval
convertXgWToxgW(
const LhsEval& XgW,
unsigned regionIdx) NOTHING_OR_CONST
1626 return XgW*MG / (MW*(1 - XgW) + XgW*MG);
1632 template <
class LhsEval>
1633 STATIC_OR_DEVICE LhsEval
convertXwGToxwG(
const LhsEval& XwG,
unsigned regionIdx) NOTHING_OR_CONST
1638 return XwG*MW / (MG*(1 - XwG) + XwG*MW);
1644 template <
class LhsEval>
1645 STATIC_OR_DEVICE LhsEval
convertXoGToxoG(
const LhsEval& XoG,
unsigned regionIdx) NOTHING_OR_CONST
1650 return XoG*MO / (MG*(1 - XoG) + XoG*MO);
1656 template <
class LhsEval>
1657 STATIC_OR_DEVICE LhsEval
convertxoGToXoG(
const LhsEval& xoG,
unsigned regionIdx) NOTHING_OR_CONST
1662 return xoG*MG / (xoG*(MG - MO) + MO);
1668 template <
class LhsEval>
1669 STATIC_OR_DEVICE LhsEval
convertXgOToxgO(
const LhsEval& XgO,
unsigned regionIdx) NOTHING_OR_CONST
1674 return XgO*MG / (MO*(1 - XgO) + XgO*MG);
1680 template <
class LhsEval>
1681 STATIC_OR_DEVICE LhsEval
convertxgOToXgO(
const LhsEval& xgO,
unsigned regionIdx) NOTHING_OR_CONST
1686 return xgO*MO / (xgO*(MO - MG) + MG);
1696 STATIC_OR_DEVICE
const GasPvt&
gasPvt() NOTHING_OR_CONST
1706 STATIC_OR_DEVICE
const OilPvt&
oilPvt() NOTHING_OR_CONST
1716 STATIC_OR_DEVICE
const WaterPvt&
waterPvt() NOTHING_OR_CONST
1717 {
return waterPvt_; }
1725 {
return reservoirTemperature_; }
1733 { reservoirTemperature_ =
value; }
1735 STATIC_OR_DEVICE
short activeToCanonicalPhaseIdx(
unsigned activePhaseIdx) NOTHING_OR_CONST;
1737 STATIC_OR_DEVICE
short canonicalToActivePhaseIdx(
unsigned phaseIdx) NOTHING_OR_CONST;
1739 STATIC_OR_DEVICE
short activeToCanonicalCompIdx(
unsigned activeCompIdx) NOTHING_OR_CONST;
1741 STATIC_OR_DEVICE
short canonicalToActiveCompIdx(
unsigned compIdx) NOTHING_OR_CONST;
1743 STATIC_OR_DEVICE
short activePhaseToActiveCompIdx(
unsigned activePhaseIdx) NOTHING_OR_CONST;
1745 STATIC_OR_DEVICE
short activeCompToActivePhaseIdx(
unsigned activeCompIdx) NOTHING_OR_CONST;
1749 {
return diffusionCoefficients_[regionIdx][
numPhases*compIdx + phaseIdx]; }
1753 { diffusionCoefficients_[regionIdx][
numPhases*compIdx + phaseIdx] = coefficient ; }
1758 template <
class Flu
idState,
class LhsEval =
typename Flu
idState::ValueType,
class ParamCacheEval = LhsEval>
1760 const ParameterCache<ParamCacheEval>& paramCache,
1762 unsigned compIdx) NOTHING_OR_CONST
1769 if(!diffusionCoefficients_.empty()) {
1773 const auto& p = decay<LhsEval>(fluidState.pressure(phaseIdx));
1774 const auto& T = decay<LhsEval>(fluidState.temperature(phaseIdx));
1775 const unsigned regionIdx = paramCache.regionIndex();
1781 default: OPM_THROW(std::logic_error,
"Unhandled phase index " + std::to_string(phaseIdx));
1784 STATIC_OR_DEVICE
void setEnergyEqualEnthalpy(
bool enthalpy_eq_energy){
1785 enthalpy_eq_energy_ = enthalpy_eq_energy;
1788 STATIC_OR_DEVICE
bool enthalpyEqualEnergy() NOTHING_OR_CONST{
1789 return enthalpy_eq_energy_;
1793 STATIC_OR_NOTHING
void resizeArrays_(std::size_t
numRegions);
1795 STATIC_OR_NOTHING
Scalar reservoirTemperature_;
1797 STATIC_OR_NOTHING GasPvt gasPvt_;
1798 STATIC_OR_NOTHING OilPvt oilPvt_;
1799 STATIC_OR_NOTHING WaterPvt waterPvt_;
1801 STATIC_OR_NOTHING
bool enableDissolvedGas_;
1802 STATIC_OR_NOTHING
bool enableDissolvedGasInWater_;
1803 STATIC_OR_NOTHING
bool enableVaporizedOil_;
1804 STATIC_OR_NOTHING
bool enableVaporizedWater_;
1805 STATIC_OR_NOTHING
bool enableConstantRs_;
1806 STATIC_OR_NOTHING
bool enableDiffusion_;
1811 STATIC_OR_NOTHING Storage<std::array<
Scalar, 3> > referenceDensity_;
1812 STATIC_OR_NOTHING Storage<std::array<
Scalar, 3> > molarMass_;
1813 STATIC_OR_NOTHING Storage<std::array<
Scalar, 3 * 3> > diffusionCoefficients_;
1815 STATIC_OR_NOTHING PhaseUsageInfo<IndexTraits> phaseUsageInfo_;
1817 STATIC_OR_NOTHING
bool isInitialized_;
1818 STATIC_OR_NOTHING
bool useSaturatedTables_;
1819 STATIC_OR_NOTHING
bool enthalpy_eq_energy_;
1821 #ifndef COMPILING_STATIC_FLUID_SYSTEM 1822 template<
template<
typename>
typename StorageT>
1823 explicit FLUIDSYSTEM_CLASSNAME(
const FLUIDSYSTEM_CLASSNAME_STATIC<Scalar, IndexTraits, StorageT>& other)
1826 , reservoirTemperature_(other.reservoirTemperature_)
1827 , gasPvt_(other.gasPvt_)
1828 , oilPvt_(other.oilPvt_)
1829 , waterPvt_(other.waterPvt_)
1830 , enableDissolvedGas_(other.enableDissolvedGas_)
1831 , enableDissolvedGasInWater_(other.enableDissolvedGasInWater_)
1832 , enableVaporizedOil_(other.enableVaporizedOil_)
1833 , enableVaporizedWater_(other.enableVaporizedWater_)
1834 , enableConstantRs_(other.enableConstantRs_)
1835 , enableDiffusion_(other.enableDiffusion_)
1836 , referenceDensity_(StorageT<typename decltype(referenceDensity_)::value_type>(other.referenceDensity_))
1837 , molarMass_(StorageT<typename decltype(molarMass_)::value_type>(other.molarMass_))
1838 , diffusionCoefficients_(StorageT<typename decltype(diffusionCoefficients_)::value_type>(other.diffusionCoefficients_))
1839 , phaseUsageInfo_(other.phaseUsageInfo_)
1840 , isInitialized_(other.isInitialized_)
1841 , useSaturatedTables_(other.useSaturatedTables_)
1842 , enthalpy_eq_energy_(other.enthalpy_eq_energy_)
1844 OPM_ERROR_IF(!other.isInitialized(),
"The fluid system must be initialized before it can be copied.");
1847 template<
class ScalarT,
class IndexTraitsT,
template<
typename>
typename StorageT>
1848 friend class FLUIDSYSTEM_CLASSNAME_STATIC;
1850 template<
class ScalarT,
class IndexTraitsT,
template<
typename>
typename StorageT>
1851 friend class FLUIDSYSTEM_CLASSNAME_NONSTATIC;
1855 template <
class Scalar,
class IndexTraits,
template<
typename>
typename Storage>
1859 isInitialized_ =
false;
1860 useSaturatedTables_ =
true;
1862 enableDissolvedGas_ =
true;
1863 enableDissolvedGasInWater_ =
false;
1864 enableVaporizedOil_ =
false;
1865 enableVaporizedWater_ =
false;
1866 enableConstantRs_ =
false;
1867 enableDiffusion_ =
false;
1869 surfaceTemperature = 273.15 + 15.56;
1870 surfacePressure = 1.01325e5;
1871 setReservoirTemperature(surfaceTemperature);
1873 phaseUsageInfo_.initFromPhases(
Phases{
true,
true,
true});
1875 resizeArrays_(numPvtRegions);
1878 template <
class Scalar,
class IndexTraits,
template<
typename>
typename Storage>
1885 referenceDensity_[regionIdx][oilPhaseIdx] = rhoOil;
1886 referenceDensity_[regionIdx][waterPhaseIdx] = rhoWater;
1887 referenceDensity_[regionIdx][gasPhaseIdx] = rhoGas;
1890 template <
class Scalar,
class IndexTraits,
template<
typename>
typename Storage>
1894 const std::size_t num_regions = molarMass_.size();
1895 for (
unsigned regionIdx = 0; regionIdx < num_regions; ++regionIdx) {
1899 molarMass_[regionIdx][waterCompIdx] = 18e-3;
1901 if (phaseIsActive(gasPhaseIdx)) {
1903 Scalar p = surfacePressure;
1904 Scalar T = surfaceTemperature;
1905 Scalar rho_g = referenceDensity_[0][gasPhaseIdx];
1910 molarMass_[regionIdx][gasCompIdx] = 2e-3;
1913 molarMass_[regionIdx][oilCompIdx] = 175e-3;
1916 isInitialized_ =
true;
1919 template <
class Scalar,
class IndexTraits,
template<
typename>
typename Storage>
1932 OPM_THROW(std::logic_error,
"Phase index " + std::to_string(phaseIdx) +
" is unknown");
1936 template <
class Scalar,
class IndexTraits,
template<
typename>
typename Storage>
1942 return waterCompIdx;
1949 OPM_THROW(std::logic_error,
"Phase index " + std::to_string(phaseIdx) +
" is unknown");
1953 template <
class Scalar,
class IndexTraits,
template<
typename>
typename Storage>
1959 if (enableDissolvedGasInWater())
1961 OPM_THROW(std::logic_error,
"The water phase does not have any solutes in the black oil model!");
1965 if (enableVaporizedWater()) {
1966 return waterCompIdx;
1971 OPM_THROW(std::logic_error,
"Phase index " + std::to_string(phaseIdx) +
" is unknown");
1975 template <
class Scalar,
class IndexTraits,
template<
typename>
typename Storage>
1988 OPM_THROW(std::logic_error,
"Component index " + std::to_string(compIdx) +
" is unknown");
1992 template <
class Scalar,
class IndexTraits,
template<
typename>
typename Storage>
1996 return phaseUsageInfo_.activeToCanonicalPhaseIdx(activePhaseIdx);
1999 template <
class Scalar,
class IndexTraits,
template<
typename>
typename Storage>
2000 NOTHING_OR_DEVICE
short FLUIDSYSTEM_CLASSNAME<Scalar,IndexTraits, Storage>::
2001 canonicalToActivePhaseIdx(
unsigned phaseIdx) NOTHING_OR_CONST
2003 return phaseUsageInfo_.canonicalToActivePhaseIdx(phaseIdx);
2006 template <
class Scalar,
class IndexTraits,
template<
typename>
typename Storage>
2007 NOTHING_OR_DEVICE
short FLUIDSYSTEM_CLASSNAME<Scalar,IndexTraits, Storage>::
2008 activeToCanonicalCompIdx(
unsigned activeCompIdx) NOTHING_OR_CONST
2010 return phaseUsageInfo_.activeToCanonicalCompIdx(activeCompIdx);
2013 template <
class Scalar,
class IndexTraits,
template<
typename>
typename Storage>
2014 NOTHING_OR_DEVICE
short FLUIDSYSTEM_CLASSNAME<Scalar, IndexTraits, Storage>::
2015 canonicalToActiveCompIdx(
unsigned compIdx) NOTHING_OR_CONST
2017 return phaseUsageInfo_.canonicalToActiveCompIdx(compIdx);
2020 template <
class Scalar,
class IndexTraits,
template<
typename>
typename Storage>
2021 NOTHING_OR_DEVICE
short FLUIDSYSTEM_CLASSNAME<Scalar, IndexTraits, Storage>::
2022 activePhaseToActiveCompIdx(
unsigned activePhaseIdx) NOTHING_OR_CONST
2024 return phaseUsageInfo_.activePhaseToActiveCompIdx(activePhaseIdx);
2027 template <
class Scalar,
class IndexTraits,
template<
typename>
typename Storage>
2028 NOTHING_OR_DEVICE
short FLUIDSYSTEM_CLASSNAME<Scalar, IndexTraits, Storage>::
2029 activeCompToActivePhaseIdx(
unsigned activeCompIdx) NOTHING_OR_CONST
2031 return phaseUsageInfo_.activeCompToActivePhaseIdx(activeCompIdx);
2034 template <
class Scalar,
class IndexTraits,
template<
typename>
typename Storage>
2035 void FLUIDSYSTEM_CLASSNAME<Scalar,IndexTraits,Storage>::
2036 resizeArrays_(std::size_t numRegions)
2038 molarMass_.resize(numRegions);
2039 referenceDensity_.resize(numRegions);
2042 #ifdef COMPILING_STATIC_FLUID_SYSTEM 2043 template <
typename T>
using BOFS = FLUIDSYSTEM_CLASSNAME<T, BlackOilDefaultFluidSystemIndices, VectorWithDefaultAllocator>;
2045 #define DECLARE_INSTANCE(T) \ 2046 template<> PhaseUsageInfo<BlackOilDefaultFluidSystemIndices> BOFS<T>::phaseUsageInfo_;\ 2047 template<> T BOFS<T>::surfaceTemperature; \ 2048 template<> T BOFS<T>::surfacePressure; \ 2049 template<> T BOFS<T>::reservoirTemperature_; \ 2050 template<> bool BOFS<T>::enableDissolvedGas_; \ 2051 template<> bool BOFS<T>::enableDissolvedGasInWater_; \ 2052 template<> bool BOFS<T>::enableVaporizedOil_; \ 2053 template<> bool BOFS<T>::enableVaporizedWater_; \ 2054 template<> bool BOFS<T>::enableConstantRs_; \ 2055 template<> bool BOFS<T>::enableDiffusion_; \ 2056 template<> BOFS<T>::OilPvt BOFS<T>::oilPvt_; \ 2057 template<> BOFS<T>::GasPvt BOFS<T>::gasPvt_; \ 2058 template<> BOFS<T>::WaterPvt BOFS<T>::waterPvt_; \ 2059 template<> std::vector<std::array<T, 3>> BOFS<T>::referenceDensity_; \ 2060 template<> std::vector<std::array<T, 3>> BOFS<T>::molarMass_; \ 2061 template<> std::vector<std::array<T, 9>> BOFS<T>::diffusionCoefficients_; \ 2062 template<> bool BOFS<T>::isInitialized_; \ 2063 template<> bool BOFS<T>::useSaturatedTables_; \ 2064 template<> bool BOFS<T>::enthalpy_eq_energy_; 2066 DECLARE_INSTANCE(
float)
2067 DECLARE_INSTANCE(
double)
2069 #undef DECLARE_INSTANCE 2072 #ifndef COMPILING_STATIC_FLUID_SYSTEM 2077 template <
class Scalar,
class IndexTraits>
2078 FLUIDSYSTEM_CLASSNAME<Scalar, IndexTraits, GpuBuffer>
2079 copy_to_gpu(
const FLUIDSYSTEM_CLASSNAME<Scalar, IndexTraits>& oldFluidSystem) {
2081 using GpuBuffer3Array = GpuBuffer<std::array<Scalar, 3>>;
2082 using GpuBuffer9Array = GpuBuffer<std::array<Scalar, 9>>;
2084 OPM_ERROR_IF(oldFluidSystem.gasPvt_.approach() != GasPvtApproach::Co2Gas,
2085 fmt::format(fmt::runtime(
"Incompatible gas PVT approach. Given {}, expected {} (GasPvtApproach::Co2Gas)."),
2086 int(oldFluidSystem.gasPvt_.approach()),
int(GasPvtApproach::Co2Gas)));
2088 OPM_ERROR_IF(oldFluidSystem.waterPvt_.approach() != WaterPvtApproach::BrineCo2,
2089 fmt::format(fmt::runtime(
"Incompatible water PVT approach. Given {}, expected {} (WaterPvtApproach::BrineCo2)."),
2090 int(oldFluidSystem.waterPvt_.approach()),
int(WaterPvtApproach::BrineCo2)));
2092 OPM_ERROR_IF(oldFluidSystem.oilPvt_.isActive(),
2093 "We currently do not support an active oil phase for the FluidSystem on GPU.");
2095 auto newGasPvt =
copy_to_gpu(oldFluidSystem.gasPvt_.template getRealPvt<GasPvtApproach::Co2Gas>());
2097 auto newOilPvt = NullOilPvt<Scalar>();
2099 auto newWaterPvt =
copy_to_gpu(oldFluidSystem.waterPvt_.template getRealPvt<WaterPvtApproach::BrineCo2>());
2101 auto newReferenceDensity = GpuBuffer3Array(oldFluidSystem.referenceDensity_);
2102 auto newMolarMass = GpuBuffer3Array(oldFluidSystem.molarMass_);
2103 auto newDiffusionCoefficients = GpuBuffer9Array(oldFluidSystem.diffusionCoefficients_);
2105 return FLUIDSYSTEM_CLASSNAME<Scalar, IndexTraits, GpuBuffer>(
2106 oldFluidSystem.surfacePressure,
2107 oldFluidSystem.surfaceTemperature,
2108 oldFluidSystem.reservoirTemperature_,
2112 oldFluidSystem.enableDissolvedGas_,
2113 oldFluidSystem.enableDissolvedGasInWater_,
2114 oldFluidSystem.enableVaporizedOil_,
2115 oldFluidSystem.enableVaporizedWater_,
2116 oldFluidSystem.enableConstantRs_,
2117 oldFluidSystem.enableDiffusion_,
2118 std::move(newReferenceDensity),
2119 std::move(newMolarMass),
2120 std::move(newDiffusionCoefficients),
2121 oldFluidSystem.phaseUsageInfo_,
2122 oldFluidSystem.isInitialized_,
2123 oldFluidSystem.useSaturatedTables_,
2124 oldFluidSystem.enthalpy_eq_energy_
2128 template <
class Scalar,
class IndexTraits>
2129 FLUIDSYSTEM_CLASSNAME<Scalar, IndexTraits, GpuView>
2130 make_view(FLUIDSYSTEM_CLASSNAME<Scalar, IndexTraits, GpuBuffer>& oldFluidSystem)
2132 using Array3 = std::array<Scalar, 3>;
2133 using Array9 = std::array<Scalar, 9>;
2135 auto newGasPvt =
make_view(oldFluidSystem.gasPvt_);
2136 auto newOilPvt = NullOilPvt<Scalar>();
2137 auto newWaterPvt =
make_view(oldFluidSystem.waterPvt_);
2139 auto newReferenceDensity = make_view<Array3>(oldFluidSystem.referenceDensity_);
2140 auto newMolarMass = make_view<Array3>(oldFluidSystem.molarMass_);
2141 auto newDiffusionCoefficients = make_view<Array9>(oldFluidSystem.diffusionCoefficients_);
2143 return FLUIDSYSTEM_CLASSNAME<Scalar, IndexTraits, GpuView>(
2144 oldFluidSystem.surfacePressure,
2145 oldFluidSystem.surfaceTemperature,
2146 oldFluidSystem.reservoirTemperature_,
2150 oldFluidSystem.enableDissolvedGas_,
2151 oldFluidSystem.enableDissolvedGasInWater_,
2152 oldFluidSystem.enableVaporizedOil_,
2153 oldFluidSystem.enableVaporizedWater_,
2154 oldFluidSystem.enableConstantRs_,
2155 oldFluidSystem.enableDiffusion_,
2156 std::move(newReferenceDensity),
2157 std::move(newMolarMass),
2158 std::move(newDiffusionCoefficients),
2159 oldFluidSystem.phaseUsageInfo_,
2160 oldFluidSystem.isInitialized_,
2161 oldFluidSystem.useSaturatedTables_,
2162 oldFluidSystem.enthalpy_eq_energy_
2167 #endif // COMPILING_STATIC_FLUID_SYSTEM A fluid system which uses the black-oil model assumptions to calculate termodynamically meaningful qu...
Definition: BlackOilFluidSystem_macrotemplate.hpp:73
This class represents the Pressure-Volume-Temperature relations of the liquid phase for a CO2-Brine s...
Definition: BrineCo2Pvt.hpp:63
This class represents the Pressure-Volume-Temperature relations of the liquid phase for a CO2-Brine s...
STATIC_OR_DEVICE const OilPvt & oilPvt() NOTHING_OR_CONST
Return a reference to the low-level object which calculates the oil phase quantities.
Definition: BlackOilFluidSystem_macrotemplate.hpp:1706
STATIC_OR_DEVICE LhsEval convertXwGToRsw(const LhsEval &XwG, unsigned regionIdx) NOTHING_OR_CONST
Convert the mass fraction of the gas component in the water phase to the corresponding gas dissolutio...
Definition: BlackOilFluidSystem_macrotemplate.hpp:1526
STATIC_OR_DEVICE LhsEval convertXgWToxgW(const LhsEval &XgW, unsigned regionIdx) NOTHING_OR_CONST
Convert a water mass fraction in the gas phase the corresponding mole fraction.
Definition: BlackOilFluidSystem_macrotemplate.hpp:1621
STATIC_OR_DEVICE Scalar referenceDensity(unsigned phaseIdx, unsigned regionIdx) NOTHING_OR_CONST
Returns the density of a fluid phase at surface pressure [kg/m^3].
Definition: BlackOilFluidSystem_macrotemplate.hpp:556
STATIC_OR_DEVICE void setReservoirTemperature(Scalar value) NOTHING_OR_CONST
Return the temperature of the reservoir.
Definition: BlackOilFluidSystem_macrotemplate.hpp:1732
STATIC_OR_DEVICE LhsEval convertRswToXwG(const LhsEval &Rsw, unsigned regionIdx) NOTHING_OR_CONST
Convert a gas dissolution factor to the the corresponding mass fraction of the gas component in the w...
Definition: BlackOilFluidSystem_macrotemplate.hpp:1580
static constexpr int gasCompIdx
Index of the gas component.
Definition: BlackOilFluidSystem_macrotemplate.hpp:433
STATIC_OR_DEVICE LhsEval convertxgOToXgO(const LhsEval &xgO, unsigned regionIdx) NOTHING_OR_CONST
Convert a oil mole fraction in the gas phase the corresponding mass fraction.
Definition: BlackOilFluidSystem_macrotemplate.hpp:1681
Null object for oil PVT calculations.
Definition: NullOilPvt.hpp:34
STATIC_OR_DEVICE const WaterPvt & waterPvt() NOTHING_OR_CONST
Return a reference to the low-level object which calculates the water phase quantities.
Definition: BlackOilFluidSystem_macrotemplate.hpp:1716
static constexpr int waterCompIdx
Index of the water component.
Definition: BlackOilFluidSystem_macrotemplate.hpp:431
STATIC_OR_DEVICE std::size_t numRegions() NOTHING_OR_CONST
Returns the number of PVT regions which are considered.
Definition: BlackOilFluidSystem_macrotemplate.hpp:489
STATIC_OR_NOTHING void initFromState(const EclipseState &eclState, const Schedule &schedule)
Initialize the fluid system using an ECL deck object.
STATIC_OR_DEVICE LhsEval saturatedVaporizationFactor(const FluidState &fluidState, unsigned phaseIdx, unsigned regionIdx) NOTHING_OR_CONST
Returns the water vaporization factor of saturated phase.
Definition: BlackOilFluidSystem_macrotemplate.hpp:1375
STATIC_OR_DEVICE LhsEval dewPointPressure(const FluidState &fluidState, unsigned regionIdx) NOTHING_OR_CONST
Returns the dew point pressure $P_d$ using the current Rv.
Definition: BlackOilFluidSystem_macrotemplate.hpp:1469
STATIC_OR_DEVICE Scalar reservoirTemperature(unsigned=0) NOTHING_OR_CONST
Set the temperature of the reservoir.
Definition: BlackOilFluidSystem_macrotemplate.hpp:1724
STATIC_OR_DEVICE LhsEval convertXgOToRv(const LhsEval &XgO, unsigned regionIdx) NOTHING_OR_CONST
Convert the mass fraction of the oil component in the gas phase to the corresponding oil vaporization...
Definition: BlackOilFluidSystem_macrotemplate.hpp:1539
STATIC_OR_DEVICE void setEnableConstantRs(bool yesno)
Specify whether the fluid system should use constant Rs tables.
Definition: BlackOilFluidSystem_macrotemplate.hpp:320
STATIC_OR_DEVICE LhsEval convertXgWToRvw(const LhsEval &XgW, unsigned regionIdx) NOTHING_OR_CONST
Convert the mass fraction of the water component in the gas phase to the corresponding water vaporiza...
Definition: BlackOilFluidSystem_macrotemplate.hpp:1552
STATIC_OR_DEVICE Scalar molarMass(unsigned compIdx, unsigned regionIdx=0) NOTHING_OR_CONST
Return the molar mass of a component in [kg/mol].
Definition: BlackOilFluidSystem_macrotemplate.hpp:461
STATIC_OR_DEVICE LhsEval enthalpy(const FluidState &fluidState, unsigned phaseIdx, unsigned regionIdx) NOTHING_OR_CONST
Given a phase's composition, temperature, pressure and density, calculate its specific enthalpy [J/kg...
Definition: BlackOilFluidSystem_macrotemplate.hpp:1354
STATIC_OR_DEVICE bool enableConstantRs() NOTHING_OR_CONST
Returns whether constant Rs tables should be used.
Definition: BlackOilFluidSystem_macrotemplate.hpp:532
PiecewiseLinearTwoPhaseMaterialParams< TraitsT, ViewType > make_view(PiecewiseLinearTwoPhaseMaterialParams< TraitsT, ContainerType > ¶ms)
this function is intented to make a GPU friendly view of the PiecewiseLinearTwoPhaseMaterialParams ...
Definition: PiecewiseLinearTwoPhaseMaterialParams.hpp:312
This class represents the Pressure-Volume-Temperature relations of the water phase in the black-oil m...
STATIC_OR_DEVICE LhsEval convertXoGToxoG(const LhsEval &XoG, unsigned regionIdx) NOTHING_OR_CONST
Convert a gas mass fraction in the oil phase the corresponding mole fraction.
Definition: BlackOilFluidSystem_macrotemplate.hpp:1645
STATIC_OR_DEVICE LhsEval density(const FluidState &fluidState, const ParameterCache< ParamCacheEval > ¶mCache, unsigned phaseIdx) NOTHING_OR_CONST
Calculate the density [kg/m^3] of a fluid phase.
Definition: BlackOilFluidSystem_macrotemplate.hpp:564
STATIC_OR_DEVICE bool enableVaporizedWater() NOTHING_OR_CONST
Returns whether the fluid system should consider that the water component can dissolve in the gas pha...
Definition: BlackOilFluidSystem_macrotemplate.hpp:526
STATIC_OR_DEVICE const GasPvt & gasPvt() NOTHING_OR_CONST
Return a reference to the low-level object which calculates the gas phase quantities.
Definition: BlackOilFluidSystem_macrotemplate.hpp:1696
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:30
Convience header to include the gpuistl headers if HAVE_CUDA is defined.
This class represents the Pressure-Volume-Temperature relations of the gas phase in the black-oil mod...
Definition: GasPvtMultiplexer.hpp:108
STATIC_OR_DEVICE void setEnableDissolvedGas(bool yesno)
Specify whether the fluid system should consider that the gas component can dissolve in the oil phase...
Definition: BlackOilFluidSystem_macrotemplate.hpp:284
A parameter cache which does nothing.
STATIC_OR_DEVICE LhsEval saturatedDensity(const FluidState &fluidState, unsigned phaseIdx, unsigned regionIdx) NOTHING_OR_CONST
Compute the density of a saturated fluid phase.
Definition: BlackOilFluidSystem_macrotemplate.hpp:716
STATIC_OR_DEVICE LhsEval convertxoGToXoG(const LhsEval &xoG, unsigned regionIdx) NOTHING_OR_CONST
Convert a gas mole fraction in the oil phase the corresponding mass fraction.
Definition: BlackOilFluidSystem_macrotemplate.hpp:1657
STATIC_OR_DEVICE bool enableVaporizedOil() NOTHING_OR_CONST
Returns whether the fluid system should consider that the oil component can dissolve in the gas phase...
Definition: BlackOilFluidSystem_macrotemplate.hpp:517
Definition: Constants.hpp:41
This macro generates a class HasMember_${MEMBER_NAME} which can be used for template specialization...
STATIC_OR_DEVICE void setEnableDissolvedGasInWater(bool yesno)
Specify whether the fluid system should consider that the gas component can dissolve in the water pha...
Definition: BlackOilFluidSystem_macrotemplate.hpp:311
STATIC_OR_DEVICE bool useSaturatedTables() NOTHING_OR_CONST
Returns whether the saturated tables should be used.
Definition: BlackOilFluidSystem_macrotemplate.hpp:548
STATIC_OR_DEVICE Scalar diffusionCoefficient(unsigned compIdx, unsigned phaseIdx, unsigned regionIdx=0) NOTHING_OR_CONST
Calculate the binary molecular diffusion coefficient for a component in a fluid phase [mol^2 * s / (k...
Definition: BlackOilFluidSystem_macrotemplate.hpp:1748
STATIC_OR_NOTHING std::string_view componentName(unsigned compIdx) NOTHING_OR_CONST
Return the human readable name of a component.
Definition: BlackOilFluidSystem_macrotemplate.hpp:1977
static constexpr unsigned numPhases
Number of fluid phases in the fluid system.
Definition: BlackOilFluidSystem_macrotemplate.hpp:396
STATIC_OR_DEVICE void setOilPvt(std::shared_ptr< OilPvt > pvtObj)
Set the pressure-volume-saturation (PVT) relations for the oil phase.
Definition: BlackOilFluidSystem_macrotemplate.hpp:348
STATIC_OR_DEVICE void setUseSaturatedTables(bool yesno)
Specify whether the saturated tables should be used.
Definition: BlackOilFluidSystem_macrotemplate.hpp:336
STATIC_OR_DEVICE LhsEval enthalpy(const FluidState &fluidState, const ParameterCache< ParamCacheEval > ¶mCache, unsigned phaseIdx)
Given a phase's composition, temperature, pressure and density, calculate its specific enthalpy [J/kg...
Definition: BlackOilFluidSystem_macrotemplate.hpp:591
STATIC_OR_DEVICE LhsEval viscosity(const FluidState &fluidState, unsigned phaseIdx, unsigned regionIdx) NOTHING_OR_CONST
Calculate the dynamic viscosity of a fluid phase [Pa*s].
Definition: BlackOilFluidSystem_macrotemplate.hpp:1089
STATIC_OR_DEVICE void setEnableVaporizedWater(bool yesno)
Specify whether the fluid system should consider that the water component can dissolve in the gas pha...
Definition: BlackOilFluidSystem_macrotemplate.hpp:302
static constexpr unsigned numComponents
Number of chemical species in the fluid system.
Definition: BlackOilFluidSystem_macrotemplate.hpp:426
STATIC_OR_DEVICE LhsEval saturatedDissolutionFactor(const FluidState &fluidState, unsigned phaseIdx, unsigned regionIdx) NOTHING_OR_CONST
Returns the dissolution factor of a saturated fluid phase.
Definition: BlackOilFluidSystem_macrotemplate.hpp:1433
Definition: PhaseUsageInfo.hpp:42
STATIC_OR_DEVICE bool enableDissolvedGasInWater() NOTHING_OR_CONST
Returns whether the fluid system should consider that the gas component can dissolve in the water pha...
Definition: BlackOilFluidSystem_macrotemplate.hpp:508
STATIC_OR_DEVICE LhsEval convertXoGToRs(const LhsEval &XoG, unsigned regionIdx) NOTHING_OR_CONST
Convert the mass fraction of the gas component in the oil phase to the corresponding gas dissolution ...
Definition: BlackOilFluidSystem_macrotemplate.hpp:1513
STATIC_OR_DEVICE void initEnd()
Finish initializing the black oil fluid system.
Definition: BlackOilFluidSystem_macrotemplate.hpp:1891
STATIC_OR_DEVICE LhsEval viscosity(const FluidState &fluidState, const ParameterCache< ParamCacheEval > ¶mCache, unsigned phaseIdx) NOTHING_OR_CONST
Calculate the dynamic viscosity of a fluid phase [Pa*s].
Definition: BlackOilFluidSystem_macrotemplate.hpp:584
This class represents the Pressure-Volume-Temperature relations of the gas phase for CO2...
Definition: Co2GasPvt.hpp:59
STATIC_OR_DEVICE void setDiffusionCoefficient(Scalar coefficient, unsigned compIdx, unsigned phaseIdx, unsigned regionIdx=0) NOTHING_OR_CONST
Definition: BlackOilFluidSystem_macrotemplate.hpp:1752
STATIC_OR_DEVICE void setGasPvt(std::shared_ptr< GasPvt > pvtObj)
Set the pressure-volume-saturation (PVT) relations for the gas phase.
Definition: BlackOilFluidSystem_macrotemplate.hpp:342
This class represents the Pressure-Volume-Temperature relations of the oil phase in the black-oil mod...
Definition: OilPvtMultiplexer.hpp:109
STATIC_OR_DEVICE bool enableDissolvedGas() NOTHING_OR_CONST
Returns whether the fluid system should consider that the gas component can dissolve in the oil phase...
Definition: BlackOilFluidSystem_macrotemplate.hpp:498
This class represents the Pressure-Volume-Temperature relations of the water phase in the black-oil m...
Definition: ConstantCompressibilityBrinePvt.hpp:39
STATIC_OR_DEVICE LhsEval bubblePointPressure(const FluidState &fluidState, unsigned regionIdx) NOTHING_OR_CONST
Returns the bubble point pressure $P_b$ using the current Rs.
Definition: BlackOilFluidSystem_macrotemplate.hpp:1458
The base class for all fluid systems.
Definition: BaseFluidSystem.hpp:42
STATIC_OR_NOTHING std::string_view phaseName(unsigned phaseIdx) NOTHING_OR_CONST
Return the human readable name of a fluid phase.
Definition: BlackOilFluidSystem_macrotemplate.hpp:1921
static constexpr unsigned waterPhaseIdx
Index of the water phase.
Definition: BlackOilFluidSystem_macrotemplate.hpp:399
STATIC_OR_DEVICE LhsEval convertRsToXoG(const LhsEval &Rs, unsigned regionIdx) NOTHING_OR_CONST
Convert a gas dissolution factor to the the corresponding mass fraction of the gas component in the o...
Definition: BlackOilFluidSystem_macrotemplate.hpp:1566
STATIC_OR_DEVICE LhsEval density(const FluidState &fluidState, unsigned phaseIdx, unsigned regionIdx) NOTHING_OR_CONST
Calculate the density [kg/m^3] of a fluid phase.
Definition: BlackOilFluidSystem_macrotemplate.hpp:608
STATIC_OR_DEVICE bool enableDiffusion() NOTHING_OR_CONST
Returns whether the fluid system should consider diffusion.
Definition: BlackOilFluidSystem_macrotemplate.hpp:540
STATIC_OR_DEVICE void setEnableVaporizedOil(bool yesno)
Specify whether the fluid system should consider that the oil component can dissolve in the gas phase...
Definition: BlackOilFluidSystem_macrotemplate.hpp:293
STATIC_OR_DEVICE LhsEval saturatedInverseFormationVolumeFactor(const FluidState &fluidState, unsigned phaseIdx, unsigned regionIdx) NOTHING_OR_CONST
Returns the formation volume factor of a "saturated" fluid phase.
Definition: BlackOilFluidSystem_macrotemplate.hpp:945
static constexpr unsigned gasPhaseIdx
Index of the gas phase.
Definition: BlackOilFluidSystem_macrotemplate.hpp:403
STATIC_OR_DEVICE bool isIdealMixture(unsigned)
Returns true if and only if a fluid phase is assumed to be an ideal mixture.
Definition: BlackOilFluidSystem_macrotemplate.hpp:465
PiecewiseLinearTwoPhaseMaterialParams< TraitsT, GPUContainerType > copy_to_gpu(const PiecewiseLinearTwoPhaseMaterialParams< TraitsT > ¶ms)
Move a PiecewiseLinearTwoPhaseMaterialParams-object to the GPU.
Definition: PiecewiseLinearTwoPhaseMaterialParams.hpp:285
STATIC_OR_DEVICE bool isIdealGas(unsigned) NOTHING_OR_CONST
Returns true if and only if a fluid phase is assumed to be an ideal gas.
Definition: BlackOilFluidSystem_macrotemplate.hpp:477
STATIC_OR_DEVICE bool phaseIsActive(unsigned phaseIdx) NOTHING_OR_CONST
Returns whether a fluid phase is active.
Definition: BlackOilFluidSystem_macrotemplate.hpp:446
FLUIDSYSTEM_CLASSNAME(const FLUIDSYSTEM_CLASSNAME< Scalar, IndexTraits, StorageT > &other)
Default copy constructor.
Definition: BlackOilFluidSystem_macrotemplate.hpp:160
The class which specifies the default phase and component indices for the black-oil fluid system...
STATIC_OR_NOTHING Scalar surfacePressure
The pressure at the surface.
Definition: BlackOilFluidSystem_macrotemplate.hpp:406
STATIC_OR_DEVICE unsigned solventComponentIndex(unsigned phaseIdx) NOTHING_OR_CONST
returns the index of "primary" component of a phase (solvent)
Definition: BlackOilFluidSystem_macrotemplate.hpp:1938
STATIC_OR_DEVICE unsigned soluteComponentIndex(unsigned phaseIdx) NOTHING_OR_CONST
returns the index of "secondary" component of a phase (solute)
Definition: BlackOilFluidSystem_macrotemplate.hpp:1955
This class represents the Pressure-Volume-Temperature relations of the oil phase in the black-oil mod...
STATIC_OR_DEVICE bool isLiquid(unsigned phaseIdx) NOTHING_OR_CONST
Return whether a phase is liquid.
Definition: BlackOilFluidSystem_macrotemplate.hpp:415
STATIC_OR_DEVICE LhsEval convertRvToXgO(const LhsEval &Rv, unsigned regionIdx) NOTHING_OR_CONST
Convert an oil vaporization factor to the corresponding mass fraction of the oil component in the gas...
Definition: BlackOilFluidSystem_macrotemplate.hpp:1594
A parameter cache which does nothing.
Definition: NullParameterCache.hpp:39
STATIC_OR_DEVICE void setWaterPvt(std::shared_ptr< WaterPvt > pvtObj)
Set the pressure-volume-saturation (PVT) relations for the water phase.
Definition: BlackOilFluidSystem_macrotemplate.hpp:354
static constexpr int oilCompIdx
Index of the oil component.
Definition: BlackOilFluidSystem_macrotemplate.hpp:429
STATIC_OR_DEVICE LhsEval saturationPressure(const FluidState &fluidState, unsigned phaseIdx, unsigned regionIdx) NOTHING_OR_CONST
Returns the saturation pressure of a given phase [Pa] depending on its composition.
Definition: BlackOilFluidSystem_macrotemplate.hpp:1486
STATIC_OR_DEVICE unsigned numActivePhases() NOTHING_OR_CONST
Returns the number of active fluid phases (i.e., usually three)
Definition: BlackOilFluidSystem_macrotemplate.hpp:442
Some templates to wrap the valgrind client request macros.
STATIC_OR_DEVICE LhsEval inverseFormationVolumeFactor(const FluidState &fluidState, unsigned phaseIdx, unsigned regionIdx) NOTHING_OR_CONST
Returns the formation volume factor of an "undersaturated" fluid phase.
Definition: BlackOilFluidSystem_macrotemplate.hpp:827
Scalar Scalar
The type used for scalar quantities.
Definition: BaseFluidSystem.hpp:48
STATIC_OR_DEVICE LhsEval convertXgOToxgO(const LhsEval &XgO, unsigned regionIdx) NOTHING_OR_CONST
Convert a oil mass fraction in the gas phase the corresponding mole fraction.
Definition: BlackOilFluidSystem_macrotemplate.hpp:1669
STATIC_OR_NOTHING Scalar surfaceTemperature
The temperature at the surface.
Definition: BlackOilFluidSystem_macrotemplate.hpp:409
STATIC_OR_DEVICE void setReferenceDensities(Scalar rhoOil, Scalar rhoWater, Scalar rhoGas, unsigned regionIdx)
Initialize the values of the reference densities.
Definition: BlackOilFluidSystem_macrotemplate.hpp:1880
STATIC_OR_DEVICE const PhaseUsageInfo< IndexTraits > & phaseUsage() NOTHING_OR_CONST
Returns a const reference to PhaseUsageInfo.
Definition: BlackOilFluidSystem_macrotemplate.hpp:438
STATIC_OR_DEVICE LhsEval convertXwGToxwG(const LhsEval &XwG, unsigned regionIdx) NOTHING_OR_CONST
Convert a gas mass fraction in the water phase the corresponding mole fraction.
Definition: BlackOilFluidSystem_macrotemplate.hpp:1633
This class represents the Pressure-Volume-Temperature relations of the gas phase in the black-oil mod...
STATIC_OR_DEVICE LhsEval diffusionCoefficient(const FluidState &fluidState, const ParameterCache< ParamCacheEval > ¶mCache, unsigned phaseIdx, unsigned compIdx) NOTHING_OR_CONST
Calculate the binary molecular diffusion coefficient for a component in a fluid phase [mol^2 * s / (k...
Definition: BlackOilFluidSystem_macrotemplate.hpp:1759
STATIC_OR_DEVICE LhsEval fugacityCoefficient(const FluidState &fluidState, const ParameterCache< ParamCacheEval > ¶mCache, unsigned phaseIdx, unsigned compIdx) NOTHING_OR_CONST
Calculate the fugacity coefficient [Pa] of an individual component in a fluid phase.
Definition: BlackOilFluidSystem_macrotemplate.hpp:571
STATIC_OR_DEVICE LhsEval convertRvwToXgW(const LhsEval &Rvw, unsigned regionIdx) NOTHING_OR_CONST
Convert an water vaporization factor to the corresponding mass fraction of the water component in the...
Definition: BlackOilFluidSystem_macrotemplate.hpp:1608
STATIC_OR_DEVICE bool isCompressible(unsigned) NOTHING_OR_CONST
Returns true if and only if a fluid phase is assumed to be compressible.
Definition: BlackOilFluidSystem_macrotemplate.hpp:473
STATIC_OR_DEVICE LhsEval fugacityCoefficient(const FluidState &fluidState, unsigned phaseIdx, unsigned compIdx, unsigned regionIdx) NOTHING_OR_CONST
Calculate the fugacity coefficient [Pa] of an individual component in a fluid phase.
Definition: BlackOilFluidSystem_macrotemplate.hpp:967
STATIC_OR_DEVICE void setEnableDiffusion(bool yesno)
Specify whether the fluid system should consider diffusion.
Definition: BlackOilFluidSystem_macrotemplate.hpp:328
static constexpr unsigned oilPhaseIdx
Index of the oil phase.
Definition: BlackOilFluidSystem_macrotemplate.hpp:401
STATIC_OR_NOTHING void initBegin(std::size_t numPvtRegions)
Begin the initialization of the black oil fluid system.
Definition: BlackOilFluidSystem_macrotemplate.hpp:1857
STATIC_OR_DEVICE LhsEval saturatedDissolutionFactor(const FluidState &fluidState, unsigned phaseIdx, unsigned regionIdx, const LhsEval &maxOilSaturation) NOTHING_OR_CONST
Returns the dissolution factor of a saturated fluid phase.
Definition: BlackOilFluidSystem_macrotemplate.hpp:1402
The base class for all fluid systems.
Definition: Runspec.hpp:45
Definition: BlackOilFluidSystemNonStatic.hpp:75