TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
EOS_to_TRUST.cpp
1/****************************************************************************
2 * Copyright (c) 2021, 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 <EOS_to_TRUST.h>
17#include <Process.h>
18
19
21{
22#ifdef HAS_EOS
23 if (op)
24 {
25 handler.set_exit_on_error(NEPTUNE::EOS_Std_Error_Handler::disable_feature); // EOS should never exit()
26 handler.set_throw_on_error(NEPTUNE::EOS_Std_Error_Handler::disable_feature); // EOS should never throw() an exception
27 handler.set_dump_on_error(NEPTUNE::EOS_Std_Error_Handler::disable_feature);
28 // handler.set_dump_on_error(ok);
29 // handler.set_dump_stream(cerr);
30 }
31 else
32 {
33 handler.set_exit_on_error(NEPTUNE::ok);
34 handler.set_throw_on_error(NEPTUNE::ok);
35 handler.set_dump_on_error(NEPTUNE::ok);
36 }
37#else
38 Cerr << "EOS_to_TRUST::" << __func__ << " should not be called since TRUST is not compiled with the EOS library !!! " << finl;
39 throw;
40#endif
41}
42
43int EOS_to_TRUST::compute_eos_field(const SpanD P_ou_T, SpanD res,const char *const property_title, const char *const property_name, bool is_T) const
44{
45#ifdef HAS_EOS
46 const char *const pp_ = is_T ? "Temperature" : "Pressure";
47 const char *const tt_ = is_T ? "T" : "P";
48 NEPTUNE::EOS_Field P_fld(pp_, tt_, (int)P_ou_T.size(), (double*)P_ou_T.begin());
49 NEPTUNE::EOS_Field z_fld(property_title,property_name, (int)res.size(), (double*)res.begin());
50 NEPTUNE::ArrOfInt tmp((int)P_ou_T.size());
51 NEPTUNE::EOS_Error_Field ferr(tmp);
52 NEPTUNE::EOS_Error cr = fluide->compute(P_fld, z_fld, ferr);
53 return (int)cr;
54#else
55 Cerr << "EOS_to_TRUST::" << __func__ << " should not be called since TRUST is not compiled with the EOS library !!! " << finl;
56 throw;
57#endif
58}
59
60int EOS_to_TRUST::compute_eos_field(const SpanD P, const SpanD T, SpanD res,const char *const property_title, const char *const property_name) const
61{
62#ifdef HAS_EOS
63 NEPTUNE::EOS_Field T_fld("Temperature", "T", (int)T.size(),(double*)T.begin()), P_fld("Pressure", "P", (int)P.size(), (double*)P.begin());
64 NEPTUNE::EOS_Field z_fld(property_title,property_name, (int)res.size(), (double*)res.begin());
65 NEPTUNE::ArrOfInt tmp((int)P.size());
66 NEPTUNE::EOS_Error_Field ferr(tmp);
67 NEPTUNE::EOS_Error cr = fluide->compute(P_fld, T_fld, z_fld, ferr);
68 return (int)cr;
69#else
70 Cerr << "EOS_to_TRUST::" << __func__ << " should not be called since TRUST is not compiled with the EOS library !!! " << finl;
71 throw;
72#endif
73}
74
75int EOS_to_TRUST::compute_eos_field_h(const SpanD P, const SpanD H, SpanD res,const char *const property_title, const char *const property_name) const
76{
77#ifdef HAS_EOS
78 NEPTUNE::EOS_Field H_fld("Enthalpy", "h", (int)H.size(),(double*)H.begin()), P_fld("Pressure", "P", (int)P.size(), (double*)P.begin());
79 NEPTUNE::EOS_Field z_fld(property_title,property_name, (int)res.size(), (double*)res.begin());
80 NEPTUNE::ArrOfInt tmp((int)P.size());
81 NEPTUNE::EOS_Error_Field ferr(tmp);
82 NEPTUNE::EOS_Error cr = fluide->compute(P_fld, H_fld, z_fld, ferr);
83 return (int)cr;
84#else
85 Cerr << "EOS_to_TRUST::" << __func__ << " should not be called since TRUST is not compiled with the EOS library !!! " << finl;
86 throw;
87#endif
88}
89
91{
92#ifdef HAS_EOS
93 if (tmax_ < -10.)
94 {
95 tmin_ = tppi_get_T_min();
96 tmax_ = tppi_get_T_max();
97 pmin_ = tppi_get_p_min();
98 pmax_ = tppi_get_p_max();
99 hmin_ = tppi_get_h_min();
100 hmax_ = tppi_get_h_max();
101 rhomin_ = tppi_get_rho_min();
102 rhomax_ = tppi_get_rho_max();
103 }
104
105 return { { "temperature", { tmin_, tmax_}}, { "pression", { pmin_, pmax_}},
106 { "enthalpie", { hmin_, hmax_}}, { "rho", { rhomin_, rhomax_}}
107 };
108#else
109 Cerr << "EOS_to_TRUST::" << __func__ << " should not be called since TRUST is not compiled with the EOS library !!! " << finl;
110 throw;
111#endif
112}
113
115{
116#ifdef HAS_EOS
117 double tmp_;
118 fluide->get_p_min(tmp_);
119 return tmp_;
120#else
121 Cerr << "EOS_to_TRUST::" << __func__ << " should not be called since TRUST is not compiled with the EOS library !!! " << finl;
122 throw;
123#endif
124}
125
127{
128#ifdef HAS_EOS
129 double tmp_;
130 fluide->get_p_max(tmp_);
131 return tmp_;
132#else
133 Cerr << "EOS_to_TRUST::" << __func__ << " should not be called since TRUST is not compiled with the EOS library !!! " << finl;
134 throw;
135#endif
136}
137
139{
140#ifdef HAS_EOS
141 double tmp_;
142 fluide->get_h_min(tmp_);
143 return tmp_;
144#else
145 Cerr << "EOS_to_TRUST::" << __func__ << " should not be called since TRUST is not compiled with the EOS library !!! " << finl;
146 throw;
147#endif
148}
149
151{
152#ifdef HAS_EOS
153 double tmp_;
154 fluide->get_h_max(tmp_);
155 return tmp_;
156#else
157 Cerr << "EOS_to_TRUST::" << __func__ << " should not be called since TRUST is not compiled with the EOS library !!! " << finl;
158 throw;
159#endif
160}
161
163{
164#ifdef HAS_EOS
165 double tmp_;
166 fluide->get_T_min(tmp_);
167 return tmp_;
168#else
169 Cerr << "EOS_to_TRUST::" << __func__ << " should not be called since TRUST is not compiled with the EOS library !!! " << finl;
170 throw;
171#endif
172}
173
175{
176#ifdef HAS_EOS
177 double tmp_;
178 fluide->get_T_max(tmp_);
179 return tmp_;
180#else
181 Cerr << "EOS_to_TRUST::" << __func__ << " should not be called since TRUST is not compiled with the EOS library !!! " << finl;
182 throw;
183#endif
184}
185
187{
188#ifdef HAS_EOS
189 double tmp_;
190 fluide->get_rho_min(tmp_);
191 return tmp_;
192#else
193 Cerr << "EOS_to_TRUST::" << __func__ << " should not be called since TRUST is not compiled with the EOS library !!! " << finl;
194 throw;
195#endif
196}
197
199{
200#ifdef HAS_EOS
201 double tmp_;
202 fluide->get_rho_max(tmp_);
203 return tmp_;
204#else
205 Cerr << "EOS_to_TRUST::" << __func__ << " should not be called since TRUST is not compiled with the EOS library !!! " << finl;
206 throw;
207#endif
208}
209
211{
212#ifdef HAS_EOS
213 double tmp_;
214 fluide->get_p_crit(tmp_);
215 return tmp_;
216#else
217 Cerr << "EOS_to_TRUST::" << __func__ << " should not be called since TRUST is not compiled with the EOS library !!! " << finl;
218 throw;
219#endif
220}
221
223{
224#ifdef HAS_EOS
225 double tmp_;
226 fluide->get_h_crit(tmp_);
227 return tmp_;
228#else
229 Cerr << "EOS_to_TRUST::" << __func__ << " should not be called since TRUST is not compiled with the EOS library !!! " << finl;
230 throw;
231#endif
232}
233
235{
236#ifdef HAS_EOS
237 double tmp_;
238 fluide->get_T_crit(tmp_);
239 return tmp_;
240#else
241 Cerr << "EOS_to_TRUST::" << __func__ << " should not be called since TRUST is not compiled with the EOS library !!! " << finl;
242 throw;
243#endif
244}
245
247{
248#ifdef HAS_EOS
249 double tmp_;
250 fluide->get_rho_crit(tmp_);
251 return tmp_;
252#else
253 Cerr << "EOS_to_TRUST::" << __func__ << " should not be called since TRUST is not compiled with the EOS library !!! " << finl;
254 throw;
255#endif
256}
double tppi_get_T_min() const override final
double tppi_get_h_crit() const override final
double tppi_get_p_min() const override final
double tppi_get_h_min() const override final
double tppi_get_h_max() const override final
double tppi_get_T_crit() const override final
double tppi_get_p_crit() const override final
double tppi_get_rho_max() const override final
MRange all_unknowns_range() override final
int compute_eos_field(const SpanD P, SpanD res, const char *const pt, const char *const pn, bool is_T=false) const
void desactivate_handler(bool op=true) override
double tppi_get_rho_min() const override final
double tppi_get_rho_crit() const override final
int compute_eos_field_h(const SpanD P, const SpanD H, SpanD res, const char *const pt, const char *const pn) const
double tppi_get_T_max() const override final
double tppi_get_p_max() const override final