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 =
98 auto const& gas_phase =
106 for (
unsigned ip = 0; ip < n_integration_points; ip++)
109 auto const& N = n_and_weight.N;
110 auto const& w = n_and_weight.weight;
112 double pressure_int_pt = 0.0;
113 double velocity_int_pt = 0.0;
114 double enthalpy_int_pt = 0.0;
126 double liquid_water_density =
130 .template value<double>(vars, pos, 0, 0);
132 double const vapour_water_density =
136 .template value<double>(vars, pos, 0, 0);
138 double const h_sat_liq_w =
142 .template value<double>(vars, pos, 0, 0);
144 double const h_sat_vap_w =
148 .template value<double>(vars, pos, 0, 0);
150 double const dryness =
151 std::max(0., (enthalpy_int_pt - h_sat_liq_w) /
152 (h_sat_vap_w - h_sat_liq_w));
154 double const T_int_pt =
159 .template value<double>(vars, pos, 0, 0)
162 saturation_temperature)
163 .template value<double>(vars, pos, 0, 0);
173 double const C_0 = 1 + 0.12 * (1 - dryness);
179 double const sigma_gl = 0.2358 *
180 std::pow((1 - T_int_pt / 647.096), 1.256) *
181 (1 - 0.625 * (1 - T_int_pt / 647.096));
184 1.18 * (1 - dryness) *
185 std::pow((9.81) * sigma_gl *
186 (liquid_water_density - vapour_water_density),
188 std::pow(liquid_water_density, 0.5);
196 using LocalJacobianMatrix =
197 Eigen::Matrix<double, 1, 1, Eigen::RowMajor>;
198 using LocalResidualVector = Eigen::Matrix<double, 1, 1>;
199 using LocalUnknownVector = Eigen::Matrix<double, 1, 1>;
200 LocalJacobianMatrix J_loc;
202 Eigen::PartialPivLU<LocalJacobianMatrix> linear_solver(1);
204 auto const update_residual = [&](LocalResidualVector& residual)
206 residual(0) = dryness * liquid_water_density *
207 (alpha * vapour_water_density +
208 (1 - alpha) * liquid_water_density) *
210 alpha * C_0 * dryness * liquid_water_density *
211 (alpha * vapour_water_density +
212 (1 - alpha) * liquid_water_density) *
214 alpha * C_0 * (1 - dryness) *
215 vapour_water_density *
216 (alpha * vapour_water_density +
217 (1 - alpha) * liquid_water_density) *
219 alpha * vapour_water_density *
220 liquid_water_density * u_gu;
223 auto const update_jacobian = [&](LocalJacobianMatrix& jacobian)
226 dryness * liquid_water_density * velocity_int_pt *
227 (vapour_water_density - liquid_water_density) -
228 (C_0 * dryness * liquid_water_density +
229 C_0 * (1 - dryness) * vapour_water_density) *
230 (2 * alpha * vapour_water_density +
231 (1 - 2 * alpha) * liquid_water_density) *
233 vapour_water_density * liquid_water_density * u_gu;
236 auto const update_solution =
237 [&](LocalUnknownVector
const& increment)
240 alpha += increment[0];
243 const int maximum_iterations(20);
244 const double residuum_tolerance(1.e-10);
245 const double increment_tolerance(0);
248 linear_solver, update_jacobian, update_residual,
250 {maximum_iterations, residuum_tolerance,
251 increment_tolerance});
253 auto const success_iterations = newton_solver.
solve(J_loc);
255 if (!success_iterations)
258 "Attention! Steam void fraction has not been correctly "
265 liquid_water_density =
268 .template value<double>(vars, pos, 0, 0);
271 double const mix_density = vapour_water_density * alpha +
272 liquid_water_density * (1 - alpha);
276 alpha * liquid_water_density * vapour_water_density *
277 mix_density / (1 - alpha) /
278 std::pow((alpha * C_0 * vapour_water_density +
279 (1 - alpha * C_0) * liquid_water_density),
281 std::pow((C_0 - 1) * velocity_int_pt + u_gu, 2);
283 double const neumann_ip_values =
284 _data.coefficients.pressure * mix_density * velocity_int_pt +
285 _data.coefficients.velocity *
286 (mix_density * velocity_int_pt * velocity_int_pt + gamma) +
287 _data.coefficients.enthalpy * mix_density * velocity_int_pt *
288 velocity_int_pt * velocity_int_pt * 0.5;
289 _local_rhs.noalias() += N.transpose() * neumann_ip_values * w;
292 b.
add(indices_current_variable, _local_rhs);