"<< std::endl;
std::cout << "prop = {density, invB, B, viscosity, rsSat, internalEnergy, enthalpy, diffusionCoefficient}" << std::endl;
std::cout << "phase = {CO2, brine}" << std::endl;
std::cout << "p: pressure in pascal" << std::endl;
std::cout << "T: temperature in kelvin" << std::endl;
std::cout << "salinity(optional): salt molality in mol/kg" << std::endl;
std::cout << "rs(optional): amount of dissolved CO2 in Brine in SM3/SM3" << std::endl;
std::cout << "OPTIONS:" << std::endl;
std::cout << "--h/--help Print help and exit." << std::endl;
std::cout << "DESCRIPTION:" << std::endl;
std::cout << "co2brinepvt computes PVT properties of a brine/co2 system " << std::endl;
std::cout << "for a given phase (oil or brine), pressure, temperature, salinity and rs." << std::endl;
std::cout << "The properties support are: density, the inverse phase formation volume factor (invB), viscosity, " << std::endl;
std::cout << "saturated dissolution factor (rsSat) " << std::endl;
std::cout << "See CO2STORE in the OPM manual for more details." << std::endl;
return EXIT_FAILURE;
}
std::string prop = argv[1];
std::string phase = argv[2];
double p = atof(argv[3]);
double T = atof(argv[4]);
double molality = 0.0;
double rs = 0.0;
double rv = 0.0; // only support 0.0 for now
if (argc > 5)
molality = atof(argv[5]);
if (argc > 6)
rs = atof(argv[6]);
const double MmNaCl = 58.44e-3; // molar mass of NaCl [kg/mol]
// convert to mass fraction
std::vector salinity = {0.0};
if (molality > 0.0)
salinity[0] = 1 / ( 1 + 1 / (molality*MmNaCl));
Opm::BrineCo2Pvt brineCo2Pvt(salinity);
Opm::Co2GasPvt co2Pvt(salinity);
double value;
if (prop == "density") {
if (phase == "CO2") {
value = densityGas(co2Pvt, p, T, rv);
} else if (phase == "brine") {
value = densityBrine(brineCo2Pvt, p, T, rs);
} else {
throw std::runtime_error("phase " + phase + " not recognized. Use either CO2 or brine");
}
} else if (prop == "invB" || prop == "B") {
if (phase == "CO2") {
value = co2Pvt.inverseFormationVolumeFactor(/*regionIdx=*/0,
T,
p,
rv,
/*Rvw=*/0.0);
} else if (phase == "brine") {
value = brineCo2Pvt.inverseFormationVolumeFactor(/*regionIdx=*/0,
T,
p,
rs);
} else {
throw std::runtime_error("phase " + phase + " not recognized. Use either CO2 or brine");
}
if (prop == "B")
value = 1 / value;
} else if (prop == "viscosity") {
if (phase == "CO2") {
value = co2Pvt.viscosity(/*regionIdx=*/0,
T,
p,
rv,
/*Rvw=*/0.0);
} else if (phase == "brine") {
value = brineCo2Pvt.viscosity(/*regionIdx=*/0,
T,
p,
rs);
} else {
throw std::runtime_error("phase " + phase + " not recognized. Use either CO2 or brine");
}
} else if (prop == "rsSat") {
if (phase == "CO2") {
value = co2Pvt.saturatedWaterVaporizationFactor(/*regionIdx=*/0,
T,
p);
} else if (phase == "brine") {
value = brineCo2Pvt.saturatedGasDissolutionFactor(/*regionIdx=*/0,
T,
p);
} else {
throw std::runtime_error("phase " + phase + " not recognized. Use either CO2 or brine");
}
} else if (prop == "diffusionCoefficient") {
size_t comp_idx = 0; // not used
if (phase == "CO2") {
value = co2Pvt.diffusionCoefficient(T,p, comp_idx);
} else if (phase == "brine") {
value = brineCo2Pvt.diffusionCoefficient(T,p, comp_idx);
} else {
throw std::runtime_error("phase " + phase + " not recognized. Use either CO2 or brine");
}
} else if (prop == "internalEnergy") {
if (phase == "CO2") {
value = co2Pvt.internalEnergy(/*regionIdx=*/0 ,T,p, rv, 0.0);
} else if (phase == "brine") {
value = brineCo2Pvt.internalEnergy(/*regionIdx=*/0 ,T,p, rs);
} else {
throw std::runtime_error("phase " + phase + " not recognized. Use either CO2 or brine");
}
} else if (prop == "enthalpy") {
if (phase == "CO2") {
value = p / densityGas(co2Pvt, p, T, rv) + co2Pvt.internalEnergy(/*regionIdx=*/0 ,T,p, rv, 0.0);
} else if (phase == "brine") {
value = p / densityBrine(brineCo2Pvt, p, T, rs) + brineCo2Pvt.internalEnergy(/*regionIdx=*/0 ,T,p, rs);
} else {
throw std::runtime_error("phase " + phase + " not recognized. Use either CO2 or brine");
}
} else {
throw std::runtime_error("prop " + prop + " not recognized. "
+ "Use either density, visosity, invB, B, internalEnergy, enthalpy or diffusionCoefficient");
}
std::cout << value << std::endl;
return 0;
}