Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use DENSITY in CO2STORE runs #3879

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
45 changes: 24 additions & 21 deletions opm/material/fluidsystems/blackoilpvt/BrineCo2Pvt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,7 @@ initFromState(const EclipseState& eclState, const Schedule&)
{

bool co2sol = eclState.runspec().co2Sol();
if (!co2sol && !eclState.getTableManager().getDensityTable().empty()) {
OpmLog::warning("CO2STORE is enabled but DENSITY is in the deck. \n"
"The surface density is computed based on CO2-BRINE "
"PVT at standard conditions (STCOND) and DENSITY is ignored");
}


if (!co2sol && (eclState.getTableManager().hasTables("PVDO") ||
!eclState.getTableManager().getPvtoTables().empty())) {
Expand All @@ -65,30 +61,37 @@ initFromState(const EclipseState& eclState, const Schedule&)
// We only supported single pvt region for the co2-brine module
size_t numRegions = 1;
setNumRegions(numRegions);

size_t regionIdx = 0;
// Currently we only support constant salinity
const Scalar molality = eclState.getTableManager().salinity(); // mol/kg
const Scalar MmNaCl = 58.44e-3; // molar mass of NaCl [kg/mol]
// convert to mass fraction
salinity_[regionIdx] = 1 / ( 1 + 1 / (molality*MmNaCl));
// set the surface conditions using the STCOND keyword
Scalar T_ref = eclState.getTableManager().stCond().temperature;
Scalar P_ref = eclState.getTableManager().stCond().pressure;

// Throw an error if STCOND is not (T, p) = (15.56 C, 1 atm) = (288.71 K, 1.01325e5 Pa)
if (T_ref != Scalar(288.71) || P_ref != Scalar(1.01325e5)) {
OPM_THROW(std::runtime_error, "CO2STORE can only be used with default values for STCOND!");
}

brineReferenceDensity_[regionIdx] = Brine::liquidDensity(T_ref, P_ref, salinity_[regionIdx], extrapolate);
co2ReferenceDensity_[regionIdx] = CO2::gasDensity(T_ref, P_ref, extrapolate);
if (co2sol) {
brineReferenceDensity_[regionIdx] = eclState.getTableManager().getDensityTable()[regionIdx].water;
Scalar T_ref = eclState.getTableManager().stCond().temperature;
Scalar P_ref = eclState.getTableManager().stCond().pressure;
// Throw an error if STCOND is not (T, p) = (15.56 C, 1 atm) = (288.71 K, 1.01325e5 Pa)
if (T_ref != Scalar(288.71) || P_ref != Scalar(1.01325e5)) {
OPM_THROW(std::runtime_error, "CO2SOL can only be used with default values for STCOND!");
}
co2ReferenceDensity_[regionIdx] = CO2::gasDensity(T_ref, P_ref, extrapolate);
} else if (!eclState.getTableManager().getDensityTable().empty()) {
brineReferenceDensity_[regionIdx] = eclState.getTableManager().getDensityTable()[regionIdx].water;
co2ReferenceDensity_[regionIdx] = eclState.getTableManager().getDensityTable()[regionIdx].gas;
} else {
Scalar T_ref = eclState.getTableManager().stCond().temperature;
Scalar P_ref = eclState.getTableManager().stCond().pressure;
// Throw an error if STCOND is not (T, p) = (15.56 C, 1 atm) = (288.71 K, 1.01325e5 Pa)
if (T_ref != Scalar(288.71) || P_ref != Scalar(1.01325e5)) {
OPM_THROW(std::runtime_error, "CO2STORE can only be used with default values for STCOND!");
}
co2ReferenceDensity_[regionIdx] = CO2::gasDensity(T_ref, P_ref, extrapolate);
brineReferenceDensity_[regionIdx] = Brine::liquidDensity(T_ref, P_ref, salinity_[regionIdx], extrapolate);
}

OpmLog::info("CO2STORE/CO2SOL is enabled. \n The surface density of CO2 is " + std::to_string(co2ReferenceDensity_[regionIdx])
+ "kg/m3 \n The surface density of Brine is " + std::to_string(brineReferenceDensity_[regionIdx])
+ "kg/m3"
+ "\n The surface densities are computed using the reference pressure ( " + std::to_string(P_ref)
+ "Pa) and the reference temperature (" + std::to_string(T_ref) + "K)."
);
}

template class BrineCo2Pvt<double>;
Expand Down
44 changes: 36 additions & 8 deletions opm/material/fluidsystems/blackoilpvt/Co2GasPvt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,44 @@ initFromState(const EclipseState& eclState, const Schedule&)
size_t numRegions = 1;
setNumRegions(numRegions);
size_t regionIdx = 0;
Scalar T_ref = eclState.getTableManager().stCond().temperature;
Scalar P_ref = eclState.getTableManager().stCond().pressure;

// Throw an error if STCOND is not (T, p) = (15.56 C, 1 atm) = (288.71 K, 1.01325e5 Pa)
if (T_ref != Scalar(288.71) || P_ref != Scalar(1.01325e5)) {
OPM_THROW(std::runtime_error, "CO2STORE/CO2SOL can only be used with default values for STCOND!");
// Currently we only support constant salinity
const Scalar molality = eclState.getTableManager().salinity(); // mol/kg
const Scalar MmNaCl = 58.44e-3; // molar mass of NaCl [kg/mol]
// convert to mass fraction
salinity_[regionIdx] = 1 / ( 1 + 1 / (molality*MmNaCl));

Copy link
Member Author

Choose a reason for hiding this comment

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

This sets the salinity used by the brine module to compute the fraction of vaporized water in the gas phase. This makes the brine module consistent with the CO2 module. Test is also the reason for the test failure.

if (co2sol) {
brineReferenceDensity_[regionIdx] = eclState.getTableManager().getDensityTable()[regionIdx].water;
Scalar T_ref = eclState.getTableManager().stCond().temperature;
Scalar P_ref = eclState.getTableManager().stCond().pressure;
// Throw an error if STCOND is not (T, p) = (15.56 C, 1 atm) = (288.71 K, 1.01325e5 Pa)
if (T_ref != Scalar(288.71) || P_ref != Scalar(1.01325e5)) {
OPM_THROW(std::runtime_error, "CO2SOL can only be used with default values for STCOND!");
}
gasReferenceDensity_[regionIdx] = CO2::gasDensity(T_ref, P_ref, extrapolate);
} else if (!eclState.getTableManager().getDensityTable().empty()) {
OpmLog::info("CO2STORE is enabled and DENSITY is given in the deck. \n"
"The surface density from DENSITY is used.");
brineReferenceDensity_[regionIdx] = eclState.getTableManager().getDensityTable()[regionIdx].water;
gasReferenceDensity_[regionIdx] = eclState.getTableManager().getDensityTable()[regionIdx].gas;
} else {
Scalar T_ref = eclState.getTableManager().stCond().temperature;
Scalar P_ref = eclState.getTableManager().stCond().pressure;
// Throw an error if STCOND is not (T, p) = (15.56 C, 1 atm) = (288.71 K, 1.01325e5 Pa)
if (T_ref != Scalar(288.71) || P_ref != Scalar(1.01325e5)) {
OPM_THROW(std::runtime_error, "CO2STORE can only be used with default values for STCOND!");
}
gasReferenceDensity_[regionIdx] = CO2::gasDensity(T_ref, P_ref, extrapolate);
brineReferenceDensity_[regionIdx] = Brine::liquidDensity(T_ref, P_ref, salinity_[regionIdx], extrapolate);
OpmLog::info("CO2STORE is enabled and DENSITY is not given in the deck. \n "
"The surface densities are computed using the reference pressure ( " + std::to_string(P_ref)
+ "Pa) and the reference temperature (" + std::to_string(T_ref) + "K)."
+ "The surface density of CO2 is " + std::to_string(gasReferenceDensity_[regionIdx])
+ "kg/m3 \n The surface density of Brine is " + std::to_string(brineReferenceDensity_[regionIdx])
+ "kg/m3"
);
}

gasReferenceDensity_[regionIdx] = CO2::gasDensity(T_ref, P_ref, extrapolate);
brineReferenceDensity_[regionIdx] = Brine::liquidDensity(T_ref, P_ref, salinity_[regionIdx], extrapolate);
initEnd();
}

Expand Down