Add Well constructor based on restart well

This commit is contained in:
Joakim Hove 2020-03-12 18:01:37 +01:00
parent e1dbd72689
commit a28f146d71
2 changed files with 184 additions and 0 deletions

View File

@ -49,6 +49,10 @@ class WellProductionProperties;
class UDQActive;
class UDQConfig;
namespace RestartIO {
class RstWell;
}
class Well {
public:
@ -394,6 +398,11 @@ public:
bool allow_xflow,
bool auto_shutin);
Well(const RestartIO::RstWell& rst_well,
int report_step,
const UnitSystem& unit_system,
double udq_undefined);
Well(const std::string& wname,
const std::string& gname,
std::size_t init_step,

View File

@ -19,6 +19,7 @@
#include <opm/parser/eclipse/Deck/DeckRecord.hpp>
#include <opm/parser/eclipse/Deck/DeckKeyword.hpp>
#include <opm/io/eclipse/rst/well.hpp>
#include <opm/parser/eclipse/Parser/ParserKeywords/W.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/MSW/updatingConnectionsWithSegments.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Well/Well.hpp>
@ -91,6 +92,180 @@ Well::Well() :
}
namespace {
constexpr Phase def_phase = Phase::OIL;
constexpr Well::Status def_status = Well::Status::OPEN;
constexpr int def_ecl_phase = 1;
constexpr int def_well_closed_control = 0;
Connection::Order order_from_int(int int_value) {
switch(int_value) {
case 0:
return Connection::Order::TRACK;
case 1:
return Connection::Order::DEPTH;
case 2:
return Connection::Order::INPUT;
default:
throw std::invalid_argument("Invalid integer value: " + std::to_string(int_value) + " encountered when determining connection ordering");
}
}
constexpr Well::ProducerCMode def_whistctl_cmode = Well::ProducerCMode::CMODE_UNDEFINED;
const static Well::WellGuideRate def_guide_rate = {true, -1, Well::GuideRateTarget::UNDEFINED, ParserKeywords::WGRUPCON::SCALING_FACTOR::defaultValue};
const static bool def_automatic_shutin = true;
constexpr double def_solvent_fraction = 0;
}
Well::Well(const RestartIO::RstWell& rst_well,
int report_step,
const UnitSystem& unit_system_arg,
double udq_undefined_arg) :
wname(rst_well.name),
group_name(rst_well.group),
init_step(report_step),
headI(rst_well.ij[0]),
headJ(rst_well.ij[1]),
ref_depth(rst_well.datum_depth),
ordering(order_from_int(rst_well.completion_ordering)),
unit_system(unit_system_arg),
udq_undefined(udq_undefined_arg),
status(rst_well.active_control == def_well_closed_control ? Well::Status::SHUT : Well::Status::OPEN),
drainage_radius(rst_well.drainage_radius),
allow_cross_flow(rst_well.allow_xflow == 1),
automatic_shutin(def_automatic_shutin),
wtype(rst_well.wtype),
guide_rate(def_guide_rate),
efficiency_factor(rst_well.efficiency_factor),
solvent_fraction(def_solvent_fraction),
prediction_mode(rst_well.pred_requested_control != 0),
econ_limits(std::make_shared<WellEconProductionLimits>()),
foam_properties(std::make_shared<WellFoamProperties>()),
polymer_properties(std::make_shared<WellPolymerProperties>()),
brine_properties(std::make_shared<WellBrineProperties>()),
tracer_properties(std::make_shared<WellTracerProperties>()),
connections(std::make_shared<WellConnections>(headI, headJ)),
production(std::make_shared<WellProductionProperties>(unit_system_arg, wname)),
injection(std::make_shared<WellInjectionProperties>(unit_system_arg, wname))
{
if (this->wtype.producer()) {
auto p = std::make_shared<WellProductionProperties>(this->unit_system, wname);
// Reverse of function ctrlMode() in AggregateWellData.cpp
p->whistctl_cmode = def_whistctl_cmode;
p->BHPTarget = rst_well.bhp_target_float;
p->OilRate = rst_well.orat_target ;
p->WaterRate = rst_well.wrat_target ;
p->GasRate = rst_well.grat_target ;
p->LiquidRate = rst_well.lrat_target ;
p->ResVRate = rst_well.resv_target ;
if (rst_well.orat_target != 0)
p->addProductionControl( Well::ProducerCMode::ORAT );
if (rst_well.wrat_target != 0)
p->addProductionControl( Well::ProducerCMode::WRAT );
if (rst_well.grat_target != 0)
p->addProductionControl( Well::ProducerCMode::GRAT );
if (rst_well.lrat_target != 0)
p->addProductionControl( Well::ProducerCMode::LRAT );
if (rst_well.resv_target != 0)
p->addProductionControl( Well::ProducerCMode::RESV );
switch (rst_well.active_control) {
case 1:
p->controlMode = Well::ProducerCMode::ORAT;
break;
case 2:
p->controlMode = Well::ProducerCMode::WRAT;
p->addProductionControl( Well::ProducerCMode::WRAT );
break;
case 3:
p->controlMode = Well::ProducerCMode::GRAT;
p->addProductionControl( Well::ProducerCMode::GRAT );
break;
case 4:
p->controlMode = Well::ProducerCMode::LRAT;
p->addProductionControl( Well::ProducerCMode::LRAT );
break;
case 5:
p->controlMode = Well::ProducerCMode::RESV;
p->addProductionControl( Well::ProducerCMode::RESV );
break;
case 6:
p->controlMode = Well::ProducerCMode::THP;
p->addProductionControl( Well::ProducerCMode::THP );
break;
case 7:
p->controlMode = Well::ProducerCMode::BHP;
p->addProductionControl( Well::ProducerCMode::BHP );
break;
default:
throw std::invalid_argument("Can convert integer value: " + std::to_string(rst_well.active_control) + " to control type");
}
p->addProductionControl(Well::ProducerCMode::BHP);
if (this->isAvailableForGroupControl())
p->addProductionControl(Well::ProducerCMode::GRUP);
this->updateProduction(std::move(p));
} else {
auto i = std::make_shared<WellInjectionProperties>(this->unit_system, wname);
// Reverse of function ctrlMode() in AggregateWellData.cpp
switch (rst_well.active_control) {
case 1:
case 2:
case 3:
case 4:
i->controlMode = Well::InjectorCMode::RATE;
i->addInjectionControl(Well::InjectorCMode::RATE);
break;
case 5:
i->controlMode = Well::InjectorCMode::RESV;
i->addInjectionControl(Well::InjectorCMode::RESV);
break;
case 6:
i->controlMode = Well::InjectorCMode::THP;
i->addInjectionControl(Well::InjectorCMode::THP);
break;
case 7:
i->controlMode = Well::InjectorCMode::BHP;
break;
case -1:
i->controlMode = Well::InjectorCMode::GRUP;
break;
default:
throw std::invalid_argument("Could not convert integer value: " + std::to_string(rst_well.active_control) + " to control type");
}
i->injectorType = rst_well.wtype.injector_type();
switch (i->injectorType) {
case InjectorType::WATER:
i->surfaceInjectionRate = rst_well.wrat_target;
break;
case InjectorType::GAS:
i->surfaceInjectionRate = rst_well.grat_target;
break;
default:
throw std::invalid_argument("What ...");
}
i->addInjectionControl(Well::InjectorCMode::BHP);
i->BHPTarget = rst_well.bhp_target_float;
if (this->isAvailableForGroupControl())
i->addInjectionControl(Well::InjectorCMode::GRUP);
this->updateInjection(std::move(i));
}
}
Well::Well(const std::string& wname_arg,
const std::string& gname,
std::size_t init_step_arg,