mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
VFPProdProperties: template Scalar type
This commit is contained in:
@@ -31,21 +31,21 @@
|
||||
|
||||
namespace Opm {
|
||||
|
||||
|
||||
|
||||
|
||||
double VFPProdProperties::thp(int table_id,
|
||||
const double& aqua,
|
||||
const double& liquid,
|
||||
const double& vapour,
|
||||
const double& bhp_arg,
|
||||
const double& alq) const {
|
||||
template<class Scalar>
|
||||
Scalar VFPProdProperties<Scalar>::
|
||||
thp(const int table_id,
|
||||
const Scalar aqua,
|
||||
const Scalar liquid,
|
||||
const Scalar vapour,
|
||||
const Scalar bhp_arg,
|
||||
const Scalar alq) const
|
||||
{
|
||||
const VFPProdTable& table = detail::getTable(m_tables, table_id);
|
||||
|
||||
// Find interpolation variables.
|
||||
double flo = 0.0;
|
||||
double wfr = 0.0;
|
||||
double gfr = 0.0;
|
||||
Scalar flo = 0.0;
|
||||
Scalar wfr = 0.0;
|
||||
Scalar gfr = 0.0;
|
||||
if (aqua == 0.0 && liquid == 0.0 && vapour == 0.0) {
|
||||
// All zero, likely at initial state.
|
||||
// Set FLO variable to minimum to avoid extrapolation.
|
||||
@@ -71,51 +71,56 @@ double VFPProdProperties::thp(int table_id,
|
||||
auto wfr_i = detail::findInterpData( wfr, table.getWFRAxis());
|
||||
auto gfr_i = detail::findInterpData( gfr, table.getGFRAxis());
|
||||
auto alq_i = detail::findInterpData( alq, table.getALQAxis());
|
||||
std::vector<double> bhp_array(nthp);
|
||||
for (int i=0; i<nthp; ++i) {
|
||||
std::vector<Scalar> bhp_array(nthp);
|
||||
for (int i = 0; i < nthp; ++i) {
|
||||
auto thp_i = detail::findInterpData(thp_array[i], thp_array);
|
||||
bhp_array[i] = detail::interpolate(table, flo_i, thp_i, wfr_i, gfr_i, alq_i).value;
|
||||
}
|
||||
|
||||
double retval = detail::findTHP(bhp_array, thp_array, bhp_arg);
|
||||
return retval;
|
||||
return detail::findTHP(bhp_array, thp_array, bhp_arg);
|
||||
}
|
||||
|
||||
|
||||
double VFPProdProperties::bhp(int table_id,
|
||||
const double& aqua,
|
||||
const double& liquid,
|
||||
const double& vapour,
|
||||
const double& thp_arg,
|
||||
const double& alq,
|
||||
const double& explicit_wfr,
|
||||
const double& explicit_gfr,
|
||||
const bool use_expvfp) const {
|
||||
template<class Scalar>
|
||||
Scalar VFPProdProperties<Scalar>::
|
||||
bhp(const int table_id,
|
||||
const Scalar aqua,
|
||||
const Scalar liquid,
|
||||
const Scalar vapour,
|
||||
const Scalar thp_arg,
|
||||
const Scalar alq,
|
||||
const Scalar explicit_wfr,
|
||||
const Scalar explicit_gfr,
|
||||
const bool use_expvfp) const
|
||||
{
|
||||
const VFPProdTable& table = detail::getTable(m_tables, table_id);
|
||||
|
||||
detail::VFPEvaluation retval = detail::bhp(table, aqua, liquid, vapour, thp_arg, alq, explicit_wfr,explicit_gfr, use_expvfp);
|
||||
return retval.value;
|
||||
}
|
||||
|
||||
|
||||
const VFPProdTable& VFPProdProperties::getTable(const int table_id) const {
|
||||
template<class Scalar>
|
||||
const VFPProdTable&
|
||||
VFPProdProperties<Scalar>::getTable(const int table_id) const
|
||||
{
|
||||
return detail::getTable(m_tables, table_id);
|
||||
}
|
||||
|
||||
bool VFPProdProperties::hasTable(const int table_id) const {
|
||||
template<class Scalar>
|
||||
bool VFPProdProperties<Scalar>::hasTable(const int table_id) const
|
||||
{
|
||||
return detail::hasTable(m_tables, table_id);
|
||||
}
|
||||
|
||||
|
||||
std::vector<double>
|
||||
VFPProdProperties::
|
||||
bhpwithflo(const std::vector<double>& flos,
|
||||
template<class Scalar>
|
||||
std::vector<Scalar>
|
||||
VFPProdProperties<Scalar>::
|
||||
bhpwithflo(const std::vector<Scalar>& flos,
|
||||
const int table_id,
|
||||
const double wfr,
|
||||
const double gfr,
|
||||
const double thp,
|
||||
const double alq,
|
||||
const double dp) const
|
||||
const Scalar wfr,
|
||||
const Scalar gfr,
|
||||
const Scalar thp,
|
||||
const Scalar alq,
|
||||
const Scalar dp) const
|
||||
{
|
||||
// Get the table
|
||||
const VFPProdTable& table = detail::getTable(m_tables, table_id);
|
||||
@@ -124,7 +129,7 @@ bhpwithflo(const std::vector<double>& flos,
|
||||
const auto gfr_i = detail::findInterpData( gfr, table.getGFRAxis());
|
||||
const auto alq_i = detail::findInterpData( alq, table.getALQAxis()); //assume constant
|
||||
|
||||
std::vector<double> bhps(flos.size(), 0.);
|
||||
std::vector<Scalar> bhps(flos.size(), 0.);
|
||||
for (std::size_t i = 0; i < flos.size(); ++i) {
|
||||
// Value of FLO is negative in OPM for producers, but positive in VFP table
|
||||
const auto flo_i = detail::findInterpData(-flos[i], table.getFloAxis());
|
||||
@@ -137,13 +142,13 @@ bhpwithflo(const std::vector<double>& flos,
|
||||
return bhps;
|
||||
}
|
||||
|
||||
double
|
||||
VFPProdProperties::
|
||||
template<class Scalar>
|
||||
Scalar VFPProdProperties<Scalar>::
|
||||
minimumBHP(const int table_id,
|
||||
const double thp,
|
||||
const double wfr,
|
||||
const double gfr,
|
||||
const double alq) const
|
||||
const Scalar thp,
|
||||
const Scalar wfr,
|
||||
const Scalar gfr,
|
||||
const Scalar alq) const
|
||||
{
|
||||
// Get the table
|
||||
const VFPProdTable& table = detail::getTable(m_tables, table_id);
|
||||
@@ -152,22 +157,24 @@ minimumBHP(const int table_id,
|
||||
return retval.second;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void VFPProdProperties::addTable(const VFPProdTable& new_table) {
|
||||
template<class Scalar>
|
||||
void VFPProdProperties<Scalar>::addTable(const VFPProdTable& new_table)
|
||||
{
|
||||
this->m_tables.emplace( new_table.getTableNum(), new_table );
|
||||
}
|
||||
|
||||
template<class Scalar>
|
||||
template <class EvalWell>
|
||||
EvalWell VFPProdProperties::bhp(const int table_id,
|
||||
const EvalWell& aqua,
|
||||
const EvalWell& liquid,
|
||||
const EvalWell& vapour,
|
||||
const double& thp,
|
||||
const double& alq,
|
||||
const double& explicit_wfr,
|
||||
const double& explicit_gfr,
|
||||
const bool use_expvfp) const
|
||||
EvalWell VFPProdProperties<Scalar>::
|
||||
bhp(const int table_id,
|
||||
const EvalWell& aqua,
|
||||
const EvalWell& liquid,
|
||||
const EvalWell& vapour,
|
||||
const Scalar thp,
|
||||
const Scalar alq,
|
||||
const Scalar explicit_wfr,
|
||||
const Scalar explicit_gfr,
|
||||
const bool use_expvfp) const
|
||||
{
|
||||
//Get the table
|
||||
const VFPProdTable& table = detail::getTable(m_tables, table_id);
|
||||
@@ -197,10 +204,18 @@ EvalWell VFPProdProperties::bhp(const int table_id,
|
||||
return bhp;
|
||||
}
|
||||
|
||||
template class VFPProdProperties<double>;
|
||||
|
||||
#define INSTANCE(...) \
|
||||
template __VA_ARGS__ VFPProdProperties::bhp<__VA_ARGS__>(const int, \
|
||||
const __VA_ARGS__&, const __VA_ARGS__&, const __VA_ARGS__&, \
|
||||
const double&, const double&, const double&, const double&, const bool) const;
|
||||
template __VA_ARGS__ VFPProdProperties<double>::bhp<__VA_ARGS__>(const int, \
|
||||
const __VA_ARGS__&, \
|
||||
const __VA_ARGS__&, \
|
||||
const __VA_ARGS__&, \
|
||||
const double, \
|
||||
const double, \
|
||||
const double, \
|
||||
const double, \
|
||||
const bool) const;
|
||||
|
||||
INSTANCE(DenseAd::Evaluation<double, -1, 4u>)
|
||||
INSTANCE(DenseAd::Evaluation<double, -1, 5u>)
|
||||
|
||||
@@ -34,9 +34,9 @@ class VFPProdTable;
|
||||
* 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.
|
||||
*/
|
||||
template<class Scalar>
|
||||
class VFPProdProperties {
|
||||
public:
|
||||
VFPProdProperties() = default;
|
||||
/**
|
||||
* Takes *no* ownership of data.
|
||||
*/
|
||||
@@ -60,15 +60,15 @@ public:
|
||||
* input ADB objects.
|
||||
*/
|
||||
template <class EvalWell>
|
||||
EvalWell bhp(const int table_id,
|
||||
EvalWell bhp(const int table_id,
|
||||
const EvalWell& aqua,
|
||||
const EvalWell& liquid,
|
||||
const EvalWell& vapour,
|
||||
const double& thp,
|
||||
const double& alq,
|
||||
const double& explicit_wfr,
|
||||
const double& explicit_gfr,
|
||||
const bool use_expvfp) const;
|
||||
const Scalar thp,
|
||||
const Scalar alq,
|
||||
const Scalar explicit_wfr,
|
||||
const Scalar explicit_gfr,
|
||||
const bool use_expvfp) const;
|
||||
|
||||
/**
|
||||
* Linear interpolation of bhp as a function of the input parameters
|
||||
@@ -82,15 +82,15 @@ public:
|
||||
* @return The bottom hole pressure, interpolated/extrapolated linearly using
|
||||
* the above parameters from the values in the input table.
|
||||
*/
|
||||
double bhp(int table_id,
|
||||
const double& aqua,
|
||||
const double& liquid,
|
||||
const double& vapour,
|
||||
const double& thp,
|
||||
const double& alq,
|
||||
const double& explicit_wfr,
|
||||
const double& explicit_gfr,
|
||||
const bool use_expvfp) const;
|
||||
Scalar bhp(const int table_id,
|
||||
const Scalar aqua,
|
||||
const Scalar liquid,
|
||||
const Scalar vapour,
|
||||
const Scalar thp,
|
||||
const Scalar alq,
|
||||
const Scalar explicit_wfr,
|
||||
const Scalar explicit_gfr,
|
||||
const bool use_expvfp) const;
|
||||
|
||||
/**
|
||||
* Linear interpolation of thp as a function of the input parameters
|
||||
@@ -104,12 +104,12 @@ public:
|
||||
* @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;
|
||||
Scalar thp(const int table_id,
|
||||
const Scalar aqua,
|
||||
const Scalar liquid,
|
||||
const Scalar vapour,
|
||||
const Scalar bhp,
|
||||
const Scalar alq) const;
|
||||
|
||||
/**
|
||||
* Returns the table associated with the ID, or throws an exception if
|
||||
@@ -125,33 +125,31 @@ public:
|
||||
/**
|
||||
* Returns true if no vfp tables are in the current map
|
||||
*/
|
||||
bool empty() const {
|
||||
bool empty() const
|
||||
{
|
||||
return m_tables.empty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns minimum bhp for given thp, wfr, gfr and alq
|
||||
*/
|
||||
double minimumBHP(const int table_id, const double thp,
|
||||
const double wfr, const double gfr, const double alq) const;
|
||||
Scalar minimumBHP(const int table_id, const Scalar thp,
|
||||
const Scalar wfr, const Scalar gfr, const Scalar alq) const;
|
||||
|
||||
protected:
|
||||
// calculate a group bhp values with a group of flo rate values
|
||||
std::vector<double> bhpwithflo(const std::vector<double>& flos,
|
||||
std::vector<Scalar> bhpwithflo(const std::vector<Scalar>& flos,
|
||||
const int table_id,
|
||||
const double wfr,
|
||||
const double gfr,
|
||||
const double thp,
|
||||
const double alq,
|
||||
const double dp) const;
|
||||
const Scalar wfr,
|
||||
const Scalar gfr,
|
||||
const Scalar thp,
|
||||
const Scalar alq,
|
||||
const Scalar dp) const;
|
||||
|
||||
// Map which connects the table number with the table itself
|
||||
std::map<int, std::reference_wrapper<const VFPProdTable>> m_tables;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
} //namespace
|
||||
|
||||
} // namespace Opm
|
||||
|
||||
#endif /* OPM_AUTODIFF_VFPPRODPROPERTIES_HPP_ */
|
||||
|
||||
@@ -68,7 +68,8 @@ public:
|
||||
/**
|
||||
* Returns the VFP properties for production wells
|
||||
*/
|
||||
const VFPProdProperties* getProd() const {
|
||||
const VFPProdProperties<double>* getProd() const
|
||||
{
|
||||
return &m_prod;
|
||||
}
|
||||
|
||||
@@ -94,7 +95,7 @@ public:
|
||||
|
||||
private:
|
||||
VFPInjProperties<double> m_inj;
|
||||
VFPProdProperties m_prod;
|
||||
VFPProdProperties<double> m_prod;
|
||||
const WellState<double>& well_state_;
|
||||
};
|
||||
|
||||
|
||||
@@ -811,7 +811,7 @@ WellGroupHelpers<Scalar>::
|
||||
computeNetworkPressures(const Network::ExtNetwork& network,
|
||||
const WellState<Scalar>& well_state,
|
||||
const GroupState<Scalar>& group_state,
|
||||
const VFPProdProperties& vfp_prod_props,
|
||||
const VFPProdProperties<Scalar>& vfp_prod_props,
|
||||
const Schedule& schedule,
|
||||
const int report_time_step)
|
||||
{
|
||||
|
||||
@@ -37,7 +37,7 @@ template<class Scalar> class GroupState;
|
||||
namespace Network { class ExtNetwork; }
|
||||
struct PhaseUsage;
|
||||
class Schedule;
|
||||
class VFPProdProperties;
|
||||
template<class Scalar> class VFPProdProperties;
|
||||
template<class Scalar> class WellState;
|
||||
class FieldPropsManager;
|
||||
|
||||
@@ -202,7 +202,7 @@ public:
|
||||
computeNetworkPressures(const Network::ExtNetwork& network,
|
||||
const WellState<Scalar>& well_state,
|
||||
const GroupState<Scalar>& group_state,
|
||||
const VFPProdProperties& vfp_prod_props,
|
||||
const VFPProdProperties<Scalar>& vfp_prod_props,
|
||||
const Schedule& schedule,
|
||||
const int report_time_step);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user