TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Flux_parietal_diphasique_simple_lineaire.cpp
1/****************************************************************************
2* Copyright (c) 2025, 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 <Flux_parietal_diphasique_simple_lineaire.h>
17#include <Milieu_composite.h>
18#include <Pb_Multiphase.h>
19
20Implemente_instanciable(Flux_parietal_diphasique_simple_lineaire, "Flux_parietal_diphasique_simple_lineaire", Flux_parietal_base);
21
23
25{
26 Param param(que_suis_je());
27 param.ajouter("coeff_echange_monophasique|single_phase_exchange_coeff", &h_mono_, Param::REQUIRED);
28 param.ajouter("coeff_osv|osv_coeff", &coeff_, Param::REQUIRED);
29 param.lire_avec_accolades_depuis(is);
30
31 /* n_l / n_g : continuous liquid / gas phases */
32 const Pb_Multiphase *pbm = sub_type(Pb_Multiphase, pb_.valeur()) ? &ref_cast(Pb_Multiphase, pb_.valeur()) : nullptr;
33
34 if (!pbm || pbm->nb_phases() == 1) // not a Pb_Multiphase -> single-phase liquid
35 Process::exit("Flux_parietal_diphasique_simple_lineaire can only be used for a multiphase problem with 2 phases!");
36 else // search for n_l, n_g: continuous {liquid,gas} phase with priority
37 {
38 for (int n = 0; n < pbm->nb_phases(); n++)
39 if (pbm->nom_phase(n).debute_par("liquide") && (n_l < 0 || pbm->nom_phase(n).finit_par("continu")))
40 n_l = n;
41 else if (pbm->nom_phase(n).debute_par("gaz") && (n_g < 0 || pbm->nom_phase(n).finit_par("continu")))
42 n_g = n;
43 }
44
45 if (n_l < 0)
46 Process::exit(que_suis_je() + " : main phase not found!");
47
48 assert (n_l >= 0 && n_g >= 0);
49
50 const Milieu_composite *mc = sub_type(Milieu_composite, pb_->milieu()) ? &ref_cast(Milieu_composite, pb_->milieu()) : nullptr;
51
52 if (mc->has_saturation(n_l, n_g))
53 sat = &mc->get_saturation(n_l, n_g);
54
55 if (!sat)
56 Process::exit("Flux_parietal_diphasique_simple_lineaire needs saturation!");
57
58 return is;
59}
60
61double Flux_parietal_diphasique_simple_lineaire::fraction_flux_vap(const input_t& in, double phi, double dTf_phi, double dp_phi, double dTp_phi, double& dTf_eps, double& dp_eps, double& dTp_eps) const
62{
63 const double Ts = sat->Tsat(in.p),
64 Tld = Ts - phi * coeff_,
65 dp_Tld = sat->dP_Tsat(in.p) - dp_phi * coeff_,
66 dTp_Tld = -dTp_phi * coeff_,
67 dTf_Tld = -dTf_phi * coeff_;
68
69 const double eps = std::min(1.0, std::max(0.0, (in.T[n_l] - Tld) / (Ts - Tld)));
70
71 if (in.T[n_l] > Tld && in.T[n_l] < Ts) // non-zero derivative
72 {
73 dTf_eps = ((Ts - Tld) * (-dTf_Tld) + (in.T[n_l] - Tld) * dTf_Tld) / (Ts - Tld) / (Ts - Tld);
74 dp_eps = ((Ts - Tld) * (-dp_Tld) - (in.T[n_l] - Tld) * (sat->dP_Tsat(in.p) - dp_Tld)) / (Ts - Tld) / (Ts - Tld);
75 dTp_eps = ((Ts - Tld) * (-dTp_Tld) + (in.T[n_l] - Tld) * dTp_Tld) / (Ts - Tld) / (Ts - Tld);
76 }
77
78 return eps;
79}
80
82{
83 double Ts = sat->Tsat(in.p) ;
84
85 const Milieu_composite& milc = ref_cast(Milieu_composite, pb_->milieu());
86
87 if (out.nonlinear)
88 (*out.nonlinear) = 1; // we turn on nonlinear in case it goes to two-phase during the newton
89
90 for (int k = 0; k < in.N; k++)
91 if (n_l != k)
92 if (milc.has_saturation(n_l, k))
93 {
94 const double P_mono = h_mono_ * (in.Tp - in.T[n_l]);
95
96 if (in.Tp < Ts)
97 {
98 if (out.qpk)
99 (*out.qpk)(n_l) = P_mono;
100 if (out.dTp_qpk)
101 (*out.dTp_qpk)(n_l) = h_mono_;
102 if (out.dTf_qpk)
103 (*out.dTf_qpk)(n_l, n_l) = -h_mono_;
104 }
105 else
106 {
107 if (Ts <= in.T[n_l]) // Everything in the evaporative term
108 {
109 if (out.qpi)
110 (*out.qpi)(n_l, k) = P_mono;
111 if (out.dTp_qpi)
112 (*out.dTp_qpi)(n_l, k) = h_mono_;
113 if (out.dTf_qpi)
114 (*out.dTf_qpi)(n_l, k, n_l) = -h_mono_;
115 }
116 else
117 {
118 double dTf_eps = 0.0, dp_eps = 0.0, dTp_eps = 0.0;
119 double eps = fraction_flux_vap(in, P_mono, -h_mono_, 0.0, h_mono_, dTf_eps, dp_eps, dTp_eps);
120
121 // Fill in the outputs : heat flux towards liquid
122 if (out.qpk)
123 (*out.qpk)(n_l) = (1.0 - eps) * P_mono;
124 if (out.dTp_qpk)
125 (*out.dTp_qpk)(n_l) = (1.0 - eps) * h_mono_ - P_mono * dTp_eps;
126 if (out.dTf_qpk)
127 (*out.dTf_qpk)(n_l, n_l) = -(1.0 - eps) * h_mono_ + P_mono * dTf_eps;
128
129 // Evaporation
130 if (out.qpi)
131 (*out.qpi)(n_l, k) = eps * P_mono;
132 if (out.dTp_qpi)
133 (*out.dTp_qpi)(n_l, k) = dTp_eps * P_mono + eps * h_mono_;
134 if (out.dTf_qpi)
135 (*out.dTf_qpi)(n_l, k, n_l) = dTf_eps * P_mono - eps * h_mono_;
136 }
137 }
138 }
139}
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
Base class for wall heat flux correlations of the form:
void qp(const input_t &input, output_t &output) const override
double fraction_flux_vap(const input_t &in, double phi, double dTf_phi, double dp_phi, double dTp_phi, double &dTf_eps, double &dp_eps, double &dTp_eps) const
Composite medium representing a multiphase fluid and its properties:
bool has_saturation(int k, int l) const
Saturation_base & get_saturation(int k, int l) const
virtual int debute_par(const char *const n) const
Definition Nom.cpp:314
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
const Nom & nom_phase(int i) const
int nb_phases() const
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