69 double const , std::vector<GlobalVector*>
const& x,
76 unsigned const n_integration_points =
79 auto const indices_current_variable =
82 mesh_item_id, *
_data.dof_table_boundary_pressure);
84 mesh_item_id, *
_data.dof_table_boundary_velocity);
86 mesh_item_id, *
_data.dof_table_boundary_enthalpy);
88 std::vector<double>
const local_pressure =
89 x[process_id]->get(indices_pressure);
90 std::vector<double>
const local_velocity =
91 x[process_id]->get(indices_velocity);
92 std::vector<double>
const local_enthalpy =
93 x[process_id]->get(indices_enthalpy);
95 auto const& medium = *
_data.media_map.getMedium(
_element.getID());
96 auto const& liquid_phase = medium.phase(
"AqueousLiquid");
97 auto const& gas_phase = medium.phase(
"Gas");
104 for (
unsigned ip = 0; ip < n_integration_points; ip++)
107 auto const& N = n_and_weight.N;
108 auto const& w = n_and_weight.weight;
110 double pressure_int_pt = 0.0;
111 double velocity_int_pt = 0.0;
112 double enthalpy_int_pt = 0.0;
124 double liquid_water_density =
128 .template value<double>(vars, pos, 0, 0);
130 double const vapour_water_density =
134 .template value<double>(vars, pos, 0, 0);
136 double const h_sat_liq_w =
140 .template value<double>(vars, pos, 0, 0);
142 double const h_sat_vap_w =
146 .template value<double>(vars, pos, 0, 0);
148 double const dryness =
149 std::max(0., (enthalpy_int_pt - h_sat_liq_w) /
150 (h_sat_vap_w - h_sat_liq_w));
152 double const T_int_pt =
157 .template value<double>(vars, pos, 0, 0)
160 saturation_temperature)
161 .template value<double>(vars, pos, 0, 0);
171 double const C_0 = 1 + 0.12 * (1 - dryness);
177 double const sigma_gl = 0.2358 *
178 std::pow((1 - T_int_pt / 647.096), 1.256) *
179 (1 - 0.625 * (1 - T_int_pt / 647.096));
182 1.18 * (1 - dryness) *
183 std::pow((9.81) * sigma_gl *
184 (liquid_water_density - vapour_water_density),
186 std::pow(liquid_water_density, 0.5);
194 using LocalJacobianMatrix =
195 Eigen::Matrix<double, 1, 1, Eigen::RowMajor>;
196 using LocalResidualVector = Eigen::Matrix<double, 1, 1>;
197 using LocalUnknownVector = Eigen::Matrix<double, 1, 1>;
198 LocalJacobianMatrix J_loc;
200 Eigen::PartialPivLU<LocalJacobianMatrix> linear_solver(1);
202 auto const update_residual = [&](LocalResidualVector& residual)
204 residual(0) = dryness * liquid_water_density *
205 (alpha * vapour_water_density +
206 (1 - alpha) * liquid_water_density) *
208 alpha * C_0 * dryness * liquid_water_density *
209 (alpha * vapour_water_density +
210 (1 - alpha) * liquid_water_density) *
212 alpha * C_0 * (1 - dryness) *
213 vapour_water_density *
214 (alpha * vapour_water_density +
215 (1 - alpha) * liquid_water_density) *
217 alpha * vapour_water_density *
218 liquid_water_density * u_gu;
221 auto const update_jacobian = [&](LocalJacobianMatrix& jacobian)
224 dryness * liquid_water_density * velocity_int_pt *
225 (vapour_water_density - liquid_water_density) -
226 (C_0 * dryness * liquid_water_density +
227 C_0 * (1 - dryness) * vapour_water_density) *
228 (2 * alpha * vapour_water_density +
229 (1 - 2 * alpha) * liquid_water_density) *
231 vapour_water_density * liquid_water_density * u_gu;
234 auto const update_solution =
235 [&](LocalUnknownVector
const& increment)
238 alpha += increment[0];
241 const int maximum_iterations(20);
242 const double residuum_tolerance(1.e-10);
243 const double increment_tolerance(0);
246 linear_solver, update_jacobian, update_residual,
248 {maximum_iterations, residuum_tolerance,
249 increment_tolerance});
251 auto const success_iterations = newton_solver.
solve(J_loc);
253 if (!success_iterations)
256 "Attention! Steam void fraction has not been correctly "
263 liquid_water_density =
266 .template value<double>(vars, pos, 0, 0);
269 double const mix_density = vapour_water_density * alpha +
270 liquid_water_density * (1 - alpha);
274 alpha * liquid_water_density * vapour_water_density *
275 mix_density / (1 - alpha) /
276 std::pow((alpha * C_0 * vapour_water_density +
277 (1 - alpha * C_0) * liquid_water_density),
279 std::pow((C_0 - 1) * velocity_int_pt + u_gu, 2);
281 double const neumann_ip_values =
282 _data.coefficients.pressure * mix_density * velocity_int_pt +
283 _data.coefficients.velocity *
284 (mix_density * velocity_int_pt * velocity_int_pt + gamma) +
285 _data.coefficients.enthalpy * mix_density * velocity_int_pt *
286 velocity_int_pt * velocity_int_pt * 0.5;
287 _local_rhs.noalias() += N.transpose() * neumann_ip_values * w;
290 b.
add(indices_current_variable, _local_rhs);