From GridLAB-D Wiki
Jump to: navigation, search

Transform - GLM model linear transformations

Synopsis

object class {
  property source * scalar + offset;
  property function(object:property);
}

Description

A transform is an internal object that converts a source value into a new value applied to a double property. Transforms can be driven from any double-valued source, i.e., a schedule, from another double property, or from any other built-in data type whose first value is a double or can be interpreted as a double.

Sources can include a functional modifier such as diff() and sum(). These will perform calculations that approximate time derivative and time integral operations. Note that the sum() operation uses a zero-order hold.  New in 3.2! 

The value of the property is updated before the presync pass, immediately after the schedules are updated.

Examples

Schedule transforms are linear functions that convert a schedule-driven value to a property of an object. A schedule transform can be defined by the function that converts the schedule's current values to the property's current value, as in

 schedule occupancy_schedule {
   * 8-16 * * 1-5
 }
 object small_building {
   n_occupants 10*occupancy_schedule;
 }
 object large_building {
   n_occupancy 100*occupancy_schedule+1;
 }

Integral and differential operations are supported as illustrated in the following example  New in 3.2! :

class test {
        double x;
        double dx;
        double sx;
}

object test {
        x this.x * 0.5 + 0.1;
        dx diff(this.x) * 1.0 + 0.0 ;
        sx sum(this.x) * 1.0 + 0.0 ;
}


History

As of Grizzly (Version 2.3) 
Any property with an underlying numeric value may be driven by a transform. This includes double, complex, bool, int16, int32, int64, set, enumeration, timestamp, loadshape, and enduse. In cases where the underlying data type is compatible, the value will be cast according to the C/C++ type-casting rules.
As of Hassayampa (Version 3.0) 
A transform may also link a variable to an external function defined using the extern directive.
As of Jojoba (Version 3.2) 
The reference to the schedule or property may be modified using the diff() or sum() functions. The diff function computes the finite difference divided by the timestep (approximating a derivative) and the sum() function computes the cumulative sum of the values multiplied by the timestep (approximating an integral).

Bugs

Sometimes the loader gets confused by the syntax of transforms. Changing the order in which the values are entered often remedies the problem. For example if

x 2*a+1;

gives a syntax error, changing it to

x a*2+1;

works ok. Also adding spaces can help.

See also