Hi,
You can't create a valid VEThermalTemplate or CasualGains object from scratch. Also for CasualGains you can only read data, not set it.
However you can modify an existing VEThemalTemplate object. Here are the methods in VEThemalTemplate you can use for that:
set (room_conditions, system_data)
Set both System Data and Room Conditions settings by passing in dictionaries of settings.
See set_apache_systems and set_room_conditions for dictionary keys.
set_apache_systems(system_data)
Set System Data settings by passing in a dictionary of settings.
Dictionary keys are:
aux_vent_system
aux_vent_system_same
conditioned
cooling_capacity_units
cooling_capacity_value
cooling_plant_radiant_fraction
dhw_system
dhw_system_same
heating_capacity_units
heating_capacity_value
heating_plant_radiant_fraction
HVAC_methodology
HVAC_system
system_air_free_cooling
system_air_free_cooling_units
system_air_minimum_flowrate
system_air_minimum_flowrate_units
system_air_variation_profile
set_room_conditions(room_conditions)
Set Room Conditions settings by passing in a dictionary of settings.
Dictionary keys are:
cooling_profile
cooling_setpoint
cooling_setpoint_constant
cooling_setpoint_profile
dhw
dhw_profile
dhw_units
heating_profile
heating_setpoint
heating_setpoint_constant
heating_setpoint_profile
plant_profile
plant_profile_type
sat_perc_lower
sat_perc_upper
You can also add and remove air exchanges and casual gains from the template. Have a look at these methods:
add_air_exchange(airExchange)
Add an AirExchange object to the template.
add_gain(casualGain)
Add a CasualGain object to the template.
remove_air_exchange(airExchange)
Remove air exchange from template. Will throw exception if air exchange is not associated with template.
remove_gain(casualGain)
Remove casual gain from template. Will throw exception if gain is not associated with template.
If you want to apply the changes made to the template back to the model, you'll need to call apply_changes():
apply_changes()
Apply any changes made to the template to the model. Note: if this is not called, changes to the template will not be reflected in the model. This includes changes to gains and air exchanges for the template.
Note – this operation may take a significant amount of time on large models.
Here's an example of correct usage:
Code: Select all
import iesve # the VE api
# Get the current VE project.
# Getting the thermal templates is a project-level operation
proj = iesve.VEProject.get_current_project()
# Get a list of the known thermal templates
# Pass True to only get templates in use (assigned), False to get all templates
templates = proj.thermal_templates(False)
# the templates are returned as a dictionary
# for this sample we don't need the key (the template handle)
# so iterate over the dictionary values only
templates_iter = templates.values()
for template in templates_iter:
# we can check the type of a template by checking its 'standard' attribute
# this returns an enum that can represent: generic, NCM, or PRM
# this allows filtering of templates similar to BTM's behaviour of not showing
# NCM templates by default
if template.standard != iesve.VEThermalTemplate_standard.generic:
continue # skip PRM and NCM templates
sys_settings = { 'HVAC_system': 'SYST0000',
'HVAC_methodology': iesve.hvac_methodology.apache_system,
'conditioned': iesve.conditioned_flag.yes,
'aux_vent_system': 'SYST0000',
'aux_vent_system_same': False,
'cooling_capacity_units': iesve.heating_cooling_capacity_unit.unlimited,
'cooling_capacity_value': 0.0,
'cooling_plant_radiant_fraction': 0.0,
'dhw_system': 'SYST0000',
'dhw_system_same': False,
'heating_capacity_units': iesve.heating_cooling_capacity_unit.unlimited,
'heating_capacity_value': 0.0,
'heating_plant_radiant_fraction': 0.2,
'system_air_free_cooling': 0.0,
'system_air_free_cooling_units': 0,
'system_air_minimum_flowrate': 0.800000011920929,
'system_air_minimum_flowrate_units': 2,
'system_air_variation_profile': 'OFF'}
room_settings = {'sat_perc_lower': 0.0,
'heating_setpoint': 19.0,
'cooling_setpoint': 23.0,
'dhw_units': 'l/h',
'cooling_setpoint_profile': '0',
'dhw_profile': '-',
'plant_profile_type': 0,
'dhw': 10.0,
'cooling_setpoint_constant': True,
'cooling_profile': 'ON',
'plant_profile': 'ON',
'sat_perc_upper': 100.0,
'heating_setpoint_constant': True,
'heating_profile': 'ON',
'heating_setpoint_profile': '0'}
template.set(room_settings, sys_settings)
template.apply_changes()
print("Templates set!")
You can also assign templates to the model by calling assign_thermal_template_to_rooms() in VEModel:
assign_thermal_template_to_rooms( template, [roomID] )
Assign the VEThermalTemplate template to the rooms, indicated by list of Room IDs (strings or VEBody objects).
Example usage for this:
Code: Select all
""""
This sample resets the selected rooms in the real model back to the "Default"
thermal template.
If no rooms are selected, it resets ALL rooms!
CAUTION: this script will modify your model !
"""
import iesve # the VE api
# the list of models is accessed through the project API
project = iesve.VEProject.get_current_project()
# get the real building
real_building = project.models[0]
# build the list of room IDs to assign template to
room_id_list = []
# first we get only the selected rooms - if no rooms were selected
# (empty list returned), then we get all rooms
selected_rooms = real_building.get_bodies(True)
if len(selected_rooms) == 0:
print("No rooms were selected - resetting all rooms back to default template")
selected_rooms = real_building.get_bodies(False)
# now build a list of room IDs
for body in selected_rooms:
if body.type == iesve.VEBody_type.room:
room_id_list.append(body.id)
print("Assigning default template to {} room(s)".format(len(room_id_list)))
# find the default thermal template
# we start with getting the full list of thermal templates
templates = project.thermal_templates(False)
# the templates are returned as a dictionary
# for this sample we don't need the key (the template handle)
# so iterate over the dictionary values only
# and we look for a template with the name "default" - this should
# always exist in every project!
templates_iter = templates.values()
for template in templates_iter:
if template.name == "default":
real_building.assign_thermal_template_to_rooms(template, room_id_list)
# no need to process further templates, so break out of the for loop
break
# end of sample
Hope that helps.