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

Revision history [back]

Assuming you only have a single FENESTRATIONSURFACE:DETAILED on each surface, you can use this code to create a strip window vertically-centred on the wall:

wwr = 0.5
old_fen = idf.idfobjects['FENESTRATIONSURFACE:DETAILED']

for f in old_fen:
    base_wall = idf.getobject(
        'BUILDINGSURFACE:DETAILED',
        f.Building_Surface_Name)
    w = idf.newidfobject(
        'WINDOW', f.Name,
        Building_Surface_Name=f.Building_Surface_Name,
        Construction_Name=f.Construction_Name,
        Starting_X_Coordinate=0,
        Starting_Z_Coordinate=base_wall.height * 1 - (wwr / 2.0),
        Length=base_wall.width,
        Height=base_wall.height * wwr,
        )
    idf.removeidfobject(f)

Assuming you only have a single FENESTRATIONSURFACE:DETAILED on each surface, you can use this code to create a strip window vertically-centred on the wall:

wwr = 0.5
old_fen = idf.idfobjects['FENESTRATIONSURFACE:DETAILED']

for f in old_fen:
    base_wall = idf.getobject(
        'BUILDINGSURFACE:DETAILED',
        f.Building_Surface_Name)
    w = idf.newidfobject(
        'WINDOW', f.Name,
        Building_Surface_Name=f.Building_Surface_Name,
        Construction_Name=f.Construction_Name,
        Starting_X_Coordinate=0,
        Starting_Z_Coordinate=base_wall.height * 1 - (wwr / 2.0),
        Length=base_wall.width,
        Height=base_wall.height * wwr,
        )
    idf.removeidfobject(f)

Or if you'd like to have WWR as a jEPlus @@variable@@, you could change two lines to create EPMacro statements:

    Starting_Z_Coordinate="#[%s * #[1 - #[@@wwr@@ / 2.0]]]" % base_wall.height,
    Height="#[%s * @@wwr@@]" % base_wall.height,

Assuming you only have a single FENESTRATIONSURFACE:DETAILED on each surface, you can use this code to create a strip window vertically-centred on the wall:

wwr = 0.5
old_fen = idf.idfobjects['FENESTRATIONSURFACE:DETAILED']

for f in old_fen:
    base_wall = idf.getobject(
        'BUILDINGSURFACE:DETAILED',
        f.Building_Surface_Name)
    w = idf.newidfobject(
        'WINDOW', f.Name,
        Building_Surface_Name=f.Building_Surface_Name,
        Construction_Name=f.Construction_Name,
        Starting_X_Coordinate=0,
        Length=base_wall.width,
        Starting_Z_Coordinate=base_wall.height * 1 - (wwr / 2.0),
        Length=base_wall.width,
        Height=base_wall.height * wwr,
        )
    idf.removeidfobject(f)

Or if you'd like to have WWR as a jEPlus @@variable@@, you could change two lines when creating the new WINDOW to create EPMacro statements:

    w = idf.newidfobject(
        ...
        Starting_Z_Coordinate="#[%s * #[1 - #[@@wwr@@ / 2.0]]]" % base_wall.height,
     Height="#[%s * @@wwr@@]" % base_wall.height,
        )

In your pseudocode it looks like you've missed the fact that WINDOW objects' X and Z coordinates are defined relative to the building surface they are based on. That makes the calculations for a specified WWR ratio simpler as you can set the window to the full width of the wall, and the height to WWR * wall height. Usefully, eppy defines a height and a width attribute for surfaces.

Putting it together for a new WINDOW based on wall, Starting X Coordinate is 0, Length is wall.width. Starting Z Coordinate is a little trickier. I use wall.height * 1-(wwr / 2.0), and finally, Height is wall.height * wwr.

Assuming you only have a single FENESTRATIONSURFACE:DETAILED on each surface, you can use this code to create a strip window vertically-centred on the wall:

wwr = 0.5
old_fen = idf.idfobjects['FENESTRATIONSURFACE:DETAILED']

for f in old_fen:
    base_wall = idf.getobject(
        'BUILDINGSURFACE:DETAILED',
        f.Building_Surface_Name)
    w = idf.newidfobject(
        'WINDOW', f.Name,
        Building_Surface_Name=f.Building_Surface_Name,
        Construction_Name=f.Construction_Name,
        Starting_X_Coordinate=0,
        Length=base_wall.width,
        Starting_Z_Coordinate=base_wall.height * 1 - (wwr / 2.0),
        Height=base_wall.height * wwr,
        )
    idf.removeidfobject(f)

Or if you'd like to have WWR as a jEPlus @@variable@@, you could change two lines when creating the new WINDOW to create EPMacro statements:

    w = idf.newidfobject(
        ...
        Starting_Z_Coordinate="#[%s * #[1 - #[@@wwr@@ / 2.0]]]" % base_wall.height,
        Height="#[%s * @@wwr@@]" % base_wall.height,
        )

In your pseudocode it looks like you've missed the fact that WINDOW objects' X and Z coordinates are defined relative to the building surface they are based on. That makes the calculations for a specified WWR ratio simpler as you can set the window to the full width of the wall, and the height to WWR * wall height. Usefully, eppy defines a height and a width attribute for surfaces.

Putting it together for a new WINDOW based on wall, Starting X Coordinate is 0, Length is wall.width. Starting Z Coordinate is a little trickier. I use wall.height * 1-(wwr / 2.0), and finally, Height is wall.height * wwr.

Assuming you only have a single FENESTRATIONSURFACE:DETAILED on each surface, you can use this code to create a strip window vertically-centred on the wall:

wwr = 0.5
old_fen = idf.idfobjects['FENESTRATIONSURFACE:DETAILED']

for f in old_fen:
    base_wall = idf.getobject(
        'BUILDINGSURFACE:DETAILED',
        f.Building_Surface_Name)
    w = idf.newidfobject(
        'WINDOW', f.Name,
        Building_Surface_Name=f.Building_Surface_Name,
        Construction_Name=f.Construction_Name,
        Starting_X_Coordinate=0,
        Length=base_wall.width,
        Starting_Z_Coordinate=base_wall.height * 1 - (wwr / 2.0),
        Height=base_wall.height * wwr,
        )
    idf.removeidfobject(f)

Or if you'd like to have WWR as a jEPlus @@variable@@, you could change two lines when creating the new WINDOW to create EPMacro statements:

    w = idf.newidfobject(
        ...
        Starting_Z_Coordinate="#[%s * #[1 - #[@@wwr@@ / 2.0]]]" % base_wall.height,
        Height="#[%s * @@wwr@@]" % base_wall.height,
        )

Using the 1ZoneUncontrolled_win_1.idf example file, this outputs:

WINDOW,                   
    Zn001:Wall001:Win001,     !- Name
    DoubleClear,              !- Construction Name
    Zn001:Wall001,            !- Building Surface Name
    ,                         !- Shading Control Name
    ,                         !- Frame and Divider Name
    1.0,                      !- Multiplier
    0,                        !- Starting X Coordinate
    #[4.572 * #[1 - #[@@wwr@@ / 2.0]]],    !- Starting Z Coordinate
    15.24,                    !- Length
    #[4.572 * @@wwr@@];       !- Height

In your pseudocode it looks like you've missed the fact that WINDOW objects' X and Z coordinates are defined relative to the building surface they are based on. That makes the calculations for a specified WWR ratio simpler as you can set the window to the full width of the wall, and the height to WWR * wall height. Usefully, eppy defines a height and a width attribute for surfaces.

Putting it together for a new WINDOW based on wall, Starting X Coordinate is 0, Length is wall.width. Starting Z Coordinate is a little trickier. I use wall.height * 1-(wwr / 2.0), and finally, Height is wall.height * wwr.

Assuming you only have a single FENESTRATIONSURFACE:DETAILED on each surface, you can use this code to create a strip window vertically-centred on the wall:

wwr = 0.5
old_fen = idf.idfobjects['FENESTRATIONSURFACE:DETAILED']

for f in old_fen:
    base_wall = idf.getobject(
        'BUILDINGSURFACE:DETAILED',
        f.Building_Surface_Name)
    w = idf.newidfobject(
        'WINDOW', f.Name,
        Building_Surface_Name=f.Building_Surface_Name,
        Construction_Name=f.Construction_Name,
        Starting_X_Coordinate=0,
        Length=base_wall.width,
        Starting_Z_Coordinate=base_wall.height * 1 - (wwr / 2.0),
        Height=base_wall.height * wwr,
        )
    idf.removeidfobject(f)

Or if you'd like to have WWR as a jEPlus @@variable@@, you could change two lines when creating the new WINDOW to create EPMacro statements:

    w = idf.newidfobject(
        ...
        Starting_Z_Coordinate="#[%s * #[1 - #[@@wwr@@ / 2.0]]]" % base_wall.height,
        Height="#[%s * @@wwr@@]" % base_wall.height,
        )

Using the 1ZoneUncontrolled_win_1.idf example file, this outputs:

WINDOW,                   
    Zn001:Wall001:Win001,     !- Name
    DoubleClear,              !- Construction Name
    Zn001:Wall001,            !- Building Surface Name
    ,                         !- Shading Control Name
    ,                         !- Frame and Divider Name
    1.0,                      !- Multiplier
    0,                        !- Starting X Coordinate
    #[4.572 * #[1 - #[@@wwr@@ / 2.0]]],    !- Starting Z Coordinate
    15.24,                    !- Length
    #[4.572 * @@wwr@@];       !- Height

edited to add

I thought I'd update this to add another option. I've just released an alpha version of geomeppy, a package that builds on Eppy and adds functionality to manipulate EnergyPlus geometry in IDF files. (PyPI, GitHub)

To install geomeppy just do pip install geomeppy (Python 2.7 only at the moment but aiming to have Python 3.5 support very soon).

Using geomeppy to set window-to-wall ratio is then as easy as:

from geomeppy import IDF  # this keeps all the same functions as Eppy's IDF

# the usual code to set the IDD and read/create an IDF here

idf.set_wwr(0.5)  # set the WWR

In your pseudocode it looks like you've missed the fact that WINDOW objects' X and Z coordinates are defined relative to the building surface they are based on. That makes the calculations for a specified WWR ratio simpler as you can set the window to the full width of the wall, and the height to WWR * wall height. Usefully, eppy defines a height and a width attribute for surfaces.

Putting it together for a new WINDOW based on wall, Starting X Coordinate is 0, Length is wall.width. Starting Z Coordinate is a little trickier. I use wall.height * 1-(wwr / 2.0), and finally, Height is wall.height * wwr.

Assuming you only have a single FENESTRATIONSURFACE:DETAILED on each surface, you can use this code to create a strip window vertically-centred on the wall:

wwr = 0.5
old_fen = idf.idfobjects['FENESTRATIONSURFACE:DETAILED']

for f in old_fen:
    base_wall = idf.getobject(
        'BUILDINGSURFACE:DETAILED',
        f.Building_Surface_Name)
    w = idf.newidfobject(
        'WINDOW', f.Name,
        Building_Surface_Name=f.Building_Surface_Name,
        Construction_Name=f.Construction_Name,
        Starting_X_Coordinate=0,
        Length=base_wall.width,
        Starting_Z_Coordinate=base_wall.height * 1 - (wwr / 2.0),
        Height=base_wall.height * wwr,
        )
    idf.removeidfobject(f)

Or if you'd like to have WWR as a jEPlus @@variable@@, you could change two lines when creating the new WINDOW to create EPMacro statements:

    w = idf.newidfobject(
        ...
        Starting_Z_Coordinate="#[%s * #[1 - #[@@wwr@@ / 2.0]]]" % base_wall.height,
        Height="#[%s * @@wwr@@]" % base_wall.height,
        )

Using the 1ZoneUncontrolled_win_1.idf example file, this outputs:

WINDOW,                   
    Zn001:Wall001:Win001,     !- Name
    DoubleClear,              !- Construction Name
    Zn001:Wall001,            !- Building Surface Name
    ,                         !- Shading Control Name
    ,                         !- Frame and Divider Name
    1.0,                      !- Multiplier
    0,                        !- Starting X Coordinate
    #[4.572 * #[1 - #[@@wwr@@ / 2.0]]],    !- Starting Z Coordinate
    15.24,                    !- Length
    #[4.572 * @@wwr@@];       !- Height

edited to add

I thought I'd update this to add another option. I've just released an alpha version of geomeppy, a package that builds on Eppy and adds functionality to manipulate EnergyPlus geometry in IDF files. (PyPI, GitHub)

To install geomeppy just do pip install geomeppy (Python 2.7 only at the moment but aiming to have Python 3.5 support very soon).soon). This now works for both Python 2 and 3.

Using geomeppy to set window-to-wall ratio is then as easy as:

from geomeppy import IDF  # this keeps all the same functions as Eppy's IDF

# the usual code to set the IDD and read/create an IDF here

idf.set_wwr(0.5)  # set the WWR

In your pseudocode it looks like you've missed the fact that WINDOW objects' X and Z coordinates are defined relative to the building surface they are based on. That makes the calculations for a specified WWR ratio simpler as you can set the window to the full width of the wall, and the height to WWR * wall height. Usefully, eppy defines a height and a width attribute for surfaces.

Putting it together for a new WINDOW based on wall, Starting X Coordinate is 0, Length is wall.width. Starting Z Coordinate is a little trickier. I use wall.height * 1-(wwr / 2.0), and finally, Height is wall.height * wwr.

Assuming you only have a single FENESTRATIONSURFACE:DETAILED on each surface, you can use this code to create a strip window vertically-centred on the wall:

wwr = 0.5
old_fen = idf.idfobjects['FENESTRATIONSURFACE:DETAILED']

for f in old_fen:
    base_wall = idf.getobject(
        'BUILDINGSURFACE:DETAILED',
        f.Building_Surface_Name)
    w = idf.newidfobject(
        'WINDOW', f.Name,
        Building_Surface_Name=f.Building_Surface_Name,
        Construction_Name=f.Construction_Name,
        Starting_X_Coordinate=0,
        Length=base_wall.width,
        Starting_Z_Coordinate=base_wall.height * 1 - (wwr / 2.0),
        Height=base_wall.height * wwr,
        )
    idf.removeidfobject(f)

Or if you'd like to have WWR as a jEPlus @@variable@@, you could change two lines when creating the new WINDOW to create EPMacro statements:

    w = idf.newidfobject(
        ...
        Starting_Z_Coordinate="#[%s * #[1 - #[@@wwr@@ / 2.0]]]" % base_wall.height,
        Height="#[%s * @@wwr@@]" % base_wall.height,
        )

Using the 1ZoneUncontrolled_win_1.idf example file, this outputs:

WINDOW,                   
    Zn001:Wall001:Win001,     !- Name
    DoubleClear,              !- Construction Name
    Zn001:Wall001,            !- Building Surface Name
    ,                         !- Shading Control Name
    ,                         !- Frame and Divider Name
    1.0,                      !- Multiplier
    0,                        !- Starting X Coordinate
    #[4.572 * #[1 - #[@@wwr@@ / 2.0]]],    !- Starting Z Coordinate
    15.24,                    !- Length
    #[4.572 * @@wwr@@];       !- Height

edited to add

I thought I'd update this to add another option. I've just released an alpha version of geomeppy, a package that builds on Eppy and adds functionality to manipulate EnergyPlus geometry in IDF files. (PyPI, GitHub)

To install geomeppy just do pip install geomeppy (Python 2.7 only at the moment but aiming to have Python 3.5 support very soon). This now works for both Python 2 and 3.

Using geomeppy to set window-to-wall ratio is then as easy as:

from geomeppy import IDF  # this keeps all the same functions as Eppy's IDF

# the usual code to set the IDD and read/create an IDF here

idf.set_wwr(0.5)  IDF.set_wwr() # set the WWR
a WWR of 20% (the default) for all external walls

IDF.set_wwr(wwr=0.25) # set a WWR of 25% for all external walls

IDF.set_wwr(wwr_map={90: 0}) # set no windows on all external walls with azimuth of 90, and WWR of 20% on other walls

IDF.set_wwr(wwr=0, wwr_map={90: 0.3}) # set a WWR of 30% for all external walls with azimuth of 90, and no windows on other walls

If wwr_map is passed, it overrides any value passed to wwr, including the default of 0.2. However it only overrides it on walls which have an azimuth in the wwr_map. Any omitted walls' WWR will be set to the value in wwr. If you want to specify no windows for walls which are not specified in wwr_map, you must also set wwr=0.