> For the complete documentation index, see [llms.txt](https://devdocs.olisystems.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://devdocs.olisystems.com/group1/api-functions/custom.md).

# Custom flash

This function calculates equilibrium condition with any number of fixed and freed system parameters.

## custom&#x20;

<mark style="color:green;">`POST`</mark> `https://api.olisystems.com/engine/flash/{dbs_file_id}/custom`

run a custom equilibrium calculation

#### Headers

| Name          | Type   | Description            |
| ------------- | ------ | ---------------------- |
| Authorization | string | Bearer {access\_token} |
| Content-Type  | string | application/json       |

{% tabs %}
{% tab title="200 Please look at "API call blueprint" page on how to obtain results" %}

```
{
	"code": 200,
	"data": {
		"file_id": "dee854a6-59db-487d-ad08-a20dee691133",
		"jobId": "f6b3375e-cd0f-4ace-a5ee-71e047b76754",
		"resultsLink": "https://api.olisystems.com/result/flash/f6b3375e-cd0f-4ace-a5ee-71e047b76754?context=engine",
		"status": "IN PROGRESS"
	},
	"message": "Process execution started Successfully",
	"status": "SUCCESS"
}
```

{% endtab %}
{% endtabs %}

### Request payload

```json
{
    "params": {
        "temperature": {
            "value": 40.0,
            "unit": "°C"
        },
        "pressure": {
            "value": 1.5,
            "unit": "atm"
        },
        "fixedVars": [
            {
                "type": "vaporPhaseComposition",
                "name": "BENZENEVAP",
                "value": 16.0,
                "unit": "mole %"
            },
            {
                "type": "property",
                "name": "volume",
                "value": 440.0,
                "unit": "L"
            }
        ],
        "freedVars": [
            {
                "type": "inflow",
                "name": "BENZENE",
                "value": 0.0,
                "unit": "mol"
            },
            {
                "type": "state",
                "name": "temperature",
                "value": 0.0,
                "unit": "°C"
            }
        ],
        "inflows": {
            "unit": "mol",
            "values": {
                "H2O": 50.0,
                "BENZENE": 10.0,
                "CH4": 20.0,
                "NACL": 35.0
            },
            "totalAmount":
            {
                "value": 115.0,
                "unit": "mol"
            }
        }
}
```

| **params**  | type                                | description                                                            |
| ----------- | ----------------------------------- | ---------------------------------------------------------------------- |
| temperature | [valueObject](/terms-definition.md) | specified or initial guess temperature with [unit](/input-unit-set.md) |
| pressure    | [valueObject](/terms-definition.md) | specified or initial guess pressure with [unit](/input-unit-set.md)    |
| fixedVars   | array of objects                    | list of objects to describe fixed flash output variables               |
| freedVars   | array of objects                    | list of objects to describe freed flash input variables                |

{% hint style="danger" %}
The sizes of the object arrays, **params.fixedVars** and **params.freedVars** must be equal&#x20;
{% endhint %}

#### Here is a description of the **type** and **name** attributes for the **params.fixedVars** array

| **params.fixedVars\[*****index\_number*****].type** | **params.fixedVars\[*****index\_number*****].name** |
| --------------------------------------------------- | --------------------------------------------------- |
| property                                            | volume, enthalpy, pH                                |
| liquid1PhaseComposition                             | species name of liquid phase                        |
| liquid2PhaseComposition                             | species name of liquid phase                        |
| vaporPhaseComposition                               | species name of vapor phase                         |
| solid                                               | species name of solid phase                         |

{% hint style="info" %}
species name can be retrieved from [chemistry information call](/group1/api-functions/chemistry-info.md) under **result.species(trueName)**, respectively.
{% endhint %}

#### Here is a description of the **unit** attribute for the **params.fixedVars** array

| **params.fixedVars\[*****index\_number*****].type or .name**            | **params.fixedVars\[*****index\_number*****].unit**           |
| ----------------------------------------------------------------------- | ------------------------------------------------------------- |
| liquid1PhaseComposition, liquid2PhaseComposition, vaporPhaseComposition | mol/mol, mole %, ppm (mole)                                   |
| solid                                                                   | mol, kgmol, lbmol, mmol, µmol, (mol/100)                      |
| volume                                                                  | L, ml, cm3, m3, E3m3, E6m3, ft3, Mft3, MMft3, gal, MMgal, bbl |
| enthalpy                                                                | cal, E3cal, E6cal, J, kJ, MJ, Btu, MMBtu                      |

#### This section explains the available flash input variables can be freed for this calculation

| **params.freedVars\[*****index\_number*****].type** | **params.freedVars\[*****index\_number*****].name** | **params.freedVars\[*****index\_number*****].unit**                             |
| --------------------------------------------------- | --------------------------------------------------- | ------------------------------------------------------------------------------- |
| state                                               | temperature                                         | °C, K, °F, R                                                                    |
| state                                               | pressure                                            | atm, bar, barg, mbar, Pa, kPa, MPa, mmHg, Torr, inHg, psia, psig, inH2O, kg/cm2 |
| inflow                                              | inflow name                                         | mol, kgmol, lbmol, mmol, µmol, (mol/100)                                        |

{% hint style="info" %}
in addition to the inputs shown above some optional properties may also be specified. They can be viewed [here](/optional-inputs.md)
{% endhint %}

### JSON output (status = PROCESSED)

```javascript
{
    "code": 200,
    "data": {
        "result": {
            ...<snip>...
            "calculatedVariables": [
                {
                    "name": "BENZENE",
                    "value": 4.048793029736938,
                    "unit": "mol"
                },
                {
                    "name": "temperature",
                    "value": 45.5766850916292,
                    "unit": "°C"
                }
            ]
        }
    }, 
    "message": "Results returned successfully", 
    "status": "PROCESSED"
}
```

The output of this calculation is the [stream output ](/stream-output-json.md)which is common result output for all OLI's flash calculations or an [error](/error-output.md). In addition to this output the result also contains the values of the free variables which can be conveniently retrieved from the **result.calculatedVariables** array&#x20;

| result.calculatedVariables [\[{}\]](/terms-definition.md) | type   | description                     |
| --------------------------------------------------------- | ------ | ------------------------------- |
| name                                                      | string | name of calculated variable     |
| value                                                     | number | value of calculated variable    |
| unit                                                      | string | unit of the calculated variable |

### Survey Calculation

Survey calculation is supported for the variables below. Please refer to [Survey calculation](/survey-calculation.md) for explained input schema.

| supported **params.surveyInputs\[{}].field**                                                                  |
| ------------------------------------------------------------------------------------------------------------- |
| "/params/temperature/value"                                                                                   |
| "/params/pressure/value"                                                                                      |
| "/params/fixedVars/***i***/value" where ***i*** is the index (0 based) of **params.fixedVars** to be surveyed |
| "/params/freedVars/***i***/value" where ***i*** is the index (0 based) of **params.freedVars** to be surveyed |
