Skip to content

Commit

Permalink
Merge pull request #38 from LBNL-ETA/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
StephenCzarnecki authored Apr 7, 2023
2 parents 57d430e + 44c6a8b commit f9b08e0
Show file tree
Hide file tree
Showing 169 changed files with 3,964 additions and 2,488 deletions.
17 changes: 7 additions & 10 deletions .github/workflows/build_wheels.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
name: Build wheels

on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches: [ main ]
pull_request:
branches: [ main ]
on: [push, pull_request]

# Cannot use cibuildwheels because the current images used by cibuildwheels do not support C++17.
# Cannot use cibuildwheels because the current images used by cibuildwheels do not support C++17.

jobs:
build_wheels_windows:
Expand All @@ -17,7 +12,7 @@ jobs:
matrix:
os: [windows-2019]
arch: [x86, x64]
python-version: [3.7, 3.8, 3.9, "3.10"]
python-version: [3.7, 3.8, 3.9, "3.10", "3.11"]

steps:
- name: Checkout repository
Expand Down Expand Up @@ -48,8 +43,10 @@ jobs:
# Trying to use cibuildwheels to build mac wheels fails because the version of XCode is not high enough.
# There is documentation here https://github.com/pypa/cibuildwheel/blob/main/docs/cpp_standards.md on how to
# set it but I could not get it to work while using the standard images provided by github actions does work.
os: [macos-10.15]
python-version: [3.7, 3.8, 3.9, "3.10"]
os: [macos-latest]
python-version: [3.7, 3.8, 3.9, "3.10", "3.11"]
env:
SYSTEM_VERSION_COMPAT: 0

steps:
- name: Checkout repository
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists-WinCalc.txt.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ include(ExternalProject)

ExternalProject_Add(wincalc
GIT_REPOSITORY https://github.com/LBNL-ETA/WinCalc.git
GIT_TAG "v2.2.4"
GIT_TAG "develop"

UPDATE_COMMAND ""
PATCH_COMMAND ""
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists-pybind11.txt.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ include(ExternalProject)

ExternalProject_Add(pybind11
GIT_REPOSITORY https://github.com/pybind/pybind11.git
GIT_TAG "v2.9.0"
GIT_TAG "v2.10.3"

UPDATE_COMMAND ""
PATCH_COMMAND ""
Expand Down
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
cmake_minimum_required(VERSION 3.8)
cmake_minimum_required(VERSION 3.12)

set( CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE ON )

set( target_name pywincalc )
set( target_name wincalcbindings )
project( ${target_name} )

set(JSON_BuildTests OFF CACHE BOOL "")
Expand All @@ -11,7 +11,7 @@ set(BUILD_WinCalc_tests OFF CACHE BOOL "")
include(CMakeLists-WinCalc.txt)
include(CMakeLists-pybind11.txt)

pybind11_add_module(${target_name} src/pywincalc.cpp)
pybind11_add_module(${target_name} src/wincalcbindings.cpp)

target_compile_features(${target_name} PUBLIC cxx_std_17)
target_link_libraries( ${target_name} PRIVATE wincalc)
Expand All @@ -22,4 +22,4 @@ target_include_directories(${target_name}
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src
)
)
6 changes: 6 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
include pywincalc/standards/*.dsp
include pywincalc/standards/*.loc
include pywincalc/standards/*.scc
include pywincalc/standards/*.ssp
include pywincalc/standards/*.std
include pywincalc/standards/*.wvl
18 changes: 18 additions & 0 deletions examples/bsdf_integrator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import pywincalc

bsdf_hemisphere = pywincalc.BSDFHemisphere.create(pywincalc.BSDFBasisType.FULL)

bsdf_path = "products/2011-SA1.XML"
bsdf_shade = pywincalc.parse_bsdf_xml_file(bsdf_path)

front_transmittance_matrix = pywincalc.SquareMatrix(bsdf_shade.measurements.solar.transmittance_front.data)
front_reflectance_matrix = pywincalc.SquareMatrix(bsdf_shade.measurements.solar.reflectance_front.data)

integrator = pywincalc.BSDFIntegrator(bsdf_hemisphere.get_directions(pywincalc.BSDFDirection.Incoming))
integrator.set_matrices(front_transmittance_matrix, front_reflectance_matrix, pywincalc.Side.Front)

front_hemispheric_transmittances = integrator.direct_hemispheric(pywincalc.Side.Front, pywincalc.PropertySimple.T)
front_hemispheric_reflectances = integrator.direct_hemispheric(pywincalc.Side.Front, pywincalc.PropertySimple.R)

print("Front hemipsheric transmittances for each incoming angle: {v}".format(v=front_hemispheric_transmittances))
print("Front hemipsheric reflectances for each incoming angle: {v}".format(v=front_hemispheric_reflectances))
24 changes: 24 additions & 0 deletions examples/bsdf_shade_igsdb_product.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import pywincalc
import requests
from igsdb_interaction import url_single_product, headers, url_single_product_datafile

bsdf_hemisphere = pywincalc.BSDFHemisphere.create(pywincalc.BSDFBasisType.FULL)

bsdf_igsdb_id = 14710

bsdf_igsdb_response = requests.get(url_single_product_datafile.format(id=bsdf_igsdb_id), headers=headers)

# The BSDF data is currently stored as XML on igsdb.lbl.gov. As a result it needs to be
# parsed using the xml string parser instead of the json parser
bsdf_shade = pywincalc.parse_bsdf_xml_string(bsdf_igsdb_response.content)

# Create a glazing system. This only shows an example of getting one result from a glazing system
# created using default environmental conditions.
#
# For more possible results see optical_results_NFRC.py
#
# For more on environmental conditions see environmental_conditions_user_defined.py
glazing_system = pywincalc.GlazingSystem(solid_layers=[bsdf_shade], bsdf_hemisphere=bsdf_hemisphere)

u_value = glazing_system.u()
print("U-value for a BSDF shade downloaded from igsdb.lbl.glv: {v}".format(v=u_value))
17 changes: 17 additions & 0 deletions examples/bsdf_shade_local_file.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import pywincalc

bsdf_hemisphere = pywincalc.BSDFHemisphere.create(pywincalc.BSDFBasisType.FULL)

bsdf_path = "products/2011-SA1.XML"
bsdf_shade = pywincalc.parse_bsdf_xml_file(bsdf_path)

# Create a glazing system. This only shows an example of getting one result from a glazing system
# created using default environmental conditions.
#
# For more possible results see optical_results_NFRC.py
#
# For more on environmental conditions see environmental_conditions_user_defined.py
glazing_system = pywincalc.GlazingSystem(solid_layers=[bsdf_shade], bsdf_hemisphere=bsdf_hemisphere)

u_value = glazing_system.u()
print("U-value for a BSDF shade created from a local file: {v}".format(v=u_value))
86 changes: 31 additions & 55 deletions examples/deflection.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
import pywincalc

# Path to the optical standard file. All other files referenced by the standard file must be in the same directory
# Note: While all optical standards packaged with WINDOW should work with optical calculations care should be
# taken to use NFRC standards if NFRC thermal results are desired. This is because for thermal calculations currently
# only ISO 15099 is supported. While it is possible to use EN optical standards and create thermal results
# those results will not be based on EN 673
optical_standard_path = "standards/W5_NFRC_2003.std"
optical_standard = pywincalc.load_standard(optical_standard_path)

# Load solid layer measured values. Solid layer information can come from either igsdb.lbl.gov or files generate
# by the Optics program. Since igsdb.lbl.gov requires registration some optics files are provided for example
# purposes
Expand All @@ -22,18 +14,10 @@
# that was just loaded and the middle is the same glass as the single clear example above
solid_layers = [clear_6, clear_3, clear_6]

# Solid layers must be separated by gap layers
# Currently there are four pre-defined gases available: Air, Argon, Krypton, and Xenon
# Vacuum gaps are not yet supported
# To create a gap with 100% of a predefined gas create a Gap_Data object with the gas type
# and thickness in meters
gap_1 = pywincalc.Gap(pywincalc.PredefinedGasType.AIR, .0127) # .0127 is gap thickness in meters

# To create a mixture of predefined gases first create the components with the gas type and portion of the mixture
# The following creates a gas that is 70% Krypton and 30% Xenon and 2cm thick
gap_2_component_1 = pywincalc.PredefinedGasMixtureComponent(pywincalc.PredefinedGasType.KRYPTON, .7)
gap_2_component_2 = pywincalc.PredefinedGasMixtureComponent(pywincalc.PredefinedGasType.XENON, .3)
gap_2 = pywincalc.Gap([gap_2_component_1, gap_2_component_2], .02) # .02 is gap thickness in meters
# Solid layers must be separated by gap layers. This example uses two air gaps
# See gaps_and_gases.py in examples for more on creating gases
gap_1 = pywincalc.Layers.gap(thickness=.0127)
gap_2 = pywincalc.Layers.gap(thickness=.02)

# Put all gaps into a list ordered from outside to inside
# Note: This is only specifying gaps between solid layers
Expand All @@ -45,14 +29,14 @@
height = 1.0 # height of the glazing system in meters
tilt = 90 # glazing system tilt in degrees

glazing_system = pywincalc.GlazingSystem(optical_standard=optical_standard, solid_layers=solid_layers, gap_layers=gaps,
width_meters=width, height_meters=height, tilt_degrees=tilt,
environment=pywincalc.nfrc_u_environments())
glazing_system = pywincalc.GlazingSystem(solid_layers=solid_layers, gap_layers=gaps,
width_meters=width, height_meters=height, tilt_degrees=tilt)

# Deflection calcs currently need to be specifically enabled
glazing_system.enable_deflection(True)

# Set initial temperature and pressure. Values just chosen for example purposes
glazing_system.set_deflection_properties(temperature_initial=273, pressure_initial=1013200)
glazing_system.set_deflection_properties(temperature_initial=273, pressure_initial=101320)

# Density can be calculated using either U or SHGC TARCOG system types. Just using SHGC for this
# example for simplicity.
Expand All @@ -64,13 +48,13 @@
print("\tU: {val}".format(val=glazing_system.u()))
print("\tSHGC: {val}".format(val=glazing_system.shgc()))
print("\tLayer temperatures (U): {val}".format(val=glazing_system.layer_temperatures(pywincalc.TarcogSystemType.U)))
print("\tLayer temperatures (SHGC): {val}".format(val=glazing_system.layer_temperatures(pywincalc.TarcogSystemType.SHGC)))
print(
"\tLayer temperatures (SHGC): {val}".format(val=glazing_system.layer_temperatures(pywincalc.TarcogSystemType.SHGC)))
visible_results = glazing_system.optical_method_results("PHOTOPIC")
print("\tVT: {val}".format(val=visible_results.system_results.front.transmittance.direct_hemispherical))


# Change initial temperature and pressure. Values just chosen for example purposes
glazing_system.set_deflection_properties(temperature_initial=290, pressure_initial=1014500)
glazing_system.set_deflection_properties(temperature_initial=290, pressure_initial=101450)
print("")
print("Changed initial temperature and pressure")
print("\tdeflection max: {val}".format(val=deflection_results.deflection_max))
Expand All @@ -79,7 +63,8 @@
print("\tU: {val}".format(val=glazing_system.u()))
print("\tSHGC: {val}".format(val=glazing_system.shgc()))
print("\tLayer temperatures (U): {val}".format(val=glazing_system.layer_temperatures(pywincalc.TarcogSystemType.U)))
print("\tLayer temperatures (SHGC): {val}".format(val=glazing_system.layer_temperatures(pywincalc.TarcogSystemType.SHGC)))
print(
"\tLayer temperatures (SHGC): {val}".format(val=glazing_system.layer_temperatures(pywincalc.TarcogSystemType.SHGC)))
visible_results = glazing_system.optical_method_results("PHOTOPIC")
print("\tVT: {val}".format(val=visible_results.system_results.front.transmittance.direct_hemispherical))
# Change tilt
Expand All @@ -94,7 +79,8 @@
print("\tU: {val}".format(val=glazing_system.u()))
print("\tSHGC: {val}".format(val=glazing_system.shgc()))
print("\tLayer temperatures (U): {val}".format(val=glazing_system.layer_temperatures(pywincalc.TarcogSystemType.U)))
print("\tLayer temperatures (SHGC): {val}".format(val=glazing_system.layer_temperatures(pywincalc.TarcogSystemType.SHGC)))
print(
"\tLayer temperatures (SHGC): {val}".format(val=glazing_system.layer_temperatures(pywincalc.TarcogSystemType.SHGC)))
visible_results = glazing_system.optical_method_results("PHOTOPIC")
print("\tVT: {val}".format(val=visible_results.system_results.front.transmittance.direct_hemispherical))

Expand All @@ -111,7 +97,8 @@
print("\tU: {val}".format(val=glazing_system.u()))
print("\tSHGC: {val}".format(val=glazing_system.shgc()))
print("\tLayer temperatures (U): {val}".format(val=glazing_system.layer_temperatures(pywincalc.TarcogSystemType.U)))
print("\tLayer temperatures (SHGC): {val}".format(val=glazing_system.layer_temperatures(pywincalc.TarcogSystemType.SHGC)))
print(
"\tLayer temperatures (SHGC): {val}".format(val=glazing_system.layer_temperatures(pywincalc.TarcogSystemType.SHGC)))
visible_results = glazing_system.optical_method_results("PHOTOPIC")
print("\tVT: {val}".format(val=visible_results.system_results.front.transmittance.direct_hemispherical))

Expand Down Expand Up @@ -160,17 +147,7 @@

custom_env = pywincalc.Environments(outside=custom_outside_env, inside=custom_inside_env)

# changing environmental conditions currently requires creating a new glazing system
# note: this resets any changes made such as if deflection is enabled or applied load is set.
# if this is a problem or you think it would be better to be able to change environmental conditions
# like tilt and load let us know.

glazing_system = pywincalc.GlazingSystem(optical_standard=optical_standard, solid_layers=solid_layers, gap_layers=gaps,
width_meters=width, height_meters=height, tilt_degrees=tilt,
environment=custom_env)

glazing_system.enable_deflection(True)
glazing_system.set_deflection_properties(temperature_initial=273, pressure_initial=1013200)
glazing_system.environments(custom_env)
deflection_results = glazing_system.calc_deflection_properties(pywincalc.TarcogSystemType.SHGC)

print("")
Expand All @@ -181,7 +158,8 @@
print("\tU: {val}".format(val=glazing_system.u()))
print("\tSHGC: {val}".format(val=glazing_system.shgc()))
print("\tLayer temperatures (U): {val}".format(val=glazing_system.layer_temperatures(pywincalc.TarcogSystemType.U)))
print("\tLayer temperatures (SHGC): {val}".format(val=glazing_system.layer_temperatures(pywincalc.TarcogSystemType.SHGC)))
print(
"\tLayer temperatures (SHGC): {val}".format(val=glazing_system.layer_temperatures(pywincalc.TarcogSystemType.SHGC)))
visible_results = glazing_system.optical_method_results("PHOTOPIC")
print("\tVT: {val}".format(val=visible_results.system_results.front.transmittance.direct_hemispherical))

Expand All @@ -194,12 +172,9 @@
custom_env_2.outside.pressure += 500
custom_env_2.inside.pressure -= 200

glazing_system = pywincalc.GlazingSystem(optical_standard=optical_standard, solid_layers=solid_layers, gap_layers=gaps,
width_meters=width, height_meters=height, tilt_degrees=tilt,
environment=custom_env_2)
glazing_system.environments(custom_env_2)

glazing_system.enable_deflection(True)
glazing_system.set_deflection_properties(temperature_initial=273, pressure_initial=1013200)
glazing_system.set_deflection_properties(temperature_initial=273, pressure_initial=101320)
deflection_results = glazing_system.calc_deflection_properties(pywincalc.TarcogSystemType.SHGC)

print("")
Expand All @@ -210,7 +185,8 @@
print("\tU: {val}".format(val=glazing_system.u()))
print("\tSHGC: {val}".format(val=glazing_system.shgc()))
print("\tLayer temperatures (U): {val}".format(val=glazing_system.layer_temperatures(pywincalc.TarcogSystemType.U)))
print("\tLayer temperatures (SHGC): {val}".format(val=glazing_system.layer_temperatures(pywincalc.TarcogSystemType.SHGC)))
print(
"\tLayer temperatures (SHGC): {val}".format(val=glazing_system.layer_temperatures(pywincalc.TarcogSystemType.SHGC)))
visible_results = glazing_system.optical_method_results("PHOTOPIC")
print("\tVT: {val}".format(val=visible_results.system_results.front.transmittance.direct_hemispherical))

Expand All @@ -224,22 +200,22 @@

solid_layers = [clear_6, clear_3, clear_6]

glazing_system = pywincalc.GlazingSystem(optical_standard=optical_standard, solid_layers=solid_layers,
gap_layers=gaps, width_meters=width, height_meters=height, tilt_degrees=tilt,
environment=custom_env_2)
glazing_system = pywincalc.GlazingSystem(solid_layers=solid_layers, gap_layers=gaps, width_meters=width,
height_meters=height, tilt_degrees=tilt, environment=custom_env_2)

glazing_system.enable_deflection(True)
glazing_system.set_deflection_properties(temperature_initial=273, pressure_initial=1013200)
glazing_system.set_deflection_properties(temperature_initial=273, pressure_initial=101320)
deflection_results = glazing_system.calc_deflection_properties(pywincalc.TarcogSystemType.SHGC)

print("")
print("Set density and youngs modulus")
print("Set density and Young's modulus")
print("\tdeflection max: {val}".format(val=deflection_results.deflection_max))
print("\tdeflection mean: {val}".format(val=deflection_results.deflection_mean))
print("\tpanes load: {val}".format(val=deflection_results.panes_load))
print("\tU: {val}".format(val=glazing_system.u()))
print("\tSHGC: {val}".format(val=glazing_system.shgc()))
print("\tLayer temperatures (U): {val}".format(val=glazing_system.layer_temperatures(pywincalc.TarcogSystemType.U)))
print("\tLayer temperatures (SHGC): {val}".format(val=glazing_system.layer_temperatures(pywincalc.TarcogSystemType.SHGC)))
print(
"\tLayer temperatures (SHGC): {val}".format(val=glazing_system.layer_temperatures(pywincalc.TarcogSystemType.SHGC)))
visible_results = glazing_system.optical_method_results("PHOTOPIC")
print("\tVT: {val}".format(val=visible_results.system_results.front.transmittance.direct_hemispherical))
print("\tVT: {val}".format(val=visible_results.system_results.front.transmittance.direct_hemispherical))
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import pywincalc

optical_standard_path = "standards/W5_NFRC_2003.std"
optical_standard = pywincalc.load_standard(optical_standard_path)

clear_3_path = "products/CLEAR_3.DAT"
clear_3 = pywincalc.parse_optics_file(clear_3_path)

Expand Down Expand Up @@ -45,5 +42,7 @@
direct_solar_radiation=outside_direct_solar_radiation)

environmental_conditions = pywincalc.Environments(outside_environment, inside_environment)
glazing_system = pywincalc.GlazingSystem(optical_standard, solid_layers, environment=environmental_conditions)
print("U-value for a single-clear system with custom environmental conditions: {u}".format(u=glazing_system.u()))
glazing_system = pywincalc.GlazingSystem(solid_layers=solid_layers, environment=environmental_conditions)

u_value = glazing_system.u()
print("U-value for a glazing system with user-defined environmental conditions: {v}".format(v=u_value))
Loading

0 comments on commit f9b08e0

Please sign in to comment.