×
Menu
Index

15.3. Defining Scripted Profiles

Scripted profiles are written in the Python programming language with access to all the standard libraries (IES libraries are not accessible). Python version 3.7 is used.
The VEScript editor or any text editor can be used to write the profile code and saved as a py file. A single python file can contain a number of profile classes.
The following code defines a very simple scripted profile, however, it illustrates some of the key elements required to create a scripted profile. The code represents a modulating profile with a constant return value of 0.75.
1.   import apache  
2.     
3.     
4.   class MyProfile_75(apache.Profile):  
5.     
6.       def evaluate(self):  
7.           return 0.75  
 
 
There are two key requirements that mark this Python class as a Scripted Profile.
1.     The class must be derived from the base class ‘Profile’ found in the apache package. The import statement on line 1 is used to import the definition of the apache package.
2.     A profile class must defined the ‘evaluate’ function. This function is called every time step to determine the return value of the profile.
When the above script is registered in APpro the profile will then be assignable in the model with the same name as the profile class. In this case ‘MyProfile_75’.