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