How to run multiple simulation with different overhangs?

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
Mattia Esposito
VE Newbie
VE Newbie
Posts: 1
Joined: Fri Sep 15, 2023 1:34 pm

How to run multiple simulation with different overhangs?

Post by Mattia Esposito »

Hello,
I am using a script to run multiple simulations in series by varying the size of the shading (3 different simulation, same building but different overhang).
Looking at the results from VistaPro of the different models I saw that the solar gains are always the same, making me think of an error related to the suncast simulations.
Would anyone be able to help me correct the script?
Below is my script:
""""
This sample shows how to run Apache simulations
with control over various settings

"""

import iesve # the VE api
import pprint
import time

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

# Get and print the current options
sim.reset_options()
sim.set_options(detailed_external_solar=True, detailed_internal_solar=True)
opt = sim.get_options()
pp.pprint(opt)

# Set batch_operation to True to queue up simulations with Tasks scheduler (Beta).
# Note: when using Task Scheduler, the simulation job is queued and script
# execution continues immediately. This means that result files cannot be
# automatically post-processed, as you don't know when they will be completed
# With batch_operation set to False, simulation will block further script
# execution, and only continue once the simulation is complete.
batch_operation = False

# 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
# if sim.show_simulation_dialog() == False:
# print("Simulation was not run from dialog (user cancelled?)")

def change_shade_size(bodies, overhang_change, depth_change):
"""
Adjusts existing shade size for local shades
Checks shade body name to check for an assigned elevation north, south, east, west
Surface orientation is compass north, south, east, west +-45 degrees

Parameters
----------
shades : list of model bodies
overhang_change : left and right overhang size change (+ is an increase) m
depth_change : depth size change (+ is an increase) m

Notes
-----
Limitation: surfaces at exactly the test orientation boundaries (os set to XYZ.01)

"""

for body in bodies:
# Check if body is a local shade
if body.type == iesve.VEBody_type.local_shade:
# Get body name
body_object = body.get_room_data(type = iesve.attribute_type.real_attributes)
body_data = body_object.get_general()

# Check NSEW via name and adjust 3 unrestrained shade sides (walls) only
surfaces = body.get_surfaces()
if 'north' in body_data['name']:
for surface in surfaces:
properties = surface.get_properties()
if properties['type'] == 'Wall' and properties['orientation'] > 45.01 and properties['orientation'] <= 135.01:
surface.move(overhang_change)
if properties['type'] == 'Wall' and properties['orientation'] > 225.01 and properties['orientation'] <= 315.01:
surface.move(overhang_change)
if properties['type'] == 'Wall' and (properties['orientation'] > 315.01 or properties['orientation'] <= 45.01):
surface.move(depth_change)
if 'south' in body_data['name']:
for surface in surfaces:
properties = surface.get_properties()
if properties['type'] == 'Wall' and properties['orientation'] > 45.01 and properties['orientation'] <= 135.01:
surface.move(overhang_change)
if properties['type'] == 'Wall' and properties['orientation'] > 225.01 and properties['orientation'] <= 315.01:
surface.move(overhang_change)
if properties['type'] == 'Wall' and properties['orientation'] > 135.01 and properties['orientation'] <= 225.01:
surface.move(depth_change)
if 'east' in body_data['name']:
for surface in surfaces:
properties = surface.get_properties()
if properties['type'] == 'Wall' and (properties['orientation'] > 315.01 or properties['orientation'] <= 45.01):
surface.move(overhang_change)
if properties['type'] == 'Wall' and properties['orientation'] > 135.01 and properties['orientation'] <= 225.01:
surface.move(overhang_change)
if properties['type'] == 'Wall' and properties['orientation'] > 45.01 and properties['orientation'] <= 135.01:
surface.move(depth_change)
if 'west' in body_data['name']:
for surface in surfaces:
properties = surface.get_properties()
if properties['type'] == 'Wall' and (properties['orientation'] > 315.01 or properties['orientation'] <= 45.01):
surface.move(overhang_change)
if properties['type'] == 'Wall' and properties['orientation'] > 135.01 and properties['orientation'] <= 225.01:
surface.move(overhang_change)
if properties['type'] == 'Wall' and properties['orientation'] > 225.01 and properties['orientation'] <= 315.01:
surface.move(depth_change)


if __name__ == '__main__':

# This is a unit test to check the functions using the current body selection set
# Select some bodies in the VE then run the script; watch the changes in VE Model view

project = iesve.VEProject.get_current_project()
model = project.models[0]
bodies = model.get_bodies(True)

# Set some test values
overhang_change = -0.5
depth_change = -0.5
numero_simulazioni = 3
start_month = 1
end_month = 12
design_day = 15


time.sleep(1)
print('3. Demo shade adjustment')
if not bodies:
print('No bodies selected; exiting')
quit()
else:
for i in range(1,numero_simulazioni+1):
name = "simulazione_{}".format(i)
change_shade_size(bodies, overhang_change, depth_change)
#Run a suncast simulation for this model
suncast = model.suncast()
sun_result = suncast.run(start_month, end_month, design_day, True)
print("Suncast simulation {} success: {}".format(i,sun_result))
# Run a simulation with this settings:
sim.set_options({'results_filename': name}, suncast=True, radiance=True)
result = sim.run_simulation(batch_operation)
print('Simulation {} run success: {}'.format(i,result))
time.sleep(1)
# Give apache time to release its resources before starting next sim...
time.sleep(2)
Post Reply