|
| 1 | +from acidwatch_api.models.base import ( |
| 2 | + BaseAdapter, |
| 3 | + BaseParameters, |
| 4 | + Parameter, |
| 5 | + RunResult, |
| 6 | + Unit, |
| 7 | +) |
| 8 | +from acidwatch_api.settings import SETTINGS |
| 9 | + |
| 10 | +DESCRIPTION: str = """Automated Reactions for CO2 Storage (ARCS) model. |
| 11 | + ARCS combines first-principles calculations with Monte-Carlo sampling and models possible reactions that may occur under a given set of conditions. |
| 12 | + This process identifies the most frequently occurring reactions and paths, final products, and expected concentrations. |
| 13 | + |
| 14 | + This model is under significant development and expected to deviate while developed. Therefore a development version of it has been released while work is ongoing |
| 15 | + Source code found at https://github.com/badw/arcs |
| 16 | + """ |
| 17 | + |
| 18 | + |
| 19 | +class ArcsParameters(BaseParameters): |
| 20 | + temperature: int = Parameter( |
| 21 | + 300, |
| 22 | + label="Temperature", |
| 23 | + unit=Unit.TEMPERATURE_KELVIN, |
| 24 | + min=200, |
| 25 | + max=400, |
| 26 | + description="Temperature in Celsius", |
| 27 | + ) |
| 28 | + |
| 29 | + pressure: int = Parameter( |
| 30 | + 10, |
| 31 | + label="Pressure", |
| 32 | + unit="bara", |
| 33 | + min=1, |
| 34 | + max=300, |
| 35 | + description="Pressure in bara", |
| 36 | + ) |
| 37 | + |
| 38 | + |
| 39 | +class ArcsExpAdapter(BaseAdapter): |
| 40 | + model_id = "arcs_exp" |
| 41 | + display_name = "ARCS experimental" |
| 42 | + description = DESCRIPTION |
| 43 | + category = "Primary" |
| 44 | + |
| 45 | + valid_substances = [ |
| 46 | + "CH2O2", |
| 47 | + "CH3CH2OH", |
| 48 | + "CO", |
| 49 | + "H2", |
| 50 | + "O2", |
| 51 | + "CH3COOH", |
| 52 | + "CH3OH", |
| 53 | + "CH4", |
| 54 | + "CH3CHO", |
| 55 | + "H2CO", |
| 56 | + "H2O", |
| 57 | + "H2SO4", |
| 58 | + "H2S", |
| 59 | + "S8", |
| 60 | + "SO2", |
| 61 | + "H2SO3", |
| 62 | + "HNO3", |
| 63 | + "NO2", |
| 64 | + "NH3", |
| 65 | + "HNO2", |
| 66 | + "NO", |
| 67 | + "N2", |
| 68 | + "NOHSO4", |
| 69 | + ] |
| 70 | + |
| 71 | + parameters: ArcsParameters |
| 72 | + base_url = SETTINGS.arcs_exp_api_base_uri |
| 73 | + |
| 74 | + async def run(self) -> RunResult: |
| 75 | + response = await self.client.post( |
| 76 | + f"{SETTINGS.arcs_exp_api_base_uri}/run_simulation", |
| 77 | + json={ |
| 78 | + "concs": { |
| 79 | + key: value / 1e6 for key, value in self.concentrations.items() |
| 80 | + }, |
| 81 | + "temperature": self.parameters.temperature, |
| 82 | + "pressure": self.parameters.pressure, |
| 83 | + "samples": 500, |
| 84 | + }, |
| 85 | + timeout=300.0, |
| 86 | + ) |
| 87 | + |
| 88 | + result = response.json() |
| 89 | + |
| 90 | + return {k: v * 1e6 for k, v in result["results"].items()} |
0 commit comments