Dynamic Simulation Tutorial with DWSIM and Python, Part 3: Adding a PID Controller

From DWSIM - Chemical Process Simulator
Revision as of 19:18, 1 July 2019 by DanWBR (talk | contribs) (Created page with "<div id="mw-content-text" lang="en" dir="ltr" class="mw-content-ltr"><table style="color: white; background-color: steelblue;" cellpadding="10" width="100%"> <tr> <td colspan=...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
Dialog-warning.png This tutorial requires advanced or above average Python programming skills.
Dialog-information.png You'll need at least DWSIM v5.1 on Windows, Linux or macOS to follow/reproduce the tasks within this tutorial.

Introduction

We will add a PID Controller to control the outlet hot water temperature (PV) at 50 C (SP) by changing the cooling water flow using the valve opening as the manipulated variable (MV).

The PID class

Our PID code uses a modified version of the Python PID Class which can be found here: <a rel="nofollow" class="external free" href="https://github.com/ivmech/ivPID">https://github.com/ivmech/ivPID</a>

Create a new script and name it 'PID'. Add the following content to it:

Adding a PID

For illustration purposes, add a new Adjust object to the flowsheet and set its manipulated object to 'FV-01' and controlled object to 'cooled_water'. The actual controlling won't be done by this object calculation routine, but rather by our PID script.

Dynamic pid.jpg

Running the Closed-Loop Dynamic Model

Create a new script and name it 'RunDynamicProcess_ClosedLoop', with the following content:

Notice that our PID variables (SP, PV and MV) are normalized (SP = 1.0).

We will run our PID controller initially with Kp = 0.5, Ki = 0.01 and Kd = 0.1.

Modify the 'GenerateCharts' script to include the following commands before the last one:

Run the closed loop model. You should get the following after a successfull run:

Dynamic pidresults.jpg

Download File

Download the simulation file with what has been done so far: dynamic_part3.dwxmz

Return to Dynamic_Simulation_Tutorial_with_DWSIM_and_Python,_Part_2:_Building_the_Dynamic_Model

Proceeed to Dynamic_Simulation_Tutorial_with_DWSIM_and_Python,_Part_4:_Tuning_the_PID_Controller_through_Non-Linear_Optimization