Skip to content

Automation API

Overview

The PHE unit operation can be fully controlled through DWSIM's Python/IronPython scripting interface. This enables:

  • Batch calculations — run multiple cases without manual intervention.
  • Parametric studies — sweep a parameter (e.g., number of plates) and collect results.
  • Sensitivity analysis — evaluate the effect of heat leak, fouling, or geometry changes on performance.
  • Integration — embed PHE calculations in larger optimization or design workflows.

All input and output properties listed in the Parameters Reference are accessible through the GetPropertyValue and SetPropertyValue methods.


Setup

Before scripting with the PHE, the external DLL must be explicitly loaded. Add the following references at the top of your script:

import clr

# Add reference to the PHE external unit operation DLL
clr.AddReference(r"C:\Users\<YourUsername>\AppData\Local\DWSIM\unitops\DWSIM.UnitOperations.PlateHeatExchanger")

# Standard DWSIM references (if not already loaded)
clr.AddReference("DWSIM.Interfaces")
clr.AddReference("DWSIM.SharedClasses")

DLL Path

Adjust the path in clr.AddReference to match your actual installation location. If you installed the DLL in a custom folder, use that path instead.

To access the PHE object in a flowsheet:

# Get the PHE unit operation by its flowsheet name
phe = sim.GetFlowsheetSimulationObject("PHE-1").GetAsObject()

Where "PHE-1" is the name assigned to the PHE object on the flowsheet. Replace it with the actual name used in your simulation.


Example: Basic PHE Calculation

This script loads a flowsheet, configures the PHE parameters, runs the simulation, and prints all results.

import clr
clr.AddReference(r"C:\Users\<YourUsername>\AppData\Local\DWSIM\unitops\DWSIM.UnitOperations.PlateHeatExchanger")

# Assume 'sim' is the active flowsheet object (available in DWSIM script manager)

# Get the PHE object
phe = sim.GetFlowsheetSimulationObject("PHE-1").GetAsObject()

# Configure plate geometry
phe.SetPropertyValue("NumberOfPlates", 50)
phe.SetPropertyValue("PlateWidth", 0.5)            # 500 mm
phe.SetPropertyValue("PlateHeight", 1.0)            # 1000 mm
phe.SetPropertyValue("PlateThickness", 0.0006)      # 0.6 mm
phe.SetPropertyValue("PlateSpacing", 0.003)          # 3.0 mm
phe.SetPropertyValue("ChevronAngle", 60.0)
phe.SetPropertyValue("EnlargementFactor", 1.17)

# Thermal properties
phe.SetPropertyValue("PlateConductivity", 16.3)
phe.SetPropertyValue("FoulingHot", 0.0001)
phe.SetPropertyValue("FoulingCold", 0.0001)

# Operating configuration
phe.SetPropertyValue("FlowDirection", 1)             # Counterflow
phe.SetPropertyValue("HeatLeak", 0.0)                # Adiabatic

# Run the simulation
sim.RequestCalculation()

# Read and print results
print("=== PHE Results ===")
print("Heat Transferred:   {:.2f} kW".format(phe.GetPropertyValue("TotalHeatTransferred")))
print("MITA:               {:.2f} °C".format(phe.GetPropertyValue("MITACalculated")))
print("UA:                 {:.1f} W/K".format(phe.GetPropertyValue("UACalculated")))
print("LMTD:               {:.2f} °C".format(phe.GetPropertyValue("LMTDEffective")))
print("Thermal Efficiency: {:.4f}".format(phe.GetPropertyValue("ThermalEfficiency")))
print("U Overall:          {:.1f} W/(m²·K)".format(phe.GetPropertyValue("UCalculated")))
print("Total Area:         {:.3f} m²".format(phe.GetPropertyValue("TotalArea")))
print("HTC Hot Side:       {:.1f} W/(m²·K)".format(phe.GetPropertyValue("HotSideHTC")))
print("HTC Cold Side:      {:.1f} W/(m²·K)".format(phe.GetPropertyValue("ColdSideHTC")))
print("Re Hot:             {:.0f}".format(phe.GetPropertyValue("ReynoldsHot")))
print("Re Cold:            {:.0f}".format(phe.GetPropertyValue("ReynoldsCold")))
print("ΔP Hot:             {:.0f} Pa".format(phe.GetPropertyValue("PressureDropHotCalc")))
print("ΔP Cold:            {:.0f} Pa".format(phe.GetPropertyValue("PressureDropColdCalc")))

Example: Parametric Study — Number of Plates

This script varies the number of plates from 10 to 100 and records the thermal efficiency, heat duty, and MITA for each case. The results can be used to determine the optimal plate count for a given application.

import clr
clr.AddReference(r"C:\Users\<YourUsername>\AppData\Local\DWSIM\unitops\DWSIM.UnitOperations.PlateHeatExchanger")

# Get the PHE object
phe = sim.GetFlowsheetSimulationObject("PHE-1").GetAsObject()

# Define the plate count range
plate_counts = list(range(10, 101, 10))

# Storage for results
results = []

print("{:<10} {:>12} {:>12} {:>12} {:>12}".format(
    "Plates", "Q (kW)", "Eff.", "MITA (°C)", "U (W/m²K)"))
print("-" * 62)

for n in plate_counts:
    # Set the number of plates
    phe.SetPropertyValue("NumberOfPlates", n)

    # Recalculate
    sim.RequestCalculation()

    # Collect results
    q = phe.GetPropertyValue("TotalHeatTransferred")
    eff = phe.GetPropertyValue("ThermalEfficiency")
    mita = phe.GetPropertyValue("MITACalculated")
    u = phe.GetPropertyValue("UCalculated")

    results.append({
        "plates": n,
        "Q_kW": q,
        "efficiency": eff,
        "MITA_C": mita,
        "U_Wm2K": u
    })

    print("{:<10} {:>12.2f} {:>12.4f} {:>12.2f} {:>12.1f}".format(
        n, q, eff, mita, u))

print("\nParametric study complete. {} cases evaluated.".format(len(results)))

Post-Processing

Export the results list to CSV or use it with matplotlib for plotting. The efficiency vs. plate count curve is particularly useful for sizing decisions — it typically shows diminishing returns beyond a certain plate count.


Example: Heat Leak Sensitivity

This script evaluates the impact of heat leak on the PHE performance by sweeping the heat leak parameter from 0 to 10 kW.

import clr
clr.AddReference(r"C:\Users\<YourUsername>\AppData\Local\DWSIM\unitops\DWSIM.UnitOperations.PlateHeatExchanger")

# Get the PHE object
phe = sim.GetFlowsheetSimulationObject("PHE-1").GetAsObject()

# Fix the geometry (use defaults or your design)
phe.SetPropertyValue("NumberOfPlates", 50)
phe.SetPropertyValue("FlowDirection", 1)

# Define heat leak values to test (kW)
heat_leaks = [0.0, 0.5, 1.0, 2.0, 3.0, 5.0, 7.5, 10.0]

print("{:<12} {:>12} {:>12} {:>12} {:>12}".format(
    "Leak (kW)", "Q (kW)", "Eff.", "MITA (°C)", "LMTD (°C)"))
print("-" * 64)

for leak in heat_leaks:
    # Set heat leak
    phe.SetPropertyValue("HeatLeak", leak)

    # Recalculate
    sim.RequestCalculation()

    # Collect results
    q = phe.GetPropertyValue("TotalHeatTransferred")
    eff = phe.GetPropertyValue("ThermalEfficiency")
    mita = phe.GetPropertyValue("MITACalculated")
    lmtd = phe.GetPropertyValue("LMTDEffective")

    print("{:<12.1f} {:>12.2f} {:>12.4f} {:>12.2f} {:>12.2f}".format(
        leak, q, eff, mita, lmtd))

# Reset heat leak to zero
phe.SetPropertyValue("HeatLeak", 0.0)
sim.RequestCalculation()

print("\nSensitivity analysis complete. Heat leak reset to 0 kW.")

Heat Leak Model

The heat leak is split 50/50 between the hot and cold sides. See the Design Mode — Heat Leak section for details on the energy balance model.


Available Properties

For a complete list of all property names, data types, default values, and units, see the Parameters Reference page.

Category Properties
Geometry NumberOfPlates, PlateWidth, PlateHeight, PlateThickness, PlateSpacing, ChevronAngle, EnlargementFactor
Thermal PlateConductivity, FoulingHot, FoulingCold
Operating FlowDirection, HeatLeak
Results TotalHeatTransferred, MITACalculated, UACalculated, LMTDEffective, ThermalEfficiency, UCalculated, TotalArea, HotSideHTC, ColdSideHTC, ReynoldsHot, ReynoldsCold, PressureDropHotCalc, PressureDropColdCalc