Changing HVAC networks with Python

The VE Python API allows users create simple programs using the Python Programming Language, to interact with a VE Model and/or Vista Results File
Post Reply
ghostzombiemonster
VE Newbie
VE Newbie
Posts: 1
Joined: Fri Sep 06, 2024 2:25 pm

Changing HVAC networks with Python

Post by ghostzombiemonster »

Hi,

I am working on a script to parametrically cycle through various mechanical system. Script would run the room loads, system load, and the 8760 simulation with goal of comparing the output aps files for savings, operation, unmet hours etc.

In the IES "Python in the VE" on page 11, they have a sample that loosely does this. Link provided below for reference.

file:///C:/IES%20models/script%20model/Introduction%20to%20using%20Python%20with%20the%20IESVE%20slides.html

My current script does technically work, but the issue is automating the apache 8760 simulation. If I allow the user to input the options in the Apache Simulation screen everything works as intended. However, if I attempt to automate the simulation screen, then the results for all the mechanical systems come out identical.

Ive included my script below if anybody has any feedback for what I am doing incorrectly.

I am wondering if the problem is the "apacheHVAC link" within the simulation screen.

If I allow the user to input the options in the screen, then they can click the checkbox and cycle thru all the applicable HVAC systems. However when automating how does this checkbox get selected??? Seems like it might just stay locked on the first mechanical system.

SCRIPT:
import os
import iesve
import importlib
import numpy as np
#import utils_parametric as utils_parametric
from datetime import datetime
from pathlib import Path
from datetime import date
import pprint
import time

# Main loop
if __name__ == "__main__":

# Get the current project
project = iesve.VEProject.get_current_project()


#paramatric mechanical system input
ap_system = ['HVAC-HP.asp', 'HVAC-VAV.asp']

# Loop thru each model change list and process each sensitivity analysis
for item in ap_system:

sim = iesve.ApacheSim()
pp = pprint.PrettyPrinter()

# Calcuate the room loads
sim.set_hvac_network(item) # Change this to the name of your HVAC network
sim.set_options({'results_filename': 'RM_Loads'})
sim.run_room_zone_loads()

# Give apache time to release its resources before starting next sim...
time.sleep(10)

# Calcuate the system loads
sim.reset_options()
sim.set_hvac_network(item)
sim.set_options({'results_filename': 'SYS_Loads'})
sim.run_loads_sizing()

# Give apache time to release its resources before starting next sim...
time.sleep(20)

# Get and print the current options
opt = sim.get_options()
pp.pprint(opt)

# Set batch_operation to True to queue up simulations with Tasks scheduler
batch_operation = True

# If you want to invoke the Apache Simulations options dialog (to run manually)
# uncomment the lines below. Script will halt until the dialog is closed
# THIS PART WORKS FINE, JUST HAVE TO MANUALLY PUSH THE SIMULATE BUTTON
#if sim.show_simulation_dialog() == False:
#print("Simulation was not run from dialog (user cancelled?)")

# Run a simulation with basic settings:
# THIS PART DOES NOT WORK CORRECTLY, results for all mech system are the same.
sim.reset_options()
sim.set_hvac_network(item)
sim.set_options({'results_filename': item})
sim.set_options({'simulation_timestep': 2, 'reporting_interval': 3}) # Values represent drop down position, not actual timestep\interval.
result = sim.run_simulation(batch_operation)
print('Simulation 1 run success: {}'.format(result))

# Give apache time to release its resources before starting next sim...
time.sleep(10)
Post Reply