31#ifndef OPM_INIT_STATE_EQUIL_COMP_HPP
32#define OPM_INIT_STATE_EQUIL_COMP_HPP
34#include <opm/common/ErrorMacros.hpp>
35#include <opm/common/OpmLog/OpmLog.hpp>
37#include <opm/material/common/Tabulated1DFunction.hpp>
38#include <opm/material/constraintsolvers/SaturationPressure.hpp>
39#include <opm/material/fluidstates/CompositionalFluidState.hpp>
41#include <opm/input/eclipse/EclipseState/EclipseState.hpp>
42#include <opm/input/eclipse/EclipseState/InitConfig/Equil.hpp>
43#include <opm/input/eclipse/EclipseState/Tables/CompvdTable.hpp>
44#include <opm/input/eclipse/EclipseState/Tables/RtempvdTable.hpp>
45#include <opm/input/eclipse/EclipseState/Tables/SwfnTable.hpp>
46#include <opm/input/eclipse/EclipseState/Tables/TableContainer.hpp>
47#include <opm/input/eclipse/EclipseState/Tables/TableManager.hpp>
48#include <opm/input/eclipse/EclipseState/Tables/ZmfvdTable.hpp>
49#include <opm/input/eclipse/Units/Units.hpp>
56#include <fmt/format.h>
57#include <fmt/ranges.h>
83template <
class Scalar>
84Scalar
evalDepthTable(
const Tabulated1DFunction<Scalar>& table,
const Scalar depth)
86 return table.eval(std::clamp(depth, table.xMin(), table.xMax()));
93template <
class Flu
idSystem>
97 using Scalar =
typename FluidSystem::Scalar;
98 using CompVec = std::array<Scalar, FluidSystem::numComponents>;
104 const unsigned phaseIdx,
105 const unsigned eosRegion,
107 : composition_(std::move(composition))
108 , tempVdTable_(tempVdTable)
109 , phaseIdx_(phaseIdx)
110 , eosRegion_(eosRegion)
117 const CompVec z = composition_(depth);
120 CompositionalFluidState<Scalar, FluidSystem> fs;
121 fs.setTemperature(temp);
122 fs.setPressure(FluidSystem::oilPhaseIdx, press);
123 fs.setPressure(FluidSystem::gasPhaseIdx, press);
124 for (
unsigned compIdx = 0; compIdx < FluidSystem::numComponents; ++compIdx) {
125 fs.setMoleFraction(phaseIdx_, compIdx, z[compIdx]);
128 typename FluidSystem::template ParameterCache<Scalar> paramCache(eosRegion_);
129 paramCache.updatePhase(fs, phaseIdx_);
131 return FluidSystem::density(fs, paramCache, phaseIdx_) * g_;
144template <
class Flu
idSystem>
148 using Scalar =
typename FluidSystem::Scalar;
152 const unsigned eosRegion,
153 const unsigned pvtRegion,
155 : tempVdTable_(tempVdTable)
156 , eosRegion_(eosRegion)
157 , pvtRegion_(pvtRegion)
164 CompositionalFluidState<Scalar, FluidSystem> fs;
166 fs.setPressure(FluidSystem::waterPhaseIdx, press);
168 typename FluidSystem::template ParameterCache<Scalar> paramCache(eosRegion_);
169 paramCache.setPvtRegionIndex(pvtRegion_);
171 return FluidSystem::density(fs, paramCache, FluidSystem::waterPhaseIdx) * g_;
241template <
class Flu
idSystem>
245 using Scalar =
typename FluidSystem::Scalar;
246 using FluidState = CompositionalFluidState<Scalar, FluidSystem>;
264 const std::vector<int>& eosnum,
266 const std::vector<int>& eqlnum,
267 const std::vector<int>& pvtnum,
270 const int numSamplePoints,
271 const std::vector<Scalar>& connateWater = {},
272 const std::vector<Scalar>& maxWater = {})
274 , numSamplePoints_(numSamplePoints)
275 , connateWater_(connateWater)
276 , maxWater_(maxWater)
278 const auto& records = inputState.getInitConfig().getEquil();
279 const auto& tables = inputState.getTableManager();
281 if (!tables.hasTables(
"ZMFVD") && !tables.hasTables(
"COMPVD")) {
282 OPM_THROW(std::runtime_error,
283 "Equilibration of a compositional model requires the composition "
284 "versus depth from the ZMFVD or the COMPVD keyword.");
287 const auto numPvtRegions = tables.getTabdims().getNumPVTTables();
290 OPM_THROW(std::runtime_error,
291 fmt::format(
"EQLNUM contains {} entries for {} cell depths.",
294 for (std::size_t cell = 0; cell < eqlnum.size(); ++cell) {
295 const auto region = eqlnum[cell];
296 if (region < 0 || std::cmp_greater_equal(region, records.size())) {
297 OPM_THROW(std::runtime_error,
298 fmt::format(
"Cell {} has EQLNUM {} outside the {} "
299 "equilibration regions.",
300 cell, region + 1, records.size()));
304 OPM_THROW(std::runtime_error,
305 fmt::format(
"PVTNUM contains {} entries for {} cell depths.",
308 for (std::size_t cell = 0; cell < pvtnum.size(); ++cell) {
309 const auto region = pvtnum[cell];
310 if (region < 0 || std::cmp_greater_equal(region, numPvtRegions)) {
311 OPM_THROW(std::runtime_error,
312 fmt::format(
"Cell {} has PVTNUM {} outside the {} "
314 cell, region + 1, numPvtRegions));
318 OPM_THROW(std::runtime_error,
319 fmt::format(
"EOSNUM contains {} entries for {} cell depths.",
322 const auto numEosRegions = inputState.runspec().tabdims().getNumEosRes();
323 for (std::size_t cell = 0; cell < eosnum.size(); ++cell) {
324 const auto region = eosnum[cell];
325 if (region < 0 || std::cmp_greater_equal(region, numEosRegions)) {
326 OPM_THROW(std::runtime_error,
327 fmt::format(
"Cell {} has EOSNUM {} outside the {} "
329 cell, region + 1, numEosRegions));
334 for (
const auto& [name, limits] : {std::pair{
"connate water", std::cref(connateWater)},
335 std::pair{
"maximum water", std::cref(maxWater)}}) {
336 if (!limits.get().empty() &&
338 OPM_THROW(std::runtime_error,
339 fmt::format(
"The {} saturation has {} entries for {} cell depths.",
345 const auto pvtRegions =
346 pvtRegionsOfEachRegion(eqlnum, pvtnum, records.size(), numPvtRegions, comm);
347 const auto eosRegions = eosRegionOfEachEqlRegion(eqlnum, eosnum, records.size(), comm);
348 regions_.reserve(records.size());
349 for (std::size_t r = 0; r < records.size(); ++r) {
350 regions_.push_back(setupRegion(records.getRecord(r), tables, pvtRegions[r],
352 gravity, numSamplePoints, r));
355 const bool waterActive = FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx);
360 const auto& reg = regions_[eqlnum[cell]];
361 const auto pvtRegion = pvtnum.empty() ? 0u :
static_cast<unsigned>(pvtnum[cell]);
362 referencePressures_[cell] = assignCell(fluidStates_[cell], reg,
367 if ((reg.initType == 1) && !(waterActive && (
cellCenterDepth[cell] > reg.zwoc))) {
368 twoPhaseCheckRegions_[cell] = eqlnum[cell];
374 {
return fluidStates_; }
377 {
return fluidStates_; }
383 {
return referencePressures_; }
390 {
return twoPhaseCheckRegions_; }
393 {
return twoPhaseCheckRegions_; }
442 std::vector<std::vector<ReportRow>>
445 std::vector<std::vector<ReportRow>> rows(regions_.size());
446 for (std::size_t r = 0; r < regions_.size(); ++r) {
448 if (regions_[r].oilPressure.has_value()) {
449 rows[r] = reportRows(regions_[r], regions.at(r));
456 using CompVec = std::array<Scalar, FluidSystem::numComponents>;
457 using TabulatedFunction = Tabulated1DFunction<Scalar>;
463 static constexpr int numComponents = FluidSystem::numComponents;
468 static constexpr Scalar constantTableSpan{1.0};
472 static constexpr Scalar minimumSpanExtent{1.0};
481 std::vector<unsigned> pvtRegions;
483 unsigned eosRegion{0};
487 std::string_view compositionKeyword;
489 std::optional<unsigned> statedPhaseIdx{};
491 unsigned nominalPhaseIdx{FluidSystem::oilPhaseIdx};
500 std::vector<TabulatedFunction> vaporVdTable;
502 CompVec vaporComposition{};
504 std::optional<TabulatedFunction> statedSaturationPressure;
506 std::array<Scalar, 2> span{};
508 std::vector<TabulatedFunction> compositionVdTable;
509 TabulatedFunction tempVdTable;
510 std::optional<PressFunc> oilPressure;
511 std::optional<PressFunc> gasPressure;
517 bool anchoredAtWaterContact{
false};
519 std::map<unsigned, WaterPressFunc> waterPressure;
524 static std::array<Scalar, 2> waterContactSpan(
const Region& reg,
525 const std::array<Scalar, 2>& span)
527 if (FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx)) {
528 return {std::min(span[0], reg.zwoc), std::max(span[1], reg.zwoc)};
534 static CompVec vaporComposition(
const Region& reg,
const Scalar depth)
538 for (
int c = 0; c < numComponents; ++c) {
543 OPM_THROW(std::runtime_error,
544 fmt::format(
"The COMPVD vapour composition vanishes at depth {} m.", depth));
546 std::ranges::transform(z, z.begin(), [sum](
const Scalar zc) { return zc / sum; });
550 static CompVec composition(
const Region& reg,
const Scalar depth)
554 for (
int c = 0; c < numComponents; ++c) {
559 OPM_THROW(std::runtime_error,
560 fmt::format(
"The composition vanishes at depth {} m.", depth));
562 std::ranges::transform(z, z.begin(), [sum](
const Scalar zc) { return zc / sum; });
571 if (reg.initType == 1) {
572 return [®](
const Scalar depth) {
return composition(reg, depth); };
575 return [®](
const Scalar depth) {
return vaporComposition(reg, depth); };
577 return [vapor = reg.vaporComposition](
const Scalar) {
return vapor; };
581 static TabulatedFunction saturationPressureTable(
const CompvdTable& compvd)
583 const auto& depthCol = compvd.getDepthColumn();
584 const auto& psatCol = compvd.getSaturationPressureColumn();
585 std::vector<Scalar> depths(depthCol.begin(), depthCol.end());
586 std::vector<Scalar> psat(psatCol.begin(), psatCol.end());
588 if (depths.size() == 1) {
589 depths.push_back(depths.front() + constantTableSpan);
590 psat.push_back(psat.front());
592 TabulatedFunction table;
593 table.setXYContainers(depths, psat);
599 template <
class Table>
600 static void setupComposition(std::vector<TabulatedFunction>& out,
602 const std::vector<std::size_t>& rows)
604 const auto& depthCol = table.getDepthColumn();
606 std::vector<Scalar> depths;
607 depths.reserve(rows.size() + 1);
608 for (
const auto row : rows) {
609 depths.push_back(depthCol[row]);
613 const bool constantComposition = (depths.size() == 1);
614 if (constantComposition) {
615 depths.push_back(depths.front() + constantTableSpan);
618 out.resize(numComponents);
619 for (
int c = 0; c < numComponents; ++c) {
620 const auto& col = table.getMoleFractionColumn(c);
621 std::vector<Scalar> values;
622 values.reserve(depths.size());
623 for (
const auto row : rows) {
624 values.push_back(col[row]);
626 if (constantComposition) {
627 values.push_back(values.front());
629 out[c].setXYContainers(depths, values);
635 static std::optional<std::size_t> sourceTable(
const TableContainer& container,
636 const std::size_t regionIdx)
638 const auto& byIndex = container.tables();
639 const auto after = byIndex.upper_bound(regionIdx);
640 if (after == byIndex.begin()) {
643 return std::prev(after)->first;
647 static std::vector<std::size_t> allRows(
const std::size_t count)
649 std::vector<std::size_t> rows(count);
650 std::iota(rows.begin(), rows.end(), std::size_t{0});
660 static Scalar zoneBoundary(
const CompvdTable& compvd,
661 const std::vector<std::size_t>& vaporRows,
662 const std::vector<std::size_t>& liquidRows,
664 const std::size_t regionIdx)
666 if (vaporRows.empty() || liquidRows.empty()) {
667 OPM_THROW(std::runtime_error,
668 fmt::format(
"The COMPVD table of region {} names both phases but has "
669 "no row for one of them.", regionIdx + 1));
672 const auto& depth = compvd.getDepthColumn();
673 const Scalar lastVapor = depth[vaporRows.back()];
674 const Scalar firstLiquid = depth[liquidRows.front()];
675 if (lastVapor > firstLiquid) {
676 OPM_THROW(std::runtime_error,
677 fmt::format(
"The COMPVD table of region {} has a vapour row at {} m "
678 "below its liquid row at {} m. All vapour rows must lie "
679 "above the liquid rows.",
680 regionIdx + 1, lastVapor, firstLiquid));
683 const Scalar boundary = std::clamp(reg.zgoc, lastVapor, firstLiquid);
684 if (boundary == reg.zgoc) {
688 if (reg.initType != 1) {
689 OPM_THROW(std::runtime_error,
690 fmt::format(
"The COMPVD table of region {} puts its vapour rows down to "
691 "{} m and its liquid rows from {} m, which do not meet at "
692 "the gas-oil contact at {} m. EQUIL item 10 = {} takes the "
693 "contact as the reference depth, so the rows must agree "
695 regionIdx + 1, lastVapor, firstLiquid, reg.zgoc,
699 OpmLog::warning(fmt::format(
"Equilibration region {}: the gas-oil contact at {} m lies "
700 "outside the COMPVD phase change between the last vapour "
701 "row at {} m and the first liquid row at {} m. With EQUIL "
702 "item 10 = 1 the rows give the composition versus depth, "
703 "so the gas zone ends at {} m instead.",
704 regionIdx + 1, reg.zgoc, lastVapor, firstLiquid, boundary));
709 static std::vector<std::size_t> rowsOfPhase(
const CompvdTable& compvd,
712 const auto& flags = compvd.phaseFlags();
713 std::vector<std::size_t> rows;
714 for (std::size_t r = 0; r < flags.size(); ++r) {
715 if (flags[r] == phase) {
724 static std::optional<unsigned> statedPhase(
const CompvdTable& compvd,
725 const std::size_t regionIdx)
727 const auto& flags = compvd.phaseFlags();
732 const auto first = flags.front();
733 if (std::ranges::any_of(flags, [first](
const auto f) {
return f != first; })) {
734 OpmLog::info(fmt::format(
"Equilibration region {}: COMPVD names both phases, "
735 "so the contact and row labels determine the gas and "
741 return (first == CompvdTable::Phase::Vapor)
742 ? FluidSystem::gasPhaseIdx : FluidSystem::oilPhaseIdx;
746 static bool compositionVariesBetween(
const Region& reg,
752 constexpr Scalar sameComposition{1.0e-10};
754 const CompVec a = composition(reg, depthA);
755 const CompVec b = composition(reg, depthB);
756 return !std::ranges::equal(a, b, [](
const Scalar x,
const Scalar y) {
757 return std::abs(x - y) <= sameComposition;
763 static std::vector<std::vector<unsigned>>
764 pvtRegionsOfEachRegion(
const std::vector<int>& eqlnum,
765 const std::vector<int>& pvtnum,
766 const std::size_t numRegions,
767 const std::size_t numPvtRegions,
772 std::vector<int> present(numRegions * numPvtRegions, 0);
773 for (std::size_t cell = 0; cell < eqlnum.size(); ++cell) {
774 const auto pvtRegion = pvtnum.empty() ? 0 : pvtnum[cell];
775 present[
static_cast<std::size_t
>(eqlnum[cell]) * numPvtRegions
776 +
static_cast<std::size_t
>(pvtRegion)] = 1;
778 comm.max(present.data(),
static_cast<int>(present.size()));
780 std::vector<std::vector<unsigned>> pvtRegions(numRegions);
781 for (std::size_t r = 0; r < numRegions; ++r) {
782 for (std::size_t p = 0; p < numPvtRegions; ++p) {
783 if (present[r * numPvtRegions + p] != 0) {
784 pvtRegions[r].push_back(
static_cast<unsigned>(p));
793 static std::vector<unsigned>
794 eosRegionOfEachEqlRegion(
const std::vector<int>& eqlnum,
795 const std::vector<int>& eosnum,
796 const std::size_t numRegions,
799 std::vector<int> lowest(numRegions, std::numeric_limits<int>::max());
800 std::vector<int> highest(numRegions, std::numeric_limits<int>::min());
801 for (std::size_t cell = 0; cell < eosnum.size(); ++cell) {
802 const auto region = eqlnum[cell];
803 lowest[region] = std::min(lowest[region], eosnum[cell]);
804 highest[region] = std::max(highest[region], eosnum[cell]);
806 comm.min(lowest.data(),
static_cast<int>(numRegions));
807 comm.max(highest.data(),
static_cast<int>(numRegions));
809 std::vector<unsigned> eosRegions(numRegions, 0);
810 for (std::size_t r = 0; r < numRegions; ++r) {
811 if (lowest[r] > highest[r]) {
814 if (lowest[r] != highest[r]) {
815 OPM_THROW(std::runtime_error,
816 fmt::format(
"Equilibration region {} holds cells of EOS regions "
817 "{} and {}; each equilibration region must lie "
818 "within one EOS region.",
819 r + 1, lowest[r] + 1, highest[r] + 1));
821 eosRegions[r] =
static_cast<unsigned>(lowest[r]);
826 Region setupRegion(
const EquilRecord& record,
827 const TableManager& tables,
828 const std::vector<unsigned>& pvtRegions,
829 const unsigned eosRegion,
831 const std::vector<int>& eqlnum,
832 const std::vector<int>& pvtnum,
835 const int numSamplePoints,
836 const std::size_t regionIdx)
const
840 reg.pvtRegions = pvtRegions;
841 reg.eosRegion = eosRegion;
842 reg.initType = record.compositionalInitType();
843 if (reg.initType != 1 && reg.initType != 3) {
844 OPM_THROW(std::runtime_error,
845 fmt::format(
"Compositional initialization type {} (EQUIL item 10) is "
846 "not supported for region {}; only type 1 (total "
847 "composition) and type 3 (liquid composition) are.",
848 reg.initType, regionIdx + 1));
851 if (record.gasOilContactCapillaryPressure() != 0.0) {
852 OPM_THROW(std::runtime_error,
853 fmt::format(
"Compositional equilibration only supports zero gas-oil "
854 "contact capillary pressure (EQUIL item 6); region {} "
857 unit::convert::to(record.gasOilContactCapillaryPressure(),
861 if (
const auto accuracy = record.initializationTargetAccuracy(); accuracy != 0) {
862 OPM_THROW(std::runtime_error,
863 fmt::format(
"Compositional equilibration only supports cell-centre "
864 "initialization (EQUIL item 9 = 0); region {} specifies {}.",
865 regionIdx + 1, accuracy));
868 reg.zgoc = record.gasOilContactDepth();
869 reg.datum = record.datumDepth();
870 reg.statedGoc = reg.zgoc;
875 const bool deckHasZmfvd = tables.hasTables(
"ZMFVD");
876 const bool deckHasCompvd = tables.hasTables(
"COMPVD");
877 const bool statesZmfvd = deckHasZmfvd &&
878 tables.getZmfvdTables().hasTable(regionIdx);
879 const bool statesCompvd = deckHasCompvd &&
880 tables.getCompvdTables().hasTable(regionIdx);
882 if (statesZmfvd && statesCompvd) {
883 OPM_THROW(std::runtime_error,
884 fmt::format(
"Region {} has both a ZMFVD and a COMPVD composition "
885 "versus depth; give only one of them.", regionIdx + 1));
888 std::optional<std::size_t> zmfvdAt;
889 std::optional<std::size_t> compvdAt;
890 if (deckHasZmfvd && deckHasCompvd) {
891 if (!statesZmfvd && !statesCompvd) {
892 OPM_THROW(std::runtime_error,
893 fmt::format(
"Region {} has neither a ZMFVD nor a COMPVD "
894 "composition versus depth. A deck using both "
895 "keywords has to give every region a record of "
896 "its own, as neither can be inherited.",
899 (statesZmfvd ? zmfvdAt : compvdAt) = regionIdx;
901 else if (deckHasZmfvd) {
902 zmfvdAt = sourceTable(tables.getZmfvdTables(), regionIdx);
904 else if (deckHasCompvd) {
905 compvdAt = sourceTable(tables.getCompvdTables(), regionIdx);
908 if (!zmfvdAt.has_value() && !compvdAt.has_value()) {
909 OPM_THROW(std::runtime_error,
910 fmt::format(
"Region {} has neither a ZMFVD nor a COMPVD composition "
911 "versus depth.", regionIdx + 1));
914 if (zmfvdAt.has_value()) {
915 reg.compositionKeyword =
"ZMFVD";
917 tables.getZmfvdTables().template getTable<ZmfvdTable>(*zmfvdAt);
918 setupComposition(reg.compositionVdTable, zmfvd,
919 allRows(zmfvd.getDepthColumn().size()));
922 reg.compositionKeyword =
"COMPVD";
924 tables.getCompvdTables().template getTable<CompvdTable>(*compvdAt);
925 reg.statedPhaseIdx = statedPhase(compvd, regionIdx);
926 reg.statedSaturationPressure = saturationPressureTable(compvd);
928 if (reg.statedPhaseIdx.has_value()) {
931 if ((reg.initType == 3) &&
932 (*reg.statedPhaseIdx == FluidSystem::gasPhaseIdx)) {
933 OPM_THROW(std::runtime_error,
934 fmt::format(
"Region {} states a vapour composition in COMPVD "
935 "while EQUIL item 10 is 3, which takes the liquid "
936 "composition at the gas-oil contact.",
939 setupComposition(reg.compositionVdTable, compvd,
940 allRows(compvd.getDepthColumn().size()));
948 const auto vaporRows = rowsOfPhase(compvd, CompvdTable::Phase::Vapor);
949 const auto liquidRows = rowsOfPhase(compvd, CompvdTable::Phase::Liquid);
950 reg.zgoc = zoneBoundary(compvd, vaporRows, liquidRows, reg, regionIdx);
952 reg.lastVaporDepth = compvd.getDepthColumn()[vaporRows.back()];
953 if (reg.initType == 1) {
954 setupComposition(reg.compositionVdTable, compvd,
955 allRows(compvd.getDepthColumn().size()));
958 setupComposition(reg.vaporVdTable, compvd, vaporRows);
959 setupComposition(reg.compositionVdTable, compvd, liquidRows);
964 if (tables.hasTables(
"RTEMPVD")) {
965 const auto& rtempvd =
966 tables.getRtempvdTables().template getTable<RtempvdTable>(regionIdx);
967 std::vector<Scalar> tempDepths(rtempvd.getDepthColumn().begin(),
968 rtempvd.getDepthColumn().end());
969 const auto& tempCol = rtempvd.getTemperatureColumn();
970 std::vector<Scalar> temps(tempCol.begin(), tempCol.end());
973 if (tempDepths.size() == 1) {
974 tempDepths.push_back(tempDepths.front() + constantTableSpan);
975 temps.push_back(temps.front());
977 reg.tempVdTable.setXYContainers(tempDepths, temps);
980 const std::vector<Scalar> tempDepths{
Scalar{0}, constantTableSpan};
981 const std::vector<Scalar> temps(tempDepths.size(), tables.rtemp());
982 reg.tempVdTable.setXYContainers(tempDepths, temps);
986 auto span = std::array{std::numeric_limits<Scalar>::max(),
987 std::numeric_limits<Scalar>::lowest()};
989 if (std::cmp_equal(eqlnum[cell], regionIdx)) {
994 span[0] = comm.min(span[0]);
995 span[1] = comm.max(span[1]);
996 if (span[0] > span[1]) {
1000 const Scalar deepestCellDepth = span[1];
1001 if (span[1] - span[0] < minimumSpanExtent) {
1002 span = {span[0] - minimumSpanExtent, span[1] + minimumSpanExtent};
1006 const bool waterActive = FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx);
1007 std::vector<unsigned> waterPvtRegions;
1009 reg.zwoc = record.waterOilContactDepth();
1010 if (pvtRegions.size() > 1) {
1014 std::vector<int> present(pvtRegions.back() + 1, 0);
1016 if (std::cmp_equal(eqlnum[cell], regionIdx) &&
1018 present[pvtnum[cell]] = 1;
1021 comm.max(present.data(),
static_cast<int>(present.size()));
1023 for (
const auto pvtRegion : pvtRegions) {
1024 if (present[pvtRegion] != 0) {
1025 waterPvtRegions.push_back(pvtRegion);
1036 Scalar hcDatum = record.datumDepth();
1037 Scalar hcPressure = record.datumDepthPressure();
1038 const bool datumInWater = waterActive && (record.datumDepth() > reg.zwoc);
1042 reg.anchoredAtWaterContact = waterActive && (record.datumDepth() >= reg.zwoc);
1049 const auto& datumPvtRegions =
1050 waterPvtRegions.empty() ? reg.pvtRegions : waterPvtRegions;
1051 integrateWaterPressure(reg, datumPvtRegions, span, gravity, numSamplePoints,
1052 record.datumDepth(), record.datumDepthPressure());
1054 hcPressure = waterContactPressure(reg, record.datumDepth(), regionIdx)
1055 + record.waterOilContactCapillaryPressure();
1056 OpmLog::info(fmt::format(
"Equilibration region {}: the datum at {} m lies below the "
1057 "water-oil contact at {} m, so it gives the water pressure; "
1058 "the hydrocarbon pressure at the contact is {:.5} bar.",
1059 regionIdx + 1, record.datumDepth(), reg.zwoc,
1060 hcPressure / 1.0e5));
1063 if (reg.initType == 1) {
1064 setupSinglePhaseRegion(reg, span, gravity, numSamplePoints, regionIdx,
1065 hcDatum, hcPressure);
1073 OPM_THROW(std::runtime_error,
1074 fmt::format(
"Compositional equilibration of region {} places the "
1075 "datum at {} m, below the water-oil contact at {} m, "
1076 "while EQUIL item 10 is 3. Put the datum in the "
1077 "hydrocarbon column or use item 10 = 1.",
1078 regionIdx + 1, record.datumDepth(), reg.zwoc));
1080 setupTwoPhaseRegion(reg, record, span, gravity, numSamplePoints, regionIdx);
1085 setupWaterZone(reg, record, span, gravity, numSamplePoints, regionIdx);
1088 if (waterPvtRegions.size() > 1) {
1089 Scalar minPressure = std::numeric_limits<Scalar>::max();
1090 Scalar maxPressure = std::numeric_limits<Scalar>::lowest();
1091 for (
const auto pvtRegion : waterPvtRegions) {
1092 const Scalar pressure = reg.waterPressure.at(pvtRegion).value(deepestCellDepth);
1093 minPressure = std::min(minPressure, pressure);
1094 maxPressure = std::max(maxPressure, pressure);
1096 const Scalar difference = maxPressure - minPressure;
1097 const Scalar scale = std::max(std::abs(minPressure), std::abs(maxPressure));
1098 if (difference > 1.0e-10 * scale) {
1099 auto displayedRegions = waterPvtRegions;
1100 for (
auto& pvtRegion : displayedRegions) {
1103 OpmLog::warning(fmt::format(
1104 "Equilibration region {} has water-zone cells in PVT regions {} "
1105 "with pressures differing by {:.6g} bar at {} m. If those cells "
1106 "connect (including numerical-aquifer NNCs), initial crossflow "
1107 "may occur. Check PVTNUM and initial pressures.",
1108 regionIdx + 1, fmt::join(displayedRegions,
", "),
1109 unit::convert::to(difference, unit::barsa), deepestCellDepth));
1119 void setupWaterZone(Region& reg,
1120 const EquilRecord& record,
1121 const std::array<Scalar, 2>& span,
1123 const int numSamplePoints,
1124 const std::size_t regionIdx)
const
1128 if (!reg.oilPressure.has_value() && !reg.gasPressure.has_value()) {
1133 const bool gasAtContact = reg.gasPressure.has_value()
1134 && (!reg.oilPressure.has_value() || (reg.zwoc <= reg.zgoc));
1135 const auto& hcPressure = gasAtContact ? reg.gasPressure : reg.oilPressure;
1136 const Scalar pcow = record.waterOilContactCapillaryPressure();
1137 const Scalar pContact = hcPressure->value(reg.zwoc) - pcow;
1139 integrateWaterPressure(reg, reg.pvtRegions, span, gravity, numSamplePoints,
1140 reg.zwoc, pContact);
1142 OpmLog::info(fmt::format(
"Equilibration region {}: the water-oil contact "
1143 "is at {} m.", regionIdx + 1, reg.zwoc));
1148 void integrateWaterPressure(Region& reg,
1149 const std::vector<unsigned>& pvtRegions,
1150 const std::array<Scalar, 2>& span,
1152 const int numSamplePoints,
1154 const Scalar pressure)
const
1156 for (
const auto pvtRegion : pvtRegions) {
1157 const WaterODE ode(reg.tempVdTable, reg.eosRegion, pvtRegion, gravity);
1158 reg.waterPressure.try_emplace(pvtRegion, ode,
1159 typename WaterPressFunc::InitCond{depth, pressure},
1160 numSamplePoints, waterContactSpan(reg, span));
1167 static Scalar waterContactPressure(
const Region& reg,
1169 const std::size_t regionIdx)
1173 constexpr Scalar samePressure{1.0e-10};
1175 const auto& [firstPvtRegion, firstColumn] = *reg.waterPressure.begin();
1176 const Scalar pressure = firstColumn.value(reg.zwoc);
1177 for (
const auto& [pvtRegion, column] : reg.waterPressure) {
1178 const Scalar other = column.value(reg.zwoc);
1179 if (std::abs(other - pressure) > samePressure * pressure) {
1180 OPM_THROW(std::runtime_error,
1181 fmt::format(
"Equilibration region {} places the datum at {} m, below "
1182 "the water-oil contact at {} m, but the water of its PVT "
1183 "regions {} and {} reaches the contact at {:.6g} and "
1184 "{:.6g} bar. Put the datum in the hydrocarbon column.",
1185 regionIdx + 1, datum, reg.zwoc,
1186 firstPvtRegion + 1, pvtRegion + 1,
1187 unit::convert::to(pressure, unit::barsa),
1188 unit::convert::to(other, unit::barsa)));
1196 static Scalar waterLimit(
const std::vector<Scalar>& limits,
1197 const std::size_t cell,
1200 return limits.empty() ? fallback : limits[cell];
1217 void setupSinglePhaseRegion(Region& reg,
1218 const std::array<Scalar, 2>& span,
1220 const int numSamplePoints,
1221 const std::size_t regionIdx,
1223 const Scalar datumPressure)
const
1226 setupTwoZoneRegion(reg, span, gravity, numSamplePoints, regionIdx,
1227 datum, datumPressure);
1236 const bool gasAtDatum = reg.anchoredAtWaterContact ? (datum <= reg.zgoc)
1237 : (datum < reg.zgoc);
1238 const auto phaseIdx = reg.statedPhaseIdx.value_or(
1239 gasAtDatum ? FluidSystem::gasPhaseIdx : FluidSystem::oilPhaseIdx);
1244 const Scalar hydrocarbonBottom = FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx)
1245 ? std::min(span[1], reg.zwoc) : span[1];
1246 if ((reg.zgoc > span[0]) && (reg.zgoc < hydrocarbonBottom) &&
1247 !compositionVariesBetween(reg, span[0], reg.zgoc) &&
1248 !compositionVariesBetween(reg, reg.zgoc, hydrocarbonBottom)) {
1249 OpmLog::warning(fmt::format(
"Equilibration region {}: the gas-oil contact "
1250 "at {} m lies inside a type-1 region, but the "
1251 "composition does not vary across the contact. "
1252 "Compositional variation is required for proper "
1253 "phase labeling.", regionIdx + 1, reg.zgoc));
1256 const ODE ode([®](
const Scalar depth) {
return composition(reg, depth); },
1257 reg.tempVdTable, phaseIdx, reg.eosRegion, gravity);
1258 reg.oilPressure.emplace(ode,
1259 typename PressFunc::InitCond{datum, datumPressure},
1260 numSamplePoints, waterContactSpan(reg, span));
1261 reg.nominalPhaseIdx = phaseIdx;
1263 OpmLog::info(fmt::format(
"Equilibration region {}: pressure integrated with one "
1264 "EOS root and the total composition from {} "
1265 "(EQUIL item 10 = 1).",
1266 regionIdx + 1, reg.compositionKeyword));
1272 void setupTwoZoneRegion(Region& reg,
1273 const std::array<Scalar, 2>& span,
1275 const int numSamplePoints,
1276 const std::size_t regionIdx,
1278 const Scalar datumPressure)
const
1280 const auto z = [®](
const Scalar depth) {
return composition(reg, depth); };
1281 const ODE liquidOde(z, reg.tempVdTable, FluidSystem::oilPhaseIdx, reg.eosRegion, gravity);
1282 const ODE gasOde(z, reg.tempVdTable, FluidSystem::gasPhaseIdx, reg.eosRegion, gravity);
1287 const auto pressureSpan = waterContactSpan(reg, span);
1288 const std::array<Scalar, 2> datumSpan{std::min(pressureSpan[0], reg.zgoc),
1289 std::max(pressureSpan[1], reg.zgoc)};
1290 if ((reg.zgoc < span[0]) || (reg.zgoc > span[1])) {
1291 OpmLog::warning(fmt::format(
"Equilibration region {}: the gas zone ends at {} m, "
1292 "outside the cells of the region, so all of them "
1293 "lie in the {} zone.",
1296 (reg.zgoc < span[0]) ?
"liquid" :
"gas"));
1299 if (datum < reg.zgoc) {
1300 reg.gasPressure.emplace(gasOde,
1301 typename PressFunc::InitCond{datum, datumPressure},
1302 numSamplePoints, datumSpan);
1303 reg.oilPressure.emplace(liquidOde,
1304 typename PressFunc::InitCond{
1305 reg.zgoc, reg.gasPressure->value(reg.zgoc)},
1306 numSamplePoints, pressureSpan);
1309 reg.oilPressure.emplace(liquidOde,
1310 typename PressFunc::InitCond{datum, datumPressure},
1311 numSamplePoints, datumSpan);
1312 reg.gasPressure.emplace(gasOde,
1313 typename PressFunc::InitCond{
1314 reg.zgoc, reg.oilPressure->value(reg.zgoc)},
1315 numSamplePoints, pressureSpan);
1318 OpmLog::info(fmt::format(
"Equilibration region {}: COMPVD gives a gas zone above "
1319 "{} m and a liquid one below it "
1320 "(EQUIL item 10 = 1).",
1332 void setupTwoPhaseRegion(Region& reg,
1333 const EquilRecord& record,
1334 const std::array<Scalar, 2>& span,
1336 const int numSamplePoints,
1337 const std::size_t regionIdx)
const
1339 const Scalar inputReferenceDepth = record.datumDepth();
1340 if (inputReferenceDepth != reg.zgoc) {
1341 OpmLog::warning(fmt::format(
"Equilibration region {}: the reference depth {} m "
1342 "does not coincide with the gas-oil contact when "
1343 "EQUIL item 10 is 3; resetting it to the contact "
1345 regionIdx + 1, inputReferenceDepth, reg.zgoc));
1348 const CompVec liquid = composition(reg, reg.zgoc);
1352 if (!SaturationPressure<Scalar, FluidSystem>::bubblePressure(liquid, temp, reg.eosRegion,
1354 OPM_THROW(std::runtime_error,
1355 fmt::format(
"The saturation pressure calculation at the gas-oil "
1356 "contact of region {} did not converge.", regionIdx + 1));
1358 reg.vaporComposition = vapor;
1365 constexpr Scalar oneAtmosphere = unit::atm;
1366 const Scalar inputPressure = record.datumDepthPressure();
1367 const bool resetToPsat = record.setToSaturationPressure()
1368 && (std::abs(inputPressure - psat) >= oneAtmosphere);
1369 const Scalar referencePressure = resetToPsat ? psat : inputPressure;
1371 OpmLog::info(fmt::format(
"Equilibration region {}: two phases, liquid composition "
1372 "specified (EQUIL item 10 is 3). The saturation pressure "
1373 "at the gas-oil contact ({} m) is {:.6g} bar.",
1374 regionIdx + 1, reg.zgoc,
1375 unit::convert::to(psat, unit::barsa)));
1378 OpmLog::warning(fmt::format(
"Equilibration region {}: the datum pressure {:.6g} bar "
1379 "differs from the saturation pressure {:.6g} bar at the "
1380 "gas-oil contact by one atmosphere or more; the "
1381 "saturation pressure is used instead.",
1383 unit::convert::to(inputPressure, unit::barsa),
1384 unit::convert::to(psat, unit::barsa)));
1387 const ODE oilOde([®](
const Scalar depth) {
return composition(reg, depth); },
1388 reg.tempVdTable, FluidSystem::oilPhaseIdx, reg.eosRegion, gravity);
1389 reg.oilPressure.emplace(oilOde,
1390 typename PressFunc::InitCond{reg.zgoc, referencePressure},
1391 numSamplePoints, waterContactSpan(reg, span));
1393 const ODE gasOde(gasColumnComposition(reg),
1394 reg.tempVdTable, FluidSystem::gasPhaseIdx, reg.eosRegion, gravity);
1395 reg.gasPressure.emplace(gasOde,
1396 typename PressFunc::InitCond{reg.zgoc, referencePressure},
1397 numSamplePoints, waterContactSpan(reg, span));
1405 static bool isInGasZone(
const Region& reg,
const Scalar depth)
1407 if (reg.twoZone && (reg.initType == 1) && (depth <= reg.lastVaporDepth)) {
1410 return ((reg.initType == 3) || reg.twoZone) && (depth < reg.zgoc);
1413 Scalar assignCell(
FluidState& fs,
const Region& reg,
const unsigned pvtRegion,
1414 const Scalar depth,
const std::size_t cell)
const
1416 const bool inGasZone = isInGasZone(reg, depth);
1418 const CompVec z = [®, depth, inGasZone]() {
1420 if (!inGasZone || (reg.initType == 1)) {
1421 return composition(reg, depth);
1425 return reg.twoZone ? vaporComposition(reg, depth) : reg.vaporComposition;
1427 const auto& pressFunc = inGasZone ? reg.gasPressure : reg.oilPressure;
1428 if (!pressFunc.has_value()) {
1429 OPM_THROW(std::runtime_error,
1430 "Evaluating the equilibrated pressure of a region without cells.");
1437 const Scalar hydrocarbonPressure = pressFunc->value(depth);
1439 const auto water = reg.waterPressure.find(pvtRegion);
1440 const WaterPressFunc* waterPressure =
1441 (water != reg.waterPressure.end()) ? &water->second :
nullptr;
1442 const bool inWaterZone = (depth > reg.zwoc) && (waterPressure !=
nullptr);
1443 const Scalar press = inWaterZone ? waterPressure->value(depth)
1444 : hydrocarbonPressure;
1447 for (
unsigned phaseIdx = 0; phaseIdx < FluidSystem::numPhases; ++phaseIdx) {
1448 if (FluidSystem::phaseIsActive(phaseIdx)) {
1449 fs.setPressure(phaseIdx, hydrocarbonPressure);
1450 fs.setSaturation(phaseIdx, 0.0);
1457 if (FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx)) {
1461 sWat = (depth > reg.zwoc) ? waterLimit(maxWater_, cell,
Scalar{1})
1462 : waterLimit(connateWater_, cell,
Scalar{0});
1463 fs.setSaturation(FluidSystem::waterPhaseIdx, sWat);
1464 if (waterPressure !=
nullptr) {
1465 fs.setPressure(FluidSystem::waterPhaseIdx, waterPressure->value(depth));
1472 fs.setSaturation(inGasZone ? FluidSystem::gasPhaseIdx : reg.nominalPhaseIdx,
1475 for (
int c = 0; c < numComponents; ++c) {
1476 fs.setMoleFraction(c, z[c]);
1482 static constexpr int numReportDepths{50};
1486 std::optional<std::pair<Scalar, CompVec>> bubblePoint(
const Region& reg,
1487 const CompVec& liquid,
1488 const Scalar depth)
const
1493 if (!SaturationPressure<Scalar, FluidSystem>::bubblePressure(liquid, temp, reg.eosRegion,
1495 return std::nullopt;
1497 return std::pair{psat, vapour};
1500 std::vector<ReportRow> reportRows(
const Region& reg,
const ReportRegion& where)
const
1505 const bool type3 = (reg.initType == 3);
1506 const CompVec contactLiquid = type3 ? composition(reg, reg.zgoc) : CompVec{};
1507 const auto gasZoneComposition = gasColumnComposition(reg);
1508 const typename ODE::CompositionFunction oilComposition =
1509 [®, type3, contactLiquid](
const Scalar depth) {
1510 return (type3 && isInGasZone(reg, depth)) ? contactLiquid
1511 : composition(reg, depth);
1513 const typename ODE::CompositionFunction gasComposition =
1514 [
this, ®, type3, gasZoneComposition](
const Scalar depth) -> CompVec {
1515 if (!type3 || isInGasZone(reg, depth)) {
1516 return gasZoneComposition(depth);
1518 const auto bubble = bubblePoint(reg, composition(reg, depth), depth);
1519 return bubble.has_value() ? bubble->second : gasZoneComposition(depth);
1522 const ODE oilOde(oilComposition, reg.tempVdTable, reg.nominalPhaseIdx, reg.eosRegion,
1524 const ODE oilDensity(oilComposition, reg.tempVdTable, reg.nominalPhaseIdx, reg.eosRegion,
1526 const ODE gasOde(gasComposition, reg.tempVdTable, FluidSystem::gasPhaseIdx,
1527 reg.eosRegion, gravity_);
1528 const ODE gasDensity(gasComposition, reg.tempVdTable, FluidSystem::gasPhaseIdx,
1529 reg.eosRegion, Scalar{1});
1534 const std::array<Scalar, 2> span{where.top, where.bottom};
1535 const PressFunc oilColumn(oilOde, reg.oilPressure->initialCondition(),
1536 numSamplePoints_, span);
1537 std::optional<PressFunc> gasColumn;
1538 if (reg.gasPressure.has_value()) {
1539 gasColumn.emplace(gasOde, reg.gasPressure->initialCondition(),
1540 numSamplePoints_, span);
1546 constexpr bool hasWaterPhase = FluidSystem::numPhases > FluidSystem::waterPhaseIdx;
1547 std::optional<WaterPressFunc> waterColumn;
1548 std::optional<WaterODE> waterDensity;
1549 if constexpr (hasWaterPhase) {
1550 auto water = reg.waterPressure.find(where.pvtRegion);
1551 if (water == reg.waterPressure.end()) {
1552 water = reg.waterPressure.begin();
1554 if (water != reg.waterPressure.end()) {
1555 const WaterODE waterOde(reg.tempVdTable, reg.eosRegion, water->first, gravity_);
1556 waterColumn.emplace(waterOde, water->second.initialCondition(),
1557 numSamplePoints_, span);
1558 waterDensity.emplace(reg.tempVdTable, reg.eosRegion, water->first, Scalar{1});
1564 const bool totalWithoutHydrocarbon = (reg.statedGoc > where.top)
1565 && (reg.statedGoc <= reg.datum) && (reg.datum < reg.zwoc);
1567 const bool waterActive = FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx);
1568 std::vector<ReportRow> rows(numReportDepths);
1569 for (
int i = 0; i < numReportDepths; ++i) {
1570 auto& row = rows[i];
1571 const Scalar depth = where.top + (where.bottom - where.top) * i / (numReportDepths - 1);
1574 const bool inGasZone = isInGasZone(reg, depth);
1575 row.poil = oilColumn.value(depth);
1576 row.pgas = gasColumn.has_value() ? gasColumn->value(depth) : row.poil;
1577 if constexpr (hasWaterPhase) {
1578 if (waterColumn.has_value()) {
1579 row.pwat = waterColumn->value(depth);
1585 const bool inWaterZone = (depth > reg.zwoc) && waterColumn.has_value();
1586 const Scalar cellPressure = inWaterZone ? row.pwat
1587 : (inGasZone && gasColumn.has_value()) ? row.pgas
1589 row.deno = oilDensity(depth, cellPressure);
1590 row.deng = gasColumn.has_value() ? gasDensity(depth, cellPressure) : row.deno;
1591 if constexpr (hasWaterPhase) {
1592 if (waterColumn.has_value()) {
1593 row.denw = (*waterDensity)(depth, cellPressure);
1599 row.swat = (depth > reg.zwoc) ? where.swu : where.swl;
1601 const auto hydrocarbonPhase = inGasZone ? FluidSystem::gasPhaseIdx
1602 : reg.nominalPhaseIdx;
1603 (hydrocarbonPhase == FluidSystem::gasPhaseIdx ? row.sgas : row.soil)
1604 = Scalar{1} - row.swat;
1606 if (reg.statedSaturationPressure.has_value()) {
1611 row.oil = row.gas = row.total = composition(reg, depth);
1613 else if (inGasZone) {
1614 row.oil = contactLiquid;
1615 row.gas = row.total = gasZoneComposition(depth);
1618 if (
const auto bubble = bubblePoint(reg, contactLiquid, depth);
1619 bubble.has_value()) {
1620 row.psat = bubble->first;
1624 row.oil = row.total = composition(reg, depth);
1626 if (
const auto bubble = bubblePoint(reg, row.oil, depth); bubble.has_value()) {
1627 row.psat = bubble->first;
1628 row.gas = bubble->second;
1631 if ((row.soil + row.sgas == 0) && !totalWithoutHydrocarbon) {
1632 row.total = CompVec{};
1639 int numSamplePoints_;
1643 std::vector<Scalar> connateWater_;
1644 std::vector<Scalar> maxWater_;
1645 std::vector<Region> regions_;
1646 std::vector<FluidState> fluidStates_;
1647 std::vector<Scalar> referencePressures_;
1648 std::vector<int> twoPhaseCheckRegions_;
1665template <
class Scalar,
class Liqu
idFraction>
1668 const LiquidFraction& liquidFraction,
1669 const std::size_t numRegions,
1675 constexpr Scalar minReportedFraction{1.0e-3};
1680 std::vector<Scalar> shallowest(numRegions, std::numeric_limits<Scalar>::max());
1681 std::vector<Scalar> deepest(numRegions, std::numeric_limits<Scalar>::lowest());
1682 std::vector<Scalar> leastFraction(numRegions, std::numeric_limits<Scalar>::max());
1683 std::vector<Scalar> mostFraction(numRegions, std::numeric_limits<Scalar>::lowest());
1684 for (std::size_t cell = 0; cell < checkRegions.size(); ++cell) {
1685 if (checkRegions[cell] < 0) {
1688 const Scalar liquid = liquidFraction(cell);
1689 const Scalar fraction = std::min(liquid, Scalar{1} - liquid);
1691 if (!(fraction >= minReportedFraction)) {
1694 const auto r =
static_cast<std::size_t
>(checkRegions[cell]);
1696 shallowest[r] = std::min(shallowest[r], depth);
1697 deepest[r] = std::max(deepest[r], depth);
1698 leastFraction[r] = std::min(leastFraction[r], fraction);
1699 mostFraction[r] = std::max(mostFraction[r], fraction);
1701 const auto count =
static_cast<int>(numRegions);
1702 comm.min(shallowest.data(), count);
1703 comm.max(deepest.data(), count);
1704 comm.min(leastFraction.data(), count);
1705 comm.max(mostFraction.data(), count);
1708 const auto depthRange = [](
const Scalar top,
const Scalar bottom) {
1709 const auto shallow = fmt::format(
"{:.2f} m", top);
1710 const auto deep = fmt::format(
"{:.2f} m", bottom);
1711 return (shallow == deep) ?
"at " + shallow :
"between " + shallow +
" and " + deep;
1713 for (std::size_t r = 0; r < numRegions; ++r) {
1714 if (shallowest[r] > deepest[r]) {
1719 const auto least = fmt::format(
"{:.3g}%", 100 * leastFraction[r]);
1720 const auto most = fmt::format(
"{:.3g}%", 100 * mostFraction[r]);
1721 OpmLog::warning(fmt::format(
"Equilibration region {}: cells {} split into gas and "
1722 "liquid at their initial pressure, with the smaller phase "
1723 "holding {} of the hydrocarbon moles. With EQUIL "
1724 "item 10 = 1, that pressure comes from the density of a "
1725 "single phase, so the gas and liquid in these cells are "
1726 "not in hydrostatic equilibrium and may move up or down "
1727 "once the simulation starts.",
1729 depthRange(shallowest[r], deepest[r]),
1730 (least == most) ? least : least +
" to " + most));
#define OPM_END_PARALLEL_TRY_CATCH(prefix, comm)
Catch exception and throw in a parallel try-catch clause.
Definition: DeferredLoggingErrorHelpers.hpp:197
#define OPM_BEGIN_PARALLEL_TRY_CATCH()
Macro to setup the try of a parallel try-catch.
Definition: DeferredLoggingErrorHelpers.hpp:160
Composition versus depth report (RPTSOL SOLVD) of the compositional equilibration.
The ODE integrator and phase-pressure function used to solve the hydrostatic equilibrium problem,...
Definition: InitStateEquilComp.hpp:95
Tabulated1DFunction< Scalar > TabulatedFunction
Definition: InitStateEquilComp.hpp:100
EosDensityODE(CompositionFunction composition, const TabulatedFunction &tempVdTable, const unsigned phaseIdx, const unsigned eosRegion, const Scalar normGrav)
Definition: InitStateEquilComp.hpp:102
Scalar operator()(const Scalar depth, const Scalar press) const
Definition: InitStateEquilComp.hpp:114
typename FluidSystem::Scalar Scalar
Definition: InitStateEquilComp.hpp:97
std::array< Scalar, FluidSystem::numComponents > CompVec
Definition: InitStateEquilComp.hpp:98
std::function< CompVec(Scalar)> CompositionFunction
Definition: InitStateEquilComp.hpp:99
Definition: InitStateEquilComp.hpp:146
Scalar operator()(const Scalar depth, const Scalar press) const
Definition: InitStateEquilComp.hpp:161
WaterDensityODE(const TabulatedFunction &tempVdTable, const unsigned eosRegion, const unsigned pvtRegion, const Scalar normGrav)
Definition: InitStateEquilComp.hpp:151
Tabulated1DFunction< Scalar > TabulatedFunction
Definition: InitStateEquilComp.hpp:149
typename FluidSystem::Scalar Scalar
Definition: InitStateEquilComp.hpp:148
Computes the initial state of a compositional model from hydrostatic equilibrium (the EQUIL and ZMFVD...
Definition: InitStateEquilComp.hpp:243
std::vector< std::vector< ReportRow > > compositionVersusDepth(const std::vector< ReportRegion > ®ions) const
Definition: InitStateEquilComp.hpp:443
CompositionalFluidState< Scalar, FluidSystem > FluidState
Definition: InitStateEquilComp.hpp:246
std::vector< int > & twoPhaseCheckRegions()
Definition: InitStateEquilComp.hpp:389
typename FluidSystem::Scalar Scalar
Definition: InitStateEquilComp.hpp:245
const std::vector< int > & twoPhaseCheckRegions() const
Definition: InitStateEquilComp.hpp:392
const std::vector< Scalar > & referencePressures() const
Definition: InitStateEquilComp.hpp:382
const std::vector< FluidState > & fluidStates() const
Definition: InitStateEquilComp.hpp:376
std::vector< FluidState > & fluidStates()
Definition: InitStateEquilComp.hpp:373
InitialStateComputer(const EclipseState &inputState, const std::vector< int > &eosnum, const std::vector< Scalar > &cellCenterDepth, const std::vector< int > &eqlnum, const std::vector< int > &pvtnum, const Parallel::Communication &comm, const Scalar gravity, const int numSamplePoints, const std::vector< Scalar > &connateWater={}, const std::vector< Scalar > &maxWater={})
Definition: InitStateEquilComp.hpp:263
Definition: PressureFunction.hpp:128
Scalar evalDepthTable(const Tabulated1DFunction< Scalar > &table, const Scalar depth)
Definition: InitStateEquilComp.hpp:84
Definition: EquilCompReport.hpp:46
void reportTwoPhaseCells(const std::vector< int > &checkRegions, const std::vector< Scalar > &cellCenterDepth, const LiquidFraction &liquidFraction, const std::size_t numRegions, const Parallel::Communication &comm)
Definition: InitStateEquilComp.hpp:1666
Scalar cellCenterDepth(const Element &element)
Definition: InitStateEquil_impl.hpp:134
Dune::Communication< MPIComm > Communication
Definition: ParallelCommunication.hpp:30
Phase
Phase indices for reservoir coupling, we currently only support black-oil phases (oil,...
Definition: ReservoirCoupling.hpp:184
One depth of the composition versus depth report, in SI units.
Definition: EquilCompReport.hpp:51
Definition: InitStateEquilComp.hpp:399
Scalar bottom
Definition: InitStateEquilComp.hpp:401
unsigned pvtRegion
Zero-based PVT region whose water column is reported.
Definition: InitStateEquilComp.hpp:406
Scalar swl
Connate and maximum water saturation of the representative cell.
Definition: InitStateEquilComp.hpp:403
Scalar swu
Definition: InitStateEquilComp.hpp:404
Scalar top
Definition: InitStateEquilComp.hpp:400