From 432c36a811668b7515f4a5687d3ef845e4ac941a Mon Sep 17 00:00:00 2001 From: Martin Bauer <martin.bauer@fau.de> Date: Tue, 4 Sep 2018 16:34:52 +0200 Subject: [PATCH] Bugfixes in lbm phasefield module --- phasefield/eos.py | 6 +++--- phasefield/phasefieldstep.py | 11 ++++------- phasefield/scenarios.py | 1 - 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/phasefield/eos.py b/phasefield/eos.py index be600eb1..fcc8a408 100644 --- a/phasefield/eos.py +++ b/phasefield/eos.py @@ -50,11 +50,12 @@ def maxwell_construction(eos, tolerance=1e-4): max_rho, min_rho, _ = critical_points max_p, min_p = eos.subs(rho, max_rho), eos.subs(rho, min_rho) shift_max = max_p * 0.999 - shift_min = max_p * 0.0001 - + shift_min = max(0, min_p) + c = (shift_max + shift_min) / 2 deviation = tolerance * 2 while abs(deviation) > tolerance: + print("Deviation", deviation, "Shift", c) zeros = sp.solve(eos - c) integral_bounds = (min(zeros), max(zeros)) deviation = get_deviation(float(integral_bounds[0]), float(integral_bounds[1]), float(c)) @@ -87,4 +88,3 @@ def carnahan_starling_eos(density, gas_constant, temperature, a, b): def carnahan_starling_critical_temperature(a, b, gas_constant): return 0.3773 * a / b / gas_constant - diff --git a/phasefield/phasefieldstep.py b/phasefield/phasefieldstep.py index 74bafa65..ae4dfed8 100644 --- a/phasefield/phasefieldstep.py +++ b/phasefield/phasefieldstep.py @@ -309,13 +309,10 @@ class PhaseFieldStep: last_index = None phi = self.phi_slice(slice_obj) - if self.order_parameters_to_concentrations is None: - return phi - else: - result = self.order_parameters_to_concentrations(phi) - if last_index is not None: - result = result[..., last_index] - return result + result = self.order_parameters_to_concentrations(phi) if self.order_parameters_to_concentrations else phi + if last_index is not None: + result = result[..., last_index] + return result def mu_slice(self, slice_obj=None): return self._get_slice(self.mu_field_name, slice_obj) diff --git a/phasefield/scenarios.py b/phasefield/scenarios.py index 49ce06cb..2e3af679 100644 --- a/phasefield/scenarios.py +++ b/phasefield/scenarios.py @@ -36,7 +36,6 @@ def create_three_phase_model(alpha=1, kappa=(0.015, 0.015, 0.015), include_rho=T return PhaseFieldStep(free_energy, order_parameters, density_order_parameter=None, transformation_matrix=transformation_matrix, order_parameters_to_concentrations=order_parameters_to_concentrations, - cahn_hilliard_gammas=[1, 1, 1 / 3], **kwargs) -- GitLab