Example Python Files
Jump to navigation
Jump to search
Navigation: User Guide ➔ COM Automation ➔ Python Automation
| Python Setup | Python Examples | Python Script | Optimisation | Visulisation | Python GUI | Tags and Data | |||
|---|---|---|---|---|---|---|---|---|---|
| Installation & Troubleshooting | List of Examples | Simple Script (pywin32) | SysCAD COM Python Class | Automated Model Testing | Constrained FEM (numpy|matplotlib) | Optimisation (numpy|scipy) | Adding Plots (numpy|matplotlib) | Dynamic with GUI | Accessing Data (sqlite3|pandas) |
Python Examples
SysCAD COM Interface Class
- SysCAD COM Interface Class - The syscadif.py module wraps essential SysCAD COM operations and is used throughout most of the examples below.
Python Integration Examples
These examples show how to integrate Python with SysCAD using the COM interface via pywin32:
- Encapsulating COM Functionality in a Python Class - Wrapping COM operations within a Python class.
- Running Scenarios Using the Python Class - Using the Python class to execute SysCAD scenarios.
- Python Example - Automated Model Testing - Using Python to automate testing of SysCAD models.
Python Script Examples for Generating Report Tags
- Generate Species Tags for Stream Report - Creates structured species tag entries for use in SysCAD stream reports, based on a user-defined input file. This simplifies the process of reporting multiple species across various flow variables.
- Generate Tags for PSD Stream Report - Generates particle size distribution (PSD) tags for SysCAD reports, formatted for multi-column layouts. Ideal for projects with multiple ores and extensive size interval data.
Python Optimisation Examples
- Constrained Free Energy Minimisation - Using Python (NumPy/SciPy/matplotlib) for complex side calculations and visualisation, driven via COM.
- Optimisation - Curve Fitting Example - Using COM and SciPy tools to optimise the product particle size distribution (PSD) in a SysCAD project.
- ChemApp Project - Nickel Laterite Smelter Multivariable Optimisation - (Located in Examples\07 ChemApp - ChemApp Full; requires a separate ChemApp license)
- Discussion: Ternary Saturation Diagrams using PHREEQC
Python Visualisation Examples
These examples demonstrate how to use matplotlib to visualise data sets:
- Plotting Data from the Gold Example Project - Plotting data from Examples\25 Gold.
- Plotting data from the Washer Example – Plotting data from Examples\03 Unit Models.
- Sensitivity Analysis Example – Plotting results from the sensitivity analysis examples\01 Reports.
Plotting Data from the Clipboard:
- Particle Size Distribution (PSD) Data - Visualising PSD using log-scale plots, size fraction subplots, and 3D plots.
- Plotting Thermophysical Data - Visualising thermophysical properties.
- Species Flow Data – Plotting species flow information.
Python GUI Examples
These examples show how to use COM to build Python-based GUI elements for interactive control:
- Interactive Dynamic Example – Simple Controls - Adds basic controls to the Dynamic Plant Example Project.
- Interactive Dynamic Example – Overlay Control Panels - Adds overlay controls to the Dynamic Transfer Pull Network Example Project.
Python Script Examples for Programmatic Model Generation
These examples demonstrate how to use Python with COM to insert models and graphics into a SysCAD project.
- Creating a Basic Flowsheet - Demonstrates how to add a simple flowsheet with a few units and links.
- Creating a Flowsheet with Multiple Units in Series - Automates part of the Gold flowsheet by generating a series of Leach and Adsorption tanks.
- Creating a Flowsheet with Multiple Input Streams - Suitable for scenarios where multiple streams need to be consolidated into a single unit, such as combining process water return flows.
- Creating a Flowsheet with Multiple Output Streams - Shows how to configure a unit with multiple output streams for more complex process routing.
Python Script Examples for updating databases
These examples show how to use Python and SQLite to update .db3 database files used in SysCAD.
- Import Species Data from Excel - Reads species and property data from an Excel file and inserts it into a SysCAD species database file.
- Find and Replace Tags in Model Database - Allows users to specify a table, column, and target text for replacement in the SysCAD model database.
Other Example
- External DLL Integration - Demonstrates how to drive a dynamic SysCAD project using Python while performing calculations in an external DLL.