add StandardWellPrimaryVariables::updateNewtonPolyMW

extracted from StandardWell::updatePrimaryVariablesNewton
This commit is contained in:
Arne Morten Kvarving 2022-11-09 11:49:30 +01:00
parent 23a8aed4e8
commit 999d4c6be9
3 changed files with 32 additions and 22 deletions

View File

@ -222,19 +222,16 @@ update(const WellState& well_state, DeferredLogger& deferred_logger)
template<class FluidSystem, class Indices, class Scalar> template<class FluidSystem, class Indices, class Scalar>
void StandardWellPrimaryVariables<FluidSystem,Indices,Scalar>:: void StandardWellPrimaryVariables<FluidSystem,Indices,Scalar>::
updatePolyMW(const BVectorWell& dwells) updatePolyMW(const WellState& well_state)
{ {
if (well_.isInjector()) { if (well_.isInjector()) {
const auto& ws = well_state.well(well_.indexOfWell());
const auto& perf_data = ws.perf_data;
const auto& water_velocity = perf_data.water_velocity;
const auto& skin_pressure = perf_data.skin_pressure;
for (int perf = 0; perf < well_.numPerfs(); ++perf) { for (int perf = 0; perf < well_.numPerfs(); ++perf) {
const int wat_vel_index = Bhp + 1 + perf; value_[Bhp + 1 + perf] = water_velocity[perf];
const int pskin_index = Bhp + 1 + well_.numPerfs() + perf; value_[Bhp + 1 + well_.numPerfs() + perf] = skin_pressure[perf];
const double relaxation_factor = 0.9;
const double dx_wat_vel = dwells[0][wat_vel_index];
value_[wat_vel_index] -= relaxation_factor * dx_wat_vel;
const double dx_pskin = dwells[0][pskin_index];
value_[pskin_index] -= relaxation_factor * dx_pskin;
} }
} }
} }
@ -286,6 +283,25 @@ updateNewton(const BVectorWell& dwells,
value_[Bhp] = std::max(value_[Bhp] - dx1_limited, 1e5); value_[Bhp] = std::max(value_[Bhp] - dx1_limited, 1e5);
} }
template<class FluidSystem, class Indices, class Scalar>
void StandardWellPrimaryVariables<FluidSystem,Indices,Scalar>::
updateNewtonPolyMW(const BVectorWell& dwells)
{
if (well_.isInjector()) {
for (int perf = 0; perf < well_.numPerfs(); ++perf) {
const int wat_vel_index = Bhp + 1 + perf;
const int pskin_index = Bhp + 1 + well_.numPerfs() + perf;
const double relaxation_factor = 0.9;
const double dx_wat_vel = dwells[0][wat_vel_index];
value_[wat_vel_index] -= relaxation_factor * dx_wat_vel;
const double dx_pskin = dwells[0][pskin_index];
value_[pskin_index] -= relaxation_factor * dx_pskin;
}
}
}
template<class FluidSystem, class Indices, class Scalar> template<class FluidSystem, class Indices, class Scalar>
void StandardWellPrimaryVariables<FluidSystem,Indices,Scalar>:: void StandardWellPrimaryVariables<FluidSystem,Indices,Scalar>::
copyToWellState(WellState& well_state, copyToWellState(WellState& well_state,

View File

@ -111,13 +111,16 @@ public:
//! \brief Copy values from well state. //! \brief Copy values from well state.
void update(const WellState& well_state, DeferredLogger& deferred_logger); void update(const WellState& well_state, DeferredLogger& deferred_logger);
//! \brief Copy polymer molecular weigt values from well state.
void updatePolyMW(const WellState& well_state);
//! \brief Update values from newton update vector. //! \brief Update values from newton update vector.
void updateNewton(const BVectorWell& dwells, void updateNewton(const BVectorWell& dwells,
const double dFLimit, const double dFLimit,
const double dBHPLimit); const double dBHPLimit);
//! \brief Update polymer molecular weight values from newton update vector. //! \brief Update polymer molecular weight values from newton update vector.
void updatePolyMW(const BVectorWell& dwells); void updateNewtonPolyMW(const BVectorWell& dwells);
//! \brief Copy values to well state. //! \brief Copy values to well state.
void copyToWellState(WellState& well_state, DeferredLogger& deferred_logger) const; void copyToWellState(WellState& well_state, DeferredLogger& deferred_logger) const;

View File

@ -979,7 +979,7 @@ namespace Opm
{ {
// for the water velocity and skin pressure // for the water velocity and skin pressure
if constexpr (Base::has_polymermw) { if constexpr (Base::has_polymermw) {
this->primary_variables_.updatePolyMW(dwells); this->primary_variables_.updateNewtonPolyMW(dwells);
} }
} }
@ -2036,16 +2036,7 @@ namespace Opm
// other primary variables related to polymer injection // other primary variables related to polymer injection
if constexpr (Base::has_polymermw) { if constexpr (Base::has_polymermw) {
if (this->isInjector()) { this->primary_variables_.updatePolyMW(well_state);
const auto& ws = well_state.well(this->index_of_well_);
const auto& perf_data = ws.perf_data;
const auto& water_velocity = perf_data.water_velocity;
const auto& skin_pressure = perf_data.skin_pressure;
for (int perf = 0; perf < this->number_of_perforations_; ++perf) {
this->primary_variables_.value_[Bhp + 1 + perf] = water_velocity[perf];
this->primary_variables_.value_[Bhp + 1 + this->number_of_perforations_ + perf] = skin_pressure[perf];
}
}
} }
for (double v : this->primary_variables_.value_) { for (double v : this->primary_variables_.value_) {
if(!isfinite(v)) if(!isfinite(v))