Added checks for BHP and fluid_volume_rate for group control. Also added error tolerance for group control

This commit is contained in:
Kjetil Olsen Lye 2012-04-13 12:57:47 +02:00
parent fdfd360481
commit affbb08795
9 changed files with 67 additions and 48 deletions

View File

@ -76,7 +76,7 @@ int main(int argc, char** argv) {
std::vector<double> well_rate;
pressure_solver.solve(totmob, omega, src, wdp, bcs.c_bcs(), pressure, face_flux, well_bhp, well_rate);
std::cout << "Solved" << std::endl;
if(wells.wellCollection().conditionsMet(well_bhp, well_rate)) {
if(wells.wellCollection().conditionsMet(well_bhp, well_rate, *grid.c_grid(), state.saturation() )) {
std::cout << "Conditions met for wells!" << std::endl;
}
else

View File

@ -3,8 +3,8 @@ namespace Opm
{
InjectionSpecification::InjectionSpecification()
: injector_type_(WATER), control_mode_(NONE), surface_flow_max_rate_(0.0),
reinjection_fraction_target_(0.0), BHP_limit_(0.0)
: injector_type_(WATER), control_mode_(NONE), surface_flow_max_rate_(1e100),
reinjection_fraction_target_(0.0), BHP_limit_(1e100)
{
}

View File

@ -7,11 +7,11 @@ namespace Opm
:
control_mode_(NONE_CM),
procedure_(NONE_P),
oil_max_rate_(-1.0),
water_production_target_(-1.0),
fluid_volume_max_rate_(-1.0),
BHP_limit_(-1.0),
guide_rate_(-1.0)
oil_max_rate_(1e100),
water_production_target_(1e100),
fluid_volume_max_rate_(1e100),
BHP_limit_(1e100),
guide_rate_(1e100)
{
}

View File

@ -88,9 +88,10 @@ namespace Opm
return NULL;
}
bool WellCollection::conditionsMet(const std::vector<double>& well_bhp, const std::vector<double>& well_rate) const {
bool WellCollection::conditionsMet(const std::vector<double>& well_bhp, const std::vector<double>& well_rate,
const UnstructuredGrid& grid, const std::vector<double>& saturations, double epsilon) const {
for(size_t i = 0; i < leaf_nodes_.size(); i++) {
if(! static_cast<WellNode*>(leaf_nodes_[i].get())->conditionsMet(well_bhp, well_rate) ) {
if(! static_cast<WellNode*>(leaf_nodes_[i].get())->conditionsMet(well_bhp, well_rate, grid, saturations, epsilon) ) {
return false;
}
}

View File

@ -40,7 +40,8 @@ namespace Opm
const EclipseGridParser& deck);
bool conditionsMet(const std::vector<double>& well_bhp, const std::vector<double>& well_rate) const;
bool conditionsMet(const std::vector<double>& well_bhp, const std::vector<double>& well_rate,
const UnstructuredGrid& grid, const std::vector<double>& saturations, double epsilon=1e-8) const;
const std::vector<std::tr1::shared_ptr<WellsGroupInterface> >& getLeafNodes() const;

View File

@ -114,11 +114,14 @@ namespace Opm
}
bool WellsGroup::conditionsMet(const std::vector<double>& well_bhp, const std::vector<double>& well_rate,
const struct Wells* wells, int index_of_well)
bool WellsGroup::conditionsMet(const std::vector<double>& well_bhp, const std::vector<double>& well_rate,
const UnstructuredGrid& grid, const std::vector<double>& saturations,
const struct Wells* wells, int index_of_well, double epsilon)
{
if (parent_ != NULL) {
bool parent_ok = (static_cast<WellsGroup*> (parent_))->conditionsMet(well_bhp, well_rate, wells, index_of_well);
bool parent_ok =
(static_cast<WellsGroup*> (parent_))->conditionsMet(well_bhp,
well_rate,grid, saturations, wells, index_of_well, epsilon);
if (!parent_ok) {
return false;
}
@ -138,15 +141,26 @@ namespace Opm
{
}
bool WellNode::conditionsMet(const std::vector<double>& well_bhp, const std::vector<double>& well_rate)
bool WellNode::conditionsMet(const std::vector<double>& well_bhp, const std::vector<double>& well_rate,
const UnstructuredGrid& grid, const std::vector<double>& saturations, double epsilon)
{
if (parent_ != NULL) {
bool parent_ok = (static_cast<WellsGroup*> (parent_))->conditionsMet(well_bhp, well_rate, wells_, self_index_);
bool parent_ok = (static_cast<WellsGroup*> (parent_))->conditionsMet(well_bhp, well_rate, grid, saturations, wells_, self_index_, epsilon);
if (!parent_ok) {
return false;
}
}
std::cout << "checking here" << std::endl;
// Check for self:
if(well_rate[self_index_] - prodSpec().BHP_limit_ > epsilon) {
return false;
}
if(well_rate[self_index_] - prodSpec().fluid_volume_max_rate_ > epsilon) {
return false;
}
return true;
}

View File

@ -67,8 +67,9 @@ namespace Opm
void addChild(std::tr1::shared_ptr<WellsGroupInterface> child);
bool conditionsMet(const std::vector<double>& well_bhp, const std::vector<double>& well_rate, const struct Wells* wells,
int index_of_well);
bool conditionsMet(const std::vector<double>& well_bhp, const std::vector<double>& well_rate,
const UnstructuredGrid& grid, const std::vector<double>& saturations, const struct Wells* wells,
int index_of_well, double epsilon = 1e-8);
virtual void calculateGuideRates();
private:
@ -85,7 +86,8 @@ namespace Opm
InjectionSpecification inj_spec);
virtual WellsGroupInterface* findGroup(std::string name_of_node);
virtual bool conditionsMet(const std::vector<double>& well_bhp, const std::vector<double>& well_rate);
virtual bool conditionsMet(const std::vector<double>& well_bhp, const std::vector<double>& well_rate,
const UnstructuredGrid& grid, const std::vector<double>& saturations, double epsilon=1e-8);
virtual bool isLeafNode() const;
void setWellsPointer(const struct Wells* wells, int self_index);

View File

@ -496,49 +496,50 @@ namespace Opm
}
// Set the guide rates:
if(deck.hasField("WGRUPCON")) {
if (deck.hasField("WGRUPCON")) {
std::cout << "Found Wgrupcon" << std::endl;
WGRUPCON wgrupcon = deck.getWGRUPCON();
const std::vector<WgrupconLine>& lines = wgrupcon.wgrupcon;
std::cout << well_collection_.getLeafNodes().size() << std::endl;
for(size_t i = 0; i < lines.size(); i++) {
for (size_t i = 0; i < lines.size(); i++) {
std::string name = lines[i].well_;
int index = well_names_to_index[name];
ASSERT(well_collection_.getLeafNodes()[index]->name() == name);
well_collection_.getLeafNodes()[index]->prodSpec().guide_rate_ = lines[i].guide_rate_;
well_collection_.getLeafNodes()[index]->prodSpec().guide_rate_type_
well_collection_.getLeafNodes()[index]->prodSpec().guide_rate_type_
= lines[i].phase_ == "OIL" ? ProductionSpecification::OIL : ProductionSpecification::RAT;
}
well_collection_.calculateGuideRates();
}
// Apply guide rates:
for(size_t i = 0; i < well_data.size(); i++) {
if(well_collection_.getLeafNodes()[i]->prodSpec().control_mode_ == ProductionSpecification::GRUP)
{
#if 0
// Apply guide rates:
for (size_t i = 0; i < well_data.size(); i++) {
std::cout << "hello" << std::endl;
if (well_collection_.getLeafNodes()[i]->prodSpec().control_mode_ == ProductionSpecification::GRUP) {
std::cout << "hello" << std::endl;
if (well_collection_.getLeafNodes()[i]->prodSpec().guide_rate_type_ == ProductionSpecification::OIL) {
well_data[i].control = RATE;
if(well_collection_.getLeafNodes()[i]->prodSpec().guide_rate_type_ == ProductionSpecification::OIL) {
well_data[i].control = RATE;
double parent_oil_rate = well_collection_.getLeafNodes()[i]->getParent()->prodSpec().oil_max_rate_;
double guide_rate = well_collection_.getLeafNodes()[i]->prodSpec().guide_rate_;
well_data[i].target = guide_rate * parent_oil_rate;
}
}
double parent_oil_rate = well_collection_.getLeafNodes()[i]->getParent()->prodSpec().oil_max_rate_;
double guide_rate = well_collection_.getLeafNodes()[i]->prodSpec().guide_rate_;
well_data[i].target = guide_rate * parent_oil_rate;
}
}
else if(well_collection_.getLeafNodes()[i]->injSpec().control_mode_ == InjectionSpecification::GRUP)
{
if(well_collection_.getLeafNodes()[i]->prodSpec().guide_rate_type_ == ProductionSpecification::RAT) {
well_data[i].control = RATE;
well_data[i].type = INJECTOR;
double parent_surface_rate = well_collection_.getLeafNodes()[i]->getParent()->injSpec().surface_flow_max_rate_;
double guide_rate = well_collection_.getLeafNodes()[i]->prodSpec().guide_rate_;
well_data[i].target = guide_rate * parent_surface_rate;
if (well_collection_.getLeafNodes()[i]->injSpec().control_mode_ == InjectionSpecification::GRUP) {
if (well_collection_.getLeafNodes()[i]->prodSpec().guide_rate_type_ == ProductionSpecification::RAT) {
well_data[i].control = RATE;
well_data[i].type = INJECTOR;
double parent_surface_rate = well_collection_.getLeafNodes()[i]->getParent()->injSpec().surface_flow_max_rate_;
double guide_rate = well_collection_.getLeafNodes()[i]->prodSpec().guide_rate_;
well_data[i].target = guide_rate * parent_surface_rate;
}
}
}
#endif
}

View File

@ -1424,7 +1424,7 @@ struct WconprodLine
WconprodLine() :
open_shut_flag_("OPEN"), oil_max_rate_(1.0E20), water_max_rate_(1.0E20),
gas_max_rate_(1.0E20), liquid_max_rate_(1.0E20),
fluid_volume_max_rate_(1.0E20), BHP_limit_(-1.0), THP_limit_(0.0),
fluid_volume_max_rate_(1.0E20), BHP_limit_(1e100), THP_limit_(0.0),
VFP_table_number_(0), artif_lift_quantity_(0.0)
{
}