Question-and-Answer Resource for the Building Energy Modeling Community
Get started with the Help page
Ask Your Question
2

Can I access hour of day, day and month by external interface from EnergyPlus?

asked 2016-12-21 03:30:38 -0600

Mike06's avatar

updated 2017-04-16 11:37:13 -0600

If I want to perform code in the external programme (like MATLAB) during every time-step, depending on e.g. the time of the day, can I get that variable from EnergyPlus? Or do I have to derive that information from the overall simulation time (either in BCVTB or MATLAB)?

edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted
2

answered 2017-12-14 06:09:26 -0600

Samuel de Vries's avatar

updated 2017-12-14 06:10:05 -0600

A bit of a late addition, but for future reference: the built in variables for the designation of time within Erl can requested as EMS ouput variables and exported to BCVTB via the external interface. These variables can be found in the EMS manual (p.11). In this instance you would probably be interested in 'Hour' (whole hours) and 'Minute' or 'CurrentTime' (gives fractional hours). The day can be requested through 'DayOfMonth', 'DayOfWeek' or 'DayOfYear'.

edit flag offensive delete link more
1

answered 2016-12-28 11:14:50 -0600

dalin_si's avatar

You can check a co-simulation platform called MLE+ https://github.com/mlab-upenn/mlep_v1.1

edit flag offensive delete link more

Comments

thanks. I am already running a co-simulation with BCVTB (Ptolemy II), but wondered, if EnergyPlus would be able to write the hour of the day and the day itself as an output variable (which I then could use), instead of deriving it from the simulation time of the co-simulation. with mle+ I found out that it is not updated anymore and would not run with current MATLAB and EnergyPlus versions.

Mike06's avatar Mike06  ( 2016-12-29 14:07:30 -0600 )edit

Thank you for your infomation

dalin_si's avatar dalin_si  ( 2016-12-29 16:11:17 -0600 )edit
1

If EnergyPlus can report your desired output variables as double values then you should be able to exchange them with the BCVTB.

Thierry Nouidui's avatar Thierry Nouidui  ( 2017-01-09 13:57:36 -0600 )edit
0

answered 2024-02-12 02:06:21 -0600

updated 2024-02-12 02:10:51 -0600

@Samuel de Vries @Joe Huang: I was wondering if you could please advise me on the error I'm getting using Erl built-in variable: DayOfWeek - as presented below:

* Severe * EnergyManagementSystem:Program="IF (DAYOFWEEK <= 5)", Invalid variable name entered. * ~~~ * ...Name; Names used for EMS Programs cannot contain spaces * Fatal * Errors found in getting EMS Runtime Language input. Preceding condition causes termination. ...Summary of Errors that led to program termination: ..... Reference severe error count=1 ..... Last severe error=EnergyManagementSystem:Program="IF (DAYOFWEEK <= 5)", Invalid variable name entered.

Please find the section of my EMS Program - where I used that DayOfWeek variable - as shown below:

IF (DayOfWeek <= 5), Window_Control_S, IF (Q_Heating > 0) || (Q_Heating_Electric > 0), IF Win_Tout_S > Win_Tin_S && Win_Tout_S > T_SET_H, Set WinS_Construct = HighUHighSHGC, ELSEIF Win_Tout_S < Win_Tin_S, Set WinS_Construct = LowUHighSHGC, ENDIF,

Thanks!

edit flag offensive delete link more

Comments

The first line of any EMS program should be the name of that program. This name is what you call within the program calling manager.

The second line of an EMS program contains the first line of your program.

Judging from this error: * Severe * EnergyManagementSystem:Program="IF (DAYOFWEEK <= 5)", * Invalid variable name entered. * ~~~ * ...Name; Names used for EMS Programs cannot contain spaces *

It looks like you put the first line of your program on line one of the EMS program object. Or you forgot a comma after the name. Not sure because you don't show the full program/idf.

Samuel de Vries's avatar Samuel de Vries  ( 2024-02-12 02:16:17 -0600 )edit

Thank you so much @Samuel de Vries

You're absolutely correct. I fixed that error, as shown below:

EnergyManagementSystem:Program, Window_Control_S, IF (DayOfWeek <= 5), IF (Q_Heating > 0) || (Q_Heating_Electric > 0), ...

However, still getting the following error:

* Severe * EnergyManagementSystem:Program="IF (DAYOFWEEK <= 5)", Invalid variable name entered. * ~~~ * ...Name; Names used for EMS Programs cannot contain spaces * Fatal * Errors found in getting EMS Runtime Language input. Preceding condition causes termination.

Mohammad's avatar Mohammad  ( 2024-02-12 10:01:21 -0600 )edit

@Samuel de Vries Please find the edited idf file here: https://drive.google.com/drive/folder...

Mohammad's avatar Mohammad  ( 2024-02-12 12:41:36 -0600 )edit

You are running the wrong file. The error you're gettting suggests that the name of your EMS program is still "IF (Q_Heating > 0) || (Q_Heating_Electric > 0)" whilst you changed it to "Window_Control_S".

In the IDF I see you correctly changed the name of the program to "Window_Control_S" so you must be selecting the wrong file in running it.

When I run your file I do get another error. This error is because you made typo's in defining the variable "Q_Heating_Electric". Sometimes you write it as "Q_Heating_Electirc"

I recommend carefully reading what the error messages say.

Samuel de Vries's avatar Samuel de Vries  ( 2024-02-13 01:38:52 -0600 )edit

This: EnergyManagementSystem:Program="IF (DAYOFWEEK <= 5)",

Means that there is an error in a program called "IF (DAYOFWEEK <= 5)".

Because you know you don't have a program that is named that gives you a clue that something must be wrong with the naming.

This error: * ~~~ * Error message: * Error: EvaluateExpression: Variable = 'Q_HEATING_ELECTRIC' used in expression has not been initialized! *

shows something is wrong with the variable "Q_HEATING_ELECTRIC". Search for it in your idf and you'll see your only using it in your program but not initializing anywhere else

Samuel de Vries's avatar Samuel de Vries  ( 2024-02-13 01:42:20 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Careers

Question Tools

1 follower

Stats

Asked: 2016-12-21 03:30:38 -0600

Seen: 564 times

Last updated: Feb 12