# Mixer calculation

### Request payload

```json
{
    "method": "scalechem.mixerCalculation",
    "params": {
        "name": "mixer",
        "chemistryModel": "mixerChemistry",
        "externalStreams": [...<snip>...],
        "inletInputs": [...<snip>...],
        "temperature": {
            "unit": "°C",
            "value": 50
        },
        "pressure": {
            "unit": "bar",
            "value": 1.1
        }
    }
}
```

| **params**      | type                                | description                                                                                                                                                                                                    |
| --------------- | ----------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| name            | string                              | name of output stream                                                                                                                                                                                          |
| chemistryModel  | string                              | [chemistry model file (dbs) name](/oli-scalechem-api/main-methods.md#chemistry-model) for mixer calculation                                                                                                    |
| externalStreams | array of objects                    | [inputs for external streams](#external-streams)                                                                                                                                                               |
| inletInputs     | array of objects                    | [flow rate specifications for mixer inlet streams](#undefined)                                                                                                                                                 |
| temperature     | [valueObject](/terms-definition.md) | specified temperature with [unit](/input-unit-set.md)                                                                                                                                                          |
| pressure        | [valueObject](/terms-definition.md) | specified pressure with [unit](/input-unit-set.md)                                                                                                                                                             |
| inheritOptions  | boolean                             | Optional, option to apply "[optionalProperties](/optional-inputs.md#optional-properties)"  and "[unitSetInfo](/optional-inputs.md#output-units)" to calculation objects in "externalStreams". Default is false |

### External streams

External streams can be calculated by three types of inputs at isothermal conditions: 1) ionic species composition, 2) inflow species composition, 3) mixer calculation to combine calculated external stream.&#x20;

{% tabs %}
{% tab title="ionic input stream" %}

```json
{
    "method": "scalechem.mixerCalculation",
    "params": {
        ...<snip>...
        "externalStreams": [
            {
                "name": "brine example",
                "chemistryModel": "brineChemistry",
                "waterAnalysisInputs": [...<snip>...]
            },
            {
                "name": "another stream",
                ...<snip>...
            },
            ...<snip>...
        ]
    }
}
```

{% endtab %}

{% tab title="inflow input stream" %}

```json
{
    "method": "scalechem.mixerCalculation",
    "params": {
        ...<snip>...
        "externalStreams": [
            {
                "name": "inflow example",
                "chemistryModel": "inflowChemistry",
                "inflows": {...<snip>...},
                "temperature": {
                    "value": 50.0,
                    "unit": "°C"
                },
                "pressure": {
                    "value": 1.5,
                    "unit": "atm"
                },
                "saturateWithH2O": "gas"
            },
            {
                "name": "another stream",
                ...<snip>...
            },
            ...<snip>...
        ]
    }
}
```

{% endtab %}

{% tab title="mixer calculation stream" %}

```json
{
    "method": "scalechem.mixerCalculation",
    "params": {
        ...<snip>...
        "externalStreams": [
            {
                "name": "example stream 1",
                ...<snip>...
            },
            {
                "name": "example stream 2",
                ...<snip>...
            },
            {
                "name": "mixer example",
                "chemistryModel": "externalMixerChemistry",
                "inletInputs": [
                    {
                        "streamName": "example stream 1",
                        "streamType": "brine",
                        "totalAmount": {
                            "value": 1,
                            "unit": "bbl/day"
                        }
                    },
                    {
                        "streamName": "example stream 2",
                        ...<snip>...
                    }
                ],
                "temperature": {
                    "value": 50.0,
                    "unit": "°C"
                },
                "pressure": {
                    "value": 1.5,
                    "unit": "atm"
                }
            },
            {
                "name": "another stream",
                ...<snip>...
            },
            ...<snip>...
        ]
    }
}
```

{% endtab %}
{% endtabs %}

#### Common external stream inputs

| **params.externalStreams\[{}]** | type   | description                                                   |
| ------------------------------- | ------ | ------------------------------------------------------------- |
| name                            | string | external stream name                                          |
| chemistryModel                  | string | optional, chemistry model file (dbs) name for external stream |

{% hint style="success" %}
"chemistryModel" input is optional. The chemistry model file of the mixer calculation will be used if this input is missing.
{% endhint %}

#### External stream from ionic input

All inputs are specified as an array of objects in "waterAnalysisInputs", which are explained in[ water analysis ](/group1/api-functions/wateranalysis.md#water-analysis)calculation.

#### External stream from inflow input

| **params.externalStreams\[{}]** | type                                | description                                                                                                                     |
| ------------------------------- | ----------------------------------- | ------------------------------------------------------------------------------------------------------------------------------- |
| inflows                         | object                              | [inflow input](/inflows-input.md)                                                                                               |
| temperature                     | [valueObject](/terms-definition.md) | specified temperature with [unit](/input-unit-set.md)                                                                           |
| pressure                        | [valueObject](/terms-definition.md) | specified pressure with [unit](/input-unit-set.md)                                                                              |
| saturateWithH2O                 | string                              | optional, could be specified as "gas" or "oil", which will add H2O to the system to saturate the corresponding phase with water |

#### External stream from mixer calculation

|                                 |                                     |                                                                                                             |
| ------------------------------- | ----------------------------------- | ----------------------------------------------------------------------------------------------------------- |
| **params.externalStreams\[{}]** | type                                | description                                                                                                 |
| inletInputs                     | array of objects                    | name, type, and flow rate for combining stream, as explained in [inlet specification](#inlet-specification) |
| temperature                     | [valueObject](/terms-definition.md) | specified temperature with [unit](/input-unit-set.md)                                                       |
| pressure                        | [valueObject](/terms-definition.md) | specified pressure with [unit](/input-unit-set.md)                                                          |

{% hint style="warning" %}
External streams are calculated in the order of the input array. Any mixer calculation specified in external streams can combine external streams that are already calculated.
{% endhint %}

{% hint style="info" %}
Any mixer calculation in external streams can be treated as an inlet for followed mixer calculations. In other words, mixer calculations can be specified cascadingly in external streams.
{% endhint %}

### Inlet specification

```json
{
    "method": "scalechem.mixerCalculation",
    "params": {
        ...<snip>...
        "inletInputs": [
            {
                "streamName": "external stream 1",
                "streamType": "brine",
                "totalAmount": {
                    "value": 1.0, 
                    "unit": "bbl/day"
                }
            },
            {
                "streamName": "external stream 2",
                ...<snip>...
            },
            ...<snip>...
        ]
    }
}
```

|                             |                                     |                                                                                                                                    |
| --------------------------- | ----------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| **params.inletInputs\[{}]** | type                                | description                                                                                                                        |
| streamName                  | string                              | name of the [external stream](#external-streams) to be combined in mixer                                                           |
| streamType                  | string                              | stream type, this determines target phases to be combined in mixer                                                                 |
| totalAmount                 | [valueObject](/terms-definition.md) | inlet stream flow rate with unit explained below                                                                                   |
| automaticFlowRate           | boolean                             | optional, when speciefied as true, total flow rate specified in the external stream will be used, then "totalAmount" is not needed |

{% hint style="warning" %}
"automaticFlowRate" can only be specified true when the corresponding external stream is calculated in [flowing system](/inflows-input.md#units-in-flowing-systems).
{% endhint %}

#### Inlet stream types

| **params.inletInputs\[{}].streamType** | phases to be combined     | phase property to be used in calculating flow rate |
| -------------------------------------- | ------------------------- | -------------------------------------------------- |
| brine                                  | liquid-1                  | liquid-1                                           |
| oil                                    | vapor, liquid-2           | liquid-2                                           |
| gas                                    | vapor, liquid-2           | vapor                                              |
| whole fluid                            | liquid-1, liquid-2, vapor | all phases                                         |

<table data-header-hidden><thead><tr><th width="221.79121149644584"></th><th></th></tr></thead><tbody><tr><td><strong>params.inletInputs[{}].streamType</strong></td><td><strong>params.inletInputs[{}].totalAmount.unit</strong> numerators</td></tr><tr><td>brine, whole fluid</td><td>bbl, L, ml, cm3, m3, E3m3, E6m3, ft3, Mft3, MMft3, gal, MMgal</td></tr><tr><td>oil</td><td>std bbl, std m3, std L, bbl, m3, L</td></tr><tr><td>gas</td><td>std MMft3, std Mft3, std ft3, std E3m3, std m3, std L, MMft3, Mft3, ft3, E3m3, m3, L</td></tr></tbody></table>

{% hint style="info" %}
**params.inletInputs\[{}].totalAmount.unit** is flow rate unit with volumetric units as shown above divide by a time unit, i.e. bbl/day. Available time units are s, min, hr, day, yr.
{% endhint %}

### Saturator option (optional)

This option can be specified to saturate one or more solid species by varying the inflow species.

```json
{
    "method": "scalechem.mixerCalculation",
    "params": {
        ...<snip>...
        "saturatorOptions": [
            {
                "mineralToSaturate": "BASO4PPT",
                "inflowToVary": "BASO4"
            },
            ...<snip>...
        ]
    }
}
```

|                                  |        |                                                                                                                                                      |
| -------------------------------- | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
| **params.saturatorOptions\[{}]** | type   | description                                                                                                                                          |
| mineralToSaturate                | string | solid species to be saturated, using "trueName"  for species with solid phase. See [chemistry information](/group1/api-functions/chemistry-info.md). |
| inflowToVary                     | string | varying inflow species, using "baseName"  for inflows. See [chemistry information](/group1/api-functions/chemistry-info.md).                         |

### Additional input

{% 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 %}

### Response (status = PROCESSED)

```json
{
    "code": 200,
    "result": {
       "external stream 1": {...<snip>...},
       "external stream 2": {...<snip>...},
       ...<snip>...,
       "mixer outlet stream": {...<snip>...}
    },
    "message": "Results returned successfully", 
    "status": "PROCESSED"
}
```

The "result" contains all [stream outputs ](/stream-output-json.md)for each external stream and the final mixer outlet stream by their names specified in the input.

### 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/inletInputs/***i***/totalAmount/value" where ***i*** is the index (0 based) of the **params.inletInputs** array of objects |


---

# 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/oli-scalechem-api/main-methods/mixer-calculation.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.
