opm-common
CompositionalConfig.hpp
1 /*
2  Copyright (C) 2024 SINTEF Digital, Mathematics and Cybernetics.
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_COMPOSITIONALCONFIG_HPP
21 #define OPM_COMPOSITIONALCONFIG_HPP
22 
23 #include <opm/input/eclipse/Units/Units.hpp>
24 
25 #include <array>
26 #include <cstddef>
27 #include <string>
28 #include <vector>
29 
30 namespace Opm {
31 
32 class Deck;
33 class Runspec;
34 
36 public:
37  enum class EOSType {
38  PR, // Peng-Robinson
39  PRCORR, // Peng-Robinson modified
40  RK, // Redlich-Kwong
41  SRK, // Soave-Redlich-Kwong
42  ZJ // Zudkevitch-Joffe-Redlich-Kwong
43  };
44 
45  static EOSType eosTypeFromString(const std::string& str);
46 
47  static std::string eosTypeToString(EOSType eos);
48 
49  // The item defaults of the LBCCOEF keyword.
50  static std::array<double, 5> defaultLBCCoefficients();
51 
52  // Properties of one EOS region. The same set of properties exists for
53  // reservoir-condition regions (EOS, MW, ACF, ...) and surface-condition
54  // regions (EOSS, MWS, ACFS, ...).
55  struct EOSProps {
56  EOSType eos_type = EOSType::PR;
57  std::vector<double> molecular_weights;
58  std::vector<double> acentric_factors;
59  std::vector<double> critical_pressure;
60  std::vector<double> critical_temperature;
61  std::vector<double> boiling_temperature;
62  std::vector<double> critical_volume;
63  std::vector<double> volume_shifts;
64  std::vector<double> critical_z_factor;
65  std::vector<double> binary_interaction_coefficient;
66  std::vector<double> omega_a;
67  std::vector<double> omega_b;
68 
69  bool operator==(const EOSProps& other) const;
70 
71  template<class Serializer>
72  void serializeOp(Serializer& serializer)
73  {
74  serializer(eos_type);
75  serializer(molecular_weights);
76  serializer(acentric_factors);
77  serializer(critical_pressure);
78  serializer(critical_temperature);
79  serializer(boiling_temperature);
80  serializer(critical_volume);
81  serializer(volume_shifts);
82  serializer(critical_z_factor);
83  serializer(binary_interaction_coefficient);
84  serializer(omega_a);
85  serializer(omega_b);
86  }
87  };
88 
89  CompositionalConfig() = default;
90 
91  CompositionalConfig(const Deck& deck, const Runspec& runspec);
92 
93  static CompositionalConfig serializationTestObject();
94 
95  bool operator==(const CompositionalConfig& other) const;
96 
97  // accessing functions
98  double standardTemperature() const;
99  double standardPressure() const;
100  const std::vector<std::string>& compName() const;
101 
102  // All properties of one reservoir or surface condition EOS region.
103  const EOSProps& eosProps(std::size_t eos_region) const;
104  const EOSProps& eosPropsSurf(std::size_t eos_region) const;
105 
106  EOSType eosType(std::size_t eos_region) const;
107  const std::vector<double>& molecularWeights(std::size_t eos_region) const;
108  const std::vector<double>& acentricFactors(std::size_t eos_region) const;
109  const std::vector<double>& criticalPressure(std::size_t eos_region) const;
110  const std::vector<double>& criticalTemperature(std::size_t eos_region) const;
111  const std::vector<double>& boilingTemperature(std::size_t eos_region) const;
112  const std::vector<double>& criticalVolume(std::size_t eos_region) const;
113  const std::vector<double>& volumeShifts(std::size_t eos_region) const;
114  const std::vector<double>& binaryInteractionCoefficient(std::size_t eos_region) const;
115  const std::vector<double>& criticalZFactor(std::size_t eos_region) const;
116  const std::vector<double>& omegaA(std::size_t eos_region) const;
117  const std::vector<double>& omegaB(std::size_t eos_region) const;
118  const std::array<double, 5>& lbcCoefficients() const;
119 
120  // Accessors for surface EOS regions.
121  EOSType eosTypeSurf(std::size_t eos_region) const;
122  const std::vector<double>& molecularWeightsSurf(std::size_t eos_region) const;
123  const std::vector<double>& acentricFactorsSurf(std::size_t eos_region) const;
124  const std::vector<double>& criticalPressureSurf(std::size_t eos_region) const;
125  const std::vector<double>& criticalTemperatureSurf(std::size_t eos_region) const;
126  const std::vector<double>& boilingTemperatureSurf(std::size_t eos_region) const;
127  const std::vector<double>& criticalVolumeSurf(std::size_t eos_region) const;
128  const std::vector<double>& criticalZFactorSurf(std::size_t eos_region) const;
129  const std::vector<double>& volumeShiftsSurf(std::size_t eos_region) const;
130  const std::vector<double>& binaryInteractionCoefficientSurf(std::size_t eos_region) const;
131  const std::vector<double>& omegaASurf(std::size_t eos_region) const;
132  const std::vector<double>& omegaBSurf(std::size_t eos_region) const;
133 
134  std::size_t numComps() const;
135 
136  template<class Serializer>
137  void serializeOp(Serializer& serializer)
138  {
139  serializer(num_comps);
140  serializer(standard_temperature);
141  serializer(standard_pressure);
142  serializer(comp_names);
143  serializer(reservoir_props);
144  serializer(surface_props);
145  serializer(lbc_coefficients);
146  }
147 
148 private:
149  // TODO: num_comps might not be totally necessary, while might be convenient.
150  // We can check the number of components without accessing Runspec
151  std::size_t num_comps = 0;
152  double standard_temperature = 288.71; // Kelvin
153  double standard_pressure = 1.0 * unit::atm; // 1 atm
154  std::vector<std::string> comp_names;
155 
156  // Coefficients for the Lorentz-Bray-Clark viscosity correlation (LBCCOEF).
157  // A single set is used for all EOS regions.
158  std::array<double, 5> lbc_coefficients = defaultLBCCoefficients();
159 
160  // One set of properties for each reservoir condition EOS region
161  std::vector<EOSProps> reservoir_props;
162 
163  // One set of properties for each surface condition EOS region
164  std::vector<EOSProps> surface_props;
165 };
166 
167 }
168 #endif // OPM_COMPOSITIONALCONFIG_HPP
Definition: CompositionalConfig.hpp:35
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:30
Definition: Runspec.hpp:608
Definition: CompositionalConfig.hpp:55
Definition: Deck.hpp:46
Class for (de-)serializing.
Definition: Serializer.hpp:95