From GridLAB-D Wiki
Jump to: navigation, search

assert (object) - General purpose assert object to ensure properties of other objects meet specified characteristics

Synopsis

module assert;
class assert {
	enumeration {NONE=3, FALSE=2, TRUE=1} status; 
	char1024 target; 
	char32 part; 
	enumeration {outside=7, inside=6, !==3, >==2, >=5, <==1, <=4, ===0} relation; 
	char1024 value; 
	char1024 within; 
	char1024 lower; 
	char1024 upper; 
}

Description

The assert examine a property of the object's parent and compares it to a value or values. If the assert fails, the simulation halts.

lower

lower "value unit";
The lower property specifies the lower bound when using the inside or outside relations.

part

part "name";
The part property specifies the property part to use when comparing values. All property parts are considered double or complex without units. The following property parts are supported:
  • complex: real, imag, mag, ang, arg
  • enduse: total (complex), energy (complex), demand (complex), breaker_amps, admittance (complex), current (complex), power (complex), impedance_fraction, current_fraction, power_fraction, power_factor, voltage_factor, heatgain, heatgain_fraction.
Parts noted as (complex) must have the complex part specified, e.g., total.real, current.mag, power.ang.

relation

relation "op";
The relation operator specifies the relationship to test.

inside

Compares the target property to determine whether it is between the lower and upper values (inclusive).

outside

Compares the target property to determine whether it is outside the lower and upper values (exclusive).

!=

Compares the target property to determine whether it is different from the value.

>=

Compares the target property to determine whether it is greater than or equal to the value.

>

Compares the target property to determine whether it is greater than the value.

<=

Compares the target property to determine whether it is less than or equal to the value.

<

Compares the target property to determine whether it is less than the value.

==

Compares the target property to determine whether it is equal to the value.

status

status NONE|TRUE|FALSE;
The status enumeration specifies the desired outcome of the test.

FALSE

The FALSE status is used to specify that the assert test should fail.

NONE

The NONE status is used to specify that the assert test should be ignore.

TRUE

The TRUE status is used to specify that the assert test should succeed.

target

target "property";
The target specifies the name of the property to examine.

upper

upper "value unit";
The upper property specifies the upper bound when using the inside or outside relation.

value

value "value unit";
The value property specifies the value to compare to when using the !=, >=, >, <=, <, or == relations.

within

within "value unit";
The within property specifies the accuracy to which == and != comparisons are performed.
WARNING: Units that have an absolute offset (e.g., degC, degF) will convert in absolute value, not relative value. Thus within 0.01 degF will not work as expected when compared to a property in degC because 0.01 degF is about -17 degC.

Examples

The first example asserts that the temperature is 50 degF. The second example asserts that the temperature is between 0 and 40 degC. The third example asserts that the temperature is within 1 degF of 49.5 degF.

module assert;
module climate;
object climate {
  temperature 50 degF;
  object assert { // example 1
    target climate#temperature;
    relation "==";
    value 50 degF;
  };
  object assert { // example 2
    target temperature;
    relation inside;
    lower 0 degC;
    upper 40 degC;
  };
  object assert { // example 3
    target climate#temperature|temperature;
    relation "==";
    value 49.5 degF;
    within 1 degF;
}

The fourth example asserts that the real part of the voltage is 120. The fifth example asserts that the magnitude of the voltage exceeds 120. The sixth example asserts that the angle of the voltage is between -45 deg and 45 deg.

module assert;
module powerflow;
object meter {
  nominal_voltage 120;
  phases A;
  voltage_A 120+1j;
  object assert { // example 4
    target voltage_A;
    part real;
    relation "==";
    value 120.0;
  };
  object assert { // example 5
    target voltage_A;
    part complex#mag;
    relation ">";
    value 120;
  };
  object assert { // example 6
    target voltage_A;
    part ang;
    relation inside;
    lower -45;
    upper 45;
  };
}

Version

The assert object was added in Hassayampa (Version 3.0).

See also