# Autoclave

{% hint style="danger" %}
This calculation is currently not supported
{% endhint %}

The **oliengine.autoclaveFlash** function mimics the autoclave application, which is a high pressure, high temperature hydrometallurgy unit with carefully controlled conditions.

{% hint style="info" %}
For this example purposes, let's assume the chemistry model file contains H2O, NACL, CO2, and CH4 as inflows in the MSE Thermodynamic framework
{% endhint %}

## JSON input (sample)

```javascript
{
    "method": "oliengine.autoclaveFlash",
    "params": {
        "ambientTemperature": {
            "value": 40.0,
            "unit": "°C"
        },
        "finalTemperature": {
            "value": 50.0,
            "unit": "°C"
        },
        "finalPressure": {
            "value": 2.0,
            "unit": "atm"
        },
        "vesselVolume": {
            "unit": "L",
            "value": 500.0
        },
        "computeAmbientCondition": true,
        "inflows": {
            "unit": "mol",
            "values": {
                "H2O": 50.0,
                "CO2": 10.0,
                "NACL": 0.1,
                "CH4": 10.0
            },
            "totalAmount":
            {
                "value": 70.1,
                "unit": "mol"
            }
        },
        "gasSpecifications": {
            "targetGases": [
                "CH4",
                "CO2"
            ],
            "specifiedTypePartialPressure": false,
            "unit": "mole %",
            "specifiedGasValues": {
                "CO2": 15.0
            }
        },
        ...<snip>...
}
```

{% hint style="info" %}
Most flash calls for OLI API follows a very similar input to describe the calculation with minor variation to specify calculation specific information
{% endhint %}

| **params**              | type        | description                                |
| ----------------------- | ----------- | ------------------------------------------ |
| ambientTemperature      | valueObject | temperature at ambient condition with unit |
| finalTemperature        | valueObject | temperature at final condition with unit   |
| finalPressure           | valueObject | pressure at final condition with unit      |
| vesselVolume            | valueObject | vessel volume with unit                    |
| computeAmbientCondition | boolean     | flash calculation condition                |

{% hint style="info" %}
A **valueObjec**t type is defined as JSON object of the type **{"value": number, "unit": "string" }**
{% endhint %}

{% hint style="info" %}
**params.temperature.unit**: °C, K, °F, R

**params.pressure.unit**: atm, bar, barg, mbar, Pa, kPa, MPa, mmHg, Torr, inHg, psia, psig, inH2O, kg/cm2

**params.computeAmbientCondition**:&#x20;

true: compute flash at ambient condition;&#x20;

false: compute flash at final condition
{% endhint %}

### Gas specification

| **params.gasSpecifications** | type      | description                                               |
| ---------------------------- | --------- | --------------------------------------------------------- |
| targetGases                  | \[string] | list of any number of gas species names as targeted gases |
| specifiedTypePartialPressure | boolean   | type of targeted gas composition                          |
| unit                         | string    | unit of targeted gas composition                          |
| specifiedGasValues           | object    | specified gas composition by {gas\_name: amount}          |

{% hint style="info" %}
**params.gasSpecifications.specifiedTypePartialPressure**:&#x20;

true: targeted gas composition specified by partial pressure. **params.gasSpecifications.unit** from atm, bar, barg, mbar, Pa, kPa, MPa, mmHg, Torr, inHg, psia, psig, inH2O, kg/cm2

false: targeted gas composition specified by mole fraction(s) in aqueous phase. **params.gasSpecifications.unit** from mol/mol, mole %, ppm (mole)
{% endhint %}

{% hint style="info" %}
**params.gasSpecifications.specifiedGasValues**: The number of specified gas should be the number of **gasSpecifications.targetGases** -1
{% endhint %}

{% hint style="info" %}
**params.gasSpecifications.targetGases** and the keys of **params.gasSpecifications.specifiedGasValues** are the inflow names of gas species, which can be retrieved from [oliengine.getChemistryInfo](https://devdocs.olisystems.com/group1/api-functions/chemistry-info) call under **result.inflows**.
{% endhint %}

### Optional inputs

Some optional inputs can be specified in JSON input, see [Optional Inputs](https://devdocs.olisystems.com/optional-inputs).

## JSON output (example)

```javascript
{
    "result": {
        "phases": {
            "liquid1": {
                ...<snip>...
                }
            },
            "vapor": {
                ...<snip>...
            },
            "solid": {
                ...<snip>...
            },
            "liquid2": {
                ...<snip>...
            }
        },
        "phaseSummary": [
            {
                "phase": "liquid1",
                "found": true
            },
            {
                "phase": "vapor",
                "found": true
            },
            {
                "phase": "solid",
                "found": false
            },
            {
                "phase": "liquid2",
                "found": false
            }
        ],
        "total": {
            "totalMolecularMoles": {
                "value": 85.54088467359415,
                "unit": "mol"
            },
            ...<snip>...
        },
        "calculatedVariable": [
            {
                "type": "calculatedParameter",
                "name": "ambientTemperature",
                "value": 40.0,
                "unit": "°C"
            },
            {
                "type": "calculatedParameter",
                "name": "ambientPressure",
                "value": 1.892610720086249,
                "unit": "atm"
            },
            {
                "type": "calculatedParameter",
                "name": "finalTemperature",
                "value": 50.0,
                "unit": "°C"
            },
            {
                "type": "calculatedParameter",
                "name": "finalPressure",
                "value": 2.0,
                "unit": "atm"
            },
            {
                "type": "calculatedParameter",
                "name": "vesselVolume",
                "value": 500.0,
                "unit": "L"
            },
            {
                "type": "inflow",
                "name": "CH4",
                "value": 35.43088467359407,
                "unit": "mol"
            },
            {
                "type": "inflow",
                "name": "CO2",
                "value": 0.009999999999999998,
                "unit": "mol"
            }
        ]
    }
}
```

This represents the **stream output JSON**, which is common to all OLI's flash calculation results. Here a condensed version of the output is shown with many major parts removed. A better description of the stream output is given here: [Stream output JSON](https://devdocs.olisystems.com/stream-output-json)

| result.calculatedVariable \[{}] | type   | description                  |
| ------------------------------- | ------ | ---------------------------- |
| type                            | string | type of calculated variable  |
| name                            | string | name of calculated variable  |
| value                           | number | value of calculated variable |
| unit                            | string | unit of calculated variable  |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://devdocs.olisystems.com/group1/api-functions/autoclave.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
