diff --git a/flowexperimental/comp/wells/CompWellInterface.hpp b/flowexperimental/comp/wells/CompWellInterface.hpp index 387646bbfc..2619ad70b4 100644 --- a/flowexperimental/comp/wells/CompWellInterface.hpp +++ b/flowexperimental/comp/wells/CompWellInterface.hpp @@ -59,11 +59,6 @@ public: virtual void updatePrimaryVariables(const Simulator& simulator, const SingleCompWellState& well_state) = 0; - // TODO: not sure this funciton will be used - // but leaviing it here for protoyping purpsoe - void solveWellEq(const Simulator& simulator, - SingleCompWellState& well_state); - virtual bool iterateWellEq(const Simulator& simulator, const Scalar dt, SingleCompWellState& well_state) = 0; diff --git a/flowexperimental/comp/wells/CompWellInterface_impl.hpp b/flowexperimental/comp/wells/CompWellInterface_impl.hpp index 281c2967a8..53e1f36f65 100644 --- a/flowexperimental/comp/wells/CompWellInterface_impl.hpp +++ b/flowexperimental/comp/wells/CompWellInterface_impl.hpp @@ -65,17 +65,6 @@ name() const return this->well_ecl_.name(); } -template -void -CompWellInterface:: -solveWellEq(const Simulator& simulator, - SingleCompWellState& well_state) -{ - const SingleCompWellState well_state0 = well_state; - const double dt = simulator.timeStepSize(); - bool converged = this->iterateWellEq(simulator, dt, well_state); -} - template void CompWellInterface:: diff --git a/flowexperimental/comp/wells/CompWellPrimaryVariables.hpp b/flowexperimental/comp/wells/CompWellPrimaryVariables.hpp index abec32cea1..2884352a71 100644 --- a/flowexperimental/comp/wells/CompWellPrimaryVariables.hpp +++ b/flowexperimental/comp/wells/CompWellPrimaryVariables.hpp @@ -64,7 +64,6 @@ public: FluidState toFluidState() const; - // void init(); void update(const SingleCompWellState& well_state); void updateEvaluation(); diff --git a/flowexperimental/comp/wells/CompWellPrimaryVariables_impl.hpp b/flowexperimental/comp/wells/CompWellPrimaryVariables_impl.hpp index 54f3cdc284..7928b3530b 100644 --- a/flowexperimental/comp/wells/CompWellPrimaryVariables_impl.hpp +++ b/flowexperimental/comp/wells/CompWellPrimaryVariables_impl.hpp @@ -22,16 +22,6 @@ namespace Opm { -// template -// void -// CompWellPrimaryVariables:: -// init() -// { -// // the following code looks like a resize function -// value_.resize(numWellEq, 0.); -// evaluation_.resize(numWellEq, 0.); -// } - template void CompWellPrimaryVariables:: @@ -180,21 +170,12 @@ template void CompWellPrimaryVariables:: updateNewton(const BVectorWell& dwells) { - std::cout << " the current values "; - for (const auto& val : value_) { - std::cout << val << " "; - } - std::cout << std::endl; + constexpr Scalar damping = 1.0; - std::cout << " dwells "; - for (unsigned i = 0; i < dwells[0].size(); ++i) { - std::cout << dwells[0][i] << " "; - } - std::cout << std::endl; for (unsigned i = 0; i < value_.size(); ++i) { - value_[i] -= 0.8 * dwells[0][i]; + value_[i] -= damping * dwells[0][i]; } - std::cout << " process the fractions " << std::endl; + // TODO: more general indices here value_[1] = std::clamp(value_[1], 1.e-10, 1.); value_[2] = std::clamp(value_[2], 1.e-10, 1.); std::vector mole_fractions(FluidSystem::numComponents, 0.); diff --git a/flowexperimental/comp/wells/CompWell_impl.hpp b/flowexperimental/comp/wells/CompWell_impl.hpp index b97e5242de..0ab8e53925 100644 --- a/flowexperimental/comp/wells/CompWell_impl.hpp +++ b/flowexperimental/comp/wells/CompWell_impl.hpp @@ -39,7 +39,6 @@ void CompWell:: init() { Base::init(); - // primary_variables_.init(); well_equations_.init(this->number_of_connection_, this->well_cells_); } @@ -106,7 +105,6 @@ calculateExplicitQuantities(const Simulator& simulator, gas_mass_fractions[compidx] * density_gas * Sg) * wellbore_volume; } } - // assembleWellEq(simulator, 1.0, well_state); } template @@ -136,10 +134,6 @@ updateTotalMass() // flash calculation in the wellbore using FluidState = CompositionalFluidState; FluidState fluid_state = this->primary_variables_.toFluidState(); - // manullay set the values for debugging purpose - /* fluid_state.setMoleFraction(0, 0.8576939356002758); - fluid_state.setMoleFraction(1, 0.04743535777357194); - fluid_state.setMoleFraction(2, 0.09487070662615232); */ const bool single_phase = PTFlash::solve(fluid_state, "ssi", 1.e-6, CompositionalConfig::EOSType::PR); // calculating the mass within the wellbore constexpr Scalar R = Constants::R; @@ -193,11 +187,11 @@ updateTotalMass() gas_mass_fractions[compidx] * density_gas * Sg) * wellbore_volume; total_mass += this->new_component_masses_[compidx]; } - // TODO: checking all the calculation's here + // TODO: some properties should go to the fluid_state? fluid_density_ = density_oil * So + density_gas * Sg; - // TODO: the derivative of the mass fradtions does not look correct + // TODO: the derivative of the mass fractions does not look correct for (unsigned compidx = 0; compidx < FluidSystem::numComponents; ++compidx) { mass_fractions_[compidx] = this->new_component_masses_[compidx] / total_mass; } @@ -209,7 +203,6 @@ CompWell:: updateSurfaceQuantities(const Simulator& simulator) { const auto& surface_cond = simulator.vanguard().eclState().getTableManager().stCond(); - std::cout << " well surface condition temperature " << surface_cond.temperature << " pressure " << surface_cond.pressure << std::endl; if (this->well_ecl_.isInjector()) { // we look for well stream for injection composition const auto& inj_composition = this->well_ecl_.getInjectionProperties().gasInjComposition(); using FluidStateScalar = CompositionalFluidState; @@ -278,12 +271,8 @@ updateSurfaceQuantities(const Simulator& simulator) this->surface_conditions_.surface_densities_[FluidSystem::gasPhaseIdx] = density_gas; this->surface_conditions_.volume_fractions_[FluidSystem::oilPhaseIdx] = So; this->surface_conditions_.volume_fractions_[FluidSystem::gasPhaseIdx] = Sg; - std::cout << " oil surface density " << density_oil << " gas surface density " << density_gas - << " oil volume fraction " << So << " gas volume fraction " << Sg << std::endl; - // TODO: it shows it is liquid, which is not correct } else { // the composition will be from the wellbore // here, it will use the composition from the wellbore and the pressure and temperature from the surface condition - std::cout << " well is a producer " << std::endl; using FluidState = CompositionalFluidState; FluidState fluid_state = this->primary_variables_.toFluidState(); fluid_state.setTemperature(surface_cond.temperature); @@ -578,7 +567,7 @@ iterateWellEq(const Simulator& simulator, const Scalar dt, SingleCompWellState& well_state) { - constexpr int max_iter = 20000; + constexpr int max_iter = 200; int it = 0; bool converged = false; @@ -588,20 +577,18 @@ iterateWellEq(const Simulator& simulator, assembleWellEq(simulator, well_state, dt); - std::cout << std::endl << " residuals "; - for (const auto& val : this->well_equations_.residual()[0]) { - std::cout << val << " "; - } - std::cout << std::endl; // get convergence converged = this->getConvergence(); if (converged) { +#if 0 std::cout << " the well " << this->well_ecl_.name() << " has converged after " << it << " iterations" << std::endl; std::cout << " the residuals "; for (const auto& val : this->well_equations_.residual()[0]) { std::cout << val << " "; } + std::cout << std::endl; +#endif break; } @@ -609,7 +596,6 @@ iterateWellEq(const Simulator& simulator, solveEqAndUpdateWellState(well_state); } while (it < max_iter); - std::cout << "converged " << converged << " after " << it << " iterations" << std::endl; return converged; } @@ -688,8 +674,6 @@ updateWellState(SingleCompWellState& well_state) const // only gas injection yet surface_phase_rates[FluidSystem::gasPhaseIdx] = total_rate; } - well_state.output(); - // std::cout << std::endl; } template @@ -699,8 +683,7 @@ getConvergence() const { bool converged = true; for (const auto& val : this->well_equations_.residual()[0]) { - // converged = converged && (std::abs(val) < 1.e-6); - converged = converged && (std::abs(val) < 1.e-6 * 1.); + converged = converged && (std::abs(val) < 1.e-8); } return converged; } diff --git a/flowexperimental/comp/wells/CompositionalWellModel_impl.hpp b/flowexperimental/comp/wells/CompositionalWellModel_impl.hpp index 9625b85eae..beea952c87 100644 --- a/flowexperimental/comp/wells/CompositionalWellModel_impl.hpp +++ b/flowexperimental/comp/wells/CompositionalWellModel_impl.hpp @@ -40,12 +40,6 @@ beginTimeStep() { createWellContainer(); initWellContainer(); -// for (auto& well : well_container_) { -// auto& well_state = comp_well_states_[well->name()]; -// well->calculateExplicitQuantities(simulator_, well_state); -// well->updateSecondaryQuantities(simulator_); -// well->solveWellEq(simulator_, well_state); -// } } template @@ -220,8 +214,8 @@ assemble(const int iterationIdx, for (auto& well : well_container_) { auto& well_state = comp_well_states_[well->name()]; well->iterateWellEq(simulator_, dt, well_state); - // TODO: do we need this? can we use the one assembled previously? - // well->assembleWellEq(simulator_, dt, well_state); + // currently we use the converged assembly of well equations directly without a new assembling + // well->assembleWellEq(simulator_, well_state, dt); } } @@ -285,13 +279,4 @@ wellData() const return this->comp_well_states_.report(); } -//template -//void -//CompositionalWellModel:: -//linearize(SparseMatrixAdapter&, GlobalEqVector&) -//{ -// -//} - - } // end of namespace Opm \ No newline at end of file diff --git a/flowexperimental/comp/wells/SingleCompWellState.hpp b/flowexperimental/comp/wells/SingleCompWellState.hpp index b7a70f476a..5c75a46d44 100644 --- a/flowexperimental/comp/wells/SingleCompWellState.hpp +++ b/flowexperimental/comp/wells/SingleCompWellState.hpp @@ -75,8 +75,6 @@ public: // WZMF std::vector total_molar_fractions; // WXMF WYMF and WAMF - // TODO: potentiall we can use std::vector> - // TODO: to do phase_molar_fractions std::vector > phase_molar_fractions; ConnectionData connection_data; diff --git a/flowexperimental/comp/wells/SingleCompWellState_impl.hpp b/flowexperimental/comp/wells/SingleCompWellState_impl.hpp index 4f637fccdf..0eefc6e44f 100644 --- a/flowexperimental/comp/wells/SingleCompWellState_impl.hpp +++ b/flowexperimental/comp/wells/SingleCompWellState_impl.hpp @@ -132,8 +132,6 @@ update_producer_targets(const Well& well, // we give a random rates for BHP controlled wells const Scalar production_rate = -1000.0 * Opm::unit::cubic(Opm::unit::meter) / Opm::unit::day; - // different from the black oil situation, surface rate is not the primary variable, so we need to - // check the how to convert it. // TODO: we should use our own phase index system // TODO: the following must be changed if (prod_controls.cmode == Well::ProducerCMode::BHP) { @@ -147,8 +145,6 @@ update_producer_targets(const Well& well, this->surface_phase_rates[BlackoilPhases::Vapour] = 100. * production_rate; } } - - } template