diff --git a/examples/compute_tof.cpp b/examples/compute_tof.cpp index 5d21d349..2c80cbb0 100644 --- a/examples/compute_tof.cpp +++ b/examples/compute_tof.cpp @@ -58,6 +58,9 @@ namespace { + const static double alq_invalid = -std::numeric_limits::max(); + const static int vfp_invalid = -std::numeric_limits::max(); + void warnIfUnusedParams(const Opm::parameter::ParameterGroup& param) { if (param.anyUnused()) { @@ -90,7 +93,9 @@ namespace WellControls* ctrl = wells.ctrls[w]; const double target = (wells.type[w] == INJECTOR) ? 200*Opm::unit::barsa : 100*Opm::unit::barsa; const double distr[3] = { 1.0, 0.0, 0.0 }; // Large enough irrespective of #phases. - well_controls_add_new(BHP, target, distr, ctrl); + well_controls_add_new(BHP, target, + alq_invalid, vfp_invalid, + distr, ctrl); well_controls_set_current(ctrl, well_controls_get_num(ctrl) - 1); } } diff --git a/opm/core/pressure/tpfa/cfs_tpfa_residual.c b/opm/core/pressure/tpfa/cfs_tpfa_residual.c index c3c6040b..f8ab9aed 100644 --- a/opm/core/pressure/tpfa/cfs_tpfa_residual.c +++ b/opm/core/pressure/tpfa/cfs_tpfa_residual.c @@ -876,6 +876,7 @@ assemble_completion_to_well(int i, int w, int c, int nc, int np, else { switch (well_controls_get_current_type(ctrl)) { case BHP : + case THP : // THP is implemented as a BHP target welleq_coeff_bhp(np, pw - well_controls_get_current_target( ctrl ), h, &res, &w2c, &w2w); break; diff --git a/opm/core/pressure/tpfa/ifs_tpfa.c b/opm/core/pressure/tpfa/ifs_tpfa.c index 84f4ac0a..673e772e 100644 --- a/opm/core/pressure/tpfa/ifs_tpfa.c +++ b/opm/core/pressure/tpfa/ifs_tpfa.c @@ -374,6 +374,7 @@ assemble_well_contrib(int nc , switch (well_controls_get_current_type(ctrls)) { case BHP: + case THP : // THP is implemented as a BHP target *all_rate = 0; assemble_bhp_well (nc, w, W, mt, wdp, h); break; diff --git a/opm/core/simulator/WellState.hpp b/opm/core/simulator/WellState.hpp index 81ae6855..dd09326b 100644 --- a/opm/core/simulator/WellState.hpp +++ b/opm/core/simulator/WellState.hpp @@ -45,6 +45,7 @@ namespace Opm const int nw = wells->number_of_wells; const int np = wells->number_of_phases; bhp_.resize(nw); + thp_.resize(nw); temperature_.resize(nw, 273.15 + 20); // standard temperature for now wellrates_.resize(nw * np, 0.0); for (int w = 0; w < nw; ++w) { @@ -52,11 +53,11 @@ namespace Opm const WellControls* ctrl = wells->ctrls[w]; if (well_controls_well_is_stopped(ctrl)) { // Stopped well: - // 1. Assign zero well rates. + // 1. Rates: assign zero well rates. for (int p = 0; p < np; ++p) { wellrates_[np*w + p] = 0.0; } - // 2. Assign bhp equal to bhp control, if + // 2. Bhp: assign bhp equal to bhp control, if // applicable, otherwise assign equal to // first perforation cell pressure. if (well_controls_get_current_type(ctrl) == BHP) { @@ -65,9 +66,16 @@ namespace Opm const int first_cell = wells->well_cells[wells->well_connpos[w]]; bhp_[w] = state.pressure()[first_cell]; } + // 3. Thp: assign thp equal to thp control, if applicable, + // otherwise assign equal to bhp value. + if (well_controls_get_current_type(ctrl) == THP) { + thp_[w] = well_controls_get_current_target( ctrl ); + } else { + thp_[w] = bhp_[w]; + } } else { // Open well: - // 1. Initialize well rates to match controls + // 1. Rates: initialize well rates to match controls // if type is SURFACE_RATE. Otherwise, we // cannot set the correct value here, so we // assign a small rate with the correct @@ -86,20 +94,30 @@ namespace Opm wellrates_[np*w + p] = small_rate * sign; } } - // 2. Initialize bhp to be target pressure if + + // 2. Bhp: initialize bhp to be target pressure if // bhp-controlled well, otherwise set to a // little above or below (depending on if // the well is an injector or producer) // pressure in first perforation cell. - if (well_controls_get_current_type(ctrl) == BHP) { - bhp_[w] = well_controls_get_current_target( ctrl ); - } else { - const int first_cell = wells->well_cells[wells->well_connpos[w]]; - const double safety_factor = (wells->type[w] == INJECTOR) ? 1.01 : 0.99; - bhp_[w] = safety_factor*state.pressure()[first_cell]; + if (well_controls_get_current_type(ctrl) == BHP) { + bhp_[w] = well_controls_get_current_target( ctrl ); + } else { + const int first_cell = wells->well_cells[wells->well_connpos[w]]; + const double safety_factor = (wells->type[w] == INJECTOR) ? 1.01 : 0.99; + bhp_[w] = safety_factor*state.pressure()[first_cell]; + } + + // 3. Thp: assign thp equal to thp control, if applicable, + // otherwise assign equal to bhp value. + if (well_controls_get_current_type(ctrl) == THP) { + thp_[w] = well_controls_get_current_target( ctrl ); + } else { + thp_[w] = bhp_[w]; + } } - } } + // The perforation rates and perforation pressures are // not expected to be consistent with bhp_ and wellrates_ // after init(). @@ -112,6 +130,10 @@ namespace Opm std::vector& bhp() { return bhp_; } const std::vector& bhp() const { return bhp_; } + /// One thp pressure per well. + std::vector& thp() { return thp_; } + const std::vector& thp() const { return thp_; } + /// One temperature per well. std::vector& temperature() { return temperature_; } const std::vector& temperature() const { return temperature_; } @@ -150,6 +172,7 @@ namespace Opm private: std::vector bhp_; + std::vector thp_; std::vector temperature_; std::vector wellrates_; std::vector perfrates_; diff --git a/opm/core/well_controls.h b/opm/core/well_controls.h index 1dd7c023..ce319b22 100644 --- a/opm/core/well_controls.h +++ b/opm/core/well_controls.h @@ -33,6 +33,7 @@ extern "C" { enum WellControlType { BHP, /**< Well constrained by BHP target */ + THP, /**< Well constrained by THP target */ RESERVOIR_RATE, /**< Well constrained by reservoir volume flow rate */ SURFACE_RATE /**< Well constrained by surface volume flow rate */ }; @@ -82,7 +83,7 @@ void well_controls_stop_well( struct WellControls * ctrl); int -well_controls_add_new(enum WellControlType type , double target , const double * distr , struct WellControls * ctrl); +well_controls_add_new(enum WellControlType type , double target , double alq , int vfp , const double * distr , struct WellControls * ctrl); enum WellControlType well_controls_iget_type(const struct WellControls * ctrl, int control_index); @@ -99,6 +100,18 @@ well_controls_iset_target(struct WellControls * ctrl, int control_index , double double well_controls_iget_target(const struct WellControls * ctrl, int control_index); +void +well_controls_iset_alq(struct WellControls * ctrl, int control_index , double alq); + +double +well_controls_iget_alq(const struct WellControls * ctrl, int control_index ); + +void +well_controls_iset_vfp(struct WellControls * ctrl, int control_index , int vfp); + +int +well_controls_iget_vfp(const struct WellControls * ctrl, int control_index ); + double well_controls_get_current_target(const struct WellControls * ctrl); diff --git a/opm/core/wells.h b/opm/core/wells.h index df23b743..4d749cda 100644 --- a/opm/core/wells.h +++ b/opm/core/wells.h @@ -212,6 +212,8 @@ add_well(enum WellType type , * * \param[in] type Control type. * \param[in] target Target value for the control. + * \param[in] alq Artificial lift quantity for control (for THP type only) + * \param[in] vfp VFP table number for control (for THP type only) * \param[in] distr Array of size W->number_of_phases or NULL. * \param[in] well_index Index of well to receive additional control. * \param[in,out] W Existing set of well controls. @@ -222,6 +224,8 @@ add_well(enum WellType type , int append_well_controls(enum WellControlType type , double target, + double alq, + int vfp, const double *distr, int well_index, struct Wells *W); diff --git a/opm/core/wells/WellsGroup.cpp b/opm/core/wells/WellsGroup.cpp index 7b65f868..bf80e464 100644 --- a/opm/core/wells/WellsGroup.cpp +++ b/opm/core/wells/WellsGroup.cpp @@ -26,6 +26,12 @@ #include #include +namespace +{ + static double invalid_alq = -1e100; + static double invalid_vfp = -2147483647; +} //Namespace + namespace Opm { @@ -678,6 +684,11 @@ namespace Opm break; } + case THP: { + //TODO: Implement support + OPM_THROW(std::invalid_argument, "THP not implemented in WellNode::conditionsMet."); + } + case RESERVOIR_RATE: { double my_rate = 0.0; const double * ctrls_distr = well_controls_iget_distr( ctrls , ctrl_index ); @@ -751,11 +762,14 @@ namespace Opm } else { const double target = 0.0; + const double alq = 0.0; const double distr[3] = {1.0, 1.0, 1.0}; if (group_control_index_ < 0) { // The well only had its own controls, no group controls. - append_well_controls(SURFACE_RATE, target, distr, self_index_, wells_); + append_well_controls(SURFACE_RATE, target, + invalid_alq, invalid_vfp, + distr, self_index_, wells_); group_control_index_ = well_controls_get_num(wells_->ctrls[self_index_]) - 1; } else { // We will now modify the last control, that @@ -763,6 +777,7 @@ namespace Opm well_controls_iset_type( wells_->ctrls[self_index_] , group_control_index_ , SURFACE_RATE); well_controls_iset_target( wells_->ctrls[self_index_] , group_control_index_ , target); + well_controls_iset_alq( wells_->ctrls[self_index_] , group_control_index_ , alq); well_controls_iset_distr(wells_->ctrls[self_index_] , group_control_index_ , distr); } well_controls_open_well( wells_->ctrls[self_index_]); @@ -810,13 +825,14 @@ namespace Opm if (group_control_index_ < 0) { // The well only had its own controls, no group controls. - append_well_controls(wct, target, distr, self_index_, wells_); + append_well_controls(wct, target, invalid_alq, invalid_vfp, distr, self_index_, wells_); group_control_index_ = well_controls_get_num(wells_->ctrls[self_index_]) - 1; } else { // We will now modify the last control, that // "belongs to" the group control. well_controls_iset_type(wells_->ctrls[self_index_] , group_control_index_ , wct); well_controls_iset_target(wells_->ctrls[self_index_] , group_control_index_ ,target); + well_controls_iset_alq(wells_->ctrls[self_index_] , group_control_index_ , -1e100); well_controls_iset_distr(wells_->ctrls[self_index_] , group_control_index_ , distr); } set_current_control(self_index_, group_control_index_, wells_); @@ -921,13 +937,14 @@ namespace Opm if (group_control_index_ < 0) { // The well only had its own controls, no group controls. - append_well_controls(wct, ntarget, distr, self_index_, wells_); + append_well_controls(wct, ntarget, invalid_alq, invalid_vfp, distr, self_index_, wells_); group_control_index_ = well_controls_get_num(wells_->ctrls[self_index_]) - 1; } else { // We will now modify the last control, that // "belongs to" the group control. well_controls_iset_type(wells_->ctrls[self_index_] , group_control_index_ , wct); well_controls_iset_target(wells_->ctrls[self_index_] , group_control_index_ , ntarget); + well_controls_iset_alq(wells_->ctrls[self_index_] , group_control_index_ , -1e100); well_controls_iset_distr(wells_->ctrls[self_index_] , group_control_index_ , distr); } set_current_control(self_index_, group_control_index_, wells_); diff --git a/opm/core/wells/WellsManager.cpp b/opm/core/wells/WellsManager.cpp index 9cc4d2cc..444d9f40 100644 --- a/opm/core/wells/WellsManager.cpp +++ b/opm/core/wells/WellsManager.cpp @@ -39,6 +39,11 @@ #include #include +namespace +{ + static double invalid_alq = -1e100; + static double invalid_vfp = -2147483647; +} //Namespace // Helper structs and functions for the implementation. namespace WellsManagerDetail @@ -452,6 +457,8 @@ namespace Opm ok = append_well_controls(SURFACE_RATE, injectionProperties.surfaceInjectionRate, + invalid_alq, + invalid_vfp, distr, well_index, w_); @@ -472,23 +479,35 @@ namespace Opm ok = append_well_controls(RESERVOIR_RATE, injectionProperties.reservoirInjectionRate, + invalid_alq, + invalid_vfp, distr, well_index, w_); } if (ok && injectionProperties.hasInjectionControl(WellInjector::BHP)) { - control_pos[WellsManagerDetail::InjectionControl::BHP] = well_controls_get_num(w_->ctrls[well_index]); control_pos[WellsManagerDetail::InjectionControl::BHP] = well_controls_get_num(w_->ctrls[well_index]); ok = append_well_controls(BHP, - injectionProperties.BHPLimit, + injectionProperties.BHPLimit, + invalid_alq, + invalid_vfp, NULL, well_index, w_); } if (ok && injectionProperties.hasInjectionControl(WellInjector::THP)) { - OPM_THROW(std::runtime_error, "We cannot handle THP limit for well " << well_names[well_index]); + control_pos[WellsManagerDetail::InjectionControl::THP] = well_controls_get_num(w_->ctrls[well_index]); + const double thp_limit = injectionProperties.THPLimit; + const int vfp_number = injectionProperties.VFPTableNumber; + ok = append_well_controls(THP, + thp_limit, + invalid_alq, + vfp_number, + NULL, + well_index, + w_); } if (!ok) { @@ -548,9 +567,11 @@ namespace Opm double distr[3] = { 0.0, 0.0, 0.0 }; distr[phaseUsage.phase_pos[BlackoilPhases::Liquid]] = 1.0; ok = append_well_controls(SURFACE_RATE, - -productionProperties.OilRate, + -productionProperties.OilRate, + invalid_alq, + invalid_vfp, distr, - well_index, + well_index, w_); } @@ -563,6 +584,8 @@ namespace Opm distr[phaseUsage.phase_pos[BlackoilPhases::Aqua]] = 1.0; ok = append_well_controls(SURFACE_RATE, -productionProperties.WaterRate, + invalid_alq, + invalid_vfp, distr, well_index, w_); @@ -577,6 +600,8 @@ namespace Opm distr[phaseUsage.phase_pos[BlackoilPhases::Vapour]] = 1.0; ok = append_well_controls(SURFACE_RATE, -productionProperties.GasRate, + invalid_alq, + invalid_vfp, distr, well_index, w_); @@ -594,7 +619,9 @@ namespace Opm distr[phaseUsage.phase_pos[BlackoilPhases::Aqua]] = 1.0; distr[phaseUsage.phase_pos[BlackoilPhases::Liquid]] = 1.0; ok = append_well_controls(SURFACE_RATE, - -productionProperties.LiquidRate , + -productionProperties.LiquidRate, + invalid_alq, + invalid_vfp, distr, well_index, w_); @@ -604,12 +631,28 @@ namespace Opm control_pos[WellsManagerDetail::ProductionControl::RESV] = well_controls_get_num(w_->ctrls[well_index]); double distr[3] = { 1.0, 1.0, 1.0 }; ok = append_well_controls(RESERVOIR_RATE, - -productionProperties.ResVRate , + -productionProperties.ResVRate, + invalid_alq, + invalid_vfp, distr, well_index, w_); } + if (ok && productionProperties.hasProductionControl(WellProducer::THP)) { + const double thp_limit = productionProperties.THPLimit; + const double alq_value = productionProperties.ALQValue; + const int vfp_number = productionProperties.VFPTableNumber; + control_pos[WellsManagerDetail::ProductionControl::THP] = well_controls_get_num(w_->ctrls[well_index]); + ok = append_well_controls(THP, + thp_limit, + alq_value, + vfp_number, + NULL, + well_index, + w_); + } + if (ok) { // Always append a BHP control. // If no explicit BHP control given, use a 1 atm control. @@ -618,15 +661,13 @@ namespace Opm control_pos[WellsManagerDetail::ProductionControl::BHP] = well_controls_get_num(w_->ctrls[well_index]); ok = append_well_controls(BHP, bhp_limit, + invalid_alq, + invalid_vfp, NULL, well_index, w_); } - if (ok && productionProperties.hasProductionControl(WellProducer::THP)) { - OPM_THROW(std::runtime_error, "We cannot handle THP limit for well " << well_names[well_index]); - } - if (!ok) { OPM_THROW(std::runtime_error, "Failure occured appending controls for well " << well_names[well_index]); } diff --git a/opm/core/wells/well_controls.c b/opm/core/wells/well_controls.c index 7a9acfce..80cd883a 100644 --- a/opm/core/wells/well_controls.c +++ b/opm/core/wells/well_controls.c @@ -48,7 +48,8 @@ * one control can be active at a time, indicated by current. The * meaning of each control's target value depends on the control type: * - * - BHP -> target pressure in Pascal. + * - BHP -> target bottom hole pressure in Pascal. + * - THP -> target tubing head pressure in Pascal. * - RESERVOIR_RATE -> target reservoir volume rate in cubic(meter)/second * - SURFACE_RATE -> target surface volume rate in cubic(meter)/second * @@ -87,6 +88,16 @@ struct WellControls */ double *target; + /** + * Array of artificial lift quantities. + */ + double *alq; + + /** + * Array of VFP table numbers + */ + int *vfp; + /** * Array of rate control distributions, * number_of_phases numbers for each control @@ -137,6 +148,8 @@ well_controls_create(void) ctrl->number_of_phases = 0; ctrl->type = NULL; ctrl->target = NULL; + ctrl->alq = NULL; + ctrl->vfp = NULL; ctrl->distr = NULL; ctrl->current = -1; ctrl->cpty = 0; @@ -153,18 +166,22 @@ well_controls_reserve(int nctrl, struct WellControls *ctrl) /* ---------------------------------------------------------------------- */ { int c, p, ok; - void *type, *target, *distr; + void *type, *target, *alq, *vfp, *distr; type = realloc(ctrl->type , nctrl * 1 * sizeof *ctrl->type ); target = realloc(ctrl->target, nctrl * 1 * sizeof *ctrl->target); + alq = realloc(ctrl->alq , nctrl * 1 * sizeof *ctrl->alq ); + vfp = realloc(ctrl->vfp , nctrl * 1 * sizeof *ctrl->vfp ); distr = realloc(ctrl->distr , nctrl * ctrl->number_of_phases * sizeof *ctrl->distr ); ok = 0; if (type != NULL) { ctrl->type = type ; ok++; } if (target != NULL) { ctrl->target = target; ok++; } + if (alq != NULL) { ctrl->alq = alq; ok++; } + if (vfp != NULL) { ctrl->vfp = vfp; ok++; } if (distr != NULL) { ctrl->distr = distr ; ok++; } - if (ok == 3) { + if (ok == 5) { for (c = ctrl->cpty; c < nctrl; c++) { ctrl->type [c] = BHP; ctrl->target[c] = -1.0; @@ -177,7 +194,7 @@ well_controls_reserve(int nctrl, struct WellControls *ctrl) ctrl->cpty = nctrl; } - return ok == 3; + return ok == 5; } @@ -188,6 +205,8 @@ well_controls_clone(const struct WellControls *ctrl) { int ok, i, n; double target; + double alq; + int vfp; const double *distr; struct WellControls *new; enum WellControlType type; @@ -210,8 +229,10 @@ well_controls_clone(const struct WellControls *ctrl) type = well_controls_iget_type (ctrl, i); distr = well_controls_iget_distr (ctrl, i); target = well_controls_iget_target(ctrl, i); + alq = well_controls_iget_alq (ctrl, i); + vfp = well_controls_iget_vfp (ctrl, i); - ok = well_controls_add_new(type, target, distr, new); + ok = well_controls_add_new(type, target, alq, vfp, distr, new); } if (i < n) { @@ -305,6 +326,26 @@ well_controls_iset_target(struct WellControls * ctrl, int control_index , double ctrl->target[control_index] = target; } +double +well_controls_iget_alq(const struct WellControls * ctrl, int control_index) { + return ctrl->alq[control_index]; +} + +void +well_controls_iset_alq(struct WellControls * ctrl, int control_index , double alq) { + ctrl->alq[control_index] = alq; +} + +int +well_controls_iget_vfp(const struct WellControls * ctrl, int control_index) { + return ctrl->vfp[control_index]; +} + +void +well_controls_iset_vfp(struct WellControls * ctrl, int control_index , int vfp) { + ctrl->vfp[control_index] = vfp; +} + const double * well_controls_iget_distr(const struct WellControls * ctrl, int control_index) { @@ -345,7 +386,7 @@ well_controls_clear(struct WellControls * ctrl) { int -well_controls_add_new(enum WellControlType type , double target , const double * distr , struct WellControls * ctrl) { +well_controls_add_new(enum WellControlType type , double target , double alq , int vfp , const double * distr , struct WellControls * ctrl) { if (ctrl->num == ctrl->cpty) { int new_cpty = 2*ctrl->cpty; if (new_cpty == ctrl->num) @@ -357,6 +398,8 @@ well_controls_add_new(enum WellControlType type , double target , const double * well_controls_iset_type( ctrl , ctrl->num , type); well_controls_iset_target( ctrl , ctrl->num , target); + well_controls_iset_alq(ctrl , ctrl->num , alq); + well_controls_iset_vfp(ctrl , ctrl->num , vfp); if (distr != NULL) well_controls_iset_distr( ctrl , ctrl->num , distr); diff --git a/opm/core/wells/wells.c b/opm/core/wells/wells.c index 0fdb8aab..e79173a7 100644 --- a/opm/core/wells/wells.c +++ b/opm/core/wells/wells.c @@ -422,6 +422,8 @@ add_well(enum WellType type , int append_well_controls(enum WellControlType type, double target, + double alq, + int vfp, const double *distr, int well_index, struct Wells *W) @@ -436,7 +438,7 @@ append_well_controls(enum WellControlType type, assert (ctrl != NULL); well_controls_assert_number_of_phases( ctrl , W->number_of_phases); - return well_controls_add_new(type , target , distr , ctrl); + return well_controls_add_new(type , target , alq , vfp , distr , ctrl); } diff --git a/tests/test_wellcontrols.cpp b/tests/test_wellcontrols.cpp index 27f989b1..8827c7bc 100644 --- a/tests/test_wellcontrols.cpp +++ b/tests/test_wellcontrols.cpp @@ -52,15 +52,21 @@ BOOST_AUTO_TEST_CASE(Construction) double dist1[3] = {0 , 1 , 2}; double dist2[3] = {10, 11 , 12}; double target = 77; + double alq = 88; + int vfp = 42; well_controls_assert_number_of_phases( ctrls , num_phases ); - well_controls_add_new( type1 , target , dist1 , ctrls ); - well_controls_add_new( type2 , 2*target , dist2 , ctrls ); + well_controls_add_new( type1 , target , alq , vfp , dist1 , ctrls ); + well_controls_add_new( type2 , 2*target , 2*alq , 2*vfp , dist2 , ctrls ); BOOST_CHECK_EQUAL( target , well_controls_iget_target(ctrls , 0 )); + BOOST_CHECK_EQUAL( alq , well_controls_iget_alq(ctrls , 0 )); + BOOST_CHECK_EQUAL( vfp , well_controls_iget_vfp(ctrls , 0 )); BOOST_CHECK_EQUAL( type1 , well_controls_iget_type(ctrls , 0 )); BOOST_CHECK_EQUAL( 2*target , well_controls_iget_target(ctrls , 1 )); + BOOST_CHECK_EQUAL( 2*alq , well_controls_iget_alq(ctrls , 1 )); + BOOST_CHECK_EQUAL( 2*vfp , well_controls_iget_vfp(ctrls , 1 )); BOOST_CHECK_EQUAL( type2 , well_controls_iget_type(ctrls , 1 )); well_controls_set_current( ctrls , 1 ); BOOST_CHECK_EQUAL( type2 , well_controls_get_current_type( ctrls )); @@ -79,6 +85,16 @@ BOOST_AUTO_TEST_CASE(Construction) well_controls_iset_target( ctrls , 1 , 456); BOOST_CHECK_EQUAL( 456 , well_controls_iget_target( ctrls , 1 )); + well_controls_iset_alq( ctrls , 0 , 789); + BOOST_CHECK_EQUAL( 789 , well_controls_iget_alq( ctrls , 0 )); + well_controls_iset_alq( ctrls , 1 , 234); + BOOST_CHECK_EQUAL( 234 , well_controls_iget_alq( ctrls , 1 )); + + well_controls_iset_vfp( ctrls , 0 , 567); + BOOST_CHECK_EQUAL( 567 , well_controls_iget_vfp( ctrls , 0 )); + well_controls_iset_vfp( ctrls , 1 , 890); + BOOST_CHECK_EQUAL( 890 , well_controls_iget_vfp( ctrls , 1 )); + well_controls_iset_type( ctrls , 0 , SURFACE_RATE); BOOST_CHECK_EQUAL( SURFACE_RATE , well_controls_iget_type( ctrls , 0 )); well_controls_iset_type( ctrls , 1 , BHP); @@ -130,10 +146,12 @@ BOOST_AUTO_TEST_CASE(Clone) const double dist1[] = { 0, 1, 2}; const double dist2[] = {10, 11, 12}; const double target = 77; + const double alq = 88; + const int vfp = 42; well_controls_assert_number_of_phases(ctrls.get(), num_phases); - well_controls_add_new(type1, target, dist1, ctrls.get()); - well_controls_add_new(type2, 2*target, dist2, ctrls.get()); + well_controls_add_new(type1, target, alq, vfp, dist1, ctrls.get()); + well_controls_add_new(type2, 2*target, 2*alq, 2*vfp, dist2, ctrls.get()); std::shared_ptr c(well_controls_clone(ctrls.get()), diff --git a/tests/test_wells.cpp b/tests/test_wells.cpp index 8502c4b8..366fb391 100644 --- a/tests/test_wells.cpp +++ b/tests/test_wells.cpp @@ -35,6 +35,12 @@ #include #include +namespace +{ + static double invalid_alq = -1e100; + static double invalid_vfp = -2147483647; +} //Namespace + BOOST_AUTO_TEST_CASE(Construction) { const int nphases = 2; @@ -97,10 +103,14 @@ BOOST_AUTO_TEST_CASE(Controls) if (ok) { const double distr[] = { 1.0, 0.0 }; - const bool ok1 = append_well_controls(BHP, 1, &distr[0], + const bool ok1 = append_well_controls(BHP, 1, + invalid_alq, invalid_vfp, + &distr[0], 0, W.get()); const bool ok2 = append_well_controls(SURFACE_RATE, 1, - &distr[0], 0, W.get()); + invalid_alq, invalid_vfp, + &distr[0], + 0, W.get()); if (ok1 && ok2) { WellControls* ctrls = W->ctrls[0]; @@ -150,9 +160,12 @@ BOOST_AUTO_TEST_CASE(Copy) bool ok = ok0 && ok1; for (int w = 0; ok && (w < W1->number_of_wells); ++w) { const double distr[] = { 1.0, 0.0 }; - const bool okc1 = append_well_controls(BHP, 1, &distr[0], - w, W1.get()); + const bool okc1 = append_well_controls(BHP, 1, + invalid_alq, invalid_vfp, + &distr[0], w, + W1.get()); const bool okc2 = append_well_controls(SURFACE_RATE, 1, + invalid_alq, invalid_vfp, &distr[0], w, W1.get());