Documentation 6b54b78464
Loading...
Searching...
No Matches
CCoolPropViscosity.hpp
Go to the documentation of this file.
1/*!
2 * \file CCoolPropViscosity.hpp
3 * \brief Defines CoolPropviscosity model.
4 * \author P.Yan, G. Gori, A. Guardone,
5 * \version 8.5.0 "Harrier"
6 *
7 * SU2 Project Website: https://su2code.github.io
8 *
9 * The SU2 Project is maintained by the SU2 Foundation
10 * (http://su2foundation.org)
11 *
12 * Copyright 2012-2026, SU2 Contributors (cf. AUTHORS.md)
13 *
14 * SU2 is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU Lesser General Public
16 * License as published by the Free Software Foundation; either
17 * version 2.1 of the License, or (at your option) any later version.
18 *
19 * SU2 is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 * Lesser General Public License for more details.
23 *
24 * You should have received a copy of the GNU Lesser General Public
25 * License along with SU2. If not, see <http://www.gnu.org/licenses/>.
26 */
27
28#pragma once
29
30#include "CCoolProp.hpp"
31#include "CViscosityModel.hpp"
32
33#ifdef USE_COOLPROP
34#include "AbstractState.h"
35#include "CoolProp.h"
36#endif
37/*!
38 * \class CCoolPropViscosity
39 * \brief Defines CoolProp viscosity model.
40 * \author P.Yan
41 */
42class CCoolPropViscosity final : public CViscosityModel {
43 private:
44#ifdef USE_COOLPROP
45 std::unique_ptr<CoolProp::AbstractState> fluid_entity; /*!< \brief fluid entity */
46#endif
47 /*!< \brief list of fluids whose viscosity model is available in CoolProp */
48 const vector<string> fluidNameList = {"Air",
49 "Ammonia",
50 "Argon",
51 "Benzene",
52 "CarbonDioxide",
53 "CycloHexane",
54 "Cyclopentane",
55 "DimethylEther",
56 "Ethane",
57 "Ethanol",
58 "HeavyWater",
59 "Helium",
60 "Hydrogen",
61 "HydrogenSulfide",
62 "IsoButane",
63 "Isopentane",
64 "Methane",
65 "Methanol",
66 "Nitrogen",
67 "Oxygen",
68 "Propylene",
69 "R11",
70 "R116",
71 "R12",
72 "R123",
73 "R1233zd(E)",
74 "R1234yf",
75 "R1234ze(E)",
76 "R124",
77 "R125",
78 "R13",
79 "R134a",
80 "R14",
81 "R141b",
82 "R142b",
83 "R143a",
84 "R152A",
85 "R218",
86 "R22",
87 "R227EA",
88 "R23",
89 "R236EA",
90 "R236FA",
91 "R245fa",
92 "R32",
93 "R404A",
94 "R407C",
95 "R410A",
96 "R507A",
97 "RC318",
98 "SulfurHexafluoride",
99 "Toluene",
100 "Water",
101 "m-Xylene",
102 "n-Butane",
103 "n-Decane",
104 "n-Dodecane",
105 "n-Heptane",
106 "n-Hexane",
107 "n-Nonane",
108 "n-Octane",
109 "n-Pentane",
110 "n-Propane",
111 "o-Xylene",
112 "p-Xylene"};
113
114 public:
115 /*!
116 * \brief Constructor of the class.
117 */
118 CCoolPropViscosity(const string& fluidname) {
119#ifdef USE_COOLPROP
120 fluid_entity = std::unique_ptr<CoolProp::AbstractState>(CoolProp::AbstractState::factory("HEOS", fluidname));
121 if (std::find(fluidNameList.begin(), fluidNameList.end(), fluidname) == fluidNameList.end()) {
122 SU2_MPI::Error("Viscosity model not available for this fluid in CoolProp library.", CURRENT_FUNCTION);
123 }
124#else
126 "SU2 was not compiled with CoolProp (-Denable-coolprop=true). Note that CoolProp cannot be used with "
127 "directdiff or autodiff",
129#endif
130 }
131
132 /*!
133 * \brief Set Viscosity.
134 */
135 void SetViscosity(su2double t, su2double rho) override {
136#ifdef USE_COOLPROP
137 fluid_entity->update(CoolProp::DmassT_INPUTS, rho, t);
138 mu_ = fluid_entity->viscosity();
139#endif
140 }
141};
Defines the state-of-the-art fluid model from CoolProp library.
Interface class for defining laminar viscosity models.
static void Error(const std::string &ErrorMsg, const std::string &FunctionName)
Definition mpi_structure.cpp:131
Defines CoolProp viscosity model.
Definition CCoolPropViscosity.hpp:42
void SetViscosity(su2double t, su2double rho) override
Set Viscosity.
Definition CCoolPropViscosity.hpp:135
CCoolPropViscosity(const string &fluidname)
Constructor of the class.
Definition CCoolPropViscosity.hpp:118
Interface class for defining the laminar viscosity model.
Definition CViscosityModel.hpp:39
su2double mu_
Dynamic viscosity.
Definition CViscosityModel.hpp:67
passivedouble su2double
Definition code_config.hpp:181
#define CURRENT_FUNCTION
Definition mpi_structure.hpp:59