# Integration¶

This page provides a brief overview of pSeven’s integration tools, data and model import and export formats, and other ways to connect pSeven and various external tools.

## Blocks¶

Many integration capabilities in pSeven are provided by special blocks which create an interface between a pSeven workflow and some program. For example, when a workflow needs data from some CAD package or a solver, you add a block which controls its execution, sends input data to this tool and processes its output. Such blocks are found in the Integration group in the block library.

This group includes two kinds of blocks:

• Direct integration blocks — program-specific blocks, which are intended to provide an easily configurable connector between pSeven and a specific software tool.
• Generic integration blocks — “general purpose” blocks, which are intended to provide greater flexibility but require more configuration.

### Direct Integration¶

Direct integration blocks are:

• ANSYSWorkbench: integrates ANSYS Workbench projects.
• CATIA (beta): integrates CATIA V5 models.
• Creo: integrates PTC Creo parts and assemblies.
• Excel: integrates Excel documents, supports formulas and macros.
• FloEFD: integrates FloEFD analysis projects.
• FMI model: integrates Functional Mock-up Units for Co-Simulation.
• Kompas3D: integrates KOMPAS-3D parts and assemblies.
• NX: integrates Siemens NX models.
• SolidWorks: integrates SolidWorks parts and assemblies.
• STAR-CCM+ (beta): integrates STAR-CCM+ simulation projects.

### Generic Integration¶

Generic integration method in pSeven relies on the Program and Text blocks. It allows to create a custom wrapper block for any tool that supports command line interface. This requires some manual configuration — you will have to add the tool’s command line to the Program block, and usually configure two Text blocks, one of which creates an input file for the program, and the other reads results from the program’s output. This solution is explained in detail in the Integration Basics tutorial.

The Program block can also run programs on a remote host, connecting over SSH or using the pSeven Agent. These features are explained in section Remote Execution on the block’s page.

The Text block can also be used to create input-output file interface in a pSeven’s workflow, which would allow it to run as a part of some external process which starts pSeven in the batch mode — see Command-Line Workflow Integration.

Finally, your workflow can integrate any Python script with the PythonScript block. This provides another option for third-party tool integration, since a Python interface is available for many applications — see section Python below for more details.

## Data Exchange¶

pSeven can use CSV and Excel files as data exchange formats. Data import and export can be automated in a workflow — using related blocks, or can be done manually in Analyze when editing a report.

### Workflows¶

In a workflow, you can use the following blocks to read and write data:

• CSVParser and CSVGenerator are suitable for reading and writing simple tabular files like CSV or fixed width column formats.
• The Excel block, while intended as an integration block (it can run VBA macros to integrate Excel calculations into workflow), can be used for simple read and write operations with Excel files.
• Text block can be used to create a fully custom file parser or writer — you can even use it to generate reports in HTML or other formats.

### Reports¶

In Analyze you can use the data import tool to add data from CSV and Excel files into a report database, and then work with this data in the same way as with the results obtained from a workflow.

Likewise, any data gathered from a workflow and saved to the project database can be added to a report, where you can use the data export tool to save selected samples to a CSV or Excel file.

The tools used to manage project and report data are described in the Results Analysis section of this manual.

## Model Exchange¶

Approximation models trained in pSeven can be exported to various formats. Similar to data exchange, the export can be done from a workflow or from a report in Analyze. Additionally, pSeven allows exporting C source code of data fusion models.

### Workflows¶

When a model is trained by an ApproxBuilder block in a workflow, you can either save it to disk into a binary format specific to pSeven or export to one of the supported formats compatible with third-party programs and tools. If you send the model to an Approximation model block for evaluation, you can also enable export in Approximation model. The latter configuration is more convenient — for example, Approximation model can export to multiple formats simultaneously, in a single run.

Supported export formats are:

• Executable: command-line executable for the platform, on which pSeven currently runs (.exe for Windows and .bin for Linux). Note that it is not possible to export an executable file for another platform — for example, you cannot export a Windows executable under Linux.

• Excel document with a linked DLL: an Excel document with macros (.xlsm), which evaluates the model stored into a complementary DLL. In addition to the Excel document and two model DLLs (for the 32-bit and 64-bit Excel editions), this format also provides a file containing the code of a VBA wrapper (.bas) for the model DLL, and C source (.c) of the DLL. Export to this format is supported only in the Windows version of pSeven.

For convenience, the DLL names are based on the name of the Excel document. However, DLL names (hence, the Excel document name) are also used in the VBA macros code. Due to this, the document name must contain only characters, which can be represented in the system locale’s encoding (see Language for non-Unicode programs in Windows’ language settings). For compatibility across different local versions of Windows, it is recommended to use English characters only.

• FMU for Co-Simulation 1.0: FMI model (Functional Mock-up Unit, .fmu) in the Co-Simulation format, with source and binary.

• FMU for Model Exchange 1.0: FMI model (Functional Mock-up Unit, .fmu) in the Model Exchange format, with source and binary.

• FMU for Co-Simulation 1.0 (source only): FMI model in the Co-Simulation format, with source only.

• FMU for Model Exchange 1.0 (source only): FMI model in the Model Exchange format, with source only.

• C# source (experimental): source code (.cs) to compile the model with C# compiler.

• C# library (experimental): a compiled .NET DLL (.dll). Note that using this export format requires a C# compiler installed (pSeven does not include a C# compiler).

• In Windows: requires .NET Framework or another package which provides the C# compiler (csc.exe). pSeven finds the compiler automatically; if there are several versions installed, the latest is used. If you want to select a specific version, you can set the CSHARP_COMPILER_ROOT environment variable. Its value should be the full path to the directory which contains csc.exe.
• In Linux: requires the dotnet command line tool which is a part of .NET Core SDK. The following environment variables are also required: CSHARP_COMPILER_ROOT must contain the path to the compiler executable (csc.dll), and CSHARP_LIBRARIES_ROOT must contain the full path to the directory where the System.dll and System.Private.CoreLib.dll libraries are located. Finally, the dotnet executable should be added to PATH.
• C source for standalone program: C source code with the main() function, which you can compile to a complete command-line program.

• C header for library: the header for a model compiled to a shared library (DLL or .so).

• C source for library: C header and model implementation, which you can compile to a shared library (DLL or .so).

• C source for MEX: source code for a MATLAB MEX file.

• Octave script: model code compatible with MATLAB.

The Approximation model block also works with data fusion models (.gtdf) trained by the DFBuilder block. If you load a data fusion model to Approximation model, you can export it to the C source code formats; other export formats are not supported for data fusion models.

Note

An FMI model in either format (Co-Simulation or Model Exchange) can be exported as a FMU with a binary, or as a source-only FMU.

The binary FMU is ready to use, but it is platform-dependent: you can use it only on the same platform where it has been exported. For example, it is not possible to export a FMU with a Windows binary if you are running pSeven on Linux. However, this FMU also contains source code, so you can recompile it for any platform.

The source-only FMU does not contain any binaries, so you will always have to compile it in order to obtain a working FMU.

pSeven also provides support for direct integration of FMI models into workflows — see the FMI model block.

### Reports¶

When a model is trained using the predictive modeling tools in Analyze (see Predictive Modeling Tools), it is added to the report database and can be exported from there. Supported formats are the same as in the Approximation model block (listed above).

## High-Performance Clusters¶

pSeven can send jobs to a TORQUE, SLURM, or LSF cluster. This is one of advanced features of the Program block, which is the main “general purpose” integration block in pSeven (see Generic Integration).

This block can connect to a batch manager over SSH and submit a job with settings specified in block’s configuration. Details of such configuration and supported job options are described in section Running Cluster Jobs on the Program block page.

## Python¶

Your workflow can integrate any Python script with the PythonScript block. Basically, this block uses the values from its input ports to set values of script variables, then runs the script, gets values of variables and sends them to output ports. You specify which variables it sets and gets, and how these variables are mapped to ports. For configuration details, see the PythonScript block page.

The PythonScript block does not require you to install Python, because the block runs your scripts using the pSeven’s built-in Python interpreter. The same built-in interpreter works when you open and run a Python script in Workspace, so you can quickly test your scripts for compatibility without even creating a workflow. The PythonScript block also supports testing — see Testing Scripts.

Many commonly used Python modules are pre-installed into pSeven — for example, numpy, scipy, scikit-learn, bokeh, PyWin32 modules, requests, tornado, and other (see Built-in Modules for full details). You can add more modules easily — see section Additional Modules on the block’s page.

## Command-Line Workflow Integration¶

If you are looking for a way to integrate pSeven as a part of some external process, it is possible to run workflows in an automated way, without using pSeven’s graphical user interface. A workflow can be started from the command line using pSeven’s batch mode (p7batch). The batch mode does not require user input, so you can use this command line in scripts or third-party process management tools. Its notable features are:

• Workflows are started from a command line, there is no need to open a project in pSeven or click any GUI buttons.
• Running a workflow in batch mode does not show pSeven’s graphical interface, so it can be used even on systems without a graphical environment.
• pSeven running in batch mode does not require a full license: a pSeven Runner license is used if available (see pSeven Runner for details).

The batch mode executable (p7batch.exe in Windows, p7batch in Linux) is found in the client subdirectory of the pSeven installation directory. Workflow run syntax is:

p7batch --run-workflow "<project_path>/<workflow_name>" [--preset "<preset_name>"]


The parameters are:

• <project_path>: the path to your project — for example, C:/Users/User/Documents/pSeven/MyProject. The path can be relative. Note that on Windows, both \ and / are accepted as path separators, though your command line cannot contain both of them at the same time.
• <workflow_name>: the name of the workflow to run — for example, myWorkflow.p7wf. Specifying the .p7wf extension is optional: myWorkflow works as well.
• <preset_name>: optional, specifies a workflow parameter preset to select (presets are created in Run). If --preset is omitted, p7batch will use the preset which comes first in the list shown by the preset selector in Run.

p7batch reads values of workflow inputs (root input ports) if they are saved in the workflow, but does not provide an option to change these values when running. It also does not show workflow outputs. This means that you will have to handle data input and output in the workflow — for example, you can add an input Text block which parses a file with workflow inputs generated by another application, and an output Text block which generates a report file with workflow results.