Articles in this section

Getting Started with OLI Corrosion APIs

Objective

This comprehensive guide is designed to help users get started with the OLI Corrosion APIs. It aims to assist in understanding the capabilities, functionalities, and practical applications of the APIs, providing detailed instructions for predicting corrosion behavior and calculating corrosion rates under various conditions.

Introduction to OLI Corrosion Analyzer

The OLI Corrosion Analyzer utilizes first-principles thermodynamic modeling to predict corrosion behavior on various contact surfaces. This advanced tool provides insights into general corrosion rates, localized corrosion tendencies, depletion profiles of heat-treated alloys, and the thermodynamic stability of metals and alloys. With the introduction of OLI Corrosion APIs, these capabilities are now accessible through simple web requests. Users can programmatically modify parameters such as temperature, pressure, pH, component concentrations, and fluid flow velocity to evaluate the cumulative corrosion of their equipment and identify assets most vulnerable to corrosion.

The Corrosion API includes two main endpoints: corrosion contact surfaces and corrosion rates. Below is detailed information on these endpoints.

Contact Surfaces

The Corrosion API supports both AQ and MSE frameworks. AQ framework currently supports a broader range of contact surfaces, and the Corrosion calculations were recently introduced with the MSE framework in version 12.0. Although the number of contact surfaces available within the MSE framework is currently limited, it is expected to expand. Users can retrieve the supported OLI contact surfaces for their chemistry file version by following these steps. If you already know the OLI name for your contact surface, proceed to the next section.

To obtain the names of contact surface metals supported by OLI for corrosion rate calculations, submit a GET request with your .dbs file ID to the "Corrosion contact surfaces” endpoint:

Corrosion Contact Surfaces Request

This function retrieves the supported corrosion contact surfaces for a given chemistry file.

Endpoint

GET <https://api.olisystems.com/engine/file/{dbs_file_id}/corrosion-contact-surface>

Response

This request returns a resultsLink, which should be polled to obtain the list of all supported surfaces in JSON format. Here is an example response:

{
    "data": {
        "result": {
            "contactSurfaces": {
                "Aluminum": [
                    ...
                ],
                "Copper based alloy": [
                    ...
                ],
                "Iron/Mild steel": [
                    "Fe (zone refined)",
                    "Fe (pure)",
                    "Carbon steel G10100 (generic)",
                    "Carbon steel A212B",
                    "Carbon steel A216",
                    "Carbon steel 1018"
                ],
                "Nickel based alloy": [
                    ...
                ],
                "Stainless steel": [
                    ...
                ]
            }
        }
    },
    "message": "Results returned successfully",
    "status": "PROCESSED"
}

In this example, "Carbon steel G10100 (generic)" is one of the many supported contact surfaces for the given chemistry file. This surface can be used in the corrosion rate calculation.

Corrosion Rates

This function calculates the corrosion rates of metal contact surfaces under specified solution conditions. To perform rate calculation, provide a JSON payload in the request body including parameters such as temperature, pressure, calculationType (e.g., "isothermal"), inflows, and corrosionParameters. The contactSurface details are specified within the corrosionParameters section. The flowType options include "static", "pipeFlow", "rotatingDisk", "rotatingCylinder", "completeAgitation", "definedShearStress", and "approximateMultiPhaseFlow".

Depending on the selected flowType, additional parameters may be required:

  • For pipeFlow: Requires pipeDiameter and pipeFlowVelocity.
  • For rotatingDisk: Requires diskDiameter and diskRotationSpeed.
  • For rotatingCylinder: Requires rotorDiameter and rotorRotation.
  • For definedShearStress: Requires shearStress.
  • For approximateMultiPhaseFlow: Requires multiple parameters such as pipeDiameter, liquidFlowInPipe, gasFlowInPipe, pipeRoughness, etc.

Once you have the JSON payload ready, submit the JSON via a POST request, including your access token and dbs file ID, to the following endpoint to get the corrosion rate results:

POST <https://api.olisystems.com/engine/flash/{dbs_file_id}/corrosion-rates>

For more information and examples of different flow types and their required parameters, please refer to the API documentation.

Calculation Workflow

This guide provides a step-by-step walkthrough for running calculations using the OLI CorrosionAPI.

1. Prerequisites

Ensure the following prerequisites are met:

  • An active OLI Portal account
  • A chemistry model (.dbs) file or instructions to create one using ChemBuilder API

2. Authentication Process

Authenticate with the OLI Cloud to obtain a JSON Web Token (JWT) required for subsequent API requests. Include this token in the authorization header for security.

3. Managing Chemistry Files

The Corrosion requests require a chemistry file, which can be created using one of the following methods:

  • Upload Chemistry Model File: Upload the .dbs chemistry model file to the upload dbs endpoint. A unique file ID is returned, which is required for future calculations.
  • Create .dbs using ChemBuilder API: Refer to the ChemBuilder documentation to create a .dbs file using the APIs.

Chemistry File Reusability: Once obtained, the chemistry file ID can be reused for similar calculations with the same framework, inflow species, phases, and chemical properties.

4. Running Corrosion Calculations

With the .dbs file ID on hand, initiate a request to retrieve contact surfaces for the dbs file. Identify the appropriate contact surface from the response and include it in your corrosion rate calculation payload to begin the corrosion rate calculation.

  • Initiate Calculation Request: Send a POST request to the corrosion rate calculation endpoint, including the required JSON input in the body payload and the chemistry model file ID in the endpoint URL.
  • Result Retrieval: Poll the resultsLink until the calculation is processed. The results will be provided in JSON format for analysis.

Note: A valid OLI account token (JWT) is required with each API request and must be included in the authorization header.

If the corrosion rate calculation succeeds, the response JSON will include corrosionOutputs in the result data, detailing corrosionCurrentDensity, corrosionPotential, corrosionRateGPerMsqDay, corrosionRateMilPerYear, corrosionRateMmPerYear, maximumPitCurrentDensity, and repassivationPotential.

By following these steps, users can effectively initiate corrosion rate calculations using the OLI Corrosion API. For further assistance or to obtain the Python starter kit for ChemBuilder API, please contact OLI Customer Support.

Was this article helpful?
0 out of 0 found this helpful