TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Loi_Etat_Binaire_GP_base.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 <Loi_Etat_Binaire_GP_base.h>
17#include <Fluide_Dilatable_base.h>
18#include <Champ_Fonc_Tabule.h>
19#include <Champ_Uniforme.h>
20#include <Param.h>
21#include <Debog.h>
22
23Implemente_base_sans_constructeur(Loi_Etat_Binaire_GP_base,"Loi_Etat_Binaire_Gaz_Parfait_base",Loi_Etat_Melange_GP_base);
24
27
29{
30 os <<que_suis_je()<< finl;
31 return os;
32}
33
35{
36 Param param(que_suis_je());
37 param.ajouter("molar_mass1",&massmol1_,Param::REQUIRED);
38 param.ajouter("molar_mass2",&massmol2_,Param::REQUIRED);
39 param.ajouter("mu1",&mu1_,Param::REQUIRED);
40 param.ajouter("mu2",&mu2_,Param::REQUIRED);
41 param.ajouter("temperature",&tempr_,Param::REQUIRED);
42 param.ajouter("diffusion_coeff",&diff_coeff_,Param::REQUIRED);
43 param.lire_avec_accolades_depuis(is);
44 return is;
45}
46
48{
49 /* Do nothing */
50}
51
52/*! @brief Computes the mixture dynamic viscosity (depends on mass fractions). See Wilke https://aip.
53 *
54 * @brief scitation.org/doi/pdf/10.1063/1.1747673
55 *
56 */
58{
59 const DoubleTab& tab_Y1 = le_fluide->inco_chaleur().valeurs();
60 DoubleTab& tab_mu = le_fluide->viscosite_dynamique().valeurs();
61
62 int i, n=tab_mu.size();
63 for (i=0 ; i<n ; i++)
64 {
65 double m1om2 = massmol1_/massmol2_;
66 double m2om1 = 1./m1om2;
67 double mu1omu2 = mu1_/mu2_;
68 double mu2omu1 = 1./mu1omu2;
69
70 // XXX : Which is better ?
71 double a1 = 1. + sqrt(mu1omu2) * pow(mu2omu1,0.25);
72 double a2 = 1. + sqrt(mu2omu1) * pow(mu1omu2,0.25);
73 //double a1 = 1. + sqrt(mu1omu2) * exp(0.25*log(mu2omu1));
74 //double a2 = 1. + sqrt(mu2omu1) * exp(0.25*log(mu1omu2));
75 double b1 = sqrt(8.*(1.+m1om2));
76 double b2 = sqrt(8.*(1.+m2om1));
77 double phi_12 = m1om2*a1*a1/b1;
78 double phi_21 = m2om1*a2*a2/b2;
79
80 double y1 = tab_Y1(i,0);
81 double y2 = 1. - y1; // All about binary mixture !
82
83 tab_mu(i,0) = (mu1_*y1)/(y1+y2*phi_12) + (mu2_*y2)/(y2+y1*phi_21);
84 }
86 Debog::verifier("calculer_mu_wilke",tab_mu);
87}
88
89/*! @brief Computes the dynamic viscosity.
90 *
91 */
93{
94 Champ_Don_base& mu = le_fluide->viscosite_dynamique();
95 if (!sub_type(Champ_Uniforme,mu))
96 {
97 if (sub_type(Champ_Fonc_Tabule,mu))
98 {
99 Cerr << "We should not have a dynamic viscosity of type Champ_Fonc_Tabule !" << finl;
101 }
102 else
104 }
105 else
106 {
107 Cerr << "We should not have a dynamic viscosity of type Champ_Uniforme !" << finl;
109 }
110}
111
113{
114 /* Do nothing */
115}
116
117/*! @brief Computes the dynamic viscosity divided by the Schmidt number (rho*D).
118 *
119 */
121{
122 /*
123 * ====================================================================
124 * Schmidt number : Sc = nu / D = mu / ( rho * D )
125 * => rho * D = mu/Sc
126 * species equation : div ( rho * D * grad Y1) = div ( mu/Sc * grad Y1)
127 * ====================================================================
128 */
129
130 Champ_Don_base& mu_sur_Sc = le_fluide->mu_sur_Schmidt();
131 const Champ_base& rho = le_fluide->masse_volumique();
132 DoubleTab& tab_mu_sur_Sc = mu_sur_Sc.valeurs();
133 const DoubleTab& tab_rho = rho.valeurs();
134 const int n=tab_mu_sur_Sc.size();
135
136 if (!sub_type(Champ_Uniforme,mu_sur_Sc))
137 {
138 if (sub_type(Champ_Uniforme,rho))
139 {
140 Cerr << "We should not have a density field of type Champ_Uniforme !" << finl;
142 }
143 else
144 for (int i=0 ; i<n ; i++) tab_mu_sur_Sc(i,0) = tab_rho(i,0)*diff_coeff_;
145 }
146 else
147 {
148 Cerr << "We should not have a mu_sur_Sc of type Champ_Uniforme !" << finl;
150 }
151
152 double temps_champ = rho.temps();
153 mu_sur_Sc.changer_temps(temps_champ);
154 tab_mu_sur_Sc.echange_espace_virtuel();
155}
156
157/*! @brief Computes the kinematic viscosity divided by the Schmidt number (D).
158 *
159 */
161{
162 /*
163 * ====================================================================
164 * Schmidt number : Sc = nu / D
165 * => D = nu/Sc
166 * ====================================================================
167 */
168
169 Champ_Don_base& nu_sur_Sc = le_fluide->nu_sur_Schmidt();
170 DoubleTab& tab_nu_sur_Sc = nu_sur_Sc.valeurs();
171 const int n=tab_nu_sur_Sc.size();
172
173 for (int i=0 ; i<n ; i++) tab_nu_sur_Sc(i,0) = diff_coeff_;
174
175 double temps_champ = le_fluide->masse_volumique().temps();
176 nu_sur_Sc.changer_temps(temps_champ);
177 tab_nu_sur_Sc.echange_espace_virtuel();
178}
179
180/*! @brief Computes Cp. Does nothing: Cp is constant.
181 *
182 */
184{
185 /* Do nothing */
186}
187
188/*! @brief Returns the type of fluid associated.
189 *
190 * @return The fluid type name ("Melange_Binaire").
191 */
193{
194 return "Melange_Binaire";
195}
196
197/*! @brief Computes the thermodynamic pressure from temperature and density.
198 *
199 */
200double Loi_Etat_Binaire_GP_base::inverser_Pth(double Y1, double rho)
201{
202 /*
203 // THIS IS OK, but we dont want to enter here !
204 double RToM2 = R_GAS*tempr_/massmol2_;
205 double mix = 1.0+Y1*(massmol2_/massmol1_-1.0);
206 double p_t = rho * RToM2 * mix ;
207
208 return p_t;
209 */
210 Cerr << "We should not enter in the method Loi_Etat_Binaire_GP_base::inverser_Pth !" << finl;
211 Cerr << "This means that you are trying to solve an ODE for pth which is forbidden for this EOS!" << finl;
212 abort();
213 throw;
214}
215
217{
218 /*
219 * Mixing species state equation
220 * ===========================================================================
221 * rho = ( P * M_mix ) / ( R * T)
222 * with M_mix = 1 / (Y1/M1 + Y2/M2) = = M2 / (M2Y1/M1 + Y2)
223 * But Y2 = 1 - Y1 => M_mix = M2 / (M2Y1/M1 + 1 -Y1) = M2 / (1 + Y1(M2/M1 -1))
224 * ===========================================================================
225 * See https://doi.org/10.1016/j.ijheatmasstransfer.2020.120470
226 */
227 const double PM2 = P*massmol2_;
228 const double RT = R_GAS*tempr_;
229 const double mix = 1.0+Y1*(massmol2_/massmol1_-1.0);
230 const double rh = PM2/(RT*mix);
231
232 return rh;
233}
class Champ_Don_base base class of Given Fields (not calculated)
DoubleTab & valeurs() override
Overrides Champ_base::valeurs() Returns the array of values.
Class Champ_Fonc_Tabule Derived class of Champ_Fonc_base representing.
virtual DoubleTab & valeurs()=0
Champ_Uniforme Represents a field that is constant in space and time.
class Champ_base This class is the base of the fields hierarchy.
Definition Champ_base.h:43
virtual double changer_temps(const double t)
Sets the time at which the field is defined.
double temps() const
Returns the time of the field.
static void verifier(const char *const msg, double)
Definition Debog.cpp:21
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
Base state law class for binary ideal-gas mixtures, defining a dilatable binary fluid with the equati...
void calculer_masse_volumique() override=0
Recomputes the density (masse volumique).
void calculer_lambda() override
Computes the thermal conductivity.
void calculer_mu_sur_Sc() override
Computes the dynamic viscosity divided by the Schmidt number (rho*D).
void calculer_nu_sur_Sc() override
Computes the kinematic viscosity divided by the Schmidt number (D).
void calculer_Cp() override
Computes Cp. Does nothing: Cp is constant.
const Nom type_fluide() const override
Returns the type of fluid associated.
void calculer_mu() override
Computes the dynamic viscosity.
void calculer_alpha() override
Computes the thermal diffusivity.
void calculer_mu_wilke()
Computes the mixture dynamic viscosity (depends on mass fractions). See Wilke https://aip.
double inverser_Pth(double, double) override
Computes the thermodynamic pressure from temperature and density.
State law class for a mixture of ideal gases.
static constexpr double R_GAS
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
const Nom & que_suis_je() const
Returns the string identifying the class.
Definition Objet_U.cpp:104
virtual Entree & readOn(Entree &)
Reads an Objet_U from an input stream. Virtual method to override.
Definition Objet_U.cpp:289
virtual Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
Definition Objet_U.cpp:278
@ REQUIRED
Definition Param.h:115
static void abort()
Abort routine for TRUST on a fatal error.
Definition Process.cpp:573
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
Definition Process.cpp:466
Base class for output streams.
Definition Sortie.h:52
_SIZE_ size() const
Definition TRUSTVect.tpp:45
virtual void echange_espace_virtuel(IsExchangeBlocking exchange_type=IsExchangeBlocking::DefaultBlocking, const std::string kernel_name="noname")