fairyfly_therm.writer module¶
Methods to write Fairyfly core objects to THERM XML and THMZ.
- fairyfly_therm.writer.boundary_to_therm_xml(boundary, plane=None, boundaries_element=None, reset_counter=True)[source]¶
Generate an THERM XML Boundary Element object from a fairyfly Boundary.
- Parameters:
boundary – A fairyfly Boundary for which an THERM XML Boundary Element object will be returned.
plane – An optional ladybug-geometry Plane to set the 2D coordinate system into which the 3D Boundary will be projected to THERM space. If None, it will be assumed that the Boundary lies in the World XY plane. (Default: None).
boundaries_element – An optional XML Element for the Boundaries to which the generated objects will be added. If None, a new XML Element will be generated. (Default: None).
reset_counter – A boolean to note whether the global counter for unique handles should be reset after the method is run. (Default: True).
<Boundary> <ID>45</ID> <UUID>14264c7e-1801-a3c1-0e115d8227ac</UUID> <Name>NFRC 100-2010 Exterior</Name> <FluxTag></FluxTag> <IsBlocking>true</IsBlocking> <NeighborPolygonUUID>5b9e5933-1080-4e9e-5c3b537d8230</NeighborPolygonUUID> <Origin> <x>0</x> <y>0</y> </Origin> <StartPoint> <x>235.670456</x> <y>-147.081726</y> </StartPoint> <EndPoint> <x>235.670456</x> <y>-297.081238</y> </EndPoint> <Side>0</Side> <ThermalEmissionProperties> <Emissivity>0.84</Emissivity> <Temperature>0</Temperature> <UseGlobalEmissivity>true</UseGlobalEmissivity> </ThermalEmissionProperties> <IsIlluminated>false</IsIlluminated> <EdgeID>0</EdgeID> <Type>Boundary Condition</Type> <Color>0x000000</Color> <Status>0</Status> </Boundary>
- fairyfly_therm.writer.boundary_to_therm_xml_str(boundary)[source]¶
Generate an THERM XML string from a fairyfly Boundary.
- Parameters:
shape_mesh – A fairyfly Boundary for which an THERM XML Boundary string will be returned.
- fairyfly_therm.writer.model_to_therm_xml(model)[source]¶
Generate an THERM XML Element object for a fairyfly Model.
The resulting Element has all geometry (Shapes and Boundaries).
- Parameters:
model – A fairyfly Model for which a THERM XML ElementTree object will be returned.
- fairyfly_therm.writer.model_to_therm_xml_str(model)[source]¶
Generate a THERM XML string for a Model.
The resulting Element has all geometry (Shapes and Boundaries).
- Parameters:
model – A fairyfly Model for which an THERM XML text string will be returned.
Usage:
import os from fairyfly.model import Model from fairyfly.config import folders from fairyfly_therm.lib.materials import concrete, air_cavity from fairyfly_therm.lib.conditions import exterior, interior # Crate an input Model model = Model.from_layers([100, 200, 100], height=1000) model.shapes[0].properties.therm.material = concrete model.shapes[1].properties.therm.material = air_cavity model.shapes[2].properties.therm.material = concrete model.boundaries[0].properties.therm.condition = exterior model.boundaries[1].properties.therm.condition = interior model.display_name = 'Roman Bath Wall' # create the THERM XML string for the model xml_str = model.to.therm_xml(model) # write the final string into an XML file using DesignBuilder encoding therm_xml = os.path.join(folders.default_simulation_folder, 'model.xml') with open(therm_xml, 'wb') as fp: fp.write(xml_str.encode('utf-8'))
- fairyfly_therm.writer.model_to_thmz(model, output_file)[source]¶
Write a THERM Zip (.thmz) file from a Fairyfly Model.
- Parameters:
model – A fairyfly Model for which an THERM XML file will be written.
output_file – The path to the THMZ file that will be written from the model.
- fairyfly_therm.writer.shape_to_therm_xml(shape, plane=None, polygons_element=None, reset_counter=True)[source]¶
Generate an THERM XML Polygon Element object from a fairyfly Shape.
- Parameters:
shape – A fairyfly Shape for which an THERM XML Polygon Element object will be returned.
plane – An optional ladybug-geometry Plane to set the 2D coordinate system into which the 3D Shape will be projected to THERM space. If None the Face3D.plane of the Shape’s geometry will be used. (Default: None).
polygons_element – An optional XML Element for the Polygons to which the generated Element will be added. If None, a new XML Element will be generated. (Default: None).
reset_counter – A boolean to note whether the global counter for unique handles should be reset after the method is run. (Default: True).
<Polygon> <UUID>9320589a-2ee0-bab0-72c3f49441f3</UUID> <ID>1</ID> <MaterialUUID>8dd145d0-5f30-11ea-bc55-0242ac130003</MaterialUUID> <MaterialName>Laminated panel</MaterialName> <Origin> <x>0</x> <y>0</y> </Origin> <Points> <Point> <x>181</x> <y>-219</y> </Point> <Point> <x>181</x> <y>-371.4</y> </Point> <Point> <x>200</x> <y>-371.4</y> </Point> <Point> <x>200</x> <y>-219</y> </Point> </Points> <Type>Material</Type> </Polygon>