diff --git a/opm/core/InjectionSpecification.hpp b/opm/core/InjectionSpecification.hpp index e986c8d4c..3cd164a8e 100644 --- a/opm/core/InjectionSpecification.hpp +++ b/opm/core/InjectionSpecification.hpp @@ -19,6 +19,7 @@ namespace Opm ControlMode control_mode_; double surface_flow_max_rate_; double reinjection_fraction_target_; + double fluid_volume_max_rate_; double BHP_limit_; }; } diff --git a/opm/core/WellsGroup.cpp b/opm/core/WellsGroup.cpp index 3346c6ae4..70d7203b3 100644 --- a/opm/core/WellsGroup.cpp +++ b/opm/core/WellsGroup.cpp @@ -6,6 +6,7 @@ */ #include +#include namespace Opm { @@ -152,24 +153,38 @@ namespace Opm } } - std::cout << "checking here" << std::endl; // Check for self: if (wells_->type[self_index_] == PRODUCER) { - if (well_rate[self_index_] - prodSpec().BHP_limit_ > epsilon) { - return false; + double bhp_diff = well_bhp[self_index_] - prodSpec().BHP_limit_; + double rate_diff = well_rate[self_index_] - prodSpec().fluid_volume_max_rate_; + + switch(*wells_->ctrls[self_index_]->type) { + case BHP: + bhp_diff = std::abs(bhp_diff); + break; + case RATE: + rate_diff = std::abs(rate_diff); + break; } - - if (well_rate[self_index_] - prodSpec().fluid_volume_max_rate_ > epsilon) { + if(bhp_diff > epsilon || rate_diff > epsilon) { return false; } } else { - if (well_rate[self_index_] - injSpec().BHP_limit_ > epsilon) { - return false; - } - - if (well_rate[self_index_] - injSpec().surface_flow_max_rate_ > epsilon) { + double bhp_diff = well_bhp[self_index_] - injSpec().BHP_limit_; + double flow_diff = well_rate[self_index_] - injSpec().fluid_volume_max_rate_; + switch(*wells_->ctrls[self_index_]->type) { + case BHP: + bhp_diff = std::abs(bhp_diff); + break; + case RATE: + flow_diff = std::abs(flow_diff); + break; + } + + if(bhp_diff > epsilon || flow_diff > epsilon) { return false; } + } return true; } @@ -326,6 +341,7 @@ namespace Opm injection_specification.injector_type_ = toSurfaceComponent(line.injector_type_); injection_specification.control_mode_ = toInjectionControlMode(line.control_mode_); injection_specification.surface_flow_max_rate_ = line.surface_flow_max_rate_; + injection_specification.fluid_volume_max_rate_ = line.fluid_volume_max_rate_; } } } diff --git a/opm/core/WellsGroup.hpp b/opm/core/WellsGroup.hpp index 46819ed0a..abf1dcfed 100644 --- a/opm/core/WellsGroup.hpp +++ b/opm/core/WellsGroup.hpp @@ -34,6 +34,7 @@ namespace Opm /// Injection specifications for the well or well group. InjectionSpecification& injSpec(); + /// \returns true if the object is a leaf node (WellNode), false otherwise. virtual bool isLeafNode() const;