70 double const , std::vector<GlobalVector*>
const& x,
77 unsigned const n_integration_points =
80 auto const indices_current_variable =
89 std::vector<double>
const local_pressure =
90 x[process_id]->get(indices_pressure);
91 std::vector<double>
const local_velocity =
92 x[process_id]->get(indices_velocity);
93 std::vector<double>
const local_enthalpy =
94 x[process_id]->get(indices_enthalpy);
97 auto const& liquid_phase = medium.
phase(
"AqueousLiquid");
98 auto const& gas_phase = medium.phase(
"Gas");
105 for (
unsigned ip = 0; ip < n_integration_points; ip++)
108 auto const& N = n_and_weight.N;
109 auto const& w = n_and_weight.weight;
111 double pressure_int_pt = 0.0;
112 double velocity_int_pt = 0.0;
113 double enthalpy_int_pt = 0.0;
125 double liquid_water_density =
129 .template value<double>(vars, pos, 0, 0);
131 double const vapour_water_density =
135 .template value<double>(vars, pos, 0, 0);
137 double const h_sat_liq_w =
141 .template value<double>(vars, pos, 0, 0);
143 double const h_sat_vap_w =
147 .template value<double>(vars, pos, 0, 0);
149 double const dryness =
150 std::max(0., (enthalpy_int_pt - h_sat_liq_w) /
151 (h_sat_vap_w - h_sat_liq_w));
153 double const T_int_pt =
158 .template value<double>(vars, pos, 0, 0)
161 saturation_temperature)
162 .
template value<double>(vars, pos, 0, 0);
172 double const C_0 = 1 + 0.12 * (1 - dryness);
178 double const sigma_gl = 0.2358 *
179 std::pow((1 - T_int_pt / 647.096), 1.256) *
180 (1 - 0.625 * (1 - T_int_pt / 647.096));
183 1.18 * (1 - dryness) *
184 std::pow((9.81) * sigma_gl *
185 (liquid_water_density - vapour_water_density),
187 std::pow(liquid_water_density, 0.5);
195 using LocalJacobianMatrix =
196 Eigen::Matrix<double, 1, 1, Eigen::RowMajor>;
197 using LocalResidualVector = Eigen::Matrix<double, 1, 1>;
198 using LocalUnknownVector = Eigen::Matrix<double, 1, 1>;
199 LocalJacobianMatrix J_loc;
201 Eigen::PartialPivLU<LocalJacobianMatrix> linear_solver(1);
203 auto const update_residual = [&](LocalResidualVector& residual)
205 residual(0) = dryness * liquid_water_density *
206 (alpha * vapour_water_density +
207 (1 - alpha) * liquid_water_density) *
209 alpha * C_0 * dryness * liquid_water_density *
210 (alpha * vapour_water_density +
211 (1 - alpha) * liquid_water_density) *
213 alpha * C_0 * (1 - dryness) *
214 vapour_water_density *
215 (alpha * vapour_water_density +
216 (1 - alpha) * liquid_water_density) *
218 alpha * vapour_water_density *
219 liquid_water_density * u_gu;
222 auto const update_jacobian = [&](LocalJacobianMatrix& jacobian)
225 dryness * liquid_water_density * velocity_int_pt *
226 (vapour_water_density - liquid_water_density) -
227 (C_0 * dryness * liquid_water_density +
228 C_0 * (1 - dryness) * vapour_water_density) *
229 (2 * alpha * vapour_water_density +
230 (1 - 2 * alpha) * liquid_water_density) *
232 vapour_water_density * liquid_water_density * u_gu;
235 auto const update_solution =
236 [&](LocalUnknownVector
const& increment)
239 alpha += increment[0];
242 const int maximum_iterations(20);
243 const double residuum_tolerance(1.e-10);
244 const double increment_tolerance(0);
247 linear_solver, update_jacobian, update_residual,
249 {maximum_iterations, residuum_tolerance,
250 increment_tolerance});
252 auto const success_iterations = newton_solver.
solve(J_loc);
254 if (!success_iterations)
257 "Attention! Steam void fraction has not been correctly "
264 liquid_water_density =
267 .template value<double>(vars, pos, 0, 0);
270 double const mix_density = vapour_water_density * alpha +
271 liquid_water_density * (1 - alpha);
275 alpha * liquid_water_density * vapour_water_density *
276 mix_density / (1 - alpha) /
277 std::pow((alpha * C_0 * vapour_water_density +
278 (1 - alpha * C_0) * liquid_water_density),
280 std::pow((C_0 - 1) * velocity_int_pt + u_gu, 2);
282 double const neumann_ip_values =
285 (mix_density * velocity_int_pt * velocity_int_pt + gamma) +
287 velocity_int_pt * velocity_int_pt * 0.5;
288 _local_rhs.noalias() += N.transpose() * neumann_ip_values * w;
291 b.
add(indices_current_variable, _local_rhs);