def calculate_eos_roots(self, fluid_type=None):
        A_mix = self.a_mix
        B_mix = self.b_mix

        p0 = 1.0
        p1 = -1.0
        p2 = A_mix - B_mix - (B_mix ** 2)
        p3 = -(A_mix * B_mix)

        if fluid_type is None:
            return calculate_roots_of_cubic_equation(p0, p1, p2, p3)
        else:
            return find_correct_root_of_cubic_eos(p0, p1, p2, p3, fluid_type)
示例#2
0
    def calculate_eos_roots(self, fluid_type=None):
        A_mix = self.a_mix
        B_mix = self.b_mix

        p0 = 1.0
        p1 = - (B_mix + 1.0)
        p2 = A_mix
        p3 = - A_mix * B_mix

        if fluid_type is None:
            return calculate_roots_of_cubic_equation(p0, p1, p2, p3)
        else:
            return find_correct_root_of_cubic_eos(p0, p1, p2, p3, fluid_type)
示例#3
0
    def calculate_eos_roots(self, fluid_type=None):
        A_mix = self.a_mix
        B_mix = self.b_mix

        p0 = 1.0
        p1 = - (1.0 - B_mix)
        p2 = A_mix - 3.0 * (B_mix ** 2) - 2.0 * B_mix
        p3 = -(A_mix * B_mix - B_mix ** 2 - B_mix ** 3)

        if fluid_type is None:
            return calculate_roots_of_cubic_equation(p0, p1, p2, p3)
        else:
            return find_correct_root_of_cubic_eos(p0, p1, p2, p3, fluid_type)
def find_correct_root_of_cubic_eos(p0, p1, p2, p3, fluid_type):
    roots = calculate_roots_of_cubic_equation(p0, p1, p2, p3)
    if len(roots) > 1:
        assert len(roots) == 3, 'Size of roots has to be 1 or 3!'

        roots.sort()
        if fluid_type is 'liquid':
            correct_root = roots[0]  # smallest
        else:
            assert fluid_type is 'vapor', 'Wrong fluid type! ' + fluid_type
            correct_root = roots[2]  # largest
    else:
        correct_root = roots[0]

    assert correct_root > 0.0, fluid_type + ' Z-factor < 0.0! %f' % correct_root

    return correct_root
示例#5
0
def find_correct_root_of_cubic_eos(p0, p1, p2, p3, fluid_type):
    roots = calculate_roots_of_cubic_equation(p0, p1, p2, p3)
    if len(roots) > 1:
        assert len(roots) == 3, 'Size of roots has to be 1 or 3!'

        roots.sort()
        if fluid_type is 'liquid':
            correct_root = roots[0]  # smallest
        else:
            assert fluid_type is 'vapor', 'Wrong fluid type! ' + fluid_type
            correct_root = roots[2]  # largest
    else:
        correct_root = roots[0]

    assert correct_root > 0.0, fluid_type + ' Z-factor < 0.0! %f' % correct_root

    return correct_root