TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Saturation_constant.cpp
1/****************************************************************************
2* Copyright (c) 2023, 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 <Saturation_constant.h>
17
18Implemente_instanciable(Saturation_constant, "Saturation_constant", Saturation_base);
19// XD saturation_constant saturation_base saturation_constant INHERITS_BRACE Class for saturation constant
20// XD attr P_sat floattant P_sat OPT Define the saturation pressure value (this is a required parameter)
21// XD attr T_sat floattant T_sat OPT Define the saturation temperature value (this is a required parameter)
22// XD attr Lvap floattant Lvap OPT Latent heat of vaporization
23// XD attr Hlsat floattant Hlsat OPT Liquid saturation enthalpy
24// XD attr Hvsat floattant Hvsat OPT Vapor saturation enthalpy
25
26Sortie& Saturation_constant::printOn(Sortie& os) const { return os; }
27
29{
30 Param param(que_suis_je());
31 param.ajouter("Tsat", &tsat_,Param::REQUIRED);
32 param.ajouter("Psat", &psat_,Param::REQUIRED);
33 param.ajouter("Lvap", &lvap_);
34 param.ajouter("Hlsat", &hls_);
35 param.ajouter("Hvsat", &hvs_);
36 param.ajouter("tension_superficielle", &sigma__);
37 param.lire_avec_accolades_depuis(is);
38 // verifications hlsat/hvsat/lvap
39 const int i = (lvap_ > 0) + (hls_ > 0) + (hvs_ > 0);
40 if (i != 2) Process::exit(que_suis_je() + " Please give 2 properties among {Lvap, Hlsat, Hvsat}");
41 if (lvap_ > 0 && hls_ > 0) hvs_ = hls_ + lvap_;
42 else if (lvap_ > 0 && hvs_ > 0) hls_ = hvs_ - lvap_;
43 else if (hls_ > 0 && hvs_ > 0) lvap_ = hvs_ - hls_;
44 else Process::exit(que_suis_je() + "bad parameters");
45 return is;
46}
47
48void Saturation_constant::Tsat_(const SpanD P, SpanD res, int ncomp, int ind) const
49{
50 for (int i =0; i < (int)P.size(); i++) res[i * ncomp + ind] = tsat_;
51}
52
53void Saturation_constant::dP_Tsat_(const SpanD P, SpanD res, int ncomp, int ind) const
54{
55 for (int i =0; i < (int)P.size(); i++) res[i * ncomp + ind] = 0.;
56}
57
58void Saturation_constant::Psat_(const SpanD T, SpanD res, int ncomp, int ind) const
59{
60 for (int i =0; i < (int)T.size() / ncomp; i++) res[i * ncomp + ind] = psat_;
61}
62
63void Saturation_constant::dT_Psat_(const SpanD T, SpanD res, int ncomp, int ind) const
64{
65 for (int i =0; i < (int)T.size() / ncomp; i++) res[i * ncomp + ind] = 0.;
66}
67
68void Saturation_constant::Lvap_(const SpanD P, SpanD res, int ncomp, int ind) const
69{
70 for (int i =0; i < (int)P.size(); i++) res[i * ncomp + ind] = lvap_;
71}
72
73void Saturation_constant::dP_Lvap_(const SpanD P, SpanD res, int ncomp, int ind) const
74{
75 for (int i =0; i < (int)P.size(); i++) res[i * ncomp + ind] = 0.;
76}
77
78void Saturation_constant::Hls_(const SpanD P, SpanD res, int ncomp, int ind) const
79{
80 for (int i =0; i < (int)P.size(); i++) res[i * ncomp + ind] = hls_;
81}
82
83void Saturation_constant::dP_Hls_(const SpanD P, SpanD res, int ncomp, int ind) const
84{
85 for (int i =0; i < (int)P.size(); i++) res[i * ncomp + ind] = 0.;
86}
87
88void Saturation_constant::Hvs_(const SpanD P, SpanD res, int ncomp, int ind) const
89{
90 for (int i =0; i < (int)P.size(); i++) res[i * ncomp + ind] = hvs_;
91}
92
93void Saturation_constant::dP_Hvs_(const SpanD P, SpanD res, int ncomp, int ind) const
94{
95 for (int i =0; i < (int)P.size(); i++) res[i * ncomp + ind] = 0.;
96}
97
98void Saturation_constant::sigma_(const SpanD T, const SpanD P, SpanD res, int ncomp, int ind) const
99{
100 if (sigma__ <= 0) Process::exit(que_suis_je() + ": expected positive value of the surface tension");
101 for (int i =0; i < (int)P.size(); i++) res[i * ncomp + ind] = sigma__;
102}
103
104void Saturation_constant::sigma_h_(const SpanD H, const SpanD P, SpanD res, int ncomp, int ind) const
105{
106 if (sigma__ <= 0) Process::exit(que_suis_je() + ": expected positive value of the surface tension");
107 for (int i =0; i < (int)P.size(); i++) res[i * ncomp + ind] = sigma__;
108}
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
const Nom & que_suis_je() const
renvoie la chaine identifiant la classe.
Definition Objet_U.cpp:104
virtual Entree & readOn(Entree &)
Lecture d'un Objet_U sur un flot d'entree Methode a surcharger.
Definition Objet_U.cpp:293
virtual Sortie & printOn(Sortie &) const
Ecriture de l'objet sur un flot de sortie Methode a surcharger.
Definition Objet_U.cpp:282
@ REQUIRED
Definition Param.h:115
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
Definition Process.cpp:455
Classe de base des flux de sortie.
Definition Sortie.h:52