mirror of
https://github.com/OPM/opm-simulators.git
synced 2024-11-22 09:16:27 -06:00
Use ScheduleState to handle VFP propertes + simplifications
This commit is contained in:
parent
8607539c2a
commit
17fcdfc87a
@ -36,12 +36,11 @@ using namespace Opm;
|
||||
|
||||
struct Setup
|
||||
{
|
||||
using VFP = VFPProperties<VFPInjProperties, VFPProdProperties>;
|
||||
std::unique_ptr<const EclipseState> ecl_state;
|
||||
std::shared_ptr<Python> python;
|
||||
std::unique_ptr<const Schedule> schedule;
|
||||
std::unique_ptr<SummaryState> summary_state;
|
||||
std::unique_ptr<VFP> vfp_properties;
|
||||
std::unique_ptr<VFPProperties> vfp_properties;
|
||||
|
||||
Setup(const std::string& file)
|
||||
{
|
||||
@ -56,7 +55,8 @@ struct Setup
|
||||
summary_state.reset( new SummaryState(std::chrono::system_clock::from_time_t(schedule->getStartTime())));
|
||||
}
|
||||
const int step = 0;
|
||||
vfp_properties = std::make_unique<VFP>(schedule->getVFPInjTables(step), schedule->getVFPProdTables(step));
|
||||
const auto& sched_state = schedule->operator[](step);
|
||||
vfp_properties = std::make_unique<VFPProperties>(sched_state.vfpinj(), sched_state.vfpprod());
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -333,7 +333,7 @@ namespace Opm {
|
||||
std::optional<int> last_run_wellpi_{};
|
||||
|
||||
std::unique_ptr<RateConverterType> rateConverter_;
|
||||
std::unique_ptr<VFPProperties<VFPInjProperties,VFPProdProperties>> vfp_properties_;
|
||||
std::unique_ptr<VFPProperties> vfp_properties_;
|
||||
|
||||
SimulatorReportSingle last_report_;
|
||||
|
||||
|
@ -302,14 +302,14 @@ namespace Opm {
|
||||
std::vector<int>(local_num_cells_, 0)));
|
||||
rateConverter_->template defineState<ElementContext>(ebosSimulator_);
|
||||
|
||||
// update VFP properties
|
||||
vfp_properties_.reset (new VFPProperties<VFPInjProperties,VFPProdProperties> (
|
||||
schedule().getVFPInjTables(timeStepIdx),
|
||||
schedule().getVFPProdTables(timeStepIdx)) );
|
||||
|
||||
this->initializeWellProdIndCalculators();
|
||||
if (this->schedule()[timeStepIdx].events().hasEvent(ScheduleEvents::Events::WELL_PRODUCTIVITY_INDEX)) {
|
||||
this->runWellPIScaling(timeStepIdx, local_deferredLogger);
|
||||
{
|
||||
const auto& sched_state = this->schedule()[timeStepIdx];
|
||||
// update VFP properties
|
||||
vfp_properties_.reset(new VFPProperties( sched_state.vfpinj(), sched_state.vfpprod()) );
|
||||
this->initializeWellProdIndCalculators();
|
||||
if (sched_state.events().hasEvent(ScheduleEvents::Events::WELL_PRODUCTIVITY_INDEX)) {
|
||||
this->runWellPIScaling(timeStepIdx, local_deferredLogger);
|
||||
}
|
||||
}
|
||||
|
||||
// update the previous well state. This is used to restart failed steps.
|
||||
|
@ -32,21 +32,6 @@
|
||||
namespace Opm {
|
||||
|
||||
|
||||
VFPInjProperties::VFPInjProperties() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
VFPInjProperties::VFPInjProperties(const VFPInjTable* table){
|
||||
m_tables[table->getTableNum()] = table;
|
||||
}
|
||||
|
||||
|
||||
VFPInjProperties::VFPInjProperties(const VFPInjProperties::InjTable& tables) {
|
||||
for (const auto& table : tables) {
|
||||
m_tables[table.first] = table.second.get();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
double VFPInjProperties::bhp(int table_id,
|
||||
@ -98,4 +83,9 @@ bool VFPInjProperties::hasTable(const int table_id) const {
|
||||
return detail::hasTable(m_tables, table_id);
|
||||
}
|
||||
|
||||
void VFPInjProperties::addTable(const VFPInjTable * new_table) {
|
||||
this->m_tables.emplace( new_table->getTableNum(), new_table );
|
||||
}
|
||||
|
||||
|
||||
} //Namespace Opm
|
||||
|
@ -34,25 +34,11 @@ namespace Opm {
|
||||
|
||||
class VFPInjProperties {
|
||||
public:
|
||||
VFPInjProperties() = default;
|
||||
/**
|
||||
* Empty constructor
|
||||
*/
|
||||
VFPInjProperties();
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* Takes *no* ownership of data.
|
||||
* @param inj_table A *single* VFPINJ table
|
||||
*/
|
||||
explicit VFPInjProperties(const VFPInjTable* inj_table);
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* Takes *no* ownership of data.
|
||||
* @param inj_tables A map of different VFPINJ tables.
|
||||
*/
|
||||
using InjTable = std::map<int, std::shared_ptr<const VFPInjTable> >;
|
||||
explicit VFPInjProperties(const InjTable& inj_tables);
|
||||
void addTable(const VFPInjTable * new_table);
|
||||
|
||||
/**
|
||||
* Linear interpolation of bhp as a function of the input parameters given as
|
||||
|
@ -33,23 +33,6 @@ namespace Opm {
|
||||
|
||||
|
||||
|
||||
VFPProdProperties::VFPProdProperties() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
VFPProdProperties::VFPProdProperties(const VFPProdTable* table){
|
||||
m_tables[table->getTableNum()] = table;
|
||||
}
|
||||
|
||||
|
||||
VFPProdProperties::VFPProdProperties(const VFPProdProperties::ProdTable& tables) {
|
||||
for (const auto& table : tables) {
|
||||
m_tables[table.first] = table.second.get();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
double VFPProdProperties::thp(int table_id,
|
||||
const double& aqua,
|
||||
const double& liquid,
|
||||
@ -261,5 +244,8 @@ calculateBhpWithTHPTarget(const std::vector<double>& ipr_a,
|
||||
}
|
||||
}
|
||||
|
||||
void VFPProdProperties::addTable(const VFPProdTable * new_table) {
|
||||
this->m_tables.emplace( new_table->getTableNum(), new_table );
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -38,25 +38,11 @@ namespace Opm {
|
||||
*/
|
||||
class VFPProdProperties {
|
||||
public:
|
||||
VFPProdProperties() = default;
|
||||
/**
|
||||
* Empty constructor
|
||||
*/
|
||||
VFPProdProperties();
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* Takes *no* ownership of data.
|
||||
* @param prod_table A *single* VFPPROD table
|
||||
*/
|
||||
explicit VFPProdProperties(const VFPProdTable* prod_table);
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* Takes *no* ownership of data.
|
||||
* @param prod_tables A map of different VFPPROD tables.
|
||||
*/
|
||||
using ProdTable = std::map<int, std::shared_ptr<const VFPProdTable> >;
|
||||
explicit VFPProdProperties(const ProdTable& prod_tables);
|
||||
void addTable(const VFPProdTable * new_table);
|
||||
|
||||
/**
|
||||
* Linear interpolation of bhp as a function of the input parameters given as
|
||||
|
@ -23,6 +23,9 @@
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/VFPInjTable.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/VFPProdTable.hpp>
|
||||
|
||||
#include <opm/simulators/wells/VFPInjProperties.hpp>
|
||||
#include <opm/simulators/wells/VFPProdProperties.hpp>
|
||||
|
||||
#include <map>
|
||||
|
||||
namespace Opm {
|
||||
@ -31,26 +34,10 @@ namespace Opm {
|
||||
* A thin wrapper class that holds one VFPProdProperties and one
|
||||
* VFPInjProperties object.
|
||||
*/
|
||||
template<typename VFPInjProp, typename VFPProdProp>
|
||||
class VFPProperties {
|
||||
public:
|
||||
VFPProperties() {}
|
||||
VFPProperties() = default;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* Takes *no* ownership of data.
|
||||
* @param inj_table A *single* VFPINJ table or NULL (no table)
|
||||
* @param prod_table A *single* VFPPROD table or NULL (no table)
|
||||
*/
|
||||
explicit VFPProperties(const VFPInjTable* inj_table, const VFPProdTable* prod_table)
|
||||
{
|
||||
if (inj_table != nullptr) {
|
||||
m_inj.reset(new VFPInjProp(inj_table));
|
||||
}
|
||||
if (prod_table != nullptr) {
|
||||
m_prod.reset(new VFPProdProp(prod_table));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@ -58,27 +45,34 @@ public:
|
||||
* @param inj_tables A map of different VFPINJ tables.
|
||||
* @param prod_tables A map of different VFPPROD tables.
|
||||
*/
|
||||
VFPProperties(const std::map<int, std::shared_ptr<const VFPInjTable> >& inj_tables,
|
||||
const std::map<int, std::shared_ptr<const VFPProdTable> >& prod_tables)
|
||||
: m_inj(new VFPInjProp(inj_tables)), m_prod(new VFPProdProp(prod_tables)) {}
|
||||
|
||||
VFPProperties(const std::vector<const VFPInjTable *>& inj_tables,
|
||||
const std::vector<const VFPProdTable *>& prod_tables)
|
||||
{
|
||||
for (const auto& vfpinj_ptr : inj_tables)
|
||||
this->m_inj.addTable( vfpinj_ptr );
|
||||
|
||||
for (const auto& vfpprod_ptr : prod_tables)
|
||||
this->m_prod.addTable( vfpprod_ptr );
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the VFP properties for injection wells
|
||||
*/
|
||||
const VFPInjProp* getInj() const {
|
||||
return m_inj.get();
|
||||
const VFPInjProperties* getInj() const {
|
||||
return &m_inj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the VFP properties for production wells
|
||||
*/
|
||||
const VFPProdProp* getProd() const {
|
||||
return m_prod.get();
|
||||
const VFPProdProperties* getProd() const {
|
||||
return &m_prod;
|
||||
}
|
||||
|
||||
private:
|
||||
std::shared_ptr<VFPInjProp> m_inj;
|
||||
std::shared_ptr<VFPProdProp> m_prod;
|
||||
VFPInjProperties m_inj;
|
||||
VFPProdProperties m_prod;
|
||||
};
|
||||
|
||||
|
||||
|
@ -151,7 +151,7 @@ namespace Opm
|
||||
/// Well cells.
|
||||
const std::vector<int>& cells() const {return well_cells_; }
|
||||
|
||||
void setVFPProperties(const VFPProperties<VFPInjProperties,VFPProdProperties>* vfp_properties_arg);
|
||||
void setVFPProperties(const VFPProperties* vfp_properties_arg);
|
||||
|
||||
void setGuideRate(const GuideRate* guide_rate_arg);
|
||||
|
||||
@ -384,7 +384,7 @@ namespace Opm
|
||||
|
||||
bool getAllowCrossFlow() const;
|
||||
|
||||
const VFPProperties<VFPInjProperties,VFPProdProperties>* vfp_properties_;
|
||||
const VFPProperties* vfp_properties_;
|
||||
|
||||
const GuideRate* guide_rate_;
|
||||
|
||||
|
@ -174,7 +174,7 @@ namespace Opm
|
||||
template<typename TypeTag>
|
||||
void
|
||||
WellInterface<TypeTag>::
|
||||
setVFPProperties(const VFPProperties<VFPInjProperties,VFPProdProperties>* vfp_properties_arg)
|
||||
setVFPProperties(const VFPProperties* vfp_properties_arg)
|
||||
{
|
||||
vfp_properties_ = vfp_properties_arg;
|
||||
}
|
||||
|
@ -205,7 +205,8 @@ struct TrivialFixture {
|
||||
alq_axis,
|
||||
data));
|
||||
|
||||
properties.reset(new Opm::VFPProdProperties(table.get()));
|
||||
properties = std::make_shared<Opm::VFPProdProperties>();
|
||||
properties->addTable( table.get() );
|
||||
}
|
||||
|
||||
double& operator()(size_t thp_idx, size_t wfr_idx, size_t gfr_idx, size_t alq_idx, size_t flo_idx) {
|
||||
@ -590,7 +591,8 @@ VFPPROD \n\
|
||||
Opm::Parser parser;
|
||||
auto deck = parser.parseString(table_str);
|
||||
Opm::VFPProdTable table(deck.getKeyword("VFPPROD", 0), units);
|
||||
Opm::VFPProdProperties properties(&table);
|
||||
Opm::VFPProdProperties properties;
|
||||
properties.addTable( &table );
|
||||
|
||||
const int n = 5; //Number of points to check per axis
|
||||
double bhp_sad = 0.0; //Sum of absolute difference
|
||||
@ -649,8 +651,8 @@ BOOST_AUTO_TEST_CASE(ParseInterpolateRealisticVFPPROD)
|
||||
BOOST_CHECK_EQUAL(deck.count("VFPPROD"), 1);
|
||||
|
||||
Opm::VFPProdTable table(deck.getKeyword("VFPPROD", 0), units);
|
||||
|
||||
Opm::VFPProdProperties properties(&table);
|
||||
Opm::VFPProdProperties properties;
|
||||
properties.addTable(&table);
|
||||
|
||||
//Do some rudimentary testing
|
||||
//Get the BHP as a function of rate, thp, wfr, gfr, alq
|
||||
|
Loading…
Reference in New Issue
Block a user