> 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/setph.md).

# set pH flash

This function calculates the equilibrium solution at a specified pH by varying inflows of acid and/or base titrant(s).

## set pH

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

fix the pH of the aqueous phase by varying acid/base amount

#### 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://devapi.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

```javascript
{
    "params": {
        "temperature": {
            "value": 30.0,
            "unit": "°C"
        },
        "pressure": {
            "value": 1.5,
            "unit": "atm"
        },
        "targetPH": {
            "value": 8.0,
            "unit": ""
        },
        "pHAcidTitrant": "HCL",
        "pHBaseTitrant": "NAOH",
        "inflows": {
            "unit": "mol",
            "values": {
                "H2O": 50.0,
                "CO2": 10.0,
                "NACL": 20.0,
                "BENZENE": 10.0,
                "HCL": 0.0,
                "NAOH": 0.0
            }
        }
    }
}
```

| **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)    |
| targetPH      | value                               | specified target pH of the solution                                    |
| pHAcidTitrant | string                              | inflow species name for pH acid titrant                                |
| pHBaseTitrant | string                              | inflow species name for pH base titrant                                |

{% hint style="danger" %}
One or both of **params.pHAcidTitrant** and **params.pHBaseTitrant** need to be specified. If only one titrant is to be specified, it is the same to specify it as **params.pHAcidTitrant** or **params.pHBaseTitrant** regardless of the chemical nature of the solvent.
{% endhint %}

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

```javascript
{
    "code": 200,
    "data": {
        "result": {
            "addedTitrants": [
                {
                    "name": "NAOH",
                    "titrantType": "Base",
                    "unit": "mol",
                    "value": 9.998955177015539
                }
            ],
            ...<snip>...
        }
    }, 
    "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 amounts of added titrants and can be conveniently retrieved from the **data.result.addedTitrants** array&#x20;

| data.result.addedTitrants [\[ { } \]](/terms-definition.md) | type   | description                                                                                       |
| ----------------------------------------------------------- | ------ | ------------------------------------------------------------------------------------------------- |
| titrantType                                                 | string | titrant type, i.e. "Acid" or "Base". This field will be missing if only one titrant is specified. |
| name                                                        | string | inflow name of the titrant                                                                        |
| value                                                       | number | added titrant amount                                                                              |
| unit                                                        | string | unit of added titrant amount                                                                      |

### 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/targetPH/value"                     |
