Menu

Changing PID Setpoint with Script in Dynamic Simulation

2021-03-10
2021-03-11
  • Morgan Helton

    Morgan Helton - 2021-03-10

    Hello,
    I am attempting to utilize a Python script to modify the setpoint of a PID controller during execution of a dynamic simulation. While I am able to change the setpoint as visible on the flowsheet by doing
    controller = Flowsheet.GetFlowsheetSimulationObject("PID-01")
    controller.SPValue = 3.9
    this does not seem to be reflected in the simulation's calculation based on what is shown in the trend. I currently have script execution tied to "Solver Started" -- thinking that should execute every simulation iteration.

    Should the PID setpoint be updating during the simulation if changed in this way? If not, is there another place or method I should be using?

    Thanks!

     
  • Daniel Medeiros

    Daniel Medeiros - 2021-03-11

    Try

    controller.AdjustValue = 3.9
    

    Currently there is no specific event to attach to when the integrator starts or ends. "Solver Started" will be executed at every single integrator step since it the flowsheet solver is called each time. It doesn't seem to do any harm in your simulation if you do it, thankfully.

    I'll add integrator events in the next version.

    Regards
    Daniel

     
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.