×
Menu
Index

15.2. Scripted Profiles Introduction

Scripted Profiles introduce a way of defining profiles using the Python programming language. During an Apache Simulation the Python source is run to provide the profile value for the current iteration (time-step).
It is important to note that Scripted Profiles are not VE Scripts; Scripted Profiles can be created in the VE Scripts editor or any 3rd Party editor, but can only be executed in Apache. As a result debugging involves checking for Python static errors in the editor, reviewing runtime errors in the Simulation Tasks dialog and using runtime data output to file (see example below).
Scripted profiles are suited to profiles that contain complex behaviour or require external input. Schedules, Compact and FreeForm profiles provide a great deal of flexibility for expressing predominately time dependent behaviour. Scripted profiles are best when state dependent behaviour is required.
Scripted profiles have a number of advantages:
·        Complex behaviour can be expressed clearly, taking advantage of the structured nature of the Python programming language.
·        Information can be retained by individual profile instances during the simulation. For example an air temperature can be recorded from a number of previous iterations, allowing behaviour to be defined in terms of conditions experienced over the previous hour or day.
·        Scripted profiles can reference model objects (rooms) directly in a robust and reliable way.
Each scripted profile is defined by a Python class.
The profile class defines a profile which can be assigned to entities or quantities in the model. The model item using the profile is referred to as the profile target.
When a simulation is launched each profile target will create an instance of the profile class, a profile instance.
An example of this might be a modulating profile assigned to control lights in a room. A scripted profile can be assigned to the lighting gain entity in the model. This gain can then be assigned to many rooms in the building.  Each lighting gain entity in the model will have its own profile instance.
Another example of this might be an absolute profile assigned to control night purge ventilation that utilises a rolling average of the external air temperature to determine a dependent state.
Each profile instance is independent and evaluated at the start of every time step.