include/meltpooldg/phase_change/evaporative_cooling.templates.hpp Source File

Developer Documentation: include/meltpooldg/phase_change/evaporative_cooling.templates.hpp Source File
Developer Documentation
evaporative_cooling.templates.hpp
Go to the documentation of this file.
1#pragma once
2
5//
6#include <deal.II/base/exceptions.h>
7
12
14{
15 template <typename number>
16 EvaporativeCooling<number>::EvaporativeCooling(const EvaporationData<number> &evapor_data,
17 const MaterialData<number> &material_data,
18 const bool setup_internal_mass_flux_operator)
19 : do_phenomenological_recoil_pressure(
20 evapor_data.evaporative_cooling.consider_enthalpy_transport_vapor_mass_flux == "true")
21 , latent_heat_of_evaporation(material_data.latent_heat_of_evaporation)
22 , specific_heat_capacity(material_data.liquid.specific_heat_capacity)
23 , specific_enthalpy_reference_temperature(material_data.specific_enthalpy_reference_temperature)
24 , boiling_temperature(material_data.boiling_temperature)
25 , ramp_enabled(evapor_data.evaporative_cooling.enable_linear_activation_ramp)
26 {
29 dealii::ExcMessage(
30 "For the phenomenological recoil pressure model, the reference temperature "
31 "for computing the specific enthalpy must be specified. Abort..."));
32
33 if (setup_internal_mass_flux_operator)
34 {
35 if (evapor_data.evaporative_mass_flux_model == EvaporationModelType::recoil_pressure)
36 {
37 mass_flux_operator = std::make_unique<EvaporationModelRecoilPressure<number>>(
38 evapor_data.recoil,
39 material_data.boiling_temperature,
40 material_data.molar_mass,
41 material_data.latent_heat_of_evaporation);
42 }
43 else if (evapor_data.evaporative_mass_flux_model ==
44 EvaporationModelType::saturated_vapor_pressure)
45 {
46 mass_flux_operator = std::make_unique<EvaporationModelSaturatedVaporPressure<number>>(
47 evapor_data.recoil,
48 material_data.boiling_temperature,
49 material_data.molar_mass,
50 material_data.latent_heat_of_evaporation);
51 }
52 else if (evapor_data.evaporative_mass_flux_model == EvaporationModelType::pressure_aware)
53 {
54 mass_flux_operator = std::make_unique<EvaporationModelPressureAware<number>>(
55 evapor_data.pressure_aware,
56 material_data.boiling_temperature,
57 material_data.latent_heat_of_evaporation);
58 }
59 else
60 {
61 AssertThrow(false, dealii::ExcNotImplemented());
62 }
63
64
65 if (numbers::is_invalid(evapor_data.evaporative_cooling.activation_temperature))
66 {
67 // Set the activation temperature so that the transition from the linear activation ramp
68 // is kink-free.
70 material_data.boiling_temperature -
73 material_data.boiling_temperature);
74 }
75 else
76 {
77 activation_temperature = evapor_data.evaporative_cooling.activation_temperature;
78 }
79
80 if (ramp_enabled)
81 {
85 }
86 }
87 }
88
89
90 template <typename number>
91 template <typename ValueType>
92 inline ValueType
94 const ValueType &mass_flux,
95 [[maybe_unused]] const ValueType &temperature) const
96 {
97 ValueType specific_enthalpy(0.0);
98 if (do_phenomenological_recoil_pressure)
99 specific_enthalpy = compute_phenomenological_specific_enthalpy(temperature);
100
101 return -(latent_heat_of_evaporation + specific_enthalpy) * mass_flux;
102 }
103
104
105 template <typename number>
106 inline number
108 {
109 Assert(mass_flux_operator,
110 dealii::ExcMessage("To use this function, the class must be constructed with "
111 "setup_internal_mass_flux_operator = true."));
112
113 if (temperature < activation_temperature)
114 return 0.0;
115 else if (temperature >= boiling_temperature or not ramp_enabled)
116 return compute_evaporative_cooling(
117 mass_flux_operator->local_compute_evaporative_mass_flux(temperature), temperature);
118 else
119 // linear activation ramp
120 return activation_ramp_derivative * (temperature - activation_temperature);
121 }
122
123
124 template <typename number>
125 dealii::VectorizedArray<number>
127 const dealii::VectorizedArray<number> &temperature) const
128 {
129 Assert(mass_flux_operator,
130 dealii::ExcMessage("To use this function, the class must be constructed with "
131 "setup_internal_mass_flux_operator = true."));
132
133 return dealii::compare_and_apply_mask<dealii::SIMDComparison::less_than>(
134 temperature,
135 activation_temperature,
136 0,
137 dealii::compare_and_apply_mask<dealii::SIMDComparison::greater_than_or_equal>(
138 temperature,
139 ramp_enabled ? boiling_temperature : activation_temperature,
140 compute_evaporative_cooling(
141 mass_flux_operator->local_compute_evaporative_mass_flux_vec(temperature), temperature),
142 activation_ramp_derivative * (temperature - activation_temperature)));
143 }
144
145
146 template <typename number>
147 template <typename ValueType>
148 inline ValueType
150 [[maybe_unused]] const ValueType &mass_flux) const
151 {
152 if (do_phenomenological_recoil_pressure)
153 return -specific_heat_capacity * mass_flux;
154 else
155 return 0.0;
156 }
157
158
159 template <typename number>
160 inline number
163 const number temperature) const
164 {
165 Assert(mass_flux_operator,
166 dealii::ExcMessage("To use this function, the class must be constructed with "
167 "setup_internal_mass_flux_operator = true."));
168
169 if (temperature < activation_temperature)
170 return 0.0;
171 else if (temperature >= boiling_temperature or not ramp_enabled)
172 {
173 const auto mass_flux_derivative =
174 mass_flux_operator->local_compute_evaporative_mass_flux_derivative(temperature);
175 if (do_phenomenological_recoil_pressure)
176 return -specific_heat_capacity *
177 mass_flux_operator->local_compute_evaporative_mass_flux(temperature) -
178 (latent_heat_of_evaporation +
179 compute_phenomenological_specific_enthalpy(temperature)) *
180 mass_flux_derivative;
181 else
182 return -specific_heat_capacity * mass_flux_derivative;
183 }
184 else
185 return activation_ramp_derivative;
186 }
187
188
189 template <typename number>
190 dealii::VectorizedArray<number>
193 const dealii::VectorizedArray<number> &temperature) const
194 {
195 Assert(mass_flux_operator,
196 dealii::ExcMessage("To use this function, the class must be constructed with "
197 "setup_internal_mass_flux_operator = true."));
198
199 return dealii::compare_and_apply_mask<dealii::SIMDComparison::less_than>(
200 temperature,
201 activation_temperature,
202 0,
203 dealii::compare_and_apply_mask<dealii::SIMDComparison::greater_than_or_equal>(
204 temperature,
205 ramp_enabled ? boiling_temperature : activation_temperature,
206 (do_phenomenological_recoil_pressure) ?
207 -specific_heat_capacity *
208 mass_flux_operator->local_compute_evaporative_mass_flux_vec(temperature) -
209 (latent_heat_of_evaporation + compute_phenomenological_specific_enthalpy(temperature)) *
210 mass_flux_operator->local_compute_evaporative_mass_flux_vec_derivative(temperature) :
211 -specific_heat_capacity *
212 mass_flux_operator->local_compute_evaporative_mass_flux_vec_derivative(temperature),
213 activation_ramp_derivative));
214 }
215
216 template <typename number>
217 template <typename ValueType>
218 inline ValueType
220 const ValueType &temperature) const
221 {
222 return specific_heat_capacity * (temperature - specific_enthalpy_reference_temperature);
223 }
224
225} // namespace MeltPoolDG::Evaporation
const bool do_phenomenological_recoil_pressure
Definition evaporative_cooling.hpp:132
number activation_temperature
Definition evaporative_cooling.hpp:137
EvaporativeCooling(const EvaporationData< number > &evapor_data, const MaterialData< number > &material_data, const bool setup_internal_mass_flux_operator=false)
Definition evaporative_cooling.templates.hpp:16
number compute_evaporative_cooling_derivative_with_temperature_dependent_mass_flux(const number temperature) const
Definition evaporative_cooling.templates.hpp:162
ValueType compute_phenomenological_specific_enthalpy(const ValueType &temperature) const
Definition evaporative_cooling.templates.hpp:219
number activation_ramp_derivative
Definition evaporative_cooling.hpp:139
std::unique_ptr< EvaporationModelBase< number > > mass_flux_operator
Definition evaporative_cooling.hpp:140
ValueType compute_evaporative_cooling_derivative_constant_mass_flux(const ValueType &mass_flux) const
Definition evaporative_cooling.templates.hpp:149
ValueType compute_evaporative_cooling(const ValueType &mass_flux, const ValueType &temperature) const
Definition evaporative_cooling.templates.hpp:93
const number specific_enthalpy_reference_temperature
Definition evaporative_cooling.hpp:135
bool ramp_enabled
Definition evaporative_cooling.hpp:138
Definition evaporation_data.hpp:15
bool is_invalid(const double &number)
Definition numbers.hpp:19
Definition material_data.hpp:84
number molar_mass
Definition material_data.hpp:109
number boiling_temperature
Definition material_data.hpp:107
number latent_heat_of_evaporation
Definition material_data.hpp:108