mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
temperature output as weighted sum of well block temperatures based on specific heat capacity of the phases
This commit is contained in:
parent
a5c5dc2ec9
commit
3ff3d549ed
@ -703,6 +703,12 @@ namespace Opm {
|
||||
const SummaryState& summaryState)
|
||||
{
|
||||
std::vector<double> cellPressures(this->local_num_cells_, 0.0);
|
||||
std::vector<double> cellTemperatures(this->local_num_cells_, 0.0);
|
||||
const int np = numPhases();
|
||||
std::vector<std::vector<double>> cellInternalEnergy(this->local_num_cells_, std::vector<double>(np));
|
||||
std::vector<std::vector<double>> cellBinv(this->local_num_cells_, std::vector<double>(np));
|
||||
std::vector<std::vector<double>> cellDensity(this->local_num_cells_, std::vector<double>(np));
|
||||
|
||||
ElementContext elemCtx(ebosSimulator_);
|
||||
|
||||
const auto& gridView = ebosSimulator_.vanguard().gridView();
|
||||
@ -719,6 +725,15 @@ namespace Opm {
|
||||
elemCtx.updatePrimaryIntensiveQuantities(/*timeIdx=*/0);
|
||||
|
||||
const auto& fs = elemCtx.intensiveQuantities(/*spaceIdx=*/0, /*timeIdx=*/0).fluidState();
|
||||
|
||||
cellTemperatures[elemCtx.globalSpaceIndex(/*spaceIdx=*/0, /*timeIdx=*/0)] = fs.temperature(/*phaseIdx*/0).value();
|
||||
|
||||
for (int phaseIdx = 0; phaseIdx < np; ++phaseIdx)
|
||||
{
|
||||
cellInternalEnergy[elemCtx.globalSpaceIndex(/*spaceIdx=*/0, /*timeIdx=*/0)][phaseIdx] = fs.enthalpy(phaseIdx).value() - fs.pressure(phaseIdx).value() / fs.density(phaseIdx).value();
|
||||
cellBinv[elemCtx.globalSpaceIndex(/*spaceIdx=*/0, /*timeIdx=*/0)][phaseIdx] = fs.invB(phaseIdx).value();
|
||||
cellDensity[elemCtx.globalSpaceIndex(/*spaceIdx=*/0, /*timeIdx=*/0)][phaseIdx] = fs.density(phaseIdx).value();
|
||||
}
|
||||
|
||||
// copy of get perfpressure in Standard well except for value
|
||||
double& perf_pressure = cellPressures[elemCtx.globalSpaceIndex(/*spaceIdx=*/0, /*timeIdx=*/0)];
|
||||
@ -731,7 +746,7 @@ namespace Opm {
|
||||
}
|
||||
}
|
||||
|
||||
well_state_.init(cellPressures, schedule(), wells_ecl_, local_parallel_well_info_, timeStepIdx,
|
||||
well_state_.init(cellPressures, cellTemperatures, cellInternalEnergy, cellBinv, cellDensity, schedule(), wells_ecl_, local_parallel_well_info_, timeStepIdx,
|
||||
&previous_well_state_, phase_usage_, well_perf_data_,
|
||||
summaryState, globalNumWells);
|
||||
}
|
||||
|
@ -39,18 +39,23 @@
|
||||
namespace Opm
|
||||
{
|
||||
/// The state of a set of wells.
|
||||
class WellState
|
||||
class WellState
|
||||
{
|
||||
public:
|
||||
typedef std::array< int, 3 > mapentry_t;
|
||||
typedef std::map< std::string, mapentry_t > WellMapType;
|
||||
|
||||
|
||||
/// Allocate and initialize if wells is non-null.
|
||||
/// Also tries to give useful initial values to the bhp() and
|
||||
/// wellRates() fields, depending on controls. The
|
||||
/// perfRates() field is filled with zero, and perfPress()
|
||||
/// with -1e100.
|
||||
void init(const std::vector<double>& cellPressures,
|
||||
const std::vector<double>& cellTemperatures,
|
||||
const std::vector<std::vector<double>>& cellInternalEnergy,
|
||||
const std::vector<std::vector<double>>& cellBinv,
|
||||
const std::vector<std::vector<double>>& cellDensity,
|
||||
const std::vector<double>& perforationRates,
|
||||
const std::vector<Well>& wells_ecl,
|
||||
const std::vector<ParallelWellInfo*>& parallel_well_info,
|
||||
const PhaseUsage& pu,
|
||||
@ -73,13 +78,13 @@ namespace Opm
|
||||
bhp_.resize(nw, 0.0);
|
||||
thp_.resize(nw, 0.0);
|
||||
temperature_.resize(nw, 273.15 + 15.56); // standard condition temperature
|
||||
wellrates_.resize(nw * np, 0.0);
|
||||
wellrates_.resize(nw * np, 0.0);
|
||||
int connpos = 0;
|
||||
for (int w = 0; w < nw; ++w) {
|
||||
const Well& well = wells_ecl[w];
|
||||
|
||||
// Initialize bhp(), thp(), wellRates(), temperature().
|
||||
initSingleWell(cellPressures, w, well, *parallel_well_info[w], pu, summary_state);
|
||||
initSingleWell(cellPressures, cellTemperatures, cellInternalEnergy, cellBinv, cellDensity, perforationRates, w, well, *parallel_well_info[w], pu, summary_state);
|
||||
|
||||
// Setup wellname -> well index mapping.
|
||||
const int num_perf_this_well = well_perf_data[w].size();
|
||||
@ -353,6 +358,11 @@ namespace Opm
|
||||
sizes.data(), displ.data(), 0);
|
||||
}
|
||||
void initSingleWell(const std::vector<double>& cellPressures,
|
||||
const std::vector<double>& cellTemperatures,
|
||||
const std::vector<std::vector<double>>& cellInternalEnergy,
|
||||
const std::vector<std::vector<double>>& cellBinv,
|
||||
const std::vector<std::vector<double>>& cellDensity,
|
||||
const std::vector<double>& perforationRates,
|
||||
const int w,
|
||||
const Well& well,
|
||||
const ParallelWellInfo& well_info,
|
||||
@ -368,9 +378,35 @@ namespace Opm
|
||||
wellrates_[np*w + p] = 0.0;
|
||||
}
|
||||
|
||||
const int num_perf_this_well = well_perf_data_[w].size();
|
||||
if ( well.isInjector() ) {
|
||||
temperature_[w] = well.injectionControls(summary_state).temperature;
|
||||
}
|
||||
if ( well.isProducer() ) {
|
||||
int sz = perforationRates.size();
|
||||
int connpos = 0;
|
||||
for (int i = 0; i < w; ++i){
|
||||
connpos += well_perf_data_[i].size();
|
||||
}
|
||||
connpos *= np;
|
||||
double weighted_temperature = 0.0;
|
||||
double total_weight = 0.0;
|
||||
if (sz > 0){
|
||||
for (int i = 0; i < num_perf_this_well; ++i){
|
||||
int perf_cell_index = well_perf_data_[w][i].cell_index;
|
||||
double weight_factor = 0.0;
|
||||
for (int p = 0; p < np; ++p) {
|
||||
weight_factor += cellDensity[perf_cell_index][p] * perforationRates[connpos + i*np + p]/cellBinv[perf_cell_index][p] * cellInternalEnergy[perf_cell_index][p]/cellTemperatures[perf_cell_index];
|
||||
}
|
||||
total_weight += weight_factor;
|
||||
weighted_temperature += weight_factor * cellTemperatures[perf_cell_index];
|
||||
}
|
||||
temperature_[w] = weighted_temperature/total_weight;
|
||||
}
|
||||
else {
|
||||
temperature_[w]=0;
|
||||
}
|
||||
}
|
||||
|
||||
const int num_perf_this_well = well_info.communication().sum(well_perf_data_[w].size());
|
||||
if ( num_perf_this_well == 0 ) {
|
||||
@ -489,9 +525,9 @@ namespace Opm
|
||||
|
||||
protected:
|
||||
std::vector<std::vector<PerforationData>> well_perf_data_;
|
||||
std::vector<ParallelWellInfo*> parallel_well_info_;
|
||||
std::vector<ParallelWellInfo*> parallel_well_info_;
|
||||
};
|
||||
|
||||
|
||||
} // namespace Opm
|
||||
|
||||
#endif // OPM_WELLSTATE_HEADER_INCLUDED
|
||||
|
@ -23,6 +23,7 @@
|
||||
|
||||
#include <opm/simulators/wells/WellState.hpp>
|
||||
#include <opm/core/props/BlackoilPhases.hpp>
|
||||
#include <opm/material/fluidsystems/BlackOilFluidSystem.hpp>
|
||||
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Well/Well.hpp>
|
||||
@ -70,6 +71,10 @@ namespace Opm
|
||||
/// to give useful initial values to the bhp(), wellRates()
|
||||
/// and perfPhaseRates() fields, depending on controls
|
||||
void init(const std::vector<double>& cellPressures,
|
||||
const std::vector<double>& cellTemperatures,
|
||||
const std::vector<std::vector<double>>& cellInternalEnergy,
|
||||
const std::vector<std::vector<double>>& cellBinv,
|
||||
const std::vector<std::vector<double>>& cellDensity,
|
||||
const Schedule& schedule,
|
||||
const std::vector<Well>& wells_ecl,
|
||||
const std::vector<ParallelWellInfo*>& parallel_well_info,
|
||||
@ -80,8 +85,11 @@ namespace Opm
|
||||
const SummaryState& summary_state,
|
||||
const int globalNumberOfWells)
|
||||
{
|
||||
//Todo: make it reservoir perforation rates
|
||||
std::vector<double> perforationRates;
|
||||
perforationRates = prevState->perfphaserates_;
|
||||
// call init on base class
|
||||
BaseType :: init(cellPressures, wells_ecl, parallel_well_info, pu, well_perf_data, summary_state);
|
||||
BaseType :: init(cellPressures, cellTemperatures, cellInternalEnergy, cellBinv, cellDensity, perforationRates, wells_ecl, parallel_well_info, pu, well_perf_data, summary_state);
|
||||
|
||||
for (const auto& winfo: parallel_well_info)
|
||||
{
|
||||
@ -348,7 +356,8 @@ namespace Opm
|
||||
const int globalNumWells)
|
||||
{
|
||||
const std::vector<double> tmp(numCells, 0.0); // <- UGLY HACK to pass the size
|
||||
init(tmp, schedule, wells_ecl, parallel_well_info, 0, nullptr, pu, well_perf_data, summary_state, globalNumWells);
|
||||
std::vector<std::vector<double>> tmp1(numCells, std::vector<double>( numPhases()));// <- UGLY HACK to pass the size
|
||||
init(tmp, tmp, tmp1, tmp1, tmp1, schedule, wells_ecl, parallel_well_info, 0, nullptr, pu, well_perf_data, summary_state, globalNumWells);
|
||||
|
||||
if (handle_ms_well) {
|
||||
initWellStateMSWell(wells_ecl, pu, nullptr);
|
||||
|
Loading…
Reference in New Issue
Block a user