User-Defined Default Expressions

15 posts / 0 new
Last post

Hi eQUEST Users,

I'm trying to create default user expressions in an effort to auto-populate
certain fields in my models.
I want to reference the activity description (C-ACTIVITY-DESC) have it
automatically fill in fields such as Area/Person.
So for this example, I'm trying to make all spaces that have Activity
Description of "RETAIL" to be populated with a Area/Person value of 67.
I've tried using the "Switch" function and if-then statements but haven't
been able to get it to work.
Any assistance is appreciated.

Thank you,
Mike Campbell

via Equest-users's picture
Joined: 2016-07-15
Reputation: 400

Note, only the first 4 characters of the C-ACTIVITY-DESC field are recognized in user defined expressions. Therefore, if your UDF uses ?RETAIL? as the test, it may fail because only ?RETA? is used.

Other than that, I suggest reviewing the BDLDFT.TXT file in the eQUEST 3-65 Data folder. It is full of example default expressions.

[Title: RWDI - Description: RWDI logo]

Christopher Jones, P.Eng. | Senior Energy Analyst
RWDI
901 King Street West, Suite 400, Toronto, ON M5V 3H5 Canada
Tel: (519) 823-1311 ext 2052
rwdi.com

via Equest-users's picture
Joined: 2016-07-15
Reputation: 400

Mike,
You can start with the expression below. Paste only the text between the brackets if you are pasting within the interface. If pasting into the input file, this would go after ?SET-DEFAULT FOR SPACE?. Like Chris said, the case statement names should be four characters or less. However, they are not case sensitive, so upper/lower case doesn?t matter.
~Bill

AREA/PERSON =
{if(#SV(#L("ZONE-TYPE"))==2) then no_def else
if(#RV(#L("PEOPLE-SCHEDULE"))!=0) then unused else
switch (#L("C-ACTIVITY-DESC"))
case "Reta": 67
case "Lobb": 150
case "Clas": 100
default: 500
endswitch
endif
endif}

William Bishop, PE, BEMP, BEAP, CEM, LEED AP | Pathfinder Engineers & Architects LLP
Senior Energy Engineer

[cid:image001.jpg at 01D29421.71957EA0] [cid:image009.jpg at 01D29421.71957EA0]

134 South Fitzhugh Street Rochester, NY 14608

T: (585) 698-1956 F: (585) 325-6005

bbishop at pathfinder-ea.com www.pathfinder-ea.com

[http://png-5.findicons.com/files/icons/977/rrze/720/globe.png]Carbon Fee and Dividend - simple, effective, and market-based.

via Equest-users's picture
Joined: 2016-07-15
Reputation: 400

Thank you Bill, Jeremy, and Chris for the responses!

via Equest-users's picture
Joined: 2016-07-15
Reputation: 400

Appending to this, while ("C-ACTIVITY-DESC") returns the first 4 characters by default, if you ever need to further distinguish inputs within spaces sharing the same/similar activity descriptors, you can also reference the 2nd set of 4 characters (or the 3rd set, or the 4th set?).

To do this, append the optional argument ?,#? wherever you?d normally specify ?C-ACTIVITY-DESC.?

To build on the running example, say you had 2 tenants to distinguish in a building with ?Retail? space, but they had two different occupancy densities. You could handle that by first adding to their descriptors, such as follows:
Retail_?_Best Buy
Retail_?_Home Depot

The first 4 characters for each case are the same: ?RETA? (list position 0). The second set of 4 is ?IL_?? (list position 1). The third set is finally distinguishable: ?_BES? and ?_HOM? (list position 2).

From here you could either insert an if/then statement for the ?Reta? case, or just nest another switch statement. Added some formatting for clarity, but highlighted the new addition:

AREA/PERSON =
{if(#SV(#L("ZONE-TYPE"))==2) then no_def else
if(#RV(#L("PEOPLE-SCHEDULE"))!=0) then unused else
switch (#L("C-ACTIVITY-DESC"))
case "Reta": switch (#L("C-ACTIVITY-DESC",2))
case ?_Bes? : 67
case ?_Hom? : 67*2
default : 500
endswitch
case "Lobb": 150
case "Clas": 100
default: 500
endswitch
endif
endif}

~Nick

[cid:image002.png at 01D2942D.5069DD00]
Nick Caton, P.E., BEMP
Senior Energy Engineer
Regional Energy Engineering Manager
Energy and Sustainability Services
Schneider Electric

D 913.564.6361
M 785.410.3317
F 913.564.6380
E nicholas.caton at schneider-electric.com

15200 Santa Fe Trail Drive
Suite 204
Lenexa, KS 66219
United States

[cid:image003.png at 01D2942D.5069DD00]

via Equest-users's picture
Joined: 2016-07-15
Reputation: 400

Nick,
Where did you find that little gem of BDL?
~Bill

via Equest-users's picture
Joined: 2016-07-15
Reputation: 400

Stop asking me hard questions! It?s a Friday!

If I had to guess I would likely credit David Reddy & the rest of crew at 360 Analytics? but honestly I can?t recall (could have been you, Bill?).

More constructively and to your point however, this optional argument however is what the doe2 reference manual is generally referring to when it lists ?i" or ?i1, i2? in its syntax / explanations of the BDL functions. Example:
[cid:image007.png at 01D29433.6607DD00]

These inputs can become very important if you are trying to set up user defaults for, say, the 2nd or 3rd plug load entries. Study the doe2 defaults expressions in that area for further reference material. That?s how the 3rd inputs know to be ?n/a? before you entered at least the 1st and 2nd entries for a given field.

~Nick

[cid:image001.png at 01D29433.07EAFF90]
Nick Caton, P.E., BEMP
Senior Energy Engineer
Regional Energy Engineering Manager
Energy and Sustainability Services
Schneider Electric

D 913.564.6361
M 785.410.3317
F 913.564.6380
E nicholas.caton at schneider-electric.com

15200 Santa Fe Trail Drive
Suite 204
Lenexa, KS 66219
United States

[cid:image002.png at 01D29433.07EAFF90]

via Equest-users's picture
Joined: 2016-07-15
Reputation: 400

Now, that is a very cool revelation. It always seemed short sighted to use only 4 characters. Being able to create sub-categories based on the following number of 4 character splits will be very helpful.

[Title: RWDI - Description: RWDI logo]

Christopher Jones, P.Eng. | Senior Energy Analyst
RWDI
901 King Street West, Suite 400, Toronto, ON M5V 3H5 Canada
Tel: (519) 823-1311 ext 2052
rwdi.com

via Equest-users's picture
Joined: 2016-07-15
Reputation: 400

To expand on Nick's trick below, I wanted to share why only the 1st 4
characters are returned by default and why his code works (this is mostly a
guess from reverse-engineering the source code, but it's consistent with
the way the actual program works).

Old versions of Fortran had no built-in character or string data types, so
programmers had to use tricks to deal with them. This would have been true
of the dialect of Fortran used in the original DOE2.1A, and so a form of
the original technique used to deal with string literals persists in the
code today. As a warning, this next part may give the mechanical engineers
out there a headache... A single character is traditionally encoded in
ASCII using a single byte. A byte is 8 bits, and the largest 8 bit number
is 11111111 = 255, so you can encode 256 unique characters using a single
byte. As an example, the btye 01100001 = 97 represents the character 'a'
in ASCII. The smallest built-in data type in early Fortran was the integer
(or float) which is encoded using 4 bytes. The trick used in DOE2 is to
encode string literals as an array of 8 integers (or float), and since each
integer contains 4 bytes (i.e. 4 characters), the entire string array
represents a total of 8x4 = 32 characters. This is why there's a 32
character limit on string fields. So accessing the first element of this
array by #L("C-ACTIVITY-DESC") or #L("C-ACTIVITY-DESC",0) returns the first
4 characters, #L("C-ACTIVITY-DESC",1) returns the second 4 characters, and
so on.

Now a little further into the weeds (this is more speculation into how it
could be done rather than how it's actually done under the DOE2 hood).
Consider the string 'abcd'. This can be encoded into a single integer by
making the four bytes of the integer be the same as the 4 character's ASCII
representation in sequence together. So the first byte is 97(01100001),
the second 98(01100010), the third 99(01100011), and the fourth
100(01100100). Also, in Fortran, integers are encoded in little-endian
style which just means that we need to order the bytes in reverse order
when constructing the integer. The entire integer in binary form is then
01100100011000110110001001100001. The value of this integer in decimal
is 1684234849. So, in DOE2-Land, the number 1684234849 is equivalent to
'abcd'.

However, it appears that you can't access the integer representation of
these four character 'words' in keyword expressions. For example:

if ("abcd" == 1684234849) then ... produces an error.

Also, you can't do arithmetic with the integer representation.
Interestingly though, the '+' operator functions as a concatenate operator
when dealing with string literals. This can be used to compare the first
4, 8, 12, ... characters of a string. For example, try the following code
for the lighting power density of a space. This expression considers the
first 8 characters when checking the C-ACTIVITY-DESC field. This could be
expanded to check all 32 characters, although the code would get a little
bloated.

switch(#L("C-ACTIVITY-DESC",0) + #L("C-ACTIVITY-DESC",1))

case "office": 1.1

case "kitchen": 1.5

case "restroom": 0.7

default: 1.0

endswitch

In this code, the result when C-ACTIVITY-DESC = "office" is 1.1, but the
result when C-ACTIVITY-DESC = "office1" is 1.0.

Aaron

*From:* Nicholas Caton [mailto:Nicholas.Caton at schneider-electric.com]
*Sent:* Friday, March 03, 2017 4:04 PM
*To:* Bishop, Bill ; Chris Jones
; Michael Campbell
*Cc:* equest-users at onebuilding.org
*Subject:* RE: [Equest-users] User-Defined Default Expressions

Appending to this, while ("C-ACTIVITY-DESC") returns the first 4 characters
by default, if you ever need to further distinguish inputs within spaces
sharing the same/similar activity descriptors, you can also reference the 2
nd set of 4 characters (or the 3rd set, or the 4th set?).

To do this, append the optional argument ?,#? wherever you?d normally
specify ?C-ACTIVITY-DESC.?

To build on the running example, say you had 2 tenants to distinguish in a
building with ?Retail? space, but they had two different occupancy
densities. You could handle that by first adding to their descriptors,
such as follows:

Retail_?_Best Buy

Retail_?_Home Depot

The first 4 characters for each case are the same: ?RETA? (list position
0). The second set of 4 is ?IL_?? (list position 1). The third set is
finally distinguishable: ?_BES? and ?_HOM? (list position 2).

or just nest another switch statement. Added some formatting for clarity,
but highlightedthe new addition:

AREA/PERSON =

{if(#SV(#L("ZONE-TYPE"))==2) then no_def else

if(#RV(#L("PEOPLE-SCHEDULE"))!=0) then unused else

switch (#L("C-ACTIVITY-DESC"))

case "Reta": switch (#L("C-ACTIVITY-DESC",2))

case ?_Bes? : 67

case ?_Hom? : 67*2

default : 500

endswitch

case "Lobb": 150

case "Clas": 100

default: 500

endswitch

endif

endif}

~Nick

*Nick Caton, P.E., BEMP*

Senior Energy Engineer
Regional Energy Engineering Manager

Energy and Sustainability Services
Schneider Electric

D 913.564.6361 <(913)%20564-6361>
M 785.410.3317 <(785)%20410-3317>
F 913.564.6380 <(913)%20564-6380>
E nicholas.caton at schneider-electric.com

15200 Santa Fe Trail Drive
Suite 204
Lenexa, KS 66219
United States

*From:* Equest-users [mailto:equest-users-bounces at lists.onebuilding.org
] *On Behalf Of *Bishop, Bill
via Equest-users
*Sent:* Friday, March 03, 2017 12:24 PM
*To:* Chris Jones ; Michael Campbell <
mcamp1206 at gmail.com>
*Cc:* equest-users at onebuilding.org
*Subject:* Re: [Equest-users] User-Defined Default Expressions

Mike,

You can start with the expression below. Paste only the text between the
brackets if you are pasting within the interface. If pasting into the input
file, this would go after ?SET-DEFAULT FOR SPACE?. Like Chris said, the
case statement names should be four characters or less. However, they are
not case sensitive, so upper/lower case doesn?t matter.

~Bill

AREA/PERSON =

{if(#SV(#L("ZONE-TYPE"))==2) then no_def else

if(#RV(#L("PEOPLE-SCHEDULE"))!=0) then unused else

switch (#L("C-ACTIVITY-DESC"))

case "Reta": 67

case "Lobb": 150

case "Clas": 100

default: 500

endswitch

endif

endif}

*William Bishop, PE, BEMP, BEAP, CEM, LEED AP **|** Pathfinder Engineers &
Architects LLP*

*Senior Energy Engineer*

134 South Fitzhugh Street Rochester, NY 14608

*T: (585) 698-1956 <(585)%20698-1956>* F: (585)
325-6005

bbishop at pathfinder-ea.com
www.pathfinder-ea.com

[image: http://png-5.findicons.com/files/icons/977/rrze/720/globe.png]Carbon
Fee and Dividend - simple, effective, and market-based.

*From:* Equest-users [mailto:equest-users-bounces at lists.onebuilding.org
] *On Behalf Of *Chris Jones
via Equest-users
*Sent:* Friday, March 03, 2017 12:52 PM
*To:* Michael Campbell
*Cc:* equest-users at onebuilding.org
*Subject:* Re: [Equest-users] User-Defined Default Expressions

Note, only the first 4 characters of the C-ACTIVITY-DESC field are
recognized in user defined expressions. Therefore, if your UDF uses
?RETAIL? as the test, it may fail because only ?RETA? is used.

Other than that, I suggest reviewing the BDLDFT.TXT file in the eQUEST 3-65
Data folder. It is full of example default expressions.

[image: Title: RWDI - Description: RWDI logo]

*Christopher Jones, **P.Eng. *| Senior Energy Analyst
*RWDI*
901 King Street West, Suite 400, Toronto, ON M5V 3H5 Canada
Tel: (519) 823-1311 ext 2052 <(519)%20823-1311>
rwdi.com

*From:* Equest-users [mailto:equest-users-bounces at lists.onebuilding.org
] *On Behalf Of *Michael
Campbell via Equest-users
*Sent:* Friday, March 03, 2017 12:32 PM
*To:* equest-users
*Subject:* [Equest-users] User-Defined Default Expressions

Hi eQUEST Users,

I'm trying to create default user expressions in an effort to auto-populate
certain fields in my models.

I want to reference the activity description (C-ACTIVITY-DESC) have it
automatically fill in fields such as Area/Person.

So for this example, I'm trying to make all spaces that have Activity
Description of "RETAIL" to be populated with a Area/Person value of 67.

I've tried using the "Switch" function and if-then statements but haven't
been able to get it to work.

Any assistance is appreciated.

Thank you,

Mike Campbell
------------------------------

*RWDI - A Platinum Member of Canada's 50 Best Managed Companies*
This communication is intended for the sole use of the party to whom it was
addressed and may contain information that is privileged and/or
confidential. Any other distribution, copying or disclosure is strictly
prohibited. If you received this email in error, please notify us
immediately by replying to this email and delete the message without
retaining any hard or electronic copies of same. Outgoing emails are
scanned for viruses, but no warranty is made to their absence in this email
or attachments. If you require any information supplied by RWDI in a
different format to facilitate accessibility, contact the sender of the
email, email solutions at rwdi.com or call +1.519.823.1311 <(519)%20823-1311>.
------------------------------

______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud service.

via Equest-users's picture
Joined: 2016-07-15
Reputation: 400

Has anyone had any luck creating default user expressions for schedules?
I was able to get it to work for other fields but when trying to use the
Switch function for schedules I am getting errors.
Any advice?

Thank you,

via Equest-users's picture
Joined: 2016-07-15
Reputation: 400

I got you buddy!

Building on what Aaron just taught me/us for stringing together 8+ descriptor characters as well:

switch(#L("C-ACTIVITY-DESC",0) + #L("C-ACTIVITY-DESC",1))
case "office": #SI("Office Ltg Sch","SPACE","LIGHTING-SCHEDUL")
case "kitchen": #SI("Kitchen Ltg Sch","SPACE","LIGHTING-SCHEDUL")
case "restroom": #SI("Restroom Ltg Sch","SPACE","LIGHTING-SCHEDUL")
default: no_def
endswitch

Coolest thread ever? Maybe!

~Nick

[cid:image001.png at 01D29699.2E8CAE60]
Nick Caton, P.E., BEMP
Senior Energy Engineer
Regional Energy Engineering Manager
Energy and Sustainability Services
Schneider Electric

D 913.564.6361
M 785.410.3317
F 913.564.6380
E nicholas.caton at schneider-electric.com

15200 Santa Fe Trail Drive
Suite 204
Lenexa, KS 66219
United States

[cid:image002.png at 01D29699.2E8CAE60]

via Equest-users's picture
Joined: 2016-07-15
Reputation: 400

This information is extremely helpful.

Thank you everyone for the help on this!

via Equest-users's picture
Joined: 2016-07-15
Reputation: 400

Ok - I am now trying to set up default expressions to auto-populate 2nd,
3rd, 4th, and 5th values for plug loads.

I have the following which is working for inputting the plug load schedule
in EQUIP-SCHEDULE 1, but how can I specify the equipment schedule for
Equipment Load #2/3/4/5?

I've tried using the BDLDFT document as reference but was unable to get
anything to work.

EQUIP-SCHEDULE = (
{switch(Local("C-ACTIVITY-DESC",0)+Local("C-ACTIVITY-DESC",1))
case "Apartmen" : #SI("ESMFHR Unit Eqp Sched", "SPACE", "EQUIP-SCHEDULE")
default : #SI("ESMFHR Non-Res Eqp Sched", "SPACE", "EQUIP-SCHEDULE")
endswitch
} )

Thank you,

via Equest-users's picture
Joined: 2016-07-15
Reputation: 400

OK, I am now trying to create a default expression for occupancy schedule
and I am running into more issues.
I used the same statement from my lighting schedule but here I am getting
an error "UNKNOWN KEYWORD or PREVIOUS .. MISSING"

Here is my expression I am using:

SET-DEFAULT FOR SPACE
PEOPLE-SCHEDULE = (
{switch(Local("C-ACTIVITY-DESC",0)+Local("C-ACTIVITY-DESC",1))
case "Apartmen" : #SI("ASHRAE MultiFam Occ Sched", "SPACE",
"PEOPLE-SCHEDULE")
default : no_default
endswitch
} )

I must be missing something because it seems to me like this should work
the same as it did for the lighting schedule.

Thank you,

via Equest-users's picture
Joined: 2016-07-15
Reputation: 400

Ok, to follow up on my last e-mail...
I was able to get it to work but I'm still not sure where the error is in
the expression that i posted.

via Equest-users's picture
Joined: 2016-07-15
Reputation: 400