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(pressure_first_connection);
69 serializer(temperature);
70 serializer(energy_rate);
71 serializer(efficiency_scaling_factor);
72 serializer(phase_mixing_rates);
73 serializer(well_potentials);
74 serializer(productivity_index);
75 serializer(implicit_ipr_a);
76 serializer(implicit_ipr_b);
77 serializer(surface_rates);
78 serializer(reservoir_rates);
79 serializer(prev_surface_rates);
80 serializer(frac_rate);
81 serializer(trivial_group_target);
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 }
95
96 bool operator==(const SingleWellState&) const;
97
98 std::string name;
99 std::reference_wrapper<const ParallelWellInfo<Scalar>> parallel_info;
100
101 WellStatus status{WellStatus::OPEN};
104 Scalar bhp{0};
105 Scalar thp{0};
107
108 // thermal related
109 Scalar temperature{0};
110 Scalar energy_rate{0.};
111
113
114 // filtration injection concentration
115 Scalar filtrate_conc{0};
116
117 std::array<Scalar,4> phase_mixing_rates{};
123 };
124
125 struct GroupTarget {
126 std::string group_name;
127 Scalar target_value{0.0};
130 Scalar guiderate_ratio{1.0}; // well to group guide rate ratio for diagnostics
131
132 bool operator==(const GroupTarget& other) const {
133 return (group_name == other.group_name
134 && target_value == other.target_value
137 && guiderate_ratio == other.guiderate_ratio);
138 }
139
140 template<class Serializer>
141 void serializeOp(Serializer& serializer) {
142 serializer(group_name);
143 serializer(target_value);
144 serializer(production_cmode);
145 serializer(injection_cmode);
146 serializer(guiderate_ratio);
147 }
148 };
149
150 std::vector<Scalar> well_potentials;
151 std::vector<Scalar> productivity_index;
152 std::vector<Scalar> implicit_ipr_a;
153 std::vector<Scalar> implicit_ipr_b;
154 std::vector<Scalar> surface_rates;
155 std::vector<Scalar> reservoir_rates;
156 std::vector<Scalar> prev_surface_rates;
157 Scalar frac_rate{0.0};
160 std::optional<GroupTarget> group_target;
161 std::optional<GroupTarget> group_target_fallback;
164 Events events;
165 WellInjectorCMode injection_cmode{WellInjectorCMode::CMODE_UNDEFINED};
166 WellProducerCMode production_cmode{WellProducerCMode::CMODE_UNDEFINED};
167 std::vector<Scalar> primaryvar;
169 // This is used to indicate whether the well was shut before applying an action
170 // if it was SHUT, even the action set the well to OPEN, the data in the well state
171 // is not well-defined. We do not use it to overwrite the current well state.
173
180 void reset_connection_factors(const std::vector<PerforationData<Scalar>>& new_perf_data);
181 void update_producer_targets(const Well& ecl_well, const SummaryState& st);
182 void update_injector_targets(const Well& ecl_well, const SummaryState& st);
188 void update_type_and_targets(const Well& ecl_well, const SummaryState& st);
189 bool updateStatus(WellStatus status);
190 void init_timestep(const SingleWellState& other);
191 void shut();
192 void stop();
193 void open();
194
195 // The sum_xxx_rates() functions sum over all connection rates of pertinent
196 // types. In the case of distributed wells this involves an MPI
197 // communication.
198 Scalar sum_solvent_rates() const;
199 Scalar sum_polymer_rates() const;
200 Scalar sum_brine_rates() const;
201 Scalar sum_microbial_rates() const;
202 Scalar sum_oxygen_rates() const;
203 Scalar sum_urea_rates() const;
204 Scalar sum_wat_mass_rates() const;
205
206 Scalar sum_filtrate_rate() const;
207 Scalar sum_filtrate_total() const;
208
209private:
210 Scalar sum_connection_rates(const std::vector<Scalar>& connection_rates) const;
211};
212
213}
214
215#endif
Definition: ALQState.hpp:32
Class encapsulating some information about parallel wells.
Definition: ParallelWellInfo.hpp:198
Definition: PerfData.hpp:35
Definition: GasLiftGroupInfo.hpp:38
Definition: SegmentState.hpp:34
Definition: SingleWellState.hpp:44
WellProducerCMode production_cmode
Definition: SingleWellState.hpp:166
Scalar thp
Definition: SingleWellState.hpp:105
std::vector< Scalar > prev_surface_rates
Definition: SingleWellState.hpp:156
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:117
std::vector< Scalar > surface_rates
Definition: SingleWellState.hpp:154
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:160
WellStatus status
Definition: SingleWellState.hpp:101
void init_timestep(const SingleWellState &other)
Scalar sum_solvent_rates() const
Scalar sum_oxygen_rates() const
std::vector< Scalar > productivity_index
Definition: SingleWellState.hpp:151
std::optional< GroupTarget > group_target_fallback
Definition: SingleWellState.hpp:161
Scalar pressure_first_connection
Definition: SingleWellState.hpp:106
Scalar bhp
Definition: SingleWellState.hpp:104
std::reference_wrapper< const ParallelWellInfo< Scalar > > parallel_info
Definition: SingleWellState.hpp:99
void update_injector_targets(const Well &ecl_well, const SummaryState &st)
ALQState< Scalar > alq_state
Definition: SingleWellState.hpp:168
Scalar sum_filtrate_total() const
Scalar sum_microbial_rates() const
std::vector< Scalar > implicit_ipr_a
Definition: SingleWellState.hpp:152
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:153
RateIndices
Definition: SingleWellState.hpp:118
@ vaporized_water
Definition: SingleWellState.hpp:122
@ dissolved_gas_in_water
Definition: SingleWellState.hpp:120
@ dissolved_gas
Definition: SingleWellState.hpp:119
@ vaporized_oil
Definition: SingleWellState.hpp:121
static const int gasPhaseIdx
Definition: SingleWellState.hpp:48
bool operator==(const SingleWellState &) const
std::vector< Scalar > primaryvar
Definition: SingleWellState.hpp:167
Scalar sum_brine_rates() const
bool was_shut_before_action_applied
Definition: SingleWellState.hpp:172
SegmentState< Scalar > segments
Definition: SingleWellState.hpp:163
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:115
std::vector< Scalar > well_potentials
Definition: SingleWellState.hpp:150
Scalar energy_rate
Definition: SingleWellState.hpp:110
bool updateStatus(WellStatus status)
static const int waterPhaseIdx
Definition: SingleWellState.hpp:46
std::string name
Definition: SingleWellState.hpp:98
Scalar sum_polymer_rates() const
Events events
Definition: SingleWellState.hpp:164
Scalar temperature
Definition: SingleWellState.hpp:109
Scalar frac_rate
Definition: SingleWellState.hpp:157
bool trivial_group_target
Definition: SingleWellState.hpp:159
WellInjectorCMode injection_cmode
Definition: SingleWellState.hpp:165
PhaseUsageInfo< IndexTraits > pu
Definition: SingleWellState.hpp:103
bool producer
Definition: SingleWellState.hpp:102
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:112
bool use_group_target_fallback
Definition: SingleWellState.hpp:162
PerfData< Scalar > perf_data
Definition: SingleWellState.hpp:158
std::vector< Scalar > reservoir_rates
Definition: SingleWellState.hpp:155
@ NONE
Definition: DeferredLogger.hpp:46
Definition: blackoilbioeffectsmodules.hh:45
Static data associated with a well perforation.
Definition: PerforationData.hpp:30
Definition: SingleWellState.hpp:125
Group::ProductionCMode production_cmode
Definition: SingleWellState.hpp:128
bool operator==(const GroupTarget &other) const
Definition: SingleWellState.hpp:132
Scalar target_value
Definition: SingleWellState.hpp:127
Scalar guiderate_ratio
Definition: SingleWellState.hpp:130
Group::InjectionCMode injection_cmode
Definition: SingleWellState.hpp:129
void serializeOp(Serializer &serializer)
Definition: SingleWellState.hpp:141
std::string group_name
Definition: SingleWellState.hpp:126