diff --git a/opm/core/WellsManager.cpp b/opm/core/WellsManager.cpp index 9ce6ff105..6d3b782e3 100644 --- a/opm/core/WellsManager.cpp +++ b/opm/core/WellsManager.cpp @@ -492,7 +492,7 @@ namespace Opm control_pos[ProductionControl::ORAT] = w_->ctrls[wix]->num; double distr[3] = { 0.0, 0.0, 0.0 }; distr[pu.phase_pos[BlackoilPhases::Liquid]] = 1.0; - ok = append_well_controls(SURFACE_RATE, wcp_line.oil_max_rate_, + ok = append_well_controls(SURFACE_RATE, -wcp_line.oil_max_rate_, distr, wix, w_); } if (ok && wcp_line.water_max_rate_ > 0.0) { @@ -502,7 +502,7 @@ namespace Opm control_pos[ProductionControl::WRAT] = w_->ctrls[wix]->num; double distr[3] = { 0.0, 0.0, 0.0 }; distr[pu.phase_pos[BlackoilPhases::Aqua]] = 1.0; - ok = append_well_controls(SURFACE_RATE, wcp_line.water_max_rate_, + ok = append_well_controls(SURFACE_RATE, -wcp_line.water_max_rate_, distr, wix, w_); } if (ok && wcp_line.gas_max_rate_ > 0.0) { @@ -512,7 +512,7 @@ namespace Opm control_pos[ProductionControl::GRAT] = w_->ctrls[wix]->num; double distr[3] = { 0.0, 0.0, 0.0 }; distr[pu.phase_pos[BlackoilPhases::Vapour]] = 1.0; - ok = append_well_controls(SURFACE_RATE, wcp_line.gas_max_rate_, + ok = append_well_controls(SURFACE_RATE, -wcp_line.gas_max_rate_, distr, wix, w_); } if (ok && wcp_line.liquid_max_rate_ > 0.0) { @@ -526,13 +526,13 @@ namespace Opm double distr[3] = { 0.0, 0.0, 0.0 }; distr[pu.phase_pos[BlackoilPhases::Aqua]] = 1.0; distr[pu.phase_pos[BlackoilPhases::Liquid]] = 1.0; - ok = append_well_controls(SURFACE_RATE, wcp_line.liquid_max_rate_, + ok = append_well_controls(SURFACE_RATE, -wcp_line.liquid_max_rate_, distr, wix, w_); } if (ok && wcp_line.reservoir_flow_max_rate_ > 0.0) { control_pos[ProductionControl::RESV] = w_->ctrls[wix]->num; double distr[3] = { 1.0, 1.0, 1.0 }; - ok = append_well_controls(RESERVOIR_RATE, wcp_line.reservoir_flow_max_rate_, + ok = append_well_controls(RESERVOIR_RATE, -wcp_line.reservoir_flow_max_rate_, distr, wix, w_); } if (ok && wcp_line.BHP_limit_ > 0.0) { diff --git a/opm/core/pressure/tpfa/ifs_tpfa.c b/opm/core/pressure/tpfa/ifs_tpfa.c index 796ffc6ed..d6d222367 100644 --- a/opm/core/pressure/tpfa/ifs_tpfa.c +++ b/opm/core/pressure/tpfa/ifs_tpfa.c @@ -287,7 +287,6 @@ assemble_well_contrib(int nc , /* ---------------------------------------------------------------------- */ { int w, p, np; - int are_rate; struct WellControls *ctrls; diff --git a/opm/core/utility/initState_impl.hpp b/opm/core/utility/initState_impl.hpp index 4bbd0250b..34f944f8d 100644 --- a/opm/core/utility/initState_impl.hpp +++ b/opm/core/utility/initState_impl.hpp @@ -214,16 +214,16 @@ namespace Opm // Initialise pressure to hydrostatic state. const double ref_p = param.getDefault("ref_pressure", 100)*unit::barsa; initHydrostaticPressure(grid, props.density(), woc, gravity, woc, ref_p, state); - } else if (param.has("init_sat")) { - // Initialise water saturation to init_sat parameter. - const double init_sat = param.get("init_sat"); + } else if (param.has("init_saturation")) { + // Initialise water saturation to init_saturation parameter. + const double init_saturation = param.get("init_saturation"); for (int cell = 0; cell < num_cells; ++cell) { - state.saturation()[2*cell] = init_sat; - state.saturation()[2*cell + 1] = 1.0 - init_sat; + state.saturation()[2*cell] = init_saturation; + state.saturation()[2*cell + 1] = 1.0 - init_saturation; } // Initialise pressure to hydrostatic state. const double ref_p = param.getDefault("ref_pressure", 100)*unit::barsa; - const double rho = props.density()[0]*init_sat + props.density()[1]*(1.0 - init_sat); + const double rho = props.density()[0]*init_saturation + props.density()[1]*(1.0 - init_saturation); const double dens[2] = { rho, rho }; const double ref_z = grid.cell_centroids[0 + grid.dimensions - 1]; initHydrostaticPressure(grid, dens, ref_z, gravity, ref_z, ref_p, state); diff --git a/opm/core/utility/miscUtilities.cpp b/opm/core/utility/miscUtilities.cpp index 2782cf8ea..6021e18cb 100644 --- a/opm/core/utility/miscUtilities.cpp +++ b/opm/core/utility/miscUtilities.cpp @@ -410,16 +410,25 @@ namespace Opm } src.resize(num_cells); for (int w = 0; w < wells.number_of_wells; ++w) { + const int cur = wells.ctrls[w]->current; if (wells.ctrls[w]->num != 1) { - THROW("In wellsToSrc(): well has more than one control."); + MESSAGE("In wellsToSrc(): well has more than one control, all but current control will be ignored."); } - if (wells.ctrls[w]->type[0] != RESERVOIR_RATE) { + if (wells.ctrls[w]->type[cur] != RESERVOIR_RATE) { THROW("In wellsToSrc(): well is something other than RESERVOIR_RATE."); } if (wells.well_connpos[w+1] - wells.well_connpos[w] != 1) { THROW("In wellsToSrc(): well has multiple perforations."); } - const double flow = wells.ctrls[w]->target[0] * wells.ctrls[w]->distr[0]; + for (int p = 0; p < np; ++p) { + if (wells.ctrls[w]->distr[np*cur + p] != 1.0) { + THROW("In wellsToSrc(): well not controlled on total rate."); + } + } + double flow = wells.ctrls[w]->target[cur]; + if (wells.type[w] == INJECTOR) { + flow *= wells.comp_frac[np*w + 0]; // Obtaining water rate for inflow source. + } const double cell = wells.well_cells[wells.well_connpos[w]]; src[cell] = flow; }