From a28311cb7c5d95fcd64f748239d6128308c7877f Mon Sep 17 00:00:00 2001 From: Kjetil Olsen Lye Date: Mon, 7 May 2012 14:28:33 +0200 Subject: [PATCH 1/5] Inserted reservoir max rate into the group structure --- opm/core/WellsGroup.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/opm/core/WellsGroup.cpp b/opm/core/WellsGroup.cpp index f8122c162..931087a55 100644 --- a/opm/core/WellsGroup.cpp +++ b/opm/core/WellsGroup.cpp @@ -1000,6 +1000,7 @@ namespace Opm production_specification.gas_max_rate_ = line.gas_max_rate_; production_specification.liquid_max_rate_ = line.liquid_max_rate_; production_specification.procedure_ = toProductionProcedure(line.procedure_); + production_specification.reservoir_flow_max_rate_ = line.resv_max_rate_; } } } From c9d96d81b8cc8d4976c24770a0108e2433931621 Mon Sep 17 00:00:00 2001 From: Kjetil Olsen Lye Date: Tue, 8 May 2012 11:04:15 +0200 Subject: [PATCH 2/5] Refactored some computations into seperate methods in wells_example.cpp --- opm/core/utility/miscUtilities.cpp | 54 ++++++++++++++++++++++++++++++ opm/core/utility/miscUtilities.hpp | 23 +++++++++++++ 2 files changed, 77 insertions(+) diff --git a/opm/core/utility/miscUtilities.cpp b/opm/core/utility/miscUtilities.cpp index 6021e18cb..b58cc0ec5 100644 --- a/opm/core/utility/miscUtilities.cpp +++ b/opm/core/utility/miscUtilities.cpp @@ -270,6 +270,32 @@ namespace Opm } } } + + /// Computes the fractional flow for each cell in the cells argument + /// @param[in] props rock and fluid properties + /// @param[in] cells cells with which the saturation values are associated + /// @param[in] saturations saturation values (for all phases) + /// @param[out] fractional_flow the fractional flow for each phase for each cell. + + void computeFractionalFlow(const Opm::IncompPropertiesInterface& props, + const std::vector& cells, + const std::vector& saturations, + std::vector& fractional_flows) + { + const int num_phases = props.numPhases(); + std::vector pc_mobs(cells.size() * num_phases); + computePhaseMobilities(props, cells, saturations, pc_mobs); + fractional_flows.resize(cells.size() * num_phases); + for (size_t i = 0; i < cells.size(); ++i) { + double phase_sum = 0.0; + for (int phase = 0; phase < num_phases; ++phase) { + phase_sum += pc_mobs[i * num_phases + phase]; + } + for (int phase = 0; phase < num_phases; ++phase) { + fractional_flows[i * num_phases + phase] = pc_mobs[i * num_phases + phase] / phase_sum; + } + } + } /// Compute two-phase transport source terms from face fluxes, /// and pressure equation source terms. This puts boundary flows @@ -494,6 +520,34 @@ namespace Opm } } + + /// Computes the phase flow rate per well + /// \param[in] wells The wells for which the flow rate should be computed + /// \param[in] flow_rates_per_cell The total flow rate for each cell (ordered the same + /// way as the wells struct + /// \param[in] fractional_flows the fractional flow for each cell in each well + /// \param[out] phase_flow_per_well Will contain the phase flow per well + + void computePhaseFlowRatesPerWell(const Wells& wells, + const std::vector& flow_rates_per_cell, + const std::vector& fractional_flows, + std::vector phase_flow_per_well) + { + const int np = wells.number_of_phases; + const int nw = wells.number_of_wells; + phase_flow_per_well.resize(nw * np); + for (int wix = 0; wix < nw; ++wix) { + for (int phase = 0; phase < np; ++phase) { + // Reset vector + phase_flow_per_well[wix + np*phase] = 0.0; + } + for (int i = wells.well_connpos[wix]; i < wells.well_connpos[wix + 1]; ++i) { + for (int phase = 0; phase < np; ++phase) { + phase_flow_per_well[wix * np + phase] += flow_rates_per_cell[i] * fractional_flows[i * np + phase]; + } + } + } + } void Watercut::push(double time, double fraction, double produced) diff --git a/opm/core/utility/miscUtilities.hpp b/opm/core/utility/miscUtilities.hpp index 9b9a3e3f7..82ba5d384 100644 --- a/opm/core/utility/miscUtilities.hpp +++ b/opm/core/utility/miscUtilities.hpp @@ -129,6 +129,17 @@ namespace Opm const std::vector& cells, const std::vector& s , std::vector& pmobc); + + + /// Computes the fractional flow for each cell in the cells argument + /// @param[in] props rock and fluid properties + /// @param[in] cells cells with which the saturation values are associated + /// @param[in] saturations saturation values (for all phases) + /// @param[out] fractional_flow the fractional flow for each phase for each cell. + void computeFractionalFlow(const Opm::IncompPropertiesInterface& props, + const std::vector& cells, + const std::vector& saturations, + std::vector& fractional_flows); /// Compute two-phase transport source terms from face fluxes, @@ -203,6 +214,18 @@ namespace Opm void computeFlowRatePerWell(const Wells& wells, const std::vector& flow_rates_per_cell, std::vector& flow_rates_per_well); + /// Computes the phase flow rate per well + /// \param[in] wells The wells for which the flow rate should be computed + /// \param[in] flow_rates_per_cell The total flow rate for each cell (ordered the same + /// way as the wells struct + /// \param[in] fractional_flows the fractional flow for each cell in each well + /// \param[out] phase_flow_per_well Will contain the phase flow per well + void computePhaseFlowRatesPerWell(const Wells& wells, + const std::vector& flow_rates_per_cell, + const std::vector& fractional_flows, + std::vector phase_flow_per_well); + + /// Encapsulates the watercut curves. class Watercut { From 6b96d48677b70bf890c1a999981e8991c35becf1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Tue, 8 May 2012 12:03:50 +0200 Subject: [PATCH 3/5] Fix a likely indexing error leading to non-unit strides. --- opm/core/utility/miscUtilities.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opm/core/utility/miscUtilities.cpp b/opm/core/utility/miscUtilities.cpp index b58cc0ec5..7f42bd9bf 100644 --- a/opm/core/utility/miscUtilities.cpp +++ b/opm/core/utility/miscUtilities.cpp @@ -539,7 +539,7 @@ namespace Opm for (int wix = 0; wix < nw; ++wix) { for (int phase = 0; phase < np; ++phase) { // Reset vector - phase_flow_per_well[wix + np*phase] = 0.0; + phase_flow_per_well[wix*np + phase] = 0.0; } for (int i = wells.well_connpos[wix]; i < wells.well_connpos[wix + 1]; ++i) { for (int phase = 0; phase < np; ++phase) { From 9e5b5be59b3723347c995e910494ff445b6dcc21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Tue, 8 May 2012 12:04:59 +0200 Subject: [PATCH 4/5] Delete trailing whitespace. --- opm/core/utility/miscUtilities.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/opm/core/utility/miscUtilities.cpp b/opm/core/utility/miscUtilities.cpp index 7f42bd9bf..5e38d943b 100644 --- a/opm/core/utility/miscUtilities.cpp +++ b/opm/core/utility/miscUtilities.cpp @@ -270,7 +270,7 @@ namespace Opm } } } - + /// Computes the fractional flow for each cell in the cells argument /// @param[in] props rock and fluid properties /// @param[in] cells cells with which the saturation values are associated @@ -520,7 +520,7 @@ namespace Opm } } - + /// Computes the phase flow rate per well /// \param[in] wells The wells for which the flow rate should be computed /// \param[in] flow_rates_per_cell The total flow rate for each cell (ordered the same From 8c6ea2895bd9e3cd743833b92eefc41c4938b4e5 Mon Sep 17 00:00:00 2001 From: Kjetil Olsen Lye Date: Tue, 8 May 2012 12:23:58 +0200 Subject: [PATCH 5/5] Changed some minor bugs in the refactored code in wells_example --- opm/core/utility/miscUtilities.cpp | 20 ++++++++++---------- opm/core/utility/miscUtilities.hpp | 6 +++--- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/opm/core/utility/miscUtilities.cpp b/opm/core/utility/miscUtilities.cpp index b58cc0ec5..92be6772f 100644 --- a/opm/core/utility/miscUtilities.cpp +++ b/opm/core/utility/miscUtilities.cpp @@ -521,17 +521,16 @@ namespace Opm } - /// Computes the phase flow rate per well - /// \param[in] wells The wells for which the flow rate should be computed - /// \param[in] flow_rates_per_cell The total flow rate for each cell (ordered the same - /// way as the wells struct - /// \param[in] fractional_flows the fractional flow for each cell in each well - /// \param[out] phase_flow_per_well Will contain the phase flow per well - + /// Computes the phase flow rate per well + /// \param[in] wells The wells for which the flow rate should be computed + /// \param[in] flow_rates_per_well_cell The total flow rate for each cell (ordered the same + /// way as the wells struct + /// \param[in] fractional_flows the fractional flow for each cell in each well + /// \param[out] phase_flow_per_well Will contain the phase flow per well void computePhaseFlowRatesPerWell(const Wells& wells, - const std::vector& flow_rates_per_cell, + const std::vector& flow_rates_per_well_cell, const std::vector& fractional_flows, - std::vector phase_flow_per_well) + std::vector& phase_flow_per_well) { const int np = wells.number_of_phases; const int nw = wells.number_of_wells; @@ -542,8 +541,9 @@ namespace Opm phase_flow_per_well[wix + np*phase] = 0.0; } for (int i = wells.well_connpos[wix]; i < wells.well_connpos[wix + 1]; ++i) { + const int cell = wells.well_cells[i]; for (int phase = 0; phase < np; ++phase) { - phase_flow_per_well[wix * np + phase] += flow_rates_per_cell[i] * fractional_flows[i * np + phase]; + phase_flow_per_well[wix * np + phase] += flow_rates_per_well_cell[i] * fractional_flows[cell * np + phase]; } } } diff --git a/opm/core/utility/miscUtilities.hpp b/opm/core/utility/miscUtilities.hpp index 82ba5d384..131580a69 100644 --- a/opm/core/utility/miscUtilities.hpp +++ b/opm/core/utility/miscUtilities.hpp @@ -216,14 +216,14 @@ namespace Opm /// Computes the phase flow rate per well /// \param[in] wells The wells for which the flow rate should be computed - /// \param[in] flow_rates_per_cell The total flow rate for each cell (ordered the same + /// \param[in] flow_rates_per_well_cell The total flow rate for each cell (ordered the same /// way as the wells struct /// \param[in] fractional_flows the fractional flow for each cell in each well /// \param[out] phase_flow_per_well Will contain the phase flow per well void computePhaseFlowRatesPerWell(const Wells& wells, - const std::vector& flow_rates_per_cell, + const std::vector& flow_rates_per_well_cell, const std::vector& fractional_flows, - std::vector phase_flow_per_well); + std::vector& phase_flow_per_well); /// Encapsulates the watercut curves.