Useful PGM code for Dynamic Projects

From SysCAD Documentation
Jump to navigation Jump to search

Navigation: PGMs ➔ Example PGM Files ➔ Startup Actions

Simple Examples Subroutines Examples Dynamic Examples Steady State Overall Mass Balance Array and Matrix Examples
Basic
Layout
Simple
Calculations
Initialise
PreStart
Multi-Step Trigger Checking
Project
Counter, While
and Random
Belt Filter
Wash Loss
Startup
Actions
Mass
Balance
Mass
Balance
Species
Balance
Elemental
Balance
Lookup
Value
Set
Values
Tridiagonal
System

Related Links: Trigger Subroutines, Example PGMs for Dynamic Projects


Defining Startup Action for a Dynamic project

It is useful to set up information such as Length of Run, Start Time, Step Size and so on at the start of the run. However, these tags can only be set while the project is stopped or as the first tags set during the startup of the Dynamic Run. The following example demonstrates how to do this.
Please note we have only used a few tags here to demonstrate the methods, user can select more start up option tags to build a bigger list as required.

  • Method 1: Manually setup the tags in View | Solver Settings | Scenario Tab while the project is stopped. (User can also import these tags as a SetTag Report (or Set Tag List Model) while SysCAD is stopped)
    DynStartupOptions.png
  • Method 2: Set up the required tags as a List, then load it into the project as a csv file via the View | PlantModel | Project SetTagList section.
    Example:
Save the following as a .csv file.
Tag, Value
Solver.Dyn.Scenario.Start.StartAt (d), 18263
$Solver.Dyn.Scenario.Type, 1
$Solver.Dyn.Scenario.DurationReqd (d), 20
$Solver.Dyn.StepSize (s), 60
$Solver.Dyn.Scenario.Start.RestartArchive, 1
$Solver.Dyn.Scenario.Start.Statistics, 1
$Solver.Dyn.Scenario.Start.EventsProfiles, 1
In SysCAD, add this file into "View - PlantModel - Project - SetTagList" section.
DynScenario.png

The tags in this file will be read and set when SysCAD Run project command is executed.

Sub InitialisePreStart()
 ;--- Logic executed very early before first iteration
 ["$Solver.Dyn.Scenario.Start.StartAt (h)"] = 418568
 ["$Solver.Dyn.Scenario.Type"] = 1
 ["$Solver.Dyn.Scenario.DurationReqd (d)"] = 20
 ["$Solver.Dyn.StepSize (s)"] = 60
 ["$Solver.Dyn.Scenario.Start.RestartArchive"] = 1
 ["$Solver.Dyn.Scenario.Start.Statistics"] = 1
 ["$Solver.Dyn.Scenario.Start.EventsProfiles"] = 1
EndSub
  • This PGM subroutine will be executed during the Startup of the Dynamic Run.

NOTE: The Solver.Dyn.Scenario.Start.StartAt variable allows user to enter the start time, with reference to the SysCAD time. The SysCAD time starts at 1.1.1970 (reference time is 0). So to enter the start date for 1.1.2020, it is 50*365.25=18262.5 days)

Accessing Dynamic Project Command

Some Dynamic Simulation Commands can be sent from 3rd party software (for example via OPC) or from PGM files. These commands may include Start/Pause/Stop Simulation, Reset certain information such as statistics or profiles based on certain user defined conditions.

The SysCAD commands available for use are located on View - Solver Setting - FS Solver Access window, under Solver Commands and Actions.

SolverCommands.png

All the above buttons can be manually pressed while within SysCAD or they can be called or used in PGM file. The tag names for these buttons can be fetched by right clicking on variable name and selecting Copy Full Tag.

The Tags for these buttons are:

["$Solver.Cmd.Start"] = 1               
["$Solver.Cmd.Idle"] = 1                
["$Solver.Cmd.Stop"] = 1                
["$Solver.SetActionAll"] = 63           ;This tag has many different states, 63 is for complete reset.        
["$Solver.Cmd.CompleteReset"] = 1       
["$Solver.Cmd.ResetProcess"] = 1        
["$Solver.Cmd.ResetControl"] = 1
["$Solver.Cmd.ResetStatistics"] = 1
["$Solver.Cmd.ResetEventsProfiles"] = 1
["$Solver.Cmd.EmptyProcess"] = 1
["$Solver.Cmd.ClearTear"] = 1
["$Solver.Cmd.PresetProcess"] = 1
["$Solver.Cmd.RestartTime"] = 1