Added further checks for well conditions. Fixed a small bug in reading WCONPROD

This commit is contained in:
Kjetil Olsen Lye 2012-04-16 13:44:53 +02:00
parent 67251e7f77
commit a7e471951d
3 changed files with 61 additions and 3 deletions

View File

@ -113,7 +113,7 @@ namespace Opm
}
}
}
bool WellsGroup::conditionsMet(const std::vector<double>& well_bhp, const std::vector<double>& well_rate,
const UnstructuredGrid& grid, const std::vector<double>& saturations,
@ -127,6 +127,38 @@ namespace Opm
return false;
}
}
int number_of_leaf_nodes = 1;//numberOfLeafNodes();
double bhp_target = 1e100;
double rate_target = 1e100;
switch(wells->type[index_of_well]) {
case INJECTOR:
{
const InjectionSpecification& inje_spec = injSpec();
bhp_target = inje_spec.BHP_limit_ / number_of_leaf_nodes;
rate_target = inje_spec.fluid_volume_max_rate_ / number_of_leaf_nodes;
break;
}
case PRODUCER:
{
const ProductionSpecification& prod_spec = prodSpec();
bhp_target = prod_spec.BHP_limit_ / number_of_leaf_nodes;
rate_target = prod_spec.fluid_volume_max_rate_ / number_of_leaf_nodes;
break;
}
}
if (well_bhp[index_of_well] - bhp_target > epsilon) {
std::cout << "BHP not met" << std::endl;
return false;
}
if(well_rate[index_of_well] - rate_target > epsilon) {
std::cout << wells->type[index_of_well] << std::endl;
std::cout << "well_rate not met" << std::endl;
std::cout << "target = " << rate_target << ", well_rate[index_of_well] = " << well_rate[index_of_well] << std::endl;
return false;
}
return true;
}
@ -135,6 +167,19 @@ namespace Opm
children_.push_back(child);
}
int WellsGroup::numberOfLeafNodes() {
// This could probably use some caching, but seeing as how the number of
// wells is relatively small, we'll do without for now.
int sum = 0;
for(size_t i = 0; i < children_.size(); i++) {
sum += children_[i]->numberOfLeafNodes();
}
return sum;
}
WellNode::WellNode(const std::string& myname,
ProductionSpecification prod_spec,
InjectionSpecification inj_spec)
@ -214,6 +259,11 @@ namespace Opm
{
// Empty
}
int WellNode::numberOfLeafNodes()
{
return 1;
}
namespace
{

View File

@ -45,7 +45,13 @@ namespace Opm
void setParent(WellsGroupInterface* parent);
const WellsGroupInterface* getParent() const;
/// Recursively calculate the guide rate for each member of the well group.
/// This should be called after the guide rates are set to the non-normalized values.
virtual void calculateGuideRates() = 0;
/// Calculates the number of leaf nodes in the given group.
/// A leaf node is defined to have one leaf node in its group.
virtual int numberOfLeafNodes() = 0;
protected:
WellsGroupInterface* parent_;
@ -73,6 +79,9 @@ namespace Opm
int index_of_well, double epsilon = 1e-8);
virtual void calculateGuideRates();
virtual int numberOfLeafNodes();
private:
std::vector<std::tr1::shared_ptr<WellsGroupInterface> > children_;
};
@ -94,6 +103,7 @@ namespace Opm
void setWellsPointer(const struct Wells* wells, int self_index);
virtual void calculateGuideRates();
virtual int numberOfLeafNodes();
private:
const struct Wells* wells_;
int self_index_;

View File

@ -517,9 +517,7 @@ namespace Opm
// 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;