Articles in this section

Exporting and Importing DBS Chemistry File to OLI Cloud

Objective

This article serves as a quick guide on exporting a chemistry file in .dbs format using OLI Studio and subsequently uploading it to your OLI Cloud account via APIs. It also covers how to obtain the chemistry file ID necessary for certain OLI API calculations.

Overview

This guide outlines the process to export a chemistry file using the OLI Studio desktop application and upload it to your OLI Cloud account via the OLI Cloud APIs. The guide is divided into two sections: the first section explains how to export the chemistry file as a .dbs file using OLI Studio, and the second section provides instructions for uploading this file to your OLI Cloud account. By the end of this article, you will have obtained a chemistry file ID for the uploaded .dbs file. This ID will be ready for use in Engine, Corrosion, or some ScaleChem API calculations.

Section 1: Export the chemistry file using OLI Studio.

Step 1: Enable "OLI File Viewer" (First-Time Setup Only)

1.1 Open your OLI Studio file.

1.2 Navigate to Tools -> Options -> Plug-Ins .

1.3 Click on "Plug-Ins" in the category section and enable the "OLI File Viewer."

Step 2: Run OLI Simulation and Save DBS File

2.1 In OLI Studio, add a stream and update the inflow components in the data entry section. Ensure that all inflow components have valid, non-zero values. Note that only the list of chemical species, not their values, will be exported with your dbs file.

2.2 Select a calculation type and initiate the OLI calculation. Then, navigate to the "File Viewer" section.

2.3 From the "File Type" dropdown menu, select "Generated Model File." Then, use the "Save file(s)" option to save the DBS file.

Section 2: Import the Chemistry file to your OLI cloud account.

To perform calculations using the OLI Cloud APIs, you must first upload your chemistry model file (.dbs file). This file will be referenced later in your API calculation requests. Follow these steps to upload the .dbs file:

Upload Directly via the API

You can directly upload .dbs files using the /channel/upload/dbs OLI API endpoint. This method uploads the .dbs file to your OLI account.

To complete the upload, initiate a POST request to the endpoint by attaching the .dbs file generated in Part 1.

  • Endpoint URL: https://api.olisystems.com/channel/upload/dbs
  • HTTP Method: POST
  • Headers: Include your API access token formatted as Bearer {access_token}.
  • Request Body: Attach the .dbs file as multipart/form-data.

Example of Uploading the File Using Python

Here’s a simple example using the requests library in Python to upload your .dbs file:

import requests
import json

# OLI dbs upload API endpoint URL
url = "https://api.olisystems.com/channel/upload/dbs"

payload = {}

files = [
('files', ('filename.dbs', open('/path/to/your/filename.dbs', 'rb'), 'application/octet-stream'))
]

headers = {
'Authorization': 'Bearer {access_token}'
}

# Sending the POST request
response = requests.post(url, headers=headers, data=payload, files=files)
data = json.loads(response.text)
file_id = data['file'][0]['id']
print("Chemistry file ID:", file_id)

Replace {access_token} with your actual access token and adjust the file path and name (path_to_your_filename.dbs and filename.dbs) as needed.

Response

A successful file upload will provide a JSON response with details about the file:

{
"file": [
{
"filename": "filename.dbs",
"id": "ff7fa6e9-a72b-4ffd-a4eb-c0e3f95746ce"
}
],
"status": "UPLOADED",
"type": "dbs"
}

The id field represents the unique identifier assigned to the uploaded file, which is necessary for making API calculation requests. Only the account that uploaded the file has access to it. If the chemistry configuration remains unchanged, you can reuse the same file ID for multiple calculations. In other words, as long as the chemistry setup remains consistent, the file ID remains valid for subsequent API requests. This allows you to perform various calculations without the need to upload the .dbs file repeatedly.

To learn more about utilizing the chemistry file ID when performing EngineAPI calculations, please refer to the "Getting Started with EngineAPI" article, which provides detailed instructions and guidelines.

Intended Audience

This article is intended for customers who have the OLI Studio desktop application and wish to create a .dbs chemistry file using their known chemistry data for use with the APIs.

For users without access to OLI Studio, we offer two robust alternatives: the OLI Chemistry Wizard and the OLI ChemBuilder API.

Alternative Methods to Obtain DBS File Without OLI Studio

  1. OLI Chemistry Wizard: This free desktop application empowers you to create the required .dbs file with ease.

  2. OLI ChemBuilder API: ChemBuilder is a set of APIs that automate the creation of .dbs files in the OLI cloud. This streamlines your workflow, eliminates the need for desktop applications, and ensures seamless integration. OLI highly recommends the OLI ChemBuilder API. Learn more about ChemBuilder at “Getting Started with OLI ChemBuilder API”.

By following one of these methods, OLI users can ensure they have the necessary .dbs chemistry file to utilize the OLI APIs effectively and initiate OLI calculations.

If you have any questions or require the Python starter kit for ChemBuilder API, please contact OLI Customer Support.

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