Tutorial 1: Creating a Flowsheet

The Basics

This tutorial provides information about the basic use of FOQUS and setting up a very simple flowsheet. A single node flowsheet will be created that performs a simple calculation using a square root so that simulation errors can be observed when a negative input value is provided.

This tutorial will show the user the procedure for creating a flowsheet in FOQUS. However, if the user is interested, the finished flowsheet is available in: examples/tutorial_files/Flowsheets/Tutorial_4

Note

The examples/ directory refers to the location where the FOQUS examples were installed, as described in Install FOQUS Examples.

  1. Start FOQUS (see Section Getting Started).

  2. In the session form enter the Session Name as “Simple_Flow” (Figure Setting the Session Name).

Setting the Session Name

Setting the Session Name

  1. Set the session description.

    1. Select the Description tab (Figure Setting the Session Description).

    2. Type the description shown in Figure Setting the Session Description. The buttons above the Description tab box can be used to format the text.

Setting the Session Description

Setting the Session Description

  1. Click the Flowsheet button at the top of the Home window (Figure Flowsheet, Input Variables).

  2. Add a node named “calc.”

    1. Click the Add Node button in the toolbar on the left side of the Home window.

    2. Click a location on the gridded flowsheet area.

    3. Enter the node name “calc” in the dialog box.

  3. Click the Select Mode button in the toolbar.

  4. Open the Node Editor by clicking the Node Editor button in the toolbar.

  5. Add input variables to the node. (When linking a node to an external simulation the input and output variables are populated automatically, and this step is not necessary.)

    1. Click + above the Input Variables table.

    2. Enter x1 in the variable Name dialog box. Enter 1 for the variable size, -2 for the min, 2 for the max, and 1 for the value.

    3. Click + above the Input Variables table.

    4. Enter x2 in the variable Name dialog box. Enter 1 for the variable size, -1 for the min, 4 for the max, and 4 for the value.

Flowsheet, Input Variables

Flowsheet, Input Variables

  1. Add an output variable to the node. (When linking a node to an external simulation the input and output variables are populated automatically.)

    1. Click Output Variables to show the Output Variables table (Figure Flowsheet, Output Variables).

    2. Click + above the Output Variables table to add a variable.

    3. Enter z in the output Name dialog box.

Flowsheet, Output Variables

Flowsheet, Output Variables

In this example, the node is not linked to any external simulation. The FOQUS nodes contain a section called node script, which can be used to do calculations before, after or instead of a simulation linked to the node. The node script can be used for things such as unit conversion, simple calculations, or simulation convergence procedures. The node scripts are written as Python. The Input Variables are contained in a dictionary named x and the Output Variables are contained in a dictionary named f. The dictionary keys are the variables names shown in the input and output tables. Only Output Variables can be modified by a node script.

  1. Add a calculation to the node.

    1. Click the Node Script tab (Figure Node Calculation).

    2. Enter the following code into the Python code box:
      f['z'] = x['x1']*math.sqrt(x['x2'])
  2. Click the Variables tab.

  3. Click the Run button (Figure Node Calculation).

The flowsheet should run successfully and the output value should be 2. Rerun the flowsheet with a negative value for x2, and observe the result. The simulation should report an error.

Node Calculation

Node Calculation

  1. Save the FOQUS session.

    1. Click the Session drop-down menu at the top of the Home window (Figure Save Session).

    2. Click Save. The exact location of save in the menu depends on whether or not the data management framework is enabled.

    3. The Change Log entry can be left blank.

    4. The default file name is the session name. Change the file name and location if desired.

Save Session

Save Session

Automatically running FOQUS for a set of user-defined input conditions

This procedure requires the Uncertainty Tab.

Therefore, the instructions for this procedure can be found in the documentation under:

Uncertainty Quantification / Tutorial / Simulation Ensemble Creation and Execution / Automatically running FOQUS for a set of user-defined input conditions

The link for these instructions is shown below:

https://foqus.readthedocs.io/en/latest/chapt_uq/tutorial/sim.html