|
4 | 4 | Parameter, |
5 | 5 | RunResult, |
6 | 6 | ) |
7 | | -from acidwatch_api.models.datamodel import TextResult |
| 7 | +from acidwatch_api.models.datamodel import TextResult, Phase |
8 | 8 |
|
9 | 9 | from solubilityccs import Fluid, ModelResults # type: ignore |
10 | 10 | from solubilityccs.neqsim_functions import get_co2_parameters # type: ignore |
@@ -68,4 +68,42 @@ async def run(self) -> RunResult: |
68 | 68 | results_obj = ModelResults(fluid, co2_properties=co2_properties) |
69 | 69 | table = results_obj.generate_table() |
70 | 70 |
|
71 | | - return [], TextResult(data=table, label="Solubility Output") |
| 71 | + phases = self._extract_phases(fluid) |
| 72 | + |
| 73 | + return phases, TextResult(data=table, label="Solubility Output") |
| 74 | + |
| 75 | + def _extract_phases(self, fluid: Fluid) -> list[Phase]: |
| 76 | + gas_phase = fluid.phases[0] |
| 77 | + gas_fraction = fluid.betta |
| 78 | + |
| 79 | + co2_rich_concs: dict[str, float | int] = {} |
| 80 | + for component, fraction in zip(gas_phase.components, gas_phase.fractions): |
| 81 | + if component != "CO2": |
| 82 | + co2_rich_concs[component] = fraction * 1e6 |
| 83 | + |
| 84 | + phases = [ |
| 85 | + Phase( |
| 86 | + kind="co2-rich", |
| 87 | + fraction=gas_fraction, |
| 88 | + concentrations=co2_rich_concs, |
| 89 | + ) |
| 90 | + ] |
| 91 | + |
| 92 | + if gas_fraction < 1.0 and len(fluid.phases) > 1: |
| 93 | + liquid_phase = fluid.phases[1] |
| 94 | + aqueous_concs: dict[str, float | int] = {} |
| 95 | + for component, fraction in zip( |
| 96 | + liquid_phase.components, liquid_phase.fractions |
| 97 | + ): |
| 98 | + if component != "CO2": |
| 99 | + aqueous_concs[component] = fraction * 1e6 |
| 100 | + |
| 101 | + phases.append( |
| 102 | + Phase( |
| 103 | + kind="aqueous", |
| 104 | + fraction=1.0 - gas_fraction, |
| 105 | + concentrations=aqueous_concs, |
| 106 | + ) |
| 107 | + ) |
| 108 | + |
| 109 | + return phases |
0 commit comments