mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-01-13 09:51:57 -06:00
218 lines
6.4 KiB
C++
218 lines
6.4 KiB
C++
|
/*
|
||
|
Copyright 2015 SINTEF ICT, Applied Mathematics.
|
||
|
|
||
|
This file is part of the Open Porous Media project (OPM).
|
||
|
|
||
|
OPM is free software: you can redistribute it and/or modify
|
||
|
it under the terms of the GNU General Public License as published by
|
||
|
the Free Software Foundation, either version 3 of the License, or
|
||
|
(at your option) any later version.
|
||
|
|
||
|
OPM is distributed in the hope that it will be useful,
|
||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
GNU General Public License for more details.
|
||
|
|
||
|
You should have received a copy of the GNU General Public License
|
||
|
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
||
|
*/
|
||
|
|
||
|
#ifndef OPM_AUTODIFF_VFPPRODPROPERTIES_HPP_
|
||
|
#define OPM_AUTODIFF_VFPPRODPROPERTIES_HPP_
|
||
|
|
||
|
#include <opm/parser/eclipse/EclipseState/Tables/VFPProdTable.hpp>
|
||
|
#include <opm/core/wells.h>
|
||
|
#include <opm/autodiff/AutoDiffBlock.hpp>
|
||
|
#include <opm/core/utility/ErrorMacros.hpp>
|
||
|
#include <opm/autodiff/AutoDiffHelpers.hpp>
|
||
|
|
||
|
#include <vector>
|
||
|
#include <map>
|
||
|
|
||
|
|
||
|
namespace Opm {
|
||
|
|
||
|
|
||
|
/**
|
||
|
* Class which linearly interpolates BHP as a function of rate, tubing head pressure,
|
||
|
* water fraction, gas fraction, and artificial lift for production VFP tables, and similarly
|
||
|
* the BHP as a function of the rate and tubing head pressure.
|
||
|
*/
|
||
|
class VFPProdProperties {
|
||
|
public:
|
||
|
typedef AutoDiffBlock<double> ADB;
|
||
|
|
||
|
/**
|
||
|
* An "ADB-like" structure with a single value and a set of derivatives
|
||
|
*/
|
||
|
struct adb_like {
|
||
|
adb_like() : value(0.0), dthp(0.0), dwfr(0.0), dgfr(0.0), dalq(0.0), dflo(0.0) {};
|
||
|
double value;
|
||
|
double dthp;
|
||
|
double dwfr;
|
||
|
double dgfr;
|
||
|
double dalq;
|
||
|
double dflo;
|
||
|
};
|
||
|
|
||
|
/**
|
||
|
* Empty constructor
|
||
|
*/
|
||
|
VFPProdProperties();
|
||
|
|
||
|
/**
|
||
|
* Constructor
|
||
|
* Takes *no* ownership of data.
|
||
|
* @param prod_table A *single* VFPPROD table
|
||
|
*/
|
||
|
VFPProdProperties(const VFPProdTable* prod_table);
|
||
|
|
||
|
/**
|
||
|
* Constructor
|
||
|
* Takes *no* ownership of data.
|
||
|
* @param prod_tables A map of different VFPPROD tables.
|
||
|
*/
|
||
|
VFPProdProperties(const std::map<int, VFPProdTable>& prod_tables);
|
||
|
|
||
|
/**
|
||
|
* Linear interpolation of bhp as function of the input parameters.
|
||
|
* @param table_id Table number to use
|
||
|
* @param wells Wells structure with information about wells in qs
|
||
|
* @param qs Flow quantities
|
||
|
* @param thp Tubing head pressure
|
||
|
* @param alq Artificial lift or other parameter
|
||
|
*
|
||
|
* @return The bottom hole pressure, interpolated/extrapolated linearly using
|
||
|
* the above parameters from the values in the input table.
|
||
|
*/
|
||
|
ADB bhp(const std::vector<int>& table_id,
|
||
|
const Wells& wells,
|
||
|
const ADB& qs,
|
||
|
const ADB& thp,
|
||
|
const ADB& alq) const;
|
||
|
|
||
|
/**
|
||
|
* Linear interpolation of bhp as a function of the input parameters given as ADBs
|
||
|
* Each entry corresponds typically to one well.
|
||
|
* @param table_id Table number to use. A negative entry (e.g., -1)
|
||
|
* will indicate that no table is used, and the corresponding
|
||
|
* BHP will be calculated as a constant -1e100.
|
||
|
* @param aqua Water phase
|
||
|
* @param liquid Oil phase
|
||
|
* @param vapour Gas phase
|
||
|
* @param thp Tubing head pressure
|
||
|
* @param alq Artificial lift or other parameter
|
||
|
*
|
||
|
* @return The bottom hole pressure, interpolated/extrapolated linearly using
|
||
|
* the above parameters from the values in the input table, for each entry in the
|
||
|
* input ADB objects.
|
||
|
*/
|
||
|
ADB bhp(const std::vector<int>& table_id,
|
||
|
const ADB& aqua,
|
||
|
const ADB& liquid,
|
||
|
const ADB& vapour,
|
||
|
const ADB& thp,
|
||
|
const ADB& alq) const;
|
||
|
|
||
|
/**
|
||
|
* Linear interpolation of bhp as a function of the input parameters
|
||
|
* @param table_id Table number to use
|
||
|
* @param aqua Water phase
|
||
|
* @param liquid Oil phase
|
||
|
* @param vapour Gas phase
|
||
|
* @param thp Tubing head pressure
|
||
|
* @param alq Artificial lift or other parameter
|
||
|
*
|
||
|
* @return The bottom hole pressure, interpolated/extrapolated linearly using
|
||
|
* the above parameters from the values in the input table.
|
||
|
*/
|
||
|
adb_like bhp(int table_id,
|
||
|
const double& aqua,
|
||
|
const double& liquid,
|
||
|
const double& vapour,
|
||
|
const double& thp,
|
||
|
const double& alq) const;
|
||
|
|
||
|
/**
|
||
|
* Linear interpolation of thp as a function of the input parameters
|
||
|
* @param table_id Table number to use
|
||
|
* @param aqua Water phase
|
||
|
* @param liquid Oil phase
|
||
|
* @param vapour Gas phase
|
||
|
* @param bhp Bottom hole pressure
|
||
|
* @param alq Artificial lift or other parameter
|
||
|
*
|
||
|
* @return The tubing hole pressure, interpolated/extrapolated linearly using
|
||
|
* the above parameters from the values in the input table.
|
||
|
*/
|
||
|
double thp(int table_id,
|
||
|
const double& aqua,
|
||
|
const double& liquid,
|
||
|
const double& vapour,
|
||
|
const double& bhp,
|
||
|
const double& alq) const;
|
||
|
|
||
|
|
||
|
private:
|
||
|
// Map which connects the table number with the table itself
|
||
|
std::map<int, const VFPProdTable*> m_tables;
|
||
|
|
||
|
|
||
|
|
||
|
/**
|
||
|
* Initialization routine
|
||
|
*/
|
||
|
void init(const std::map<int, VFPProdTable>& prod_tables);
|
||
|
|
||
|
/**
|
||
|
* Misc helper functions
|
||
|
*/
|
||
|
const VFPProdTable* getProdTable(int table_id) const;
|
||
|
|
||
|
};
|
||
|
|
||
|
|
||
|
|
||
|
inline VFPProdProperties::adb_like operator+(
|
||
|
VFPProdProperties::adb_like lhs,
|
||
|
const VFPProdProperties::adb_like& rhs) {
|
||
|
lhs.value += rhs.value;
|
||
|
lhs.dthp += rhs.dthp;
|
||
|
lhs.dwfr += rhs.dwfr;
|
||
|
lhs.dgfr += rhs.dgfr;
|
||
|
lhs.dalq += rhs.dalq;
|
||
|
lhs.dflo += rhs.dflo;
|
||
|
return lhs;
|
||
|
}
|
||
|
|
||
|
inline VFPProdProperties::adb_like operator-(
|
||
|
VFPProdProperties::adb_like lhs,
|
||
|
const VFPProdProperties::adb_like& rhs) {
|
||
|
lhs.value -= rhs.value;
|
||
|
lhs.dthp -= rhs.dthp;
|
||
|
lhs.dwfr -= rhs.dwfr;
|
||
|
lhs.dgfr -= rhs.dgfr;
|
||
|
lhs.dalq -= rhs.dalq;
|
||
|
lhs.dflo -= rhs.dflo;
|
||
|
return lhs;
|
||
|
}
|
||
|
|
||
|
inline VFPProdProperties::adb_like operator*(
|
||
|
double lhs,
|
||
|
const VFPProdProperties::adb_like& rhs) {
|
||
|
VFPProdProperties::adb_like retval;
|
||
|
retval.value = rhs.value * lhs;
|
||
|
retval.dthp = rhs.dthp * lhs;
|
||
|
retval.dwfr = rhs.dwfr * lhs;
|
||
|
retval.dgfr = rhs.dgfr * lhs;
|
||
|
retval.dalq = rhs.dalq * lhs;
|
||
|
retval.dflo = rhs.dflo * lhs;
|
||
|
return retval;
|
||
|
}
|
||
|
|
||
|
|
||
|
} //namespace
|
||
|
|
||
|
|
||
|
#endif /* OPM_AUTODIFF_VFPPRODPROPERTIES_HPP_ */
|