Adds the new interface to SinglePvtLivGas
This commit is contained in:
parent
1c904aa451
commit
01bb02f4cd
@ -81,12 +81,12 @@ namespace Opm
|
||||
if (phase_usage_.phase_used[Liquid]) {
|
||||
if (deck.hasField("PVDO")) {
|
||||
if (samples > 0) {
|
||||
// props_[phase_usage_.phase_pos[Liquid]].reset(new SinglePvtDeadSpline(deck.getPVDO().pvdo_, samples));
|
||||
props_[phase_usage_.phase_pos[Liquid]].reset(new SinglePvtDeadSpline(deck.getPVDO().pvdo_, samples));
|
||||
} else {
|
||||
props_[phase_usage_.phase_pos[Liquid]].reset(new SinglePvtDead(deck.getPVDO().pvdo_));
|
||||
}
|
||||
} else if (deck.hasField("PVTO")) {
|
||||
//props_[phase_usage_.phase_pos[Liquid]].reset(new SinglePvtLiveOil(deck.getPVTO().pvto_));
|
||||
props_[phase_usage_.phase_pos[Liquid]].reset(new SinglePvtLiveOil(deck.getPVTO().pvto_));
|
||||
} else if (deck.hasField("PVCDO")) {
|
||||
props_[phase_usage_.phase_pos[Liquid]].reset(new SinglePvtConstCompr(deck.getPVCDO().pvcdo_));
|
||||
} else {
|
||||
@ -97,12 +97,12 @@ namespace Opm
|
||||
if (phase_usage_.phase_used[Vapour]) {
|
||||
if (deck.hasField("PVDG")) {
|
||||
if (samples > 0) {
|
||||
// props_[phase_usage_.phase_pos[Vapour]].reset(new SinglePvtDeadSpline(deck.getPVDG().pvdg_, samples));
|
||||
props_[phase_usage_.phase_pos[Vapour]].reset(new SinglePvtDeadSpline(deck.getPVDG().pvdg_, samples));
|
||||
} else {
|
||||
props_[phase_usage_.phase_pos[Vapour]].reset(new SinglePvtDead(deck.getPVDG().pvdg_));
|
||||
}
|
||||
} else if (deck.hasField("PVTG")) {
|
||||
// props_[phase_usage_.phase_pos[Vapour]].reset(new SinglePvtLiveGas(deck.getPVTG().pvtg_));
|
||||
props_[phase_usage_.phase_pos[Vapour]].reset(new SinglePvtLiveGas(deck.getPVTG().pvtg_));
|
||||
} else {
|
||||
THROW("Input is missing PVDG or PVTG\n");
|
||||
}
|
||||
|
@ -49,12 +49,12 @@ namespace Opm
|
||||
double* output_mu) const;
|
||||
|
||||
/// Viscosity and its derivatives as a function of p and r.
|
||||
virtual void mu(const int n,
|
||||
const double* p,
|
||||
const double* r,
|
||||
double* output_mu,
|
||||
double* output_dmudp,
|
||||
double* output_dmudr) const;
|
||||
virtual void mu(const int n,
|
||||
const double* p,
|
||||
const double* r,
|
||||
double* output_mu,
|
||||
double* output_dmudp,
|
||||
double* output_dmudr) const;
|
||||
|
||||
/// Formation volume factor as a function of p and z.
|
||||
virtual void B(const int n,
|
||||
|
@ -52,7 +52,7 @@ namespace Opm
|
||||
B_inv[i] = 1.0 / pvd_table[region_number][1][i];
|
||||
visc[i] = pvd_table[region_number][2][i];
|
||||
}
|
||||
buildUniformMonotoneTable(press, B_inv, samples, one_over_B_);
|
||||
buildUniformMonotoneTable(press, B_inv, samples, b_);
|
||||
buildUniformMonotoneTable(press, visc, samples, viscosity_);
|
||||
|
||||
// Dumping the created tables.
|
||||
@ -81,6 +81,23 @@ namespace Opm
|
||||
}
|
||||
}
|
||||
|
||||
void SinglePvtDeadSpline::mu(const int n,
|
||||
const double* p,
|
||||
const double* /*r*/,
|
||||
double* output_mu,
|
||||
double* output_dmudp,
|
||||
double* output_dmudr) const
|
||||
{
|
||||
// #pragma omp parallel for
|
||||
|
||||
for (int i = 0; i < n; ++i) {
|
||||
output_mu[i] = viscosity_(p[i]);
|
||||
output_dmudp[i] = viscosity_.derivative(p[i]);
|
||||
}
|
||||
std::fill(output_dmudr, output_dmudr + n, 0.0);
|
||||
|
||||
}
|
||||
|
||||
void SinglePvtDeadSpline::B(const int n,
|
||||
const double* p,
|
||||
const double* /*z*/,
|
||||
@ -88,7 +105,7 @@ namespace Opm
|
||||
{
|
||||
// #pragma omp parallel for
|
||||
for (int i = 0; i < n; ++i) {
|
||||
output_B[i] = 1.0/one_over_B_(p[i]);
|
||||
output_B[i] = 1.0/b_(p[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -102,10 +119,36 @@ namespace Opm
|
||||
// #pragma omp parallel for
|
||||
for (int i = 0; i < n; ++i) {
|
||||
double Bg = output_B[i];
|
||||
output_dBdp[i] = -Bg*Bg*one_over_B_.derivative(p[i]);
|
||||
output_dBdp[i] = -Bg*Bg*b_.derivative(p[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void SinglePvtDeadSpline::b(const int n,
|
||||
const double* p,
|
||||
const double* /*r*/,
|
||||
double* output_b,
|
||||
double* output_dbdp,
|
||||
double* output_dbdr) const
|
||||
|
||||
{
|
||||
// #pragma omp parallel for
|
||||
for (int i = 0; i < n; ++i) {
|
||||
output_b[i] = b_(p[i]);
|
||||
output_dbdp[i] = b_.derivative(p[i]);
|
||||
|
||||
}
|
||||
std::fill(output_dbdr, output_dbdr + n, 0.0);
|
||||
|
||||
}
|
||||
|
||||
void SinglePvtDeadSpline::rbub(const int n,
|
||||
const double* /*p*/,
|
||||
double* output_rbub,
|
||||
double* output_drbubdp) const
|
||||
{
|
||||
std::fill(output_rbub, output_rbub + n, 0.0);
|
||||
std::fill(output_drbubdp, output_drbubdp + n, 0.0);
|
||||
}
|
||||
|
||||
void SinglePvtDeadSpline::R(const int n,
|
||||
const double* /*p*/,
|
||||
|
@ -29,8 +29,10 @@ namespace Opm
|
||||
{
|
||||
|
||||
/// Class for immiscible dead oil and dry gas.
|
||||
/// For all the virtual methods, the following apply: p and z
|
||||
/// are expected to be of size n and n*num_phases, respectively.
|
||||
/// The PVT properties can either be given as a function of pressure (p) and surface volume (z)
|
||||
/// or pressure (p) and gas resolution factor (r).
|
||||
/// For all the virtual methods, the following apply: p, r and z
|
||||
/// are expected to be of size n, size n and n*num_phases, respectively.
|
||||
/// Output arrays shall be of size n, and must be valid before
|
||||
/// calling the method.
|
||||
class SinglePvtDeadSpline : public SinglePvtInterface
|
||||
@ -47,6 +49,14 @@ namespace Opm
|
||||
const double* z,
|
||||
double* output_mu) const;
|
||||
|
||||
/// Viscosity and its derivatives as a function of p and r.
|
||||
virtual void mu(const int n,
|
||||
const double* p,
|
||||
const double* r,
|
||||
double* output_mu,
|
||||
double* output_dmudp,
|
||||
double* output_dmudr) const;
|
||||
|
||||
/// Formation volume factor as a function of p and z.
|
||||
virtual void B(const int n,
|
||||
const double* p,
|
||||
@ -60,6 +70,20 @@ namespace Opm
|
||||
double* output_B,
|
||||
double* output_dBdp) const;
|
||||
|
||||
/// The inverse of the formation volume factor b = 1 / B, and its derivatives as a function of p and r.
|
||||
virtual void b(const int n,
|
||||
const double* p,
|
||||
const double* r,
|
||||
double* output_b,
|
||||
double* output_dbdp,
|
||||
double* output_dbdr) const;
|
||||
|
||||
/// Gas resolution and its derivatives at bublepoint as a function of p.
|
||||
virtual void rbub(const int n,
|
||||
const double* p,
|
||||
double* output_rbub,
|
||||
double* output_drbubdp) const;
|
||||
|
||||
/// Solution factor as a function of p and z.
|
||||
virtual void R(const int n,
|
||||
const double* p,
|
||||
@ -74,7 +98,7 @@ namespace Opm
|
||||
double* output_dRdp) const;
|
||||
private:
|
||||
// PVT properties of dry gas or dead oil
|
||||
UniformTableLinear<double> one_over_B_;
|
||||
UniformTableLinear<double> b_;
|
||||
UniformTableLinear<double> viscosity_;
|
||||
};
|
||||
|
||||
|
@ -98,6 +98,17 @@ namespace Opm
|
||||
}
|
||||
}
|
||||
|
||||
/// Viscosity and its derivatives as a function of p and r.
|
||||
void SinglePvtLiveGas::mu(const int n,
|
||||
const double* p,
|
||||
const double* r,
|
||||
double* output_mu,
|
||||
double* output_dmudp,
|
||||
double* output_dmudr) const
|
||||
{
|
||||
THROW("The new fluid interface not yet implemented");
|
||||
}
|
||||
|
||||
|
||||
/// Formation volume factor as a function of p and z.
|
||||
void SinglePvtLiveGas::B(const int n,
|
||||
@ -126,6 +137,26 @@ namespace Opm
|
||||
}
|
||||
}
|
||||
|
||||
/// The inverse of the formation volume factor b = 1 / B, and its derivatives as a function of p and r.
|
||||
void SinglePvtLiveGas::b(const int n,
|
||||
const double* p,
|
||||
const double* r,
|
||||
double* output_b,
|
||||
double* output_dbdp,
|
||||
double* output_dbdr) const
|
||||
|
||||
{
|
||||
THROW("The new fluid interface not yet implemented");
|
||||
}
|
||||
|
||||
/// Gas resolution and its derivatives at bublepoint as a function of p.
|
||||
void SinglePvtLiveGas::rbub(const int n,
|
||||
const double* p,
|
||||
double* output_rbub,
|
||||
double* output_drbubdp) const
|
||||
{
|
||||
THROW("The new fluid interface not yet implemented");
|
||||
}
|
||||
|
||||
/// Solution factor as a function of p and z.
|
||||
void SinglePvtLiveGas::R(const int n,
|
||||
|
@ -26,8 +26,10 @@
|
||||
namespace Opm
|
||||
{
|
||||
/// Class for miscible wet gas (with vaporized oil in vapour phase).
|
||||
/// For all the virtual methods, the following apply: p and z
|
||||
/// are expected to be of size n and n*num_phases, respectively.
|
||||
/// The PVT properties can either be given as a function of pressure (p) and surface volume (z)
|
||||
/// or pressure (p) and gas resolution factor (r).
|
||||
/// For all the virtual methods, the following apply: p, r and z
|
||||
/// are expected to be of size n, size n and n*num_phases, respectively.
|
||||
/// Output arrays shall be of size n, and must be valid before
|
||||
/// calling the method.
|
||||
class SinglePvtLiveGas : public SinglePvtInterface
|
||||
@ -44,6 +46,14 @@ namespace Opm
|
||||
const double* z,
|
||||
double* output_mu) const;
|
||||
|
||||
/// Viscosity and its derivatives as a function of p and r.
|
||||
virtual void mu(const int n,
|
||||
const double* p,
|
||||
const double* r,
|
||||
double* output_mu,
|
||||
double* output_dmudp,
|
||||
double* output_dmudr) const;
|
||||
|
||||
/// Formation volume factor as a function of p and z.
|
||||
virtual void B(const int n,
|
||||
const double* p,
|
||||
@ -57,6 +67,22 @@ namespace Opm
|
||||
double* output_B,
|
||||
double* output_dBdp) const;
|
||||
|
||||
/// The inverse of the formation volume factor b = 1 / B, and its derivatives as a function of p and r.
|
||||
virtual void b(const int n,
|
||||
const double* p,
|
||||
const double* r,
|
||||
double* output_b,
|
||||
double* output_dbdp,
|
||||
double* output_dbdr) const;
|
||||
|
||||
|
||||
|
||||
/// Gas resolution and its derivatives at bublepoint as a function of p.
|
||||
virtual void rbub(const int n,
|
||||
const double* p,
|
||||
double* output_rbub,
|
||||
double* output_drbubdp) const;
|
||||
|
||||
/// Solution factor as a function of p and z.
|
||||
virtual void R(const int n,
|
||||
const double* p,
|
||||
|
@ -175,6 +175,23 @@ namespace Opm
|
||||
}
|
||||
}
|
||||
|
||||
/// Viscosity and its derivatives as a function of p and r.
|
||||
void SinglePvtLiveOil::mu(const int n,
|
||||
const double* p,
|
||||
const double* r,
|
||||
double* output_mu,
|
||||
double* output_dmudp,
|
||||
double* output_dmudr) const
|
||||
{
|
||||
// #pragma omp parallel for
|
||||
for (int i = 0; i < n; ++i) {
|
||||
output_mu[i] = miscible_oil(p[i], r[i], 2, 0);
|
||||
output_dmudp[i] = miscible_oil(p[i], r[i], 2, 1);
|
||||
output_dmudr[i] = miscible_oil(p[i], r[i], 2, 2);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Formation volume factor as a function of p and z.
|
||||
void SinglePvtLiveOil::B(const int n,
|
||||
@ -203,6 +220,37 @@ namespace Opm
|
||||
}
|
||||
}
|
||||
|
||||
void SinglePvtLiveOil::b(const int n,
|
||||
const double* p,
|
||||
const double* r,
|
||||
double* output_b,
|
||||
double* output_dbdp,
|
||||
double* output_dbdr) const
|
||||
|
||||
{
|
||||
// #pragma omp parallel for
|
||||
for (int i = 0; i < n; ++i) {
|
||||
output_b[i] = miscible_oil(p[i], r[i], 1, 0);
|
||||
output_dbdp[i] = miscible_oil(p[i], r[i], 1, 1);
|
||||
output_dbdr[i] = miscible_oil(p[i], r[i], 1, 2);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void SinglePvtLiveOil::rbub(const int n,
|
||||
const double* p,
|
||||
double* output_rbub,
|
||||
double* output_drbubdp) const
|
||||
{
|
||||
|
||||
for (int i = 0; i < n; ++i) {
|
||||
output_rbub[i] = linearInterpolation(saturated_oil_table_[0],
|
||||
saturated_oil_table_[3],p[i]);
|
||||
output_drbubdp[i] = linearInterpolationDerivative(saturated_oil_table_[0],
|
||||
saturated_oil_table_[3],p[i]);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/// Solution factor as a function of p and z.
|
||||
void SinglePvtLiveOil::R(const int n,
|
||||
@ -347,4 +395,84 @@ namespace Opm
|
||||
}
|
||||
}
|
||||
|
||||
double SinglePvtLiveOil::miscible_oil(const double press,
|
||||
const double r,
|
||||
const int item,
|
||||
const int deriv) const
|
||||
{
|
||||
int section;
|
||||
double Rval = linearInterpolation(saturated_oil_table_[0],
|
||||
saturated_oil_table_[3],
|
||||
press, section);
|
||||
// derivative with respect to frist component (pressure)
|
||||
if (deriv == 1) {
|
||||
if (Rval < r ) { // Saturated case
|
||||
return linearInterpolationDerivative(saturated_oil_table_[0],
|
||||
saturated_oil_table_[item],
|
||||
press);
|
||||
} else { // Undersaturated case
|
||||
int is = tableIndex(saturated_oil_table_[3], r);
|
||||
double w = (r - saturated_oil_table_[3][is]) /
|
||||
(saturated_oil_table_[3][is+1] - saturated_oil_table_[3][is]);
|
||||
ASSERT(undersat_oil_tables_[is][0].size() >= 2);
|
||||
ASSERT(undersat_oil_tables_[is+1][0].size() >= 2);
|
||||
double val1 =
|
||||
linearInterpolationDerivative(undersat_oil_tables_[is][0],
|
||||
undersat_oil_tables_[is][item],
|
||||
press);
|
||||
double val2 =
|
||||
linearInterpolationDerivative(undersat_oil_tables_[is+1][0],
|
||||
undersat_oil_tables_[is+1][item],
|
||||
press);
|
||||
double val = val1 + w*(val2 - val1);
|
||||
return val;
|
||||
}
|
||||
// derivative with respect to second component (r)
|
||||
} else if (deriv == 2) {
|
||||
if (Rval < r ) { // Saturated case
|
||||
return 0;
|
||||
} else { // Undersaturated case
|
||||
int is = tableIndex(saturated_oil_table_[3], r);
|
||||
ASSERT(undersat_oil_tables_[is][0].size() >= 2);
|
||||
ASSERT(undersat_oil_tables_[is+1][0].size() >= 2);
|
||||
double val1 =
|
||||
linearInterpolation(undersat_oil_tables_[is][0],
|
||||
undersat_oil_tables_[is][item],
|
||||
press);
|
||||
double val2 =
|
||||
linearInterpolation(undersat_oil_tables_[is+1][0],
|
||||
undersat_oil_tables_[is+1][item],
|
||||
press);
|
||||
|
||||
double val = (val2 - val1)/(saturated_oil_table_[3][is+1]-saturated_oil_table_[3][is]);
|
||||
return val;
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
if (Rval < r ) { // Saturated case
|
||||
return linearInterpolation(saturated_oil_table_[0],
|
||||
saturated_oil_table_[item],
|
||||
press);
|
||||
} else { // Undersaturated case
|
||||
// Interpolate between table sections
|
||||
int is = tableIndex(saturated_oil_table_[3], r);
|
||||
double w = (r - saturated_oil_table_[3][is]) /
|
||||
(saturated_oil_table_[3][is+1] - saturated_oil_table_[3][is]);
|
||||
ASSERT(undersat_oil_tables_[is][0].size() >= 2);
|
||||
ASSERT(undersat_oil_tables_[is+1][0].size() >= 2);
|
||||
double val1 =
|
||||
linearInterpolation(undersat_oil_tables_[is][0],
|
||||
undersat_oil_tables_[is][item],
|
||||
press);
|
||||
double val2 =
|
||||
linearInterpolation(undersat_oil_tables_[is+1][0],
|
||||
undersat_oil_tables_[is+1][item],
|
||||
press);
|
||||
double val = val1 + w*(val2 - val1);
|
||||
return val;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Opm
|
||||
|
@ -27,8 +27,10 @@
|
||||
namespace Opm
|
||||
{
|
||||
/// Class for miscible live oil (with dissolved gas in liquid phase).
|
||||
/// For all the virtual methods, the following apply: p and z
|
||||
/// are expected to be of size n and n*num_phases, respectively.
|
||||
/// The PVT properties can either be given as a function of pressure (p) and surface volume (z)
|
||||
/// or pressure (p) and gas resolution factor (r).
|
||||
/// For all the virtual methods, the following apply: p, r and z
|
||||
/// are expected to be of size n, size n and n*num_phases, respectively.
|
||||
/// Output arrays shall be of size n, and must be valid before
|
||||
/// calling the method.
|
||||
class SinglePvtLiveOil : public SinglePvtInterface
|
||||
@ -45,6 +47,14 @@ namespace Opm
|
||||
const double* z,
|
||||
double* output_mu) const;
|
||||
|
||||
/// Viscosity and its derivatives as a function of p and r.
|
||||
virtual void mu(const int n,
|
||||
const double* p,
|
||||
const double* r,
|
||||
double* output_mu,
|
||||
double* output_dmudp,
|
||||
double* output_dmudr) const;
|
||||
|
||||
/// Formation volume factor as a function of p and z.
|
||||
virtual void B(const int n,
|
||||
const double* p,
|
||||
@ -58,6 +68,20 @@ namespace Opm
|
||||
double* output_B,
|
||||
double* output_dBdp) const;
|
||||
|
||||
/// The inverse of the formation volume factor b = 1 / B, and its derivatives as a function of p and r.
|
||||
virtual void b(const int n,
|
||||
const double* p,
|
||||
const double* r,
|
||||
double* output_b,
|
||||
double* output_dbdp,
|
||||
double* output_dbdr) const;
|
||||
|
||||
/// Gas resolution and its derivatives at bublepoint as a function of p.
|
||||
virtual void rbub(const int n,
|
||||
const double* p,
|
||||
double* output_rbub,
|
||||
double* output_drbubdp) const;
|
||||
|
||||
/// Solution factor as a function of p and z.
|
||||
virtual void R(const int n,
|
||||
const double* p,
|
||||
@ -83,6 +107,11 @@ namespace Opm
|
||||
const int item,
|
||||
const bool deriv = false) const;
|
||||
|
||||
double miscible_oil(const double press,
|
||||
const double r,
|
||||
const int item,
|
||||
const int deriv = 0) const;
|
||||
|
||||
// PVT properties of live oil (with dissolved gas)
|
||||
std::vector<std::vector<double> > saturated_oil_table_;
|
||||
std::vector<std::vector<std::vector<double> > > undersat_oil_tables_;
|
||||
|
@ -2,6 +2,9 @@
|
||||
#include <opm/core/grid/GridManager.hpp>
|
||||
#include <opm/core/props/pvt/SinglePvtConstCompr.hpp>
|
||||
#include <opm/core/props/pvt/SinglePvtDead.hpp>
|
||||
#include <opm/core/props/pvt/SinglePvtDeadSpline.hpp>
|
||||
#include <opm/core/props/pvt/SinglePvtLiveOil.hpp>
|
||||
#include <opm/core/props/pvt/SinglePvtLiveGas.hpp>
|
||||
#include <opm/core/props/phaseUsageFromDeck.hpp>
|
||||
#include <opm/core/props/BlackoilPhases.hpp>
|
||||
#include <opm/core/utility/Units.hpp>
|
||||
@ -15,13 +18,31 @@ using namespace Opm;
|
||||
using namespace std;
|
||||
|
||||
|
||||
// The function object divides a Factor with an element
|
||||
template <class Type>
|
||||
class MultValue
|
||||
{
|
||||
private:
|
||||
Type Factor; // The value to multiply by
|
||||
public:
|
||||
// Constructor initializes the value to multiply by
|
||||
MultValue ( const Type& _Val ) : Factor ( _Val ) {
|
||||
}
|
||||
|
||||
// The function call for the element to be multiplied
|
||||
int operator ( ) ( Type& elem ) const
|
||||
{
|
||||
return Factor / elem;
|
||||
}
|
||||
};
|
||||
int main () {
|
||||
// read parameters from command-line
|
||||
const string filename = "../tests/SPE9small.DATA";
|
||||
const string filename = "../../opm-core/tests/not-unit/blackoil/SPE9small.DATA";
|
||||
cout << "Reading deck: " << filename << endl;
|
||||
const EclipseGridParser deck (filename);
|
||||
std::string mu_output = "mu_output";
|
||||
std::string b_output = "b_output";
|
||||
std::string rbub_output = "rbub_output";
|
||||
|
||||
PhaseUsage phase_usage_;
|
||||
|
||||
@ -38,6 +59,22 @@ int main () {
|
||||
exit(3);
|
||||
}
|
||||
|
||||
std::fstream bos(b_output.c_str(), std::fstream::out | std::fstream::trunc);
|
||||
bos << setiosflags(ios::scientific) << setprecision(12);
|
||||
if(!(bos.good())){
|
||||
std::cout << "Could not open"<< b_output << std::endl;
|
||||
exit(3);
|
||||
}
|
||||
|
||||
std::fstream rbubos(rbub_output.c_str(), std::fstream::out | std::fstream::trunc);
|
||||
rbubos << setiosflags(ios::scientific) << setprecision(12);
|
||||
if(!(rbubos.good())){
|
||||
std::cout << "Could not open"<< rbub_output << std::endl;
|
||||
exit(3);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Set the properties.
|
||||
props_.resize(phase_usage_.num_phases);
|
||||
// Water PVT
|
||||
@ -53,12 +90,13 @@ int main () {
|
||||
if (phase_usage_.phase_used[Liquid]) {
|
||||
if (deck.hasField("PVDO")) {
|
||||
if (samples > 0) {
|
||||
//props_[phase_usage_.phase_pos[Liquid]].reset(new SinglePvtDeadSpline(deck.getPVDO().pvdo_, samples));
|
||||
props_[phase_usage_.phase_pos[Liquid]].reset(new SinglePvtDeadSpline(deck.getPVDO().pvdo_, samples));
|
||||
} else {
|
||||
props_[phase_usage_.phase_pos[Liquid]].reset(new SinglePvtDead(deck.getPVDO().pvdo_));
|
||||
}
|
||||
} else if (deck.hasField("PVTO")) {
|
||||
//props_[phase_usage_.phase_pos[Liquid]].reset(new SinglePvtLiveOil(deck.getPVTO().pvto_));
|
||||
|
||||
props_[phase_usage_.phase_pos[Liquid]].reset(new SinglePvtLiveOil(deck.getPVTO().pvto_));
|
||||
} else if (deck.hasField("PVCDO")) {
|
||||
props_[phase_usage_.phase_pos[Liquid]].reset(new SinglePvtConstCompr(deck.getPVCDO().pvcdo_));
|
||||
} else {
|
||||
@ -69,44 +107,149 @@ int main () {
|
||||
if (phase_usage_.phase_used[Vapour]) {
|
||||
if (deck.hasField("PVDG")) {
|
||||
if (samples > 0) {
|
||||
//props_[phase_usage_.phase_pos[Vapour]].reset(new SinglePvtDeadSpline(deck.getPVDG().pvdg_, samples));
|
||||
props_[phase_usage_.phase_pos[Vapour]].reset(new SinglePvtDeadSpline(deck.getPVDG().pvdg_, samples));
|
||||
} else {
|
||||
props_[phase_usage_.phase_pos[Vapour]].reset(new SinglePvtDead(deck.getPVDG().pvdg_));
|
||||
}
|
||||
} else if (deck.hasField("PVTG")) {
|
||||
//props_[phase_usage_.phase_pos[Vapour]].reset(new SinglePvtLiveGas(deck.getPVTG().pvtg_));
|
||||
props_[phase_usage_.phase_pos[Vapour]].reset(new SinglePvtLiveGas(deck.getPVTG().pvtg_));
|
||||
} else {
|
||||
THROW("Input is missing PVDG or PVTG\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int n = 1;
|
||||
int np = 1; //phase_usage_.num_phases;
|
||||
int n = 6;
|
||||
int np = 3; //phase_usage_.num_phases;
|
||||
double p[n];
|
||||
double r[n];
|
||||
double z[n];
|
||||
double z[np*n];
|
||||
|
||||
double mu[n];
|
||||
double dmudp[n];
|
||||
double dmudr[n];
|
||||
double mu_new[n];
|
||||
double dmudp_diff;
|
||||
double dmudr_diff;
|
||||
double dmudp_diff_u;
|
||||
double dmudr_diff_u;
|
||||
|
||||
p[0] = 10000;
|
||||
//double rf[n];
|
||||
|
||||
// not in use yet
|
||||
r[0] = 0;
|
||||
z[0] = 0;
|
||||
double h = 1;
|
||||
double rh = 1;
|
||||
|
||||
p[0] = 10000000;
|
||||
p[1] = p[0] + h;
|
||||
p[2] = 10000000;
|
||||
|
||||
p[3] = 10000000;
|
||||
p[4] = p[0] + h;
|
||||
p[5] = 10000000;
|
||||
|
||||
|
||||
for (int phase = 0; phase < np; ++phase) {
|
||||
// saturated
|
||||
r[0] = 200;
|
||||
r[1] = 200;
|
||||
r[2] = 200 + rh;
|
||||
|
||||
// undersaturated
|
||||
r[3] = 50;
|
||||
r[4] = 50;
|
||||
r[5] = 50 +rh;
|
||||
|
||||
|
||||
for (int i = 0; i < n; ++i) {
|
||||
z[0+i*np] = 0; z[1+i*np] = 1;
|
||||
z[2+i*np] = r[i];
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// test mu
|
||||
for (int phase = 1; phase < 2; ++phase) {
|
||||
props_[phase]->mu(n, p, r, mu_new,dmudp,dmudr);
|
||||
props_[phase]->mu(n, z, r, mu);
|
||||
props_[phase]->mu(n, p, z, mu);
|
||||
dmudp_diff = (mu_new[1]-mu_new[0])/h;
|
||||
dmudr_diff = (mu_new[2]-mu_new[0])/rh;
|
||||
dmudp_diff_u = (mu_new[4]-mu_new[3])/h;
|
||||
dmudr_diff_u = (mu_new[5]-mu_new[3])/rh;
|
||||
|
||||
std::copy(mu,mu + n, std::ostream_iterator<double>(muos, " "));
|
||||
muos << "\n";
|
||||
std::copy(mu_new,mu_new + n, std::ostream_iterator<double>(muos, " "));
|
||||
muos << "\n";
|
||||
std::copy(dmudp,dmudp + n, std::ostream_iterator<double>(muos, " "));
|
||||
muos << "\n";
|
||||
muos << dmudp_diff << " " << dmudp_diff_u << "\n";
|
||||
std::copy(dmudr,dmudr + n, std::ostream_iterator<double>(muos, " "));
|
||||
muos << "\n";
|
||||
muos << dmudr_diff << " " << dmudr_diff_u << "\n";
|
||||
}
|
||||
|
||||
// test b
|
||||
double b[n];
|
||||
double B[n];
|
||||
double invB[n];
|
||||
double dinvBdp[n];
|
||||
double dBdp[n];
|
||||
double dbdr[n];
|
||||
double dbdp[n];
|
||||
double dbdp_diff;
|
||||
double dbdr_diff;
|
||||
double dbdp_diff_u;
|
||||
double dbdr_diff_u;
|
||||
|
||||
for (int phase = 1; phase < 2; ++phase) {
|
||||
props_[phase]->b(n, p, r, b,dbdp,dbdr);
|
||||
//props_[phase]->B(n, p, z, B);
|
||||
props_[phase]->dBdp(n, p, z, B, dBdp);
|
||||
dbdp_diff = (b[1]-b[0])/h;
|
||||
dbdr_diff = (b[2]-b[0])/rh;
|
||||
dbdp_diff_u = (b[4]-b[3])/h;
|
||||
dbdr_diff_u = (b[5]-b[3])/rh;
|
||||
for (int i = 0; i < n; ++i){
|
||||
invB[i] = 1/B[i];
|
||||
dinvBdp[i] = -1/pow(B[i],2) * dBdp[i];
|
||||
|
||||
}
|
||||
std::copy(b,b + n, std::ostream_iterator<double>(bos, " "));
|
||||
bos << "\n";
|
||||
std::copy(invB,invB + n, std::ostream_iterator<double>(bos, " "));
|
||||
bos << "\n";
|
||||
std::copy(dinvBdp,dinvBdp + n, std::ostream_iterator<double>(bos, " "));
|
||||
bos << "\n";
|
||||
std::copy(dbdp,dbdp + n, std::ostream_iterator<double>(bos, " "));
|
||||
bos << "\n";
|
||||
bos << dbdp_diff << " " << dbdp_diff_u << "\n";
|
||||
std::copy(dbdr,dbdr + n, std::ostream_iterator<double>(bos, " "));
|
||||
bos << "\n";
|
||||
bos << dbdr_diff << " " << dbdr_diff_u << "\n";
|
||||
|
||||
}
|
||||
std::copy(mu,mu + np*n, std::ostream_iterator<double>(muos, " "));
|
||||
std::copy(mu_new,mu_new + np*n, std::ostream_iterator<double>(muos, " "));
|
||||
|
||||
// test rbub
|
||||
|
||||
double rbub[n];
|
||||
double drbubdp[n];
|
||||
double drbubdp_diff;
|
||||
|
||||
for (int phase = 1; phase < 2; ++phase) {
|
||||
props_[phase] ->rbub(n,p,rbub,drbubdp);
|
||||
|
||||
drbubdp_diff = (rbub[1]-rbub[0])/h;
|
||||
std::copy(rbub,rbub + n, std::ostream_iterator<double>(rbubos, " "));
|
||||
rbubos << "\n";
|
||||
std::copy(drbubdp,drbubdp + n, std::ostream_iterator<double>(rbubos, " "));
|
||||
rbubos << drbubdp_diff;
|
||||
rbubos << "\n";
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user