mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Initial integration of VFP
This commit is contained in:
parent
24f91aa248
commit
f320b04c4d
@ -45,6 +45,7 @@ namespace Opm
|
|||||||
const int nw = wells->number_of_wells;
|
const int nw = wells->number_of_wells;
|
||||||
const int np = wells->number_of_phases;
|
const int np = wells->number_of_phases;
|
||||||
bhp_.resize(nw);
|
bhp_.resize(nw);
|
||||||
|
thp_.resize(nw);
|
||||||
temperature_.resize(nw, 273.15 + 20); // standard temperature for now
|
temperature_.resize(nw, 273.15 + 20); // standard temperature for now
|
||||||
wellrates_.resize(nw * np, 0.0);
|
wellrates_.resize(nw * np, 0.0);
|
||||||
for (int w = 0; w < nw; ++w) {
|
for (int w = 0; w < nw; ++w) {
|
||||||
@ -59,11 +60,19 @@ namespace Opm
|
|||||||
// 2. Assign bhp equal to bhp control, if
|
// 2. Assign bhp equal to bhp control, if
|
||||||
// applicable, otherwise assign equal to
|
// applicable, otherwise assign equal to
|
||||||
// first perforation cell pressure.
|
// first perforation cell pressure.
|
||||||
if (well_controls_get_current_type(ctrl) == BHP) {
|
// thp set to thp control
|
||||||
bhp_[w] = well_controls_get_current_target( ctrl );
|
switch (well_controls_get_current_type(ctrl)) {
|
||||||
} else {
|
case BHP:
|
||||||
const int first_cell = wells->well_cells[wells->well_connpos[w]];
|
bhp_[w] = well_controls_get_current_target( ctrl );
|
||||||
bhp_[w] = state.pressure()[first_cell];
|
break;
|
||||||
|
case THP:
|
||||||
|
thp_[w] = well_controls_get_current_target( ctrl );
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
const int first_cell = wells->well_cells[wells->well_connpos[w]];
|
||||||
|
bhp_[w] = state.pressure()[first_cell];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Open well:
|
// Open well:
|
||||||
@ -112,6 +121,10 @@ namespace Opm
|
|||||||
std::vector<double>& bhp() { return bhp_; }
|
std::vector<double>& bhp() { return bhp_; }
|
||||||
const std::vector<double>& bhp() const { return bhp_; }
|
const std::vector<double>& bhp() const { return bhp_; }
|
||||||
|
|
||||||
|
/// One thp pressure per well.
|
||||||
|
std::vector<double>& thp() { return thp_; }
|
||||||
|
const std::vector<double>& thp() const { return thp_; }
|
||||||
|
|
||||||
/// One temperature per well.
|
/// One temperature per well.
|
||||||
std::vector<double>& temperature() { return temperature_; }
|
std::vector<double>& temperature() { return temperature_; }
|
||||||
const std::vector<double>& temperature() const { return temperature_; }
|
const std::vector<double>& temperature() const { return temperature_; }
|
||||||
@ -150,6 +163,7 @@ namespace Opm
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<double> bhp_;
|
std::vector<double> bhp_;
|
||||||
|
std::vector<double> thp_;
|
||||||
std::vector<double> temperature_;
|
std::vector<double> temperature_;
|
||||||
std::vector<double> wellrates_;
|
std::vector<double> wellrates_;
|
||||||
std::vector<double> perfrates_;
|
std::vector<double> perfrates_;
|
||||||
|
@ -33,6 +33,7 @@ extern "C" {
|
|||||||
|
|
||||||
enum WellControlType {
|
enum WellControlType {
|
||||||
BHP, /**< Well constrained by BHP target */
|
BHP, /**< Well constrained by BHP target */
|
||||||
|
THP, /**< Well constrained by THP target */
|
||||||
RESERVOIR_RATE, /**< Well constrained by reservoir volume flow rate */
|
RESERVOIR_RATE, /**< Well constrained by reservoir volume flow rate */
|
||||||
SURFACE_RATE /**< Well constrained by surface volume flow rate */
|
SURFACE_RATE /**< Well constrained by surface volume flow rate */
|
||||||
};
|
};
|
||||||
@ -82,7 +83,7 @@ void
|
|||||||
well_controls_stop_well( struct WellControls * ctrl);
|
well_controls_stop_well( struct WellControls * ctrl);
|
||||||
|
|
||||||
int
|
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
|
enum WellControlType
|
||||||
well_controls_iget_type(const struct WellControls * ctrl, int control_index);
|
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
|
double
|
||||||
well_controls_iget_target(const struct WellControls * ctrl, int control_index);
|
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
|
double
|
||||||
well_controls_get_current_target(const struct WellControls * ctrl);
|
well_controls_get_current_target(const struct WellControls * ctrl);
|
||||||
|
|
||||||
|
@ -212,6 +212,8 @@ add_well(enum WellType type ,
|
|||||||
*
|
*
|
||||||
* \param[in] type Control type.
|
* \param[in] type Control type.
|
||||||
* \param[in] target Target value for the control.
|
* \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] distr Array of size W->number_of_phases or NULL.
|
||||||
* \param[in] well_index Index of well to receive additional control.
|
* \param[in] well_index Index of well to receive additional control.
|
||||||
* \param[in,out] W Existing set of well controls.
|
* \param[in,out] W Existing set of well controls.
|
||||||
@ -222,6 +224,8 @@ add_well(enum WellType type ,
|
|||||||
int
|
int
|
||||||
append_well_controls(enum WellControlType type ,
|
append_well_controls(enum WellControlType type ,
|
||||||
double target,
|
double target,
|
||||||
|
double alq,
|
||||||
|
int vfp,
|
||||||
const double *distr,
|
const double *distr,
|
||||||
int well_index,
|
int well_index,
|
||||||
struct Wells *W);
|
struct Wells *W);
|
||||||
|
@ -751,11 +751,12 @@ namespace Opm
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const double target = 0.0;
|
const double target = 0.0;
|
||||||
|
const double alq = 0.0;
|
||||||
const double distr[3] = {1.0, 1.0, 1.0};
|
const double distr[3] = {1.0, 1.0, 1.0};
|
||||||
|
|
||||||
if (group_control_index_ < 0) {
|
if (group_control_index_ < 0) {
|
||||||
// The well only had its own controls, no group controls.
|
// 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, -1e100, -1e100, distr, self_index_, wells_);
|
||||||
group_control_index_ = well_controls_get_num(wells_->ctrls[self_index_]) - 1;
|
group_control_index_ = well_controls_get_num(wells_->ctrls[self_index_]) - 1;
|
||||||
} else {
|
} else {
|
||||||
// We will now modify the last control, that
|
// We will now modify the last control, that
|
||||||
@ -763,6 +764,7 @@ namespace Opm
|
|||||||
|
|
||||||
well_controls_iset_type( wells_->ctrls[self_index_] , group_control_index_ , SURFACE_RATE);
|
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_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_iset_distr(wells_->ctrls[self_index_] , group_control_index_ , distr);
|
||||||
}
|
}
|
||||||
well_controls_open_well( wells_->ctrls[self_index_]);
|
well_controls_open_well( wells_->ctrls[self_index_]);
|
||||||
@ -810,13 +812,14 @@ namespace Opm
|
|||||||
|
|
||||||
if (group_control_index_ < 0) {
|
if (group_control_index_ < 0) {
|
||||||
// The well only had its own controls, no group controls.
|
// The well only had its own controls, no group controls.
|
||||||
append_well_controls(wct, target, distr, self_index_, wells_);
|
append_well_controls(wct, target, -1e100, -1e100, distr, self_index_, wells_);
|
||||||
group_control_index_ = well_controls_get_num(wells_->ctrls[self_index_]) - 1;
|
group_control_index_ = well_controls_get_num(wells_->ctrls[self_index_]) - 1;
|
||||||
} else {
|
} else {
|
||||||
// We will now modify the last control, that
|
// We will now modify the last control, that
|
||||||
// "belongs to" the group control.
|
// "belongs to" the group control.
|
||||||
well_controls_iset_type(wells_->ctrls[self_index_] , group_control_index_ , wct);
|
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_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);
|
well_controls_iset_distr(wells_->ctrls[self_index_] , group_control_index_ , distr);
|
||||||
}
|
}
|
||||||
set_current_control(self_index_, group_control_index_, wells_);
|
set_current_control(self_index_, group_control_index_, wells_);
|
||||||
@ -921,13 +924,14 @@ namespace Opm
|
|||||||
|
|
||||||
if (group_control_index_ < 0) {
|
if (group_control_index_ < 0) {
|
||||||
// The well only had its own controls, no group controls.
|
// The well only had its own controls, no group controls.
|
||||||
append_well_controls(wct, ntarget, distr, self_index_, wells_);
|
append_well_controls(wct, ntarget, -1e100, -1e100, distr, self_index_, wells_);
|
||||||
group_control_index_ = well_controls_get_num(wells_->ctrls[self_index_]) - 1;
|
group_control_index_ = well_controls_get_num(wells_->ctrls[self_index_]) - 1;
|
||||||
} else {
|
} else {
|
||||||
// We will now modify the last control, that
|
// We will now modify the last control, that
|
||||||
// "belongs to" the group control.
|
// "belongs to" the group control.
|
||||||
well_controls_iset_type(wells_->ctrls[self_index_] , group_control_index_ , wct);
|
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_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);
|
well_controls_iset_distr(wells_->ctrls[self_index_] , group_control_index_ , distr);
|
||||||
}
|
}
|
||||||
set_current_control(self_index_, group_control_index_, wells_);
|
set_current_control(self_index_, group_control_index_, wells_);
|
||||||
|
@ -452,6 +452,8 @@ namespace Opm
|
|||||||
|
|
||||||
ok = append_well_controls(SURFACE_RATE,
|
ok = append_well_controls(SURFACE_RATE,
|
||||||
injectionProperties.surfaceInjectionRate,
|
injectionProperties.surfaceInjectionRate,
|
||||||
|
-1e100,
|
||||||
|
-1e100,
|
||||||
distr,
|
distr,
|
||||||
well_index,
|
well_index,
|
||||||
w_);
|
w_);
|
||||||
@ -472,6 +474,8 @@ namespace Opm
|
|||||||
|
|
||||||
ok = append_well_controls(RESERVOIR_RATE,
|
ok = append_well_controls(RESERVOIR_RATE,
|
||||||
injectionProperties.reservoirInjectionRate,
|
injectionProperties.reservoirInjectionRate,
|
||||||
|
-1e100,
|
||||||
|
-1e100,
|
||||||
distr,
|
distr,
|
||||||
well_index,
|
well_index,
|
||||||
w_);
|
w_);
|
||||||
@ -481,14 +485,16 @@ namespace Opm
|
|||||||
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]);
|
||||||
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,
|
ok = append_well_controls(BHP,
|
||||||
injectionProperties.BHPLimit,
|
injectionProperties.BHPLimit,
|
||||||
|
-1e100,
|
||||||
|
-1e100,
|
||||||
NULL,
|
NULL,
|
||||||
well_index,
|
well_index,
|
||||||
w_);
|
w_);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ok && injectionProperties.hasInjectionControl(WellInjector::THP)) {
|
if (ok && injectionProperties.hasInjectionControl(WellInjector::THP)) {
|
||||||
OPM_THROW(std::runtime_error, "We cannot handle THP limit for well " << well_names[well_index]);
|
OPM_THROW(std::runtime_error, "We cannot handle THP limit for injecting well " << well_names[well_index]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
@ -548,7 +554,9 @@ namespace Opm
|
|||||||
double distr[3] = { 0.0, 0.0, 0.0 };
|
double distr[3] = { 0.0, 0.0, 0.0 };
|
||||||
distr[phaseUsage.phase_pos[BlackoilPhases::Liquid]] = 1.0;
|
distr[phaseUsage.phase_pos[BlackoilPhases::Liquid]] = 1.0;
|
||||||
ok = append_well_controls(SURFACE_RATE,
|
ok = append_well_controls(SURFACE_RATE,
|
||||||
-productionProperties.OilRate,
|
-productionProperties.OilRate,
|
||||||
|
-1e100,
|
||||||
|
-1e100,
|
||||||
distr,
|
distr,
|
||||||
well_index,
|
well_index,
|
||||||
w_);
|
w_);
|
||||||
@ -563,6 +571,8 @@ namespace Opm
|
|||||||
distr[phaseUsage.phase_pos[BlackoilPhases::Aqua]] = 1.0;
|
distr[phaseUsage.phase_pos[BlackoilPhases::Aqua]] = 1.0;
|
||||||
ok = append_well_controls(SURFACE_RATE,
|
ok = append_well_controls(SURFACE_RATE,
|
||||||
-productionProperties.WaterRate,
|
-productionProperties.WaterRate,
|
||||||
|
-1e100,
|
||||||
|
-1e100,
|
||||||
distr,
|
distr,
|
||||||
well_index,
|
well_index,
|
||||||
w_);
|
w_);
|
||||||
@ -577,6 +587,8 @@ namespace Opm
|
|||||||
distr[phaseUsage.phase_pos[BlackoilPhases::Vapour]] = 1.0;
|
distr[phaseUsage.phase_pos[BlackoilPhases::Vapour]] = 1.0;
|
||||||
ok = append_well_controls(SURFACE_RATE,
|
ok = append_well_controls(SURFACE_RATE,
|
||||||
-productionProperties.GasRate,
|
-productionProperties.GasRate,
|
||||||
|
-1e100,
|
||||||
|
-1e100,
|
||||||
distr,
|
distr,
|
||||||
well_index,
|
well_index,
|
||||||
w_);
|
w_);
|
||||||
@ -595,6 +607,8 @@ namespace Opm
|
|||||||
distr[phaseUsage.phase_pos[BlackoilPhases::Liquid]] = 1.0;
|
distr[phaseUsage.phase_pos[BlackoilPhases::Liquid]] = 1.0;
|
||||||
ok = append_well_controls(SURFACE_RATE,
|
ok = append_well_controls(SURFACE_RATE,
|
||||||
-productionProperties.LiquidRate ,
|
-productionProperties.LiquidRate ,
|
||||||
|
-1e100,
|
||||||
|
-1e100,
|
||||||
distr,
|
distr,
|
||||||
well_index,
|
well_index,
|
||||||
w_);
|
w_);
|
||||||
@ -605,11 +619,31 @@ namespace Opm
|
|||||||
double distr[3] = { 1.0, 1.0, 1.0 };
|
double distr[3] = { 1.0, 1.0, 1.0 };
|
||||||
ok = append_well_controls(RESERVOIR_RATE,
|
ok = append_well_controls(RESERVOIR_RATE,
|
||||||
-productionProperties.ResVRate ,
|
-productionProperties.ResVRate ,
|
||||||
|
-1e100,
|
||||||
|
-1e100,
|
||||||
distr,
|
distr,
|
||||||
well_index,
|
well_index,
|
||||||
w_);
|
w_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ok && productionProperties.hasProductionControl(WellProducer::THP)) {
|
||||||
|
const bool has_explicit_limit = productionProperties.hasProductionControl(WellProducer::THP);
|
||||||
|
if (!has_explicit_limit) {
|
||||||
|
OPM_THROW(std::runtime_error, "THP specified, but no target THP supplied for well " << well_names[well_index]);
|
||||||
|
}
|
||||||
|
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) {
|
if (ok) {
|
||||||
// Always append a BHP control.
|
// Always append a BHP control.
|
||||||
// If no explicit BHP control given, use a 1 atm control.
|
// If no explicit BHP control given, use a 1 atm control.
|
||||||
@ -618,15 +652,13 @@ namespace Opm
|
|||||||
control_pos[WellsManagerDetail::ProductionControl::BHP] = well_controls_get_num(w_->ctrls[well_index]);
|
control_pos[WellsManagerDetail::ProductionControl::BHP] = well_controls_get_num(w_->ctrls[well_index]);
|
||||||
ok = append_well_controls(BHP,
|
ok = append_well_controls(BHP,
|
||||||
bhp_limit,
|
bhp_limit,
|
||||||
|
-1e100,
|
||||||
|
-1e100,
|
||||||
NULL,
|
NULL,
|
||||||
well_index,
|
well_index,
|
||||||
w_);
|
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) {
|
if (!ok) {
|
||||||
OPM_THROW(std::runtime_error, "Failure occured appending controls for well " << well_names[well_index]);
|
OPM_THROW(std::runtime_error, "Failure occured appending controls for well " << well_names[well_index]);
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,8 @@
|
|||||||
* one control can be active at a time, indicated by current. The
|
* one control can be active at a time, indicated by current. The
|
||||||
* meaning of each control's target value depends on the control type:
|
* 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
|
* - RESERVOIR_RATE -> target reservoir volume rate in cubic(meter)/second
|
||||||
* - SURFACE_RATE -> target surface volume rate in cubic(meter)/second
|
* - SURFACE_RATE -> target surface volume rate in cubic(meter)/second
|
||||||
*
|
*
|
||||||
@ -87,6 +88,16 @@ struct WellControls
|
|||||||
*/
|
*/
|
||||||
double *target;
|
double *target;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Array of artificial lift quantities.
|
||||||
|
*/
|
||||||
|
double *alq;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Array of VFP table numbers
|
||||||
|
*/
|
||||||
|
int *vfp;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Array of rate control distributions,
|
* Array of rate control distributions,
|
||||||
* <CODE>number_of_phases</CODE> numbers for each control
|
* <CODE>number_of_phases</CODE> numbers for each control
|
||||||
@ -137,6 +148,8 @@ well_controls_create(void)
|
|||||||
ctrl->number_of_phases = 0;
|
ctrl->number_of_phases = 0;
|
||||||
ctrl->type = NULL;
|
ctrl->type = NULL;
|
||||||
ctrl->target = NULL;
|
ctrl->target = NULL;
|
||||||
|
ctrl->alq = NULL;
|
||||||
|
ctrl->vfp = NULL;
|
||||||
ctrl->distr = NULL;
|
ctrl->distr = NULL;
|
||||||
ctrl->current = -1;
|
ctrl->current = -1;
|
||||||
ctrl->cpty = 0;
|
ctrl->cpty = 0;
|
||||||
@ -153,18 +166,22 @@ well_controls_reserve(int nctrl, struct WellControls *ctrl)
|
|||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
{
|
{
|
||||||
int c, p, ok;
|
int c, p, ok;
|
||||||
void *type, *target, *distr;
|
void *type, *target, *alq, *vfp, *distr;
|
||||||
|
|
||||||
type = realloc(ctrl->type , nctrl * 1 * sizeof *ctrl->type );
|
type = realloc(ctrl->type , nctrl * 1 * sizeof *ctrl->type );
|
||||||
target = realloc(ctrl->target, nctrl * 1 * sizeof *ctrl->target);
|
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 );
|
distr = realloc(ctrl->distr , nctrl * ctrl->number_of_phases * sizeof *ctrl->distr );
|
||||||
|
|
||||||
ok = 0;
|
ok = 0;
|
||||||
if (type != NULL) { ctrl->type = type ; ok++; }
|
if (type != NULL) { ctrl->type = type ; ok++; }
|
||||||
if (target != NULL) { ctrl->target = target; 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 (distr != NULL) { ctrl->distr = distr ; ok++; }
|
||||||
|
|
||||||
if (ok == 3) {
|
if (ok == 5) {
|
||||||
for (c = ctrl->cpty; c < nctrl; c++) {
|
for (c = ctrl->cpty; c < nctrl; c++) {
|
||||||
ctrl->type [c] = BHP;
|
ctrl->type [c] = BHP;
|
||||||
ctrl->target[c] = -1.0;
|
ctrl->target[c] = -1.0;
|
||||||
@ -177,7 +194,7 @@ well_controls_reserve(int nctrl, struct WellControls *ctrl)
|
|||||||
ctrl->cpty = nctrl;
|
ctrl->cpty = nctrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ok == 3;
|
return ok == 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -188,6 +205,8 @@ well_controls_clone(const struct WellControls *ctrl)
|
|||||||
{
|
{
|
||||||
int ok, i, n;
|
int ok, i, n;
|
||||||
double target;
|
double target;
|
||||||
|
double alq;
|
||||||
|
int vfp;
|
||||||
const double *distr;
|
const double *distr;
|
||||||
struct WellControls *new;
|
struct WellControls *new;
|
||||||
enum WellControlType type;
|
enum WellControlType type;
|
||||||
@ -210,8 +229,10 @@ well_controls_clone(const struct WellControls *ctrl)
|
|||||||
type = well_controls_iget_type (ctrl, i);
|
type = well_controls_iget_type (ctrl, i);
|
||||||
distr = well_controls_iget_distr (ctrl, i);
|
distr = well_controls_iget_distr (ctrl, i);
|
||||||
target = well_controls_iget_target(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) {
|
if (i < n) {
|
||||||
@ -305,6 +326,26 @@ well_controls_iset_target(struct WellControls * ctrl, int control_index , double
|
|||||||
ctrl->target[control_index] = target;
|
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 *
|
const double *
|
||||||
well_controls_iget_distr(const struct WellControls * ctrl, int control_index) {
|
well_controls_iget_distr(const struct WellControls * ctrl, int control_index) {
|
||||||
@ -345,7 +386,7 @@ well_controls_clear(struct WellControls * ctrl) {
|
|||||||
|
|
||||||
|
|
||||||
int
|
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) {
|
if (ctrl->num == ctrl->cpty) {
|
||||||
int new_cpty = 2*ctrl->cpty;
|
int new_cpty = 2*ctrl->cpty;
|
||||||
if (new_cpty == ctrl->num)
|
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_type( ctrl , ctrl->num , type);
|
||||||
well_controls_iset_target( ctrl , ctrl->num , target);
|
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)
|
if (distr != NULL)
|
||||||
well_controls_iset_distr( ctrl , ctrl->num , distr);
|
well_controls_iset_distr( ctrl , ctrl->num , distr);
|
||||||
|
@ -422,6 +422,8 @@ add_well(enum WellType type ,
|
|||||||
int
|
int
|
||||||
append_well_controls(enum WellControlType type,
|
append_well_controls(enum WellControlType type,
|
||||||
double target,
|
double target,
|
||||||
|
double alq,
|
||||||
|
int vfp,
|
||||||
const double *distr,
|
const double *distr,
|
||||||
int well_index,
|
int well_index,
|
||||||
struct Wells *W)
|
struct Wells *W)
|
||||||
@ -436,7 +438,7 @@ append_well_controls(enum WellControlType type,
|
|||||||
assert (ctrl != NULL);
|
assert (ctrl != NULL);
|
||||||
|
|
||||||
well_controls_assert_number_of_phases( ctrl , W->number_of_phases);
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -52,15 +52,21 @@ BOOST_AUTO_TEST_CASE(Construction)
|
|||||||
double dist1[3] = {0 , 1 , 2};
|
double dist1[3] = {0 , 1 , 2};
|
||||||
double dist2[3] = {10, 11 , 12};
|
double dist2[3] = {10, 11 , 12};
|
||||||
double target = 77;
|
double target = 77;
|
||||||
|
double alq = 88;
|
||||||
|
int vfp = 42;
|
||||||
|
|
||||||
well_controls_assert_number_of_phases( ctrls , num_phases );
|
well_controls_assert_number_of_phases( ctrls , num_phases );
|
||||||
well_controls_add_new( type1 , target , dist1 , ctrls );
|
well_controls_add_new( type1 , target , alq , vfp , dist1 , ctrls );
|
||||||
well_controls_add_new( type2 , 2*target , dist2 , 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( 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( type1 , well_controls_iget_type(ctrls , 0 ));
|
||||||
|
|
||||||
BOOST_CHECK_EQUAL( 2*target , well_controls_iget_target(ctrls , 1 ));
|
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 ));
|
BOOST_CHECK_EQUAL( type2 , well_controls_iget_type(ctrls , 1 ));
|
||||||
well_controls_set_current( ctrls , 1 );
|
well_controls_set_current( ctrls , 1 );
|
||||||
BOOST_CHECK_EQUAL( type2 , well_controls_get_current_type( ctrls ));
|
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);
|
well_controls_iset_target( ctrls , 1 , 456);
|
||||||
BOOST_CHECK_EQUAL( 456 , well_controls_iget_target( ctrls , 1 ));
|
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_alq( ctrls , 0 , 567);
|
||||||
|
BOOST_CHECK_EQUAL( 567 , well_controls_iget_vfp( ctrls , 0 ));
|
||||||
|
well_controls_iset_alq( ctrls , 1 , 890);
|
||||||
|
BOOST_CHECK_EQUAL( 890 , well_controls_iget_vfp( ctrls , 1 ));
|
||||||
|
|
||||||
well_controls_iset_type( ctrls , 0 , SURFACE_RATE);
|
well_controls_iset_type( ctrls , 0 , SURFACE_RATE);
|
||||||
BOOST_CHECK_EQUAL( SURFACE_RATE , well_controls_iget_type( ctrls , 0 ));
|
BOOST_CHECK_EQUAL( SURFACE_RATE , well_controls_iget_type( ctrls , 0 ));
|
||||||
well_controls_iset_type( ctrls , 1 , BHP);
|
well_controls_iset_type( ctrls , 1 , BHP);
|
||||||
@ -130,10 +146,12 @@ BOOST_AUTO_TEST_CASE(Clone)
|
|||||||
const double dist1[] = { 0, 1, 2};
|
const double dist1[] = { 0, 1, 2};
|
||||||
const double dist2[] = {10, 11, 12};
|
const double dist2[] = {10, 11, 12};
|
||||||
const double target = 77;
|
const double target = 77;
|
||||||
|
const double alq = 88;
|
||||||
|
const int vfp = 42;
|
||||||
|
|
||||||
well_controls_assert_number_of_phases(ctrls.get(), num_phases);
|
well_controls_assert_number_of_phases(ctrls.get(), num_phases);
|
||||||
well_controls_add_new(type1, target, dist1, ctrls.get());
|
well_controls_add_new(type1, target, alq, vfp, dist1, ctrls.get());
|
||||||
well_controls_add_new(type2, 2*target, dist2, ctrls.get());
|
well_controls_add_new(type2, 2*target, 2*alq, 2*vfp, dist2, ctrls.get());
|
||||||
|
|
||||||
std::shared_ptr<WellControls>
|
std::shared_ptr<WellControls>
|
||||||
c(well_controls_clone(ctrls.get()),
|
c(well_controls_clone(ctrls.get()),
|
||||||
|
@ -97,10 +97,14 @@ BOOST_AUTO_TEST_CASE(Controls)
|
|||||||
|
|
||||||
if (ok) {
|
if (ok) {
|
||||||
const double distr[] = { 1.0, 0.0 };
|
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,
|
||||||
|
-1e100, -1e100,
|
||||||
|
&distr[0],
|
||||||
0, W.get());
|
0, W.get());
|
||||||
const bool ok2 = append_well_controls(SURFACE_RATE, 1,
|
const bool ok2 = append_well_controls(SURFACE_RATE, 1,
|
||||||
&distr[0], 0, W.get());
|
-1e100, -1e100,
|
||||||
|
&distr[0],
|
||||||
|
0, W.get());
|
||||||
|
|
||||||
if (ok1 && ok2) {
|
if (ok1 && ok2) {
|
||||||
WellControls* ctrls = W->ctrls[0];
|
WellControls* ctrls = W->ctrls[0];
|
||||||
@ -150,9 +154,12 @@ BOOST_AUTO_TEST_CASE(Copy)
|
|||||||
bool ok = ok0 && ok1;
|
bool ok = ok0 && ok1;
|
||||||
for (int w = 0; ok && (w < W1->number_of_wells); ++w) {
|
for (int w = 0; ok && (w < W1->number_of_wells); ++w) {
|
||||||
const double distr[] = { 1.0, 0.0 };
|
const double distr[] = { 1.0, 0.0 };
|
||||||
const bool okc1 = append_well_controls(BHP, 1, &distr[0],
|
const bool okc1 = append_well_controls(BHP, 1,
|
||||||
w, W1.get());
|
-1e100, -1e100,
|
||||||
|
&distr[0], w,
|
||||||
|
W1.get());
|
||||||
const bool okc2 = append_well_controls(SURFACE_RATE, 1,
|
const bool okc2 = append_well_controls(SURFACE_RATE, 1,
|
||||||
|
-1e100, -1e100,
|
||||||
&distr[0], w,
|
&distr[0], w,
|
||||||
W1.get());
|
W1.get());
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user