Skip to content

ekagrazi/dwsim-python-gui

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

DWSIM Python Automation

This is a Python script that drives DWSIM headlessly using its .NET API.

It's set up to run parametric sweeps on two specific unit operations:

  1. Plug Flow Reactor (PFR): Simulating n-pentane isomerization across different reactor volumes and feed temperatures.
  2. Distillation Column: Separating a pentane mix across different reflux ratios and stage counts.

It systematically runs every combination of inputs, handles any solver failures gracefully, and drops all the data into a clean CSV file and a couple of plots.

1. Requirements

You'll need a few things installed:

  • Windows OS
  • DWSIM installed locally
  • Python 3.9 or 3.10
  • pip

2. Installation

First, clone or download this folder to your machine. Then open up a terminal inside the folder and set up a virtual environment:

python -m venv venv

Activate it:

  • Command Prompt: venv\Scripts\activate.bat
  • PowerShell: .\venv\Scripts\Activate.ps1

Then install the dependencies:

pip install -r requirements.txt

3. Configuration

Before running anything, open run_screening.py and look at the top of the file. You'll see a DWSIM_PATH variable.

Update that path so it points exactly to where DWSIM is installed on your computer (for example, C:\Users\YourName\AppData\Local\DWSIM).

4. Running the Script

Make sure your virtual environment is still activated, then just run:

python run_screening.py

When it finishes, you'll see a new results.csv file pop up in your folder, along with a plots/ folder containing some graphs mapping out the sweep data.

5. What's in the Output?

The results.csv file contains 32 rows (16 combinations for the PFR and 16 for the Column).

Here's what the columns mean:

  • case_id: A unique name for the run (like PFR_V1.0_T350).
  • simulation_type: Either PFR or COL.
  • sweep_var: The parameters that were tweaked for that run.
  • success: True if the flowsheet converged, False if it crashed or couldn't solve.
  • error_message: If the run failed, the exact solver error is logged here.
  • KPIs: Output properties like conversion rates, purities, and heat duties. If a case failed, these are just left blank.

6. Troubleshooting

  • "DLL not found": The script can't find DWSIM. Double-check that your DWSIM_PATH in run_screening.py is correct.
  • "pythonnet import error": This usually means you're using an unsupported Python version (try 3.9 or 3.10) or you forgot to pip install the requirements.
  • "All cases failed": If every single simulation crashes, your DWSIM installation might be incomplete or missing a thermodynamics library. Try a fresh reinstall of DWSIM.

About

Automate DWSIM chemical simulations headlessly using Python and .NET. Includes parametric sweeps for reactors and distillation columns.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages