mirror of
https://github.com/OPM/opm-simulators.git
synced 2026-10-26 23:50:08 -05:00
cleaning up the code before reviewing
This commit is contained in:
1 parent
65af93d967
commit
a57b5292d7
8 files changed
+12
-86
No files matched your search
@@ -59,11 +59,6 @@ public:
|
||||
virtual void updatePrimaryVariables(const Simulator& simulator,
|
||||
const SingleCompWellState<Scalar>& well_state) = 0;
|
||||
|
||||
// TODO: not sure this funciton will be used
|
||||
// but leaviing it here for protoyping purpsoe
|
||||
void solveWellEq(const Simulator& simulator,
|
||||
SingleCompWellState<Scalar>& well_state);
|
||||
|
||||
virtual bool iterateWellEq(const Simulator& simulator,
|
||||
const Scalar dt,
|
||||
SingleCompWellState<Scalar>& well_state) = 0;
|
||||
|
||||
@@ -65,17 +65,6 @@ name() const
|
||||
return this->well_ecl_.name();
|
||||
}
|
||||
|
||||
template <typename TypeTag>
|
||||
void
|
||||
CompWellInterface<TypeTag>::
|
||||
solveWellEq(const Simulator& simulator,
|
||||
SingleCompWellState<Scalar>& well_state)
|
||||
{
|
||||
const SingleCompWellState<Scalar> well_state0 = well_state;
|
||||
const double dt = simulator.timeStepSize();
|
||||
bool converged = this->iterateWellEq(simulator, dt, well_state);
|
||||
}
|
||||
|
||||
template <typename TypeTag>
|
||||
void
|
||||
CompWellInterface<TypeTag>::
|
||||
|
||||
@@ -64,7 +64,6 @@ public:
|
||||
|
||||
FluidState toFluidState() const;
|
||||
|
||||
// void init();
|
||||
void update(const SingleCompWellState<Scalar>& well_state);
|
||||
void updateEvaluation();
|
||||
|
||||
|
||||
@@ -22,16 +22,6 @@
|
||||
namespace Opm
|
||||
{
|
||||
|
||||
// template <typename FluidSystem, typename Indices>
|
||||
// void
|
||||
// CompWellPrimaryVariables<FluidSystem, Indices>::
|
||||
// init()
|
||||
// {
|
||||
// // the following code looks like a resize function
|
||||
// value_.resize(numWellEq, 0.);
|
||||
// evaluation_.resize(numWellEq, 0.);
|
||||
// }
|
||||
|
||||
template <typename FluidSystem, typename Indices>
|
||||
void
|
||||
CompWellPrimaryVariables<FluidSystem, Indices>::
|
||||
@@ -180,21 +170,12 @@ template <typename FluidSystem, typename Indices>
|
||||
void
|
||||
CompWellPrimaryVariables<FluidSystem, Indices>::
|
||||
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<Scalar> mole_fractions(FluidSystem::numComponents, 0.);
|
||||
|
||||
@@ -39,7 +39,6 @@ void
|
||||
CompWell<TypeTag>::
|
||||
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 <typename TypeTag>
|
||||
@@ -136,10 +134,6 @@ updateTotalMass()
|
||||
// flash calculation in the wellbore
|
||||
using FluidState = CompositionalFluidState<EvalWell, FluidSystem>;
|
||||
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<Scalar, FluidSystem>::solve(fluid_state, "ssi", 1.e-6, CompositionalConfig::EOSType::PR);
|
||||
// calculating the mass within the wellbore
|
||||
constexpr Scalar R = Constants<Scalar>::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<TypeTag>::
|
||||
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<Scalar, FluidSystem>;
|
||||
@@ -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<EvalWell, FluidSystem>;
|
||||
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<Scalar>& 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<Scalar>& well_state) const
|
||||
// only gas injection yet
|
||||
surface_phase_rates[FluidSystem::gasPhaseIdx] = total_rate;
|
||||
}
|
||||
well_state.output();
|
||||
// std::cout << std::endl;
|
||||
}
|
||||
|
||||
template <typename TypeTag>
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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 <typename TypeTag>
|
||||
@@ -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 <typename TypeTag>
|
||||
//void
|
||||
//CompositionalWellModel<TypeTag>::
|
||||
//linearize(SparseMatrixAdapter&, GlobalEqVector&)
|
||||
//{
|
||||
//
|
||||
//}
|
||||
|
||||
|
||||
} // end of namespace Opm
|
||||
@@ -75,8 +75,6 @@ public:
|
||||
// WZMF
|
||||
std::vector<Scalar> total_molar_fractions;
|
||||
// WXMF WYMF and WAMF
|
||||
// TODO: potentiall we can use std::vector<std::vector<Sclar>>
|
||||
// TODO: to do phase_molar_fractions
|
||||
std::vector<std::vector<Scalar> > phase_molar_fractions;
|
||||
|
||||
ConnectionData<Scalar> connection_data;
|
||||
|
||||
@@ -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 <typename Scalar>
|
||||
|
||||
Reference in new issue
Block a user