SingleWellState.hpp
Go to the documentation of this file.
1/*
2 Copyright 2021 Equinor ASA
3
4 This file is part of the Open Porous Media project (OPM).
5
6 OPM is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 OPM is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with OPM. If not, see <http://www.gnu.org/licenses/>.
18*/
19
20#ifndef OPM_SINGLE_WELL_STATE_HEADER_INCLUDED
21#define OPM_SINGLE_WELL_STATE_HEADER_INCLUDED
22
23#include <functional>
24#include <vector>
25
26#include <opm/input/eclipse/Schedule/Well/WellEnums.hpp>
27#include <opm/input/eclipse/Schedule/Events.hpp>
28#include <opm/input/eclipse/Schedule/Group/Group.hpp>
29
30#include <opm/material/fluidsystems/PhaseUsageInfo.hpp>
31
36
37namespace Opm {
38
39template<class Scalar> struct PerforationData;
40class SummaryState;
41class Well;
42
43template<typename Scalar, typename IndexTraits>
45public:
49
50 SingleWellState(const std::string& name,
51 const ParallelWellInfo<Scalar>& pinfo,
53 bool is_producer,
55 const std::vector<PerforationData<Scalar>>& perf_input,
56 Scalar temp);
57
59
60 template<class Serializer>
61 void serializeOp(Serializer& serializer)
62 {
63 serializer(name);
64 serializer(status);
65 serializer(producer);
66 serializer(bhp);
67 serializer(thp);
68 serializer(network_thp_limit);
69 serializer(pressure_first_connection);
70 serializer(temperature);
71 serializer(energy_rate);
72 serializer(efficiency_scaling_factor);
73 serializer(phase_mixing_rates);
74 serializer(well_potentials);
75 serializer(productivity_index);
76 serializer(implicit_ipr_a);
77 serializer(implicit_ipr_b);
78 serializer(surface_rates);
79 serializer(reservoir_rates);
80 serializer(prev_surface_rates);
81 serializer(frac_rate);
82 serializer(segments);
83 serializer(events);
84 serializer(injection_cmode);
85 serializer(production_cmode);
86 serializer(filtrate_conc);
87 serializer(perf_data);
88 serializer(primaryvar);
89 serializer(alq_state);
90 serializer(group_target);
91 serializer(group_target_fallback);
92 serializer(use_group_target_fallback);
94 serializer(weldraw_max_rate);
95 serializer(weldraw_cmode);
96 }
97
98 bool operator==(const SingleWellState&) const;
99
100 std::string name;
101 std::reference_wrapper<const ParallelWellInfo<Scalar>> parallel_info;
102
103 WellStatus status{WellStatus::OPEN};
106 Scalar bhp{0};
107 Scalar thp{0};
108 // Network-imposed THP limit retained until the schedule re-specifies the
109 // well's THP limit or VFP table.
110 std::optional<Scalar> network_thp_limit;
112
113 // thermal related
114 Scalar temperature{0};
115 Scalar energy_rate{0.};
116
118
119 // filtration injection concentration
120 Scalar filtrate_conc{0};
121
122 std::array<Scalar,4> phase_mixing_rates{};
128 };
129
130 struct GroupTarget {
131 std::string group_name;
132 Scalar target_value{0.0};
135 Scalar guiderate_ratio{1.0}; // well to group guide rate ratio for diagnostics
136
137 bool operator==(const GroupTarget& other) const {
138 return (group_name == other.group_name
139 && target_value == other.target_value
142 && guiderate_ratio == other.guiderate_ratio);
143 }
144
145 template<class Serializer>
146 void serializeOp(Serializer& serializer) {
147 serializer(group_name);
148 serializer(target_value);
149 serializer(production_cmode);
150 serializer(injection_cmode);
151 serializer(guiderate_ratio);
152 }
153 };
154
155 std::vector<Scalar> well_potentials;
156 std::vector<Scalar> productivity_index;
157 std::vector<Scalar> implicit_ipr_a;
158 std::vector<Scalar> implicit_ipr_b;
159 std::vector<Scalar> surface_rates;
160 std::vector<Scalar> reservoir_rates;
161 std::vector<Scalar> prev_surface_rates;
162 Scalar frac_rate{0.0};
164 std::optional<GroupTarget> group_target;
165 std::optional<GroupTarget> group_target_fallback;
168 Events events;
169 WellInjectorCMode injection_cmode{WellInjectorCMode::CMODE_UNDEFINED};
170 WellProducerCMode production_cmode{WellProducerCMode::CMODE_UNDEFINED};
171 std::vector<Scalar> primaryvar;
173 // This is used to indicate whether the well was shut before applying an action
174 // if it was SHUT, even the action set the well to OPEN, the data in the well state
175 // is not well-defined. We do not use it to overwrite the current well state.
177 // Maximum production rate of the WELDRAW target phase derived from the
178 // well's drawdown limit; updated during the first NUPCOL iterations of
179 // each timestep and unset when no drawdown limit is active.
180 std::optional<Scalar> weldraw_max_rate{};
181 // The rate control which carries that limit, set only while the limit is
182 // at least as restrictive as the well's own target for the same phase.
183 // The well is under drawdown control when this is its active control.
184 std::optional<WellProducerCMode> weldraw_cmode{};
185
192 void reset_connection_factors(const std::vector<PerforationData<Scalar>>& new_perf_data);
193 void update_producer_targets(const Well& ecl_well, const SummaryState& st);
194 void update_injector_targets(const Well& ecl_well, const SummaryState& st);
200 void update_type_and_targets(const Well& ecl_well, const SummaryState& st);
201 bool updateStatus(WellStatus status);
202 void init_timestep(const SingleWellState& other);
203 void shut();
204 void stop();
205 void open();
206
207 // The sum_xxx_rates() functions sum over all connection rates of pertinent
208 // types. In the case of distributed wells this involves an MPI
209 // communication.
210 Scalar sum_solvent_rates() const;
211 Scalar sum_polymer_rates() const;
212 Scalar sum_brine_rates() const;
213 Scalar sum_microbial_rates() const;
214 Scalar sum_oxygen_rates() const;
215 Scalar sum_urea_rates() const;
216 Scalar sum_wat_mass_rates() const;
217
218 Scalar sum_filtrate_rate() const;
219 Scalar sum_filtrate_total() const;
220
221private:
222 Scalar sum_connection_rates(const std::vector<Scalar>& connection_rates) const;
223};
224
225}
226
227#endif
Definition: ALQState.hpp:32
Class encapsulating some information about parallel wells.
Definition: ParallelWellInfo.hpp:217
Definition: PerfData.hpp:35
Definition: GasLiftGroupInfo.hpp:38
Definition: SegmentState.hpp:34
Definition: SingleWellState.hpp:44
WellProducerCMode production_cmode
Definition: SingleWellState.hpp:170
Scalar thp
Definition: SingleWellState.hpp:107
std::vector< Scalar > prev_surface_rates
Definition: SingleWellState.hpp:161
void reset_connection_factors(const std::vector< PerforationData< Scalar > > &new_perf_data)
static SingleWellState serializationTestObject(const ParallelWellInfo< Scalar > &pinfo)
std::array< Scalar, 4 > phase_mixing_rates
Definition: SingleWellState.hpp:122
std::vector< Scalar > surface_rates
Definition: SingleWellState.hpp:159
std::optional< Scalar > weldraw_max_rate
Definition: SingleWellState.hpp:180
SingleWellState(const std::string &name, const ParallelWellInfo< Scalar > &pinfo, const PhaseUsageInfo< IndexTraits > &pu, bool is_producer, Scalar pressure_first_connection, const std::vector< PerforationData< Scalar > > &perf_input, Scalar temp)
std::optional< GroupTarget > group_target
Definition: SingleWellState.hpp:164
WellStatus status
Definition: SingleWellState.hpp:103
void init_timestep(const SingleWellState &other)
Scalar sum_solvent_rates() const
Scalar sum_oxygen_rates() const
std::vector< Scalar > productivity_index
Definition: SingleWellState.hpp:156
std::optional< GroupTarget > group_target_fallback
Definition: SingleWellState.hpp:165
Scalar pressure_first_connection
Definition: SingleWellState.hpp:111
Scalar bhp
Definition: SingleWellState.hpp:106
std::reference_wrapper< const ParallelWellInfo< Scalar > > parallel_info
Definition: SingleWellState.hpp:101
void update_injector_targets(const Well &ecl_well, const SummaryState &st)
ALQState< Scalar > alq_state
Definition: SingleWellState.hpp:172
std::optional< WellProducerCMode > weldraw_cmode
Definition: SingleWellState.hpp:184
Scalar sum_filtrate_total() const
Scalar sum_microbial_rates() const
std::vector< Scalar > implicit_ipr_a
Definition: SingleWellState.hpp:157
void serializeOp(Serializer &serializer)
Definition: SingleWellState.hpp:61
Scalar sum_filtrate_rate() const
Scalar sum_wat_mass_rates() const
std::vector< Scalar > implicit_ipr_b
Definition: SingleWellState.hpp:158
RateIndices
Definition: SingleWellState.hpp:123
@ vaporized_water
Definition: SingleWellState.hpp:127
@ dissolved_gas_in_water
Definition: SingleWellState.hpp:125
@ dissolved_gas
Definition: SingleWellState.hpp:124
@ vaporized_oil
Definition: SingleWellState.hpp:126
static const int gasPhaseIdx
Definition: SingleWellState.hpp:48
bool operator==(const SingleWellState &) const
std::vector< Scalar > primaryvar
Definition: SingleWellState.hpp:171
Scalar sum_brine_rates() const
bool was_shut_before_action_applied
Definition: SingleWellState.hpp:176
SegmentState< Scalar > segments
Definition: SingleWellState.hpp:167
void update_type_and_targets(const Well &ecl_well, const SummaryState &st)
update the type of the well and the targets.
Scalar filtrate_conc
Definition: SingleWellState.hpp:120
std::vector< Scalar > well_potentials
Definition: SingleWellState.hpp:155
Scalar energy_rate
Definition: SingleWellState.hpp:115
bool updateStatus(WellStatus status)
static const int waterPhaseIdx
Definition: SingleWellState.hpp:46
std::string name
Definition: SingleWellState.hpp:100
Scalar sum_polymer_rates() const
Events events
Definition: SingleWellState.hpp:168
Scalar temperature
Definition: SingleWellState.hpp:114
Scalar frac_rate
Definition: SingleWellState.hpp:162
WellInjectorCMode injection_cmode
Definition: SingleWellState.hpp:169
PhaseUsageInfo< IndexTraits > pu
Definition: SingleWellState.hpp:105
bool producer
Definition: SingleWellState.hpp:104
static const int oilPhaseIdx
Definition: SingleWellState.hpp:47
void update_producer_targets(const Well &ecl_well, const SummaryState &st)
Scalar sum_urea_rates() const
Scalar efficiency_scaling_factor
Definition: SingleWellState.hpp:117
bool use_group_target_fallback
Definition: SingleWellState.hpp:166
PerfData< Scalar > perf_data
Definition: SingleWellState.hpp:163
std::vector< Scalar > reservoir_rates
Definition: SingleWellState.hpp:160
std::optional< Scalar > network_thp_limit
Definition: SingleWellState.hpp:110
@ NONE
Definition: DeferredLogger.hpp:46
Definition: blackoilbioeffectsmodules.hh:45
Static data associated with a well perforation.
Definition: PerforationData.hpp:30
Definition: SingleWellState.hpp:130
Group::ProductionCMode production_cmode
Definition: SingleWellState.hpp:133
bool operator==(const GroupTarget &other) const
Definition: SingleWellState.hpp:137
Scalar target_value
Definition: SingleWellState.hpp:132
Scalar guiderate_ratio
Definition: SingleWellState.hpp:135
Group::InjectionCMode injection_cmode
Definition: SingleWellState.hpp:134
void serializeOp(Serializer &serializer)
Definition: SingleWellState.hpp:146
std::string group_name
Definition: SingleWellState.hpp:131