Skip to content

Solution calculation #1567

@lars-petter-hauge

Description

@lars-petter-hauge

Hi there,

We are doing flash calculations for a CO2 stream. Current implementation is something like this:

    def flash_activity(self):
        self.validate_composition()
        self.calc_vapour_pressure()
        self.normalize()
        self.K_values = [1e50, 0.005, 0.005]
        self.calc_fugacicy_coefficient_neqsim_CPA()
        self.iteration = 0

        while 1:
            K_old = self.K_values.copy()
            bettaOld = self.betta
            self.solve_Rachford_Rice()
            bettaNew = self.betta
            self.calc_phases()

            for i in range(len(self.phases)):
                self.phases[i].set_phase_flow_rate(self.flow_rate)
            self.get_phase(1).set_component_fraction("CO2", 1e-50)
            self.get_phase(1).normalize()
            self.calc_fugacity_neqsim_CPA(self.phases[0].fractions)
            self.calc_activity()
            self.update_k_values_activity()
            K_new = self.K_values.copy()
            self.iteration += 1
            self.error = 0

            for i, component in enumerate(self.components):
                self.error += abs(K_new[i] - K_old[i])

            if self.error < self.tol:
                break

        self.phases[1].set_name()

and we have some simple activity model calculations for each component, eg:

elif component == "H2SO4":
                activity = np.exp(
                    (
                        self.ActivityK1[i] * ((self.temperature - 273.15) ** 2)
                        + self.ActivityK2[i] * (self.temperature - 273.15)
                        + self.ActivityK3[i]
                    )
                    * (self.get_phase(1).get_fraction_component("H2O")) ** 2
                )

full code here: https://github.com/equinor/SolubilityCCS/blob/a80f6c70d25c0848793eac2895ba6a2fd5fb508e/solubilityccs/fluid.py#L509

we imagine all of this should be possible to do in neqsim alone. Would be awesome if we could be able to achieve this with less of our duplicated code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions