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

EnergyPlus/Matlab Co-Simulation through BCVTB [closed]

asked 2023-03-14 04:55:54 -0600

Zakaria's avatar

updated 2023-03-17 09:08:00 -0600

Hello community,

I am currently working on a project to model a product's thermal load using EnergyPlus and Matlab, and I would like to use the co-simulation approach through the BCVTB to exchange data between the two programs.

The approach I am using is to model the product as an internal load using OtherEquipment instead of calculating the load separately and adding it as a schedule. I have used Matlab to calculate the heat load of the product and send it to E+ using BCVTB. E+ will then calculate the temperature inside the freezer and send it back to Matlab to calculate the new heat load for the next step, and so on.

However, I have encountered some errors while trying to perform this simulation, and I have no idea how to solve them. I would be grateful if someone with experience in co-simulation and the BCVTB could help me with this issue. I have attached the necessary files for anyone who wants to check on the model.

Thank you in advance for your help.

The Link to the model files: https://drive.google.com/drive/folders

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Zakaria
close date 2024-01-09 07:28:40.017245

2 Answers

Sort by ยป oldest newest most voted
2

answered 2023-06-10 05:36:27 -0600

Zakaria's avatar

updated 2023-06-10 05:37:12 -0600

The data exchange between EnergyPlus and Matlba is working. Instead of using BCVTB I used the EnergyPlus Co-simulation Toolbox.

This how I defined the variable in EnergyPlus.

!-   ===========  ALL OBJECTS IN CLASS: OTHEREQUIPMENT ===========
OtherEquipment,
    BASE-1 OthEq 1,          !- Name
    None,                    !- Fuel Type
    ZN,                      !- Zone or ZoneList Name
    Ref System work sch,     !- Schedule Name
    EquipmentLevel,          !- Design Level Calculation Method
    *,                       !- Design Level {W}
    ,                        !- Power per Zone Floor Area {W/m2}
    ,                        !- Power per Person {W/person}
    ,                        !- Fraction Latent
    ,                        !- Fraction Radiant
    ;                        !- Fraction Lost

!-   ===========  ALL OBJECTS IN CLASS: EXTERNALINTERFACE ===========
ExternalInterface,
    PtolemyServer;           !- Name of External Interface

!-   ===========  ALL OBJECTS IN CLASS: EXTERNALINTERFACE:ACTUATOR ===========
ExternalInterface:Actuator,
    OtherEp,                 !- Name
    BASE-1 OthEq 1,          !- Actuated Component Unique Name
    OtherEquipment,          !- Actuated Component Type
    Power Level,             !- Actuated Component Control Type
    726;                     !- Optional Initial Value

Output:Variable,
    ZoneName,                  !- Key Value
    Zone Air Temperature,      !- Variable Name
    Timestep;                  !- Reporting Frequency

variables.cfg File

<?xml version="1.0" encoding="utf-8"?>    
<!DOCTYPE BCVTB-variables
  SYSTEM "variables.dtd">
<BCVTB-variables><!--INPUT to E+-->
   <variable source="Ptolemy">
      <EnergyPlus actuator="OtherEp"/>
   </variable><!--OUTPUT from E+-->
       <variable source="EnergyPlus">
          <EnergyPlus name="ZoneName" type="Zone Air Temperature"/>
       </variable>
</BCVTB-variables>
edit flag offensive delete link more
1

answered 2023-03-14 06:03:14 -0600

I have not run your model (since I do not have Matlab installed) but looking at your variables.cfg

I see the following

<BCVTB-variables><!--INPUT--><variable source="Ptolemy">
      <EnergyPlus schedule="OtherEqTest"/>
   </variable>

This indicates that EnergyPlus will receive values from outside (in your case from Matlab) that will be fed into an EnergyPlus schedule. However, when I look at your IDF I see the following:

ExternalInterface:Actuator,
    OtherEqTest,             !- Name
    OthEq,                   !- Actuated Component Unique Name
    Other Equipment,         !- Actuated Component Type
    Design Level;            !- Actuated Component Control Type

where OtherEqTest is defined as an Actuator as opposed to a Schedule.

This mismatch is most likely causing your system not to run properly.

edit flag offensive delete link more

Comments

Thank you for your answer I did not notice the mismatch.

I changed it to Actuator since I want fed the calculate values to EnergyPlus as Design Level of the OtherEquipment object and I get error below

- Component Type not found Component

- Unique key name not found

- Control Type not found

How can I defin Design Level as an Actuator ?


Update

Actuated Component Control Type should be set to "Power Level"

Zakaria's avatar Zakaria  ( 2023-03-14 06:28:40 -0600 )edit

I suggest removing all external interface objects from your model and first adding a native EnergyPlus EMS actuator that should mimic what the BCVTB will do. This way, you will be able to test your EnergyPlus model without the BCVTB in the loop. If you manage to successfully run the program with the native EnergyPlus EMS Actuator then you could later replace it with the ExternalInterface:Actuator

Thierry Nouidui's avatar Thierry Nouidui  ( 2023-03-14 07:08:18 -0600 )edit

Thank you @Thierry for your comment.

I have used the EMS as you suggested and created a simple program that calculates the Products Temperature as well as the Products Thermal loads (Q=mCp(Tproduct-Tfreezer)) and have defined as outputs as well. But when I check the results the Products Thermal loads is always = 0, even if the Tproduct and Tfreezer are different at each time step.

The link to the EMS Test File: https://drive.google.com/drive/folders

Zakaria's avatar Zakaria  ( 2023-03-30 12:02:09 -0600 )edit

I suggest creating a new post that describes the issue you are having with E+ and EMS with the appropriate tags. The issue seems to not be related to the BCVTB. Once the issue will be sorted out, then you could replace the EMS objects with the external interface objects.

Thierry Nouidui's avatar Thierry Nouidui  ( 2023-03-31 07:45:44 -0600 )edit

Training Workshops

Careers

Question Tools

2 followers

Stats

Asked: 2023-03-14 04:55:54 -0600

Seen: 206 times

Last updated: Jun 10 '23