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

Thermochromic colors simulation debug

asked 2021-05-21 09:31:02 -0500

Amirhossein's avatar

updated 2021-05-25 14:10:34 -0500

Hi

I am trying to simulate thermochromic colors on the building facade. My intended thermochromic color changes its color and furtherly its related physical properties (thermal, solar, and visible absorptance) around 28degree( C ) so I need a control procedure that checks external surfaces temperature at the start of any timestep during the run process and modifies those physical properties based on the current exterior surface temperature. I tried the Energyplus EMS scripting possibility and based on tutorial video and guide resources I've written a script but it doesn't work and I can't debug it.

I send the script in this post and would be thankful if anyone helps me in debugging this script.

<ForAllExternalSurfaces>
EnergyManagementSystem:Sensor,
Surface_Outside_Face_Temperature_<LoopSurfaceVariableName>,
<LoopSurfaceIDFName>,
Surface Outside Face Temperature;
<LoopNextSurface>
<ForAllExternalSurfaces>
EnergyManagementSystem:Actuator,
Surface_Property_Solar_Absorptance_<LoopSurfaceVariableName>,
<LoopSurfaceIDFName>,
Material,
Surface Property Solar Absorptance;
<LoopNextSurface>
<ForAllExternalSurfaces>
EnergyManagementSystem:Actuator,
Surface_Property_Thermal_Absorptance_<LoopSurfaceVariableName>,
<LoopSurfaceIDFName>,
Material,
Surface Property Thermal Absorptance;
<LoopNextSurface>
<ForAllExternalSurfaces>
EnergyManagementSystem:Actuator,
Surface_Property_Visible_Absorptance_<LoopSurfaceVariableName>,
<LoopSurfaceIDFName>,
Material,
Surface Property Visible Absorptance;
<LoopNextSurface>

EnergyManagementSystem:ProgramCallingManager,
Thermo,
BeginTimestepBeforePredictor,
Thermo;

EnergyManagementSystem:Program,
Thermo,
<ForAllExternalSurfaces>
if Surface_Outside_Face_Temperature_<LoopSurfaceVariableName> < 28,
set Surface_Property_Solar_Absorptance_<LoopSurfaceVariableName> == 0.9,
set Surface_Property_Thermal_Absorptance_<LoopSurfaceVariableName> == 0.9,
set Surface_Property_Visible_Absorptance_<LoopSurfaceVariableName> == 0.9,
elseif Surface_Outside_Face_Temperature_<LoopSurfaceVariableName> > 28,
set Surface_Property_Solar_Absorptance_<LoopSurfaceVariableName> == 0.1,
set Surface_Property_Thermal_Absorptance_<LoopSurfaceVariableName> == 0.1,
set Surface_Property_Visible_Absorptance_<LoopSurfaceVariableName> == 0.1,
elseif Surface_Outside_Face_Temperature_<LoopSurfaceVariableName> == 28,
set Surface_Property_Solar_Absorptance_<LoopSurfaceVariableName> == 0.5,
set Surface_Property_Thermal_Absorptance_<LoopSurfaceVariableName> == 0.5,
set Surface_Property_Visible_Absorptance_<LoopSurfaceVariableName> == 0.5,
endif,
<LoopNextSurface>
;
edit retag flag offensive close merge delete

Comments

1

Have you considered using PythonPlugin instead of EMS?

__AmirRoth__'s avatar __AmirRoth__  ( 2021-05-25 10:17:35 -0500 )edit

@Amir Roth Actually, I wish I could, but since I haven't had any experience in working with Python I thought it may be impossible for me to be able to operate PythonPlugin during my research work deadlines

Amirhossein's avatar Amirhossein  ( 2021-05-27 04:11:06 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted
4

answered 2021-05-21 09:46:29 -0500

updated 2021-05-30 18:07:56 -0500

In an EMS Program, you should only use two equal signs "==" within a logic statement (IF, ELSE, etc.). When defining a SET statement, you only need one equal sign "=". So all of your EMS Program lines setting the absorptance values should use one equal sign near the right end of the lines.

...
if Surface_Outside_Face_Temperature_<LoopSurfaceVariableName> < 28,
set Surface_Property_Solar_Absorptance_<LoopSurfaceVariableName> = 0.9,
set Surface_Property_Thermal_Absorptance_<LoopSurfaceVariableName> = 0.9,
set Surface_Property_Visible_Absorptance_<LoopSurfaceVariableName> = 0.9,
...

You can read more in the EMS Application Guide about statement keywords and see some examples in various expressions.

UPDATE

The original post above settles some syntax issues in the EMS program, but your EMS Actuator also has issues. You are trying to read EMS sensors for every exterior surface, then use that sensor data to change the absorption of the outermost material layer of that surface. You are correctly looping over surfaces to create the EMS actuator, but the actuator information you have entered is for material layers. These are different types of objects in the model, which is why you're still getting severe errors after the syntax fixes above.

If you want to potentially change the absorption of the outermost material layer of any exterior surface, then you will need to change your EMS script approach. Instead of directly setting absorptance in your EMS program, you should be setting the Surface Construction State. This is an EMS Actuator that works with an EMS Construction Index Variable object that is connected to a specific construction assembly defined in the model. With this new approach, you will have to:

  1. Create three material layers in your model -- one for each of the absorptance values you want to apply with your EMS program
  2. Create three constructions in your model -- these are almost identical with the only thing changing is the outermost layer touching outdoor air is one of the three material layers created in the previous step.
  3. Save your DB model and export the EnergyPlus input data file (IDF). Search for the name of the 3 Construction objects you created in the previous step to see if the names are identical to what you entered in DB or if DB has changed them in some way when creating the IDF.
  4. Create thee EMS Construction Index Variables in your EMS script -- one for each of the three Construction names reviewed in the IDF from the previous step.
  5. Update your loop creating EMS Actuators for each surface to only create one actuator for the construction state (don't need 3 actuators for each surface anymore)
  6. Update your EMS Program to set the construction state for each surface to the appropriate EMS Construction Index Variable according to the same if/elsif/else temperature checks and loop for all exterior surfaces

Example:

<ForAllExternalSurfaces>
EnergyManagementSystem:Sensor,
  Surface_Outside_Face_Temperature_<LoopSurfaceVariableName>,
  <LoopSurfaceIDFName>,
  Surface Outside Face Temperature;
<LoopNextSurface>

<ForAllExternalSurfaces>
EnergyManagementSystem:Actuator,
  Surface_Cons_State_<LoopSurfaceVariableName>,
  <LoopSurfaceIDFName>,
  Surface,
  Construction State;
<LoopNextSurface>

EnergyManagementSystem:ConstructionIndexVariable,
  EMS_Cons_High_Abs,    !- Name
  High Absorptance Construction;              !- Construction Object Name (needs to match name of Construction object in exported IDF)

EnergyManagementSystem:ConstructionIndexVariable,
  EMS_Cons_Mid_Abs,    !- Name
  Mid Absorptance ...
(more)
edit flag offensive delete link more

Comments

Thank you dear Aaron I followed your instruction and some of the errors has been eliminated by that but there are still some other warning errors that stop the simulation process. I send simulation error panel text for more clarification in the next comment.

Amirhossein's avatar Amirhossein  ( 2021-05-21 10:19:32 -0500 )edit

* Warning * GetSurfaceData: Entered Zone Floor Areas differ from calculated Zone Floor Area(s). * ~~~ * ...use Output:Diagnostics,DisplayExtraWarnings; to show more details on individual zones. * Warning * GetSurfaceData: There are 4 window/glass door(s) that may cause inaccurate shadowing due to Solar Distribution. * ~~~ * For explicit details on each window, use Output:Diagnostics,DisplayExtraWarnings; *** Note that the following warning(s) may/will occur if you have not enclosed your zone completely.

Amirhossein's avatar Amirhossein  ( 2021-05-21 10:23:26 -0500 )edit

* Warning * Entered Zone Volumes differ from calculated zone volume(s). * ~~~ * ...use Output:Diagnostics,DisplayExtraWarnings; to show more details on individual zones. * Warning * CheckUsedConstructions: There are 5 nominally unused constructions in input. * ~~~ * For explicit details on each unused construction, use Output:Diagnostics,DisplayExtraWarnings; * Fatal * EMS, caught unexpected token = "=" ; while parsing string=SURFACE_OUTSIDE_FACE_TEMPERATURE_Z10_GROUNDFLOOR_0_0_0 = 28

Amirhossein's avatar Amirhossein  ( 2021-05-21 10:24:21 -0500 )edit

@Amirhossein the lines that begin with * Warning * are warnings -- messages that reflect a questionable input, but EnergyPlus will keep simulating anyway. It's up to you if these indicate something that absolutely needs to be fixed. For example, the ... 5 nominally unused constructions in input warning means you have defined 5 construction assemblies in the model that are not assigned to surfaces. This doesn't affect simulation accuracy or run-time, so this is safe to ignore. However, the lines that begin with * Fatal * are why the simulation stops, and these need to be addressed.

Aaron Boranian's avatar Aaron Boranian  ( 2021-05-21 11:50:51 -0500 )edit

Based on the fatal error message without looking at your model, it looks like you have incorrectly changed your EMS Program line checking if the surface temp sensor is equal to 28C.

...
elseif Surface_Outside_Face_Temperature_<LoopSurfaceVariableName> = 28,
...

Since this is a logic statement, this should use two equal signs, like how you had it originally.

...
elseif Surface_Outside_Face_Temperature_<LoopSurfaceVariableName> == 28,
...
Aaron Boranian's avatar Aaron Boranian  ( 2021-05-21 11:53:34 -0500 )edit
0

answered 2022-12-16 04:37:51 -0500

updated 2022-12-17 10:39:34 -0500

Hi @Amirhossein and @aaron Borian Thanks for this post. I am trying to test thermochromic paints with only two options (darker and lighter color), under 28 dergres and over 28 degrees. I followed @aaron Borian script, but there is a sever error running the simulation.

Do you know how can I fix it?

This is the script that I am using:

 <ForAllExternalSurfaces>
 EnergyManagementSystem:Sensor,
   Surface_Outside_Face_Temperature_<LoopSurfaceVariableName>,
   <LoopSurfaceIDFName>,
   Surface Outside Face Temperature;
<LoopNextSurface>

<ForAllExternalSurfaces>
EnergyManagementSystem:Actuator,
  Surface_Cons_State_<LoopSurfaceVariableName>,
  <LoopSurfaceIDFName>,
  Surface,
  Construction State;
<LoopNextSurface>

EnergyManagementSystem:ConstructionIndexVariable,
  EMS_Cons_High_Abs,    !- Name
  High Absorptance Construction;              !- Material, 3_1_10061

EnergyManagementSystem:ConstructionIndexVariable,
  EMS_Cons_Low_Abs,    !- Name
  Low Absorptance Construction;              !- Material, 19_1_10062

EnergyManagementSystem:ProgramCallingManager,
  Thermo,
  BeginTimestepBeforePredictor,
  Thermo;

EnergyManagementSystem:Program,
  Thermo,
  <ForAllExternalSurfaces>
  if Surface_Outside_Face_Temperature_<LoopSurfaceVariableName> < 28,
  set Surface_Cons_State_<LoopSurfaceVariableName> = Material, 3_1_10061
  elseif Surface_Outside_Face_Temperature_<LoopSurfaceVariableName> > 28,
  set Surface_Cons_State_<LoopSurfaceVariableName> = Material, 19_1_10062,
  endif,
  <LoopNextSurface>
  ;

And this is the error message:

** Severe  ** GetRuntimeLanguageUserInput: EnergyManagementSystem:ConstructionIndexVariable="EMS_CONS_HIGH_ABS invalid field.
**   ~~~   ** Invalid Construction Object Name=HIGH ABSORPTANCE CONSTRUCTION
**   ~~~   ** Construction was not found.
** Severe  ** GetRuntimeLanguageUserInput: EnergyManagementSystem:ConstructionIndexVariable="EMS_CONS_LOW_ABS invalid field.
**   ~~~   ** Invalid Construction Object Name=LOW ABSORPTANCE CONSTRUCTION
**   ~~~   ** Construction was not found.
**  Fatal  ** Errors found in getting EMS Runtime Language input. Preceding condition causes termination.

Thanks! Camila

edit flag offensive delete link more

Comments

@camilamacorreia@gmail.com this is posted as an answer to Amir's question, but this is really a new question that is similar. Can you make a new question post for this? You should be able to copy the text of this answer (click "edit" to copy over the code formatting correctly) into the new question post.

Aaron Boranian's avatar Aaron Boranian  ( 2022-12-17 10:42:33 -0500 )edit

Looks like a new post was made. Thank you!

Aaron Boranian's avatar Aaron Boranian  ( 2022-12-18 19:09:48 -0500 )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

Stats

Asked: 2021-05-21 09:31:02 -0500

Seen: 277 times

Last updated: Dec 17 '22