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

Revision history [back]

click to hide/show revision 1
initial version

How can I simulate just one time-step (dt = 60s) with the E+-API?

I still have some questions because of the EnergyPlus-API for Python :)

How I can simulate just one step with the api? Because there is just the function run_energyplus(state: ctypes.c_void_p, command_line_args: List[Union[str, bytes]]) and it simulates the whole time span.

In my function, I want to simulate one step, calculate one actuator value with an external function, use api.exchange.set_actuator_value() to set the actuator for the baseboard heater and simulate the next time step.

Previously we used the FMU-simulation in python and there we could define a do_step function.

Thank you very much :)

def do_step(self, setpoints):
    """
    Simulate one step
    :param setpoints: dict of setpoints
    :return: variables
    """
    # set set-points and do sim-step
    for key in setpoints.keys():
        self.model.set(key, setpoints[key])

    self.model.do_step(self.model._get_time(), self.config["dt_s"])
    # time.append(model._get_time())
    # get values for variables in varliable-list:
    var_dict = {var_name: self.model.get(var_name) for var_name in self.var_list}
    return var_dict

How can I simulate just one time-step (dt = 60s) with the E+-API?

I still have some questions because of the EnergyPlus-API for Python :)

How I can simulate just one step with the api? Because there is just the function run_energyplus(state: ctypes.c_void_p, command_line_args: List[Union[str, bytes]]) and it simulates the whole time span.

In my function, I want to simulate one step, calculate one actuator value with an external function, use api.exchange.set_actuator_value() to set the actuator for the baseboard heater and simulate the next time step.

Previously we used the FMU-simulation in python and there we could define a do_step function.

Thank you very much :)

def do_step(self, setpoints):
    """
    Simulate one step
    :param setpoints: dict of setpoints
    :return: variables
    """
    # set set-points and do sim-step
    for key in setpoints.keys():
        self.model.set(key, setpoints[key])

    self.model.do_step(self.model._get_time(), self.config["dt_s"])
    # time.append(model._get_time())
    # get values for variables in varliable-list:
    var_dict = {var_name: self.model.get(var_name) for var_name in self.var_list}
    return var_dict