Exemplo n.º 1
0
def test_nichita_problem_5(model, expected_phase_split):
    P = convert_bar_to_Pa(76)
    T = 270

    result = stability_test(model, P, T, model.mixture.z)

    assert result.phase_split == expected_phase_split
Exemplo n.º 2
0
def test_nichita_problem_2(model, pressure, expected_phase_split):
    P = convert_bar_to_Pa(pressure)
    T = 277.6

    result = stability_test(model, P, T, model.mixture.z)

    assert result.phase_split == expected_phase_split
Exemplo n.º 3
0
def test_nichita_problem_5(model, expected_phase_split):
    P = convert_bar_to_Pa(76)
    T = 270

    result = stability_test(model,
                            P,
                            T,
                            model.mixture.z,
                            solver_args=PygmoSelfAdaptiveDESettings(20,
                                                                    500,
                                                                    seed=seed))

    assert result.phase_split == expected_phase_split
Exemplo n.º 4
0
def test_equilibrium_nichita_ternary_mixture_phase_fractions(
        mixture_nichita_ternary, model_nichita_ternary):
    T = 294.3
    P = convert_bar_to_Pa(67)
    z = mixture_nichita_ternary.z
    expected_F = np.sort(np.array([0.5645, 0.2962, 0.1393]))

    result = calculate_equilibrium(model_nichita_ternary,
                                   P,
                                   T,
                                   z,
                                   number_of_trial_phases=3,
                                   compare_trial_phases=False,
                                   solver_args=PygmoSelfAdaptiveDESettings(
                                       20, 500, seed=seed))

    phase_fraction_sorted = np.sort(result.F)

    relative_l2_norm = la.norm(phase_fraction_sorted -
                               expected_F) / la.norm(expected_F)
    assert relative_l2_norm < 1.5e-1
Exemplo n.º 5
0
def test_equilibrium_nichita_ternary_mixture_composition(
        mixture_nichita_ternary, model_nichita_ternary):
    T = 294.3
    P = convert_bar_to_Pa(67)
    z = mixture_nichita_ternary.z
    expected_y = np.array([0.078112, 0.000069, 0.921819])
    expected_x1 = np.array([0.036181, 0.340224, 0.623595])
    expected_x2 = np.array([0.038707, 0.004609, 0.956683])

    result = calculate_equilibrium(model_nichita_ternary,
                                   P,
                                   T,
                                   z,
                                   number_of_trial_phases=3,
                                   compare_trial_phases=False,
                                   solver_args=PygmoSelfAdaptiveDESettings(
                                       10, 350, seed=seed))

    for expected_composition in [expected_y, expected_x1, expected_x2]:
        expected_norm = la.norm(expected_composition)
        assert any(
            la.norm(composition - expected_composition) / expected_norm < 5e-2
            for composition in result.X)
Exemplo n.º 6
0
def test_bar_to_Pa(P_in_bar, P_in_Pa):
    assert convert_bar_to_Pa(P_in_bar) == pytest.approx(P_in_Pa, rel=1e-3)