TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
CoolProp_to_TRUST.cpp
1/****************************************************************************
2* Copyright (c) 2024, CEA
3* All rights reserved.
4*
5* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
9*
10* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
11* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
12* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
13*
14*****************************************************************************/
15
16#include <CoolProp_to_TRUST.h>
17#include <cstdlib>
18
20{
21 if (phase_name == "LIQUID" || phase_name == "LIQUIDE") return;
22 if (phase_name == "VAPOR" || phase_name == "VAPEUR") return;
23 if (phase_name == "UNKNOWN" || phase_name == "NOT_SET") return;
24
25 Cerr << "Error in CoolProp_to_TRUST::" << __func__ << " !! The phase " << phase_name << " is not a recognized word !" << finl;
26 Cerr << "Please specify a phase of the following : liquid|liquide / vapor|vapeur / unknown / not_set ! Otherise dont specify any phase CoolProp will guess it !" << finl;
28}
29
31{
32#ifdef HAS_COOLPROP
33 const char *use_refprop = std::getenv("TRUST_USE_REFPROP");
34
35 if (use_refprop != nullptr && std::string(use_refprop) == "1")
36 {
37 const char * refprop_dir = std::getenv("TRUST_REFPROP_HOME_DIR");
38 assert (refprop_dir != nullptr);
39 CoolProp::set_config_string(configuration_keys::ALTERNATIVE_REFPROP_PATH, std::string(refprop_dir));
40 }
41 else
42 {
43 Cerr << "You want to use the RefProp model but no path is provided towards the RefProp install !" << finl;
44 Cerr << "Check your TRUST configuration !" << finl;
46 }
47#else
48 Cerr << "CoolProp_to_TRUST::" << __func__ << " should not be called since TRUST is not compiled with the CoolProp library !!! " << finl;
49 throw;
50#endif
51}
52
53void CoolProp_to_TRUST::set_phase(const Motcle& phase_name)
54{
55#ifdef HAS_COOLPROP
56 assert(fluide != nullptr);
57 if (phase_name == "LIQUID" || phase_name == "LIQUIDE")
58 fluide->specify_phase(CoolProp::iphase_liquid);
59 else if (phase_name == "VAPOR" || phase_name == "VAPEUR")
60 fluide->specify_phase(CoolProp::iphase_gas);
61 else if (phase_name == "UNKNOWN")
62 fluide->specify_phase(CoolProp::iphase_unknown);
63 else if (phase_name == "NOT_SET")
64 fluide->specify_phase(CoolProp::iphase_not_imposed);
65 else
66 verify_phase(phase_name);
67#else
68 Cerr << "CoolProp_to_TRUST::" << __func__ << " should not be called since TRUST is not compiled with the CoolProp library !!! " << finl;
69 throw;
70#endif
71}
72
74{
75#ifdef HAS_COOLPROP
76 return fluide->p_triple();
77#else
78 Cerr << "CoolProp_to_TRUST::" << __func__ << " should not be called since TRUST is not compiled with the CoolProp library !!! " << finl;
79 throw;
80#endif
81}
82
84{
85#ifdef HAS_COOLPROP
86 return fluide->pmax();
87#else
88 Cerr << "CoolProp_to_TRUST::" << __func__ << " should not be called since TRUST is not compiled with the CoolProp library !!! " << finl;
89 throw;
90#endif
91}
92
94{
95#ifdef HAS_COOLPROP
96 const double T_min = fluide->Tmin(), p_min = fluide->p_triple();
97 std::array<double,1> t = { T_min }, p = { p_min }, h = { 0. };
98 tppi_get_h_pT(p, t , h);
99 return h[0];
100#else
101 Cerr << "CoolProp_to_TRUST::" << __func__ << " should not be called since TRUST is not compiled with the CoolProp library !!! " << finl;
102 throw;
103#endif
104}
105
107{
108#ifdef HAS_COOLPROP
109 const double T_max = fluide->Tmax(), p_max = fluide->pmax();
110 std::array<double,1> t = { T_max }, p = { p_max }, h = { 0. };
111 tppi_get_h_pT(p, t , h);
112 return h[0];
113#else
114 Cerr << "CoolProp_to_TRUST::" << __func__ << " should not be called since TRUST is not compiled with the CoolProp library !!! " << finl;
115 throw;
116#endif
117}
118
120{
121#ifdef HAS_COOLPROP
122 return fluide->Tmin();
123#else
124 Cerr << "CoolProp_to_TRUST::" << __func__ << " should not be called since TRUST is not compiled with the CoolProp library !!! " << finl;
125 throw;
126#endif
127}
128
130{
131#ifdef HAS_COOLPROP
132 return fluide->Tmax();
133#else
134 Cerr << "CoolProp_to_TRUST::" << __func__ << " should not be called since TRUST is not compiled with the CoolProp library !!! " << finl;
135 throw;
136#endif
137}
138
140{
141#ifdef HAS_COOLPROP
142 Cerr << "CoolProp_to_TRUST::" << __func__ << " is not implemented ... Call 911 for help ! " << finl;
143 throw;
144#else
145 Cerr << "CoolProp_to_TRUST::" << __func__ << " should not be called since TRUST is not compiled with the CoolProp library !!! " << finl;
146 throw;
147#endif
148}
149
151{
152#ifdef HAS_COOLPROP
153 Cerr << "CoolProp_to_TRUST::" << __func__ << " is not implemented ... Call 911 for help ! " << finl;
154 throw;
155#else
156 Cerr << "CoolProp_to_TRUST::" << __func__ << " should not be called since TRUST is not compiled with the CoolProp library !!! " << finl;
157 throw;
158#endif
159}
160
162{
163#ifdef HAS_COOLPROP
164 return fluide->p_critical();
165#else
166 Cerr << "CoolProp_to_TRUST::" << __func__ << " should not be called since TRUST is not compiled with the CoolProp library !!! " << finl;
167 throw;
168#endif
169}
170
172{
173#ifdef HAS_COOLPROP
174 Cerr << "CoolProp_to_TRUST::" << __func__ << " is not implemented ... Call 911 for help ! " << finl;
175 throw;
176#else
177 Cerr << "CoolProp_to_TRUST::" << __func__ << " should not be called since TRUST is not compiled with the CoolProp library !!! " << finl;
178 throw;
179#endif
180}
181
183{
184#ifdef HAS_COOLPROP
185 return fluide->T_critical();
186#else
187 Cerr << "CoolProp_to_TRUST::" << __func__ << " should not be called since TRUST is not compiled with the CoolProp library !!! " << finl;
188 throw;
189#endif
190}
191
193{
194#ifdef HAS_COOLPROP
195 return fluide->rhomass_critical();
196#else
197 Cerr << "CoolProp_to_TRUST::" << __func__ << " should not be called since TRUST is not compiled with the CoolProp library !!! " << finl;
198 throw;
199#endif
200}
double tppi_get_h_crit() const override final
double tppi_get_h_max() const override final
double tppi_get_rho_min() const override final
void set_phase(const Motcle &) override
void set_path_refprop() override
double tppi_get_rho_crit() const override final
double tppi_get_T_crit() const override final
double tppi_get_p_min() const override final
double tppi_get_T_min() const override final
double tppi_get_rho_max() const override final
double tppi_get_h_min() const override final
double tppi_get_T_max() const override final
double tppi_get_p_crit() const override final
double tppi_get_p_max() const override final
void verify_phase(const Motcle &) override
Une chaine de caractere (Nom) en majuscules.
Definition Motcle.h:26
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
Definition Process.cpp:455
virtual int tppi_get_h_pT(const SpanD P, const SpanD T, SpanD R, int ncomp=1, int ind=0) const
Definition TPPI.h:87