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

BCVTB Data Conversion

asked 2019-04-24 07:16:42 -0600

Tanay's avatar

updated 2019-04-24 11:10:09 -0600

Hello All,

I am making a simple PID controller in BCVTB using EnergyPlus. In my model, I have a Simulator actor(called HouseModel in the image) that connects to EnergyPlus (v9.0.1). It takes setpoint temperature for cooling an heating thermostat as inputs array (for example, [16; 20]). image description

In the SystemCommnad actor (called PyController in the image), I have written a P-controller in Python file, as shown below,

import sys

setRef = sys.argv[1]
currTemp = sys.argv[2]

error = float(setRef) - float(currTemp)

# P-Controller
kP = 10
out = kP*error

value = {out, 20}
print(value)

sys.exit(0)

As the EnergyPlus model is expecting an array input, how do I convert the Output of the PyController to a usable array for HouseModel?

I also thought of using FileReader actor in Ptolemy and write the values in the file and then read it from them, but I could not find any good example of that to see how exactly I can use it.

If you have any good examples, I will love to try them.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2019-04-27 13:08:21 -0600

updated 2019-04-27 13:12:02 -0600

Your HouseModel is expecting a vector of doubles. Currently it is a String. I hence suggest to do the following:

  1. Change value to be a Vector by changing the curly brackets to square brackets: value = [out, 20]

  2. Use the ExpressionToToken actor from the BCVTB library to convert that String to a vector of doubles. The ExpressionToToken is in the Conversions package of the BCVTB library.
    You will need to configure the output of ExpressionToToken to be a vector of doubles. You can do it by right clicking on the actor selecting Customize -> Ports and by setting the Type of the output Ports to be [double]. This type should be compatible with the input of your HouseModel.

edit flag offensive delete link more

Your Answer

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

Add Answer

Training Workshops

Careers

Question Tools

1 follower

Stats

Asked: 2019-04-24 07:16:42 -0600

Seen: 371 times

Last updated: Apr 27 '19