diff --git a/CMakeLists-WinCalc.txt.in b/CMakeLists-WinCalc.txt.in index 6595301..22f2726 100644 --- a/CMakeLists-WinCalc.txt.in +++ b/CMakeLists-WinCalc.txt.in @@ -4,7 +4,7 @@ include(ExternalProject) ExternalProject_Add(wincalc GIT_REPOSITORY https://github.com/LBNL-ETA/WinCalc.git - GIT_TAG "VariableAirflowCoefficients" + GIT_TAG "VacuumDec2023" UPDATE_COMMAND "" PATCH_COMMAND "" diff --git a/pywincalc/__init__.py b/pywincalc/__init__.py index 2d13a56..2e961e0 100644 --- a/pywincalc/__init__.py +++ b/pywincalc/__init__.py @@ -1,68 +1,42 @@ from pathlib import Path import deprecation -# Ideally the following long list would just be `from wincalcbindings import *`. -# But there are a few things that we'd like to provide python versions of -# while keeping the same function name for backwards compatibility. -# So the options seem to be either change the name of the C++ bindings, which is a possiblilty -# or specifically import the functions that should be re-exported and alias them in the process -# -# Currently this seems like a better approach since it allows for future cases if needed. -# Also changing library code because of an issue in the client does not seem like the correct approach in general. -# -# If there were a way to import * and then rename the individual functions that would likely work as well -# and require less maintenance. However so far the only way I have come up with is something like -# -# def prepend_underscore_to_package_item(package, name): -# f = getattr(package, name) -# setattr(package, "_"+name, f) -# delattr(package, name) -# return package -# -# wincalcbindings_pkg = importlib.import_module("wincalcbindings") -# wincalcbindings_pkg = prepend_underscore_to_package_item(wincalcbindings_pkg, "load_standard") -# wincalcbindings_pkg = prepend_underscore_to_package_item(wincalcbindings_pkg, "GlazingSystem") -# globals().update(vars(wincalcbindings_pkg)) -# -# And I don't think I understand the implications of that fully enough to trust it doesn't have -# any other side effets. e.g. __file__ changes after the globals update - -from wincalcbindings import AirHorizontalDirection, BSDF, BSDFBasisType, BSDFDirection, BSDFDirections, BSDFHemisphere, \ - BSDFIntegrator, BoundaryConditionsCoefficientModelType, CMABestWorstUFactors, CMAResult, CMAWindow, \ - CMAWindowDualVisionHorizontal, CMAWindowDualVisionVertical, CMAWindowSingleVision, CellSpacingType, PolygonType, pillar_cell_area, \ - PillarData, CylindricalPillar, SphericalPillar, RectangularPillar, TriangularPillar, PentagonPillar, HexagonPillar, LinearBearingPillar, TruncatedConePillar, Glass, PillarMeasurement, \ - AnnulusCylinderPillar, CShapedCylinderPillar, UniversalSupportPillar, CylindricalPillarLayer, SphericalPillarLayer, RectangularPillarLayer, \ - TriangularPillarLayer, PentagonPillarLayer, HexagonPillarLayer, LinearBearingPillarLayer, TruncatedConePillarLayer, \ - AnnulusCylinderPillarLayer, CShapedCylinderPillarLayer, MeasuredPillarLayer, CoatedSide, \ - ColorResult, DeflectionResults, DistributionMethodType, DualBandBSDF, EffectiveOpenness, Environment, Environments, \ - FlippableSolidLayer, Gas, GasCoefficients, GasData, GlazingSystem as _GlazingSystem, GlazingSystemDimensions, \ - IGUGapLayer, IntegrationRule, IntegrationRuleType, Lab, Layers, MaterialType, \ - OpticalMeasurementComponent, OpticalResultAbsorptance, OpticalResultFluxType, OpticalResultFluxTypeColor, \ - OpticalResultLayer, OpticalResultSide, OpticalResultSideColor, OpticalResultSide_Layer, OpticalResultTransmission, \ - OpticalResultTransmissionColor, OpticalResults, OpticalResultsColor, OpticalStandard, OpticalStandardMethod, \ - PVPowerProperty, PVWavelengthData, ParsedPerforatedGeometry, ParsedVenetianGeometry, ParsedWovenGeometry, \ - PerforatedGeometry, PredefinedGasType, ProductComposistionData, ProductData, \ - ProductDataOptical, ProductDataOpticalAndThermal, ProductDataOpticalDualBand, \ - ProductDataOpticalDualBandBSDF, ProductDataOpticalDualBandHemispheric, ProductDataOpticalNBand, \ - ProductDataOpticalPerforatedScreen, ProductDataOpticalVenetian, ProductDataOpticalWithMaterial, \ - ProductDataOpticalWovenShade, ProductDataThermal, ProductGeometry, PropertySimple, RGB, Side, \ - SpectalDataWavelengthRangeMethodType, Spectrum, SpectrumType, SquareMatrix, TarcogSystemType, \ - ThermalIRResults, ThmxBoundaryCondition, ThmxBoundaryConditionPolygon, ThmxCMABestWorstOption, ThmxCMAOptions, \ - ThmxFileContents, ThmxMaterial, ThmxMeshParameters, ThmxPolygon, ThmxPolygonPoint, ThmxRGB, ThmxResult, \ - ThmxUFactorProjectionResult, ThmxUFactorResults, Trichromatic, VenetianGeometry, WavelengthBSDFs, \ - WavelengthBoundary, WavelengthBoundaryType, WavelengthData, WavelengthSet, WavelengthSetType, WovenGeometry, \ - load_standard as _load_standard, calc_cma, calc_thermal_ir, convert_to_solid_layer, convert_to_solid_layers, \ - create_best_worst_u_factor_option, create_gas, create_perforated_screen, create_venetian_blind, create_woven_shade, \ - get_cma_window_double_vision_horizontal, get_cma_window_double_vision_vertical, get_cma_window_single_vision, \ - get_spacer_keff, nfrc_shgc_environments, nfrc_u_environments, parse_bsdf_xml_file, parse_bsdf_xml_string, \ - parse_json, parse_json_file, parse_optics_file, parse_thmx_file, parse_thmx_string, IGUVentilatedGapLayer, \ - forced_ventilation_gap - - +from wincalcbindings import ( + AirHorizontalDirection, BSDF, BSDFBasisType, BSDFDirection, BSDFDirections, BSDFHemisphere, + BSDFIntegrator, BoundaryConditionsCoefficientModelType, CMABestWorstUFactors, CMAResult, CMAWindow, + CMAWindowDualVisionHorizontal, CMAWindowDualVisionVertical, CMAWindowSingleVision, layers, CellSpacingType, PolygonType, pillar_cell_area, + PillarData, CylindricalPillar, SphericalPillar, RectangularPillar, TriangularPillar, PentagonPillar, HexagonPillar, LinearBearingPillar, TruncatedConePillar, Glass, PillarMeasurement, + AnnulusCylinderPillar, CShapedCylinderPillar, UniversalSupportPillar, CylindricalPillarLayer, SphericalPillarLayer, RectangularPillarLayer, + TriangularPillarLayer, PentagonPillarLayer, HexagonPillarLayer, LinearBearingPillarLayer, TruncatedConePillarLayer, + AnnulusCylinderPillarLayer, CShapedCylinderPillarLayer, MeasuredPillarLayer, CoatedSide, + ColorResult, DeflectionResults, DistributionMethodType, DualBandBSDF, EffectiveOpenness, Environment, Environments, + FlippableSolidLayer, Gas, GasCoefficients, GasData, GlazingSystem as _GlazingSystem, GlazingSystemDimensions, + IGUGapLayer, IntegrationRule, IntegrationRuleType, Lab, MaterialType, + OpticalMeasurementComponent, OpticalResultAbsorptance, OpticalResultFluxType, OpticalResultFluxTypeColor, + OpticalResultLayer, OpticalResultSide, OpticalResultSideColor, OpticalResultSide_Layer, OpticalResultTransmission, + OpticalResultTransmissionColor, OpticalResults, OpticalResultsColor, OpticalStandard, OpticalStandardMethod, + PVPowerProperty, PVWavelengthData, ParsedPerforatedGeometry, ParsedVenetianGeometry, ParsedWovenGeometry, + PerforatedGeometry, PredefinedGasType, ProductComposistionData, ProductData, + ProductDataOptical, ProductDataOpticalAndThermal, ProductDataOpticalDualBand, + ProductDataOpticalDualBandBSDF, ProductDataOpticalDualBandHemispheric, ProductDataOpticalNBand, + ProductDataOpticalPerforatedScreen, ProductDataOpticalVenetian, ProductDataOpticalWithMaterial, + ProductDataOpticalWovenShade, ProductDataThermal, ProductGeometry, PropertySimple, RGB, Side, + SpectalDataWavelengthRangeMethodType, Spectrum, SpectrumType, SquareMatrix, TarcogSystemType, + ThermalIRResults, ThmxBoundaryCondition, ThmxBoundaryConditionPolygon, ThmxCMABestWorstOption, ThmxCMAOptions, + ThmxFileContents, ThmxMaterial, ThmxMeshParameters, ThmxPolygon, ThmxPolygonPoint, ThmxRGB, ThmxResult, + ThmxUFactorProjectionResult, ThmxUFactorResults, Trichromatic, VenetianGeometry, WavelengthBSDFs, + WavelengthBoundary, WavelengthBoundaryType, WavelengthData, WavelengthSet, WavelengthSetType, WovenGeometry, + load_standard as _load_standard, calc_cma, calc_thermal_ir, convert_to_solid_layer, convert_to_solid_layers, + create_best_worst_u_factor_option, create_gas, create_perforated_screen, create_venetian_blind, create_woven_shade, + get_cma_window_double_vision_horizontal, get_cma_window_double_vision_vertical, get_cma_window_single_vision, + get_spacer_keff, nfrc_shgc_environments, nfrc_u_environments, parse_bsdf_xml_file, parse_bsdf_xml_string, + parse_json, parse_json_file, parse_optics_file, parse_thmx_file, parse_thmx_string, IGUVentilatedGapLayer, + forced_ventilation_gap +) @deprecation.deprecated(deprecated_in="3.0.0", removed_in="4.0.0", current_version="3.0.0", - details="Use pywincalc.Layers.gap or pywincalc.create_gas instead") + details="Use pywincalc.layers.gap or pywincalc.create_gas instead") def Gap(gas, thickness): converted_gas = None if type(gas) is list: @@ -72,7 +46,7 @@ def Gap(gas, thickness): else: # otherwise it is just a single component and therefore 100% of the mixture converted_gas = create_gas([[1.0, gas]]) - return Layers.gap(gas=converted_gas, thickness=thickness) + return layers.gap(gas=converted_gas, thickness=thickness) @deprecation.deprecated(deprecated_in="3.0.0", removed_in="4.0.0", diff --git a/src/wincalcbindings.cpp b/src/wincalcbindings.cpp index 0c0efba..1a6bf52 100644 --- a/src/wincalcbindings.cpp +++ b/src/wincalcbindings.cpp @@ -1777,101 +1777,136 @@ PYBIND11_MODULE(wincalcbindings, m) { &EffectiveLayers::EffectiveOpenness::FrontPorosity); m.def("is_closed", &EffectiveLayers::isClosed, py::arg("effective_openness")); - - py::class_(m, "Layers") - .def_static("solid", &Tarcog::ISO15099::Layers::solid, - "Factory method for creating a solid Tarcog layer", - py::arg("thickness"), py::arg("conductivity"), - py::arg("frontEmissivity") = 0.84, - py::arg("frontIRTransmittance") = 0.0, - py::arg("backEmissivity") = 0.84, - py::arg("backIRTransmittance") = 0.0) - .def_static("update_material_data", - &Tarcog::ISO15099::Layers::updateMaterialData, - "Static method for updating the material information for a " - "solid Tarcog layer.", - py::arg("layer"), - py::arg("density") = Tarcog::MaterialConstants::GLASSDENSITY, - py::arg("youngs_modulus") = - Tarcog::DeflectionConstants::YOUNGSMODULUS) - .def_static("shading", &Tarcog::ISO15099::Layers::shading, - "Factory function to create a Tarcog shading layer.", - py::arg("thickness"), py::arg("conductivity"), - py::arg("effective_openness") = - EffectiveLayers::EffectiveOpenness(0, 0, 0, 0, 0, 0), - py::arg("front_emissivity") = 0.84, - py::arg("front_transmittance") = 0.0, - py::arg("back_emissivity") = 0.84, - py::arg("back_transmittance") = 0.0) - .def_static( - "gap", - py::overload_cast(&Tarcog::ISO15099::Layers::gap), - "Factory function to create a Tarcog air gap", py::arg("thickness"), - py::arg("pressure") = 101325) - .def_static("gap", - py::overload_cast( - &Tarcog::ISO15099::Layers::gap), - "Factory function to create a Tarcog gap from a gas", - py::arg("thickness"), py::arg("gas"), - py::arg("pressure") = 101325) - .def_static( - "create_pillar", - py::overload_cast(&Tarcog::ISO15099::Layers::createPillar), - "Static function to add a cylindrical pillar to a Tarcog gap", - py::arg("pillar"), py::arg("pressure")) - .def_static( - "create_pillar", - py::overload_cast( - &Tarcog::ISO15099::Layers::createPillar), - "Static function to add a spherical pillar to a Tarcog gap", - py::arg("pillar"), py::arg("pressure")) - .def_static( - "create_pillar", - py::overload_cast(&Tarcog::ISO15099::Layers::createPillar), - "Static function to add a rectangular pillar to a Tarcog gap", - py::arg("pillar"), py::arg("pressure")) - .def_static( - "create_pillar", - py::overload_cast( - &Tarcog::ISO15099::Layers::createPillar), - "Static function to add a triangular pillar to a Tarcog gap", - py::arg("pillar"), py::arg("pressure")) - .def_static( - "create_pillar", - py::overload_cast( - &Tarcog::ISO15099::Layers::createPillar), - "Static function to add a pentagon pillar to a Tarcog gap", - py::arg("pillar"), py::arg("pressure")) - .def_static( - "create_pillar", - py::overload_cast( - &Tarcog::ISO15099::Layers::createPillar), - "Static function to add a hexagon pillar to a Tarcog gap", - py::arg("pillar"), py::arg("pressure")) - .def_static( - "create_pillar", - py::overload_cast(&Tarcog::ISO15099::Layers::createPillar), - "Static function to add a linear bearing pillar to a Tarcog gap", - py::arg("pillar"), py::arg("pressure")) - .def_static( - "create_pillar", - py::overload_cast(&Tarcog::ISO15099::Layers::createPillar), - "Static function to add a truncated cone pillar to a Tarcog gap", - py::arg("pillar"), py::arg("pressure")) - .def_static( - "create_pillar", - py::overload_cast(&Tarcog::ISO15099::Layers::createPillar), - "Static function to add a annulus cylinder pillar to a Tarcog gap", - py::arg("pillar"), py::arg("pressure")) - .def_static( - "create_pillar", - py::overload_cast( - &Tarcog::ISO15099::Layers::createPillar), - "Static function to add a measured pillar to a Tarcog gap", - py::arg("pillar")); + + py::module_ layers = m.def_submodule("layers", "Submodule for Tarcog Layers"); + + layers.def("solid", py::overload_cast(&Tarcog::ISO15099::Layers::solid), + "Factory method for creating a solid Tarcog layer with basic parameters", + py::arg("thickness"), py::arg("conductivity")); + + layers.def("solid", py::overload_cast(&Tarcog::ISO15099::Layers::solid), + "Factory method for creating a solid Tarcog layer including IR parameters", + py::arg("thickness"), py::arg("conductivity"), + py::arg("frontEmissivity") = 0.84, + py::arg("frontIRTransmittance") = 0.0, + py::arg("backEmissivity") = 0.84, + py::arg("backIRTransmittance") = 0.0); + + layers.def("update_material_data", + &Tarcog::ISO15099::Layers::updateMaterialData, + "Static method for updating the material information for a " + "solid Tarcog layer.", + py::arg("layer"), + py::arg("density") = Tarcog::MaterialConstants::GLASSDENSITY, + py::arg("youngs_modulus") = Tarcog::DeflectionConstants::YOUNGSMODULUS); + + layers.def("shading", &Tarcog::ISO15099::Layers::shading, + "Factory function to create a Tarcog shading layer.", + py::arg("thickness"), py::arg("conductivity"), + py::arg("effective_openness") = EffectiveLayers::EffectiveOpenness(0, 0, 0, 0, 0, 0), + py::arg("front_emissivity") = 0.84, + py::arg("front_transmittance") = 0.0, + py::arg("back_emissivity") = 0.84, + py::arg("back_transmittance") = 0.0); + + layers.def("sealedLayer", &Tarcog::ISO15099::Layers::sealedLayer, + "Factory function to create a Tarcog sealed layer.", + py::arg("thickness"), py::arg("conductivity"), + py::arg("front_emissivity") = 0.84, + py::arg("front_transmittance") = 0.0, + py::arg("back_emissivity") = 0.84, + py::arg("back_transmittance") = 0.0); + + layers.def("gap", py::overload_cast(&Tarcog::ISO15099::Layers::gap), + "Factory function to create a Tarcog gap with basic parameters", + py::arg("thickness")); + + layers.def("gap", py::overload_cast(&Tarcog::ISO15099::Layers::gap), + "Factory function to create a Tarcog gap with thickness and pressure", + py::arg("thickness"), py::arg("pressure") = 101325); + + layers.def("gap", py::overload_cast(&Tarcog::ISO15099::Layers::gap), + "Factory function to create a Tarcog gap with thickness and gas", + py::arg("thickness"), py::arg("gas")); + + layers.def("gap", py::overload_cast(&Tarcog::ISO15099::Layers::gap), + "Factory function to create a Tarcog gap with thickness, pressure and gas", + py::arg("thickness"), py::arg("pressure"), py::arg("gas")); + + layers.def("gap", py::overload_cast(&Tarcog::ISO15099::Layers::gap), + "Factory function to create a Tarcog gap with all parameters", + py::arg("thickness"), py::arg("pressure"), py::arg("gas"), + py::arg("accommodation1"), py::arg("accommodation2")); + + layers.def("forced_ventilation_gap", &Tarcog::ISO15099::Layers::forcedVentilationGap, + "Function to create a forced ventilation Tarcog gap", + py::arg("gap"), py::arg("forcedVentilationAirSpeed"), + py::arg("forcedVentilationAirTemperature")); + + layers.def("default_vacuum_mixture", &Tarcog::ISO15099::Layers::defaultVacuumMixture, + "Function to get the default vacuum mixture"); + + layers.def("create_pillar", py::overload_cast(&Tarcog::ISO15099::Layers::createPillar), + "Static function to add a cylindrical pillar to a Tarcog gap", + py::arg("pillar"), py::arg("pressure"), py::arg("gas") = Tarcog::ISO15099::Layers::defaultVacuumMixture(), + py::arg("accommodation1") = ConstantsData::DEFAULT_SURFACE_ACCOMMODATION_COEFFICIENT, + py::arg("accommodation2") = ConstantsData::DEFAULT_SURFACE_ACCOMMODATION_COEFFICIENT); + + layers.def("create_pillar", py::overload_cast(&Tarcog::ISO15099::Layers::createPillar), + "Static function to add a spherical pillar to a Tarcog gap", + py::arg("pillar"), py::arg("pressure"), py::arg("gas") = Tarcog::ISO15099::Layers::defaultVacuumMixture(), + py::arg("accommodation1") = ConstantsData::DEFAULT_SURFACE_ACCOMMODATION_COEFFICIENT, + py::arg("accommodation2") = ConstantsData::DEFAULT_SURFACE_ACCOMMODATION_COEFFICIENT); + + layers.def("create_pillar", py::overload_cast(&Tarcog::ISO15099::Layers::createPillar), + "Static function to add a rectangular pillar to a Tarcog gap", + py::arg("pillar"), py::arg("pressure"), py::arg("gas") = Tarcog::ISO15099::Layers::defaultVacuumMixture(), + py::arg("accommodation1") = ConstantsData::DEFAULT_SURFACE_ACCOMMODATION_COEFFICIENT, + py::arg("accommodation2") = ConstantsData::DEFAULT_SURFACE_ACCOMMODATION_COEFFICIENT); + + layers.def("create_pillar", py::overload_cast(&Tarcog::ISO15099::Layers::createPillar), + "Static function to add a triangular pillar to a Tarcog gap", + py::arg("pillar"), py::arg("pressure"), py::arg("gas") = Tarcog::ISO15099::Layers::defaultVacuumMixture(), + py::arg("accommodation1") = ConstantsData::DEFAULT_SURFACE_ACCOMMODATION_COEFFICIENT, + py::arg("accommodation2") = ConstantsData::DEFAULT_SURFACE_ACCOMMODATION_COEFFICIENT); + + layers.def("create_pillar", py::overload_cast(&Tarcog::ISO15099::Layers::createPillar), + "Static function to add a pentagon pillar to a Tarcog gap", + py::arg("pillar"), py::arg("pressure"), py::arg("gas") = Tarcog::ISO15099::Layers::defaultVacuumMixture(), + py::arg("accommodation1") = ConstantsData::DEFAULT_SURFACE_ACCOMMODATION_COEFFICIENT, + py::arg("accommodation2") = ConstantsData::DEFAULT_SURFACE_ACCOMMODATION_COEFFICIENT); + + layers.def("create_pillar", py::overload_cast(&Tarcog::ISO15099::Layers::createPillar), + "Static function to add a hexagon pillar to a Tarcog gap", + py::arg("pillar"), py::arg("pressure"), py::arg("gas") = Tarcog::ISO15099::Layers::defaultVacuumMixture(), + py::arg("accommodation1") = ConstantsData::DEFAULT_SURFACE_ACCOMMODATION_COEFFICIENT, + py::arg("accommodation2") = ConstantsData::DEFAULT_SURFACE_ACCOMMODATION_COEFFICIENT); + + layers.def("create_pillar", py::overload_cast(&Tarcog::ISO15099::Layers::createPillar), + "Static function to add a linear bearing pillar to a Tarcog gap", + py::arg("pillar"), py::arg("pressure"), py::arg("gas") = Tarcog::ISO15099::Layers::defaultVacuumMixture(), + py::arg("accommodation1") = ConstantsData::DEFAULT_SURFACE_ACCOMMODATION_COEFFICIENT, + py::arg("accommodation2") = ConstantsData::DEFAULT_SURFACE_ACCOMMODATION_COEFFICIENT); + + layers.def("create_pillar", py::overload_cast(&Tarcog::ISO15099::Layers::createPillar), + "Static function to add a truncated cone pillar to a Tarcog gap", + py::arg("pillar"), py::arg("pressure"), py::arg("gas") = Tarcog::ISO15099::Layers::defaultVacuumMixture(), + py::arg("accommodation1") = ConstantsData::DEFAULT_SURFACE_ACCOMMODATION_COEFFICIENT, + py::arg("accommodation2") = ConstantsData::DEFAULT_SURFACE_ACCOMMODATION_COEFFICIENT); + + layers.def("create_pillar", py::overload_cast(&Tarcog::ISO15099::Layers::createPillar), + "Static function to add an annulus cylinder pillar to a Tarcog gap", + py::arg("pillar"), py::arg("pressure"), py::arg("gas") = Tarcog::ISO15099::Layers::defaultVacuumMixture(), + py::arg("accommodation1") = ConstantsData::DEFAULT_SURFACE_ACCOMMODATION_COEFFICIENT, + py::arg("accommodation2") = ConstantsData::DEFAULT_SURFACE_ACCOMMODATION_COEFFICIENT); + + layers.def("create_pillar", py::overload_cast(&Tarcog::ISO15099::Layers::createPillar), + "Static function to add a C-shaped cylinder pillar to a Tarcog gap", + py::arg("pillar"), py::arg("pressure"), py::arg("gas") = Tarcog::ISO15099::Layers::defaultVacuumMixture(), + py::arg("accommodation1") = ConstantsData::DEFAULT_SURFACE_ACCOMMODATION_COEFFICIENT, + py::arg("accommodation2") = ConstantsData::DEFAULT_SURFACE_ACCOMMODATION_COEFFICIENT); + + layers.def("create_pillar", py::overload_cast(&Tarcog::ISO15099::Layers::createPillar), + "Static function to add a measured pillar to a Tarcog gap", + py::arg("pillar")); }