Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deflection gap interface #22

Merged
merged 7 commits into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion CMakeLists-Windows-CalcEngine.txt.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ include(ExternalProject)

ExternalProject_Add(Windows-CalcEngine
GIT_REPOSITORY https://github.com/LBNL-ETA/Windows-CalcEngine.git
GIT_TAG "Version_1.0.43"
GIT_TAG "Version_1.0.46"

UPDATE_COMMAND ""
PATCH_COMMAND ""
Expand Down
8 changes: 5 additions & 3 deletions src/deflection_results.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ namespace wincalc
{
struct Deflection_Results
{
std::vector<double> deflection_max;
std::vector<double> deflection_mean;
std::vector<double> panes_load;
std::vector<double> layer_deflection_max;
std::vector<double> layer_deflection_mean;
std::vector<double> panes_load;
std::vector<double> gap_width_max;
std::vector<double> gap_width_mean;
};
} // namespace wincalc

Expand Down
77 changes: 46 additions & 31 deletions src/glazing_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ namespace wincalc

Tarcog::ISO15099::CIGU & Glazing_System::get_igu(double theta, double phi)
{
if(current_igu.has_value() && theta == last_theta && phi == last_phi)
if(current_igu.has_value() && FenestrationCommon::isEqual(theta, last_theta)
&& FenestrationCommon::isEqual(phi, last_phi))
{
return current_igu.value();
}
Expand All @@ -112,7 +113,8 @@ namespace wincalc

Tarcog::ISO15099::CSystem & Glazing_System::get_system(double theta, double phi)
{
if(current_system.has_value() && theta == last_theta && phi == last_phi)
if(current_system.has_value() && FenestrationCommon::isEqual(theta, last_theta)
&& FenestrationCommon::isEqual(phi, last_phi))
{
return current_system.value();
}
Expand All @@ -128,7 +130,7 @@ namespace wincalc

double Glazing_System::u(double theta, double phi)
{
do_deflection_updates(theta, phi);
do_updates_for_thermal(theta, phi);
auto & system = get_system(theta, phi);
return system.getUValue();
}
Expand All @@ -140,13 +142,10 @@ namespace wincalc
// files do not have conductivity and so can be used in optical calcs but not thermal.
// Creating the system is much less expensive than doing the optical calcs so do that first
// to save time if there are any errors.
do_deflection_updates(theta, phi);
auto & system = get_system(theta, phi);
do_updates_for_thermal(theta, phi);

auto absportances = get_solar_abs_front(theta, phi);
auto solar_front_transmittance = get_solar_transmittance_front(theta, phi);

system.setAbsorptances(absportances);
auto & system = get_system(theta, phi);
return system.getSHGC(solar_front_transmittance);
}

Expand All @@ -169,17 +168,13 @@ namespace wincalc
// files do not have conductivity and so can be used in optical calcs but not thermal.
// Creating the system is much less expensive than doing the optical calcs so do that first
// to save time if there are any errors.
if(theta != last_theta || phi != last_phi)
if(!FenestrationCommon::isEqual(theta, last_theta)
|| !FenestrationCommon::isEqual(phi, last_phi))
{
do_deflection_updates(theta, phi);
do_updates_for_thermal(theta, phi);
}
auto & system = get_system(theta, phi);

if(system_type == Tarcog::ISO15099::System::SHGC)
{
auto solar_front_absorptances = get_solar_abs_front(theta, phi);
system.setAbsorptances(solar_front_absorptances);
}
return system.getTemperatures(system_type);
}

Expand Down Expand Up @@ -210,12 +205,18 @@ namespace wincalc
Deflection_Results Glazing_System::calc_deflection_properties(
Tarcog::ISO15099::System system_type, double theta, double phi)
{
do_deflection_updates(theta, phi);
do_updates_for_thermal(theta, phi);
auto & system = get_system(theta, phi);
auto deflection_max = system.getMaxDeflections(system_type);
auto deflection_mean = system.getMeanDeflections(system_type);
auto panes_load = system.getPanesLoad(system_type);
return {deflection_max, deflection_mean, panes_load};
const auto layer_deflection_max = system.getMaxLayerDeflections(system_type);
const auto layer_deflection_mean = system.getMeanLayerDeflections(system_type);
const auto panes_load = system.getPanesLoad(system_type);
const auto gap_deflection_max = system.getMaxGapWidth(system_type);
const auto gap_deflection_mean = system.getMeanGapWidth(system_type);
return {layer_deflection_max,
layer_deflection_mean,
panes_load,
gap_deflection_max,
gap_deflection_mean};
}

void Glazing_System::do_deflection_updates(double theta, double phi)
Expand All @@ -238,26 +239,38 @@ namespace wincalc
}
}

void Glazing_System::do_layer_absorptance_updates(double theta, double phi)
{
auto & system = get_system(theta, phi);
auto solar_front_absorptances = get_solar_abs_front(theta, phi);
system.setAbsorptances(solar_front_absorptances);
}

void Glazing_System::do_updates_for_thermal(double theta, double phi)
{
do_deflection_updates(theta, phi);
do_layer_absorptance_updates(theta, phi);
}

std::vector<double> Glazing_System::solid_layers_effective_conductivities(
Tarcog::ISO15099::System system_type, double theta, double phi)
{
do_deflection_updates(theta, phi);
do_updates_for_thermal(theta, phi);
auto & system = get_system(theta, phi);
return system.getSolidEffectiveLayerConductivities(system_type);
}
std::vector<double> Glazing_System::gap_layers_effective_conductivities(
Tarcog::ISO15099::System system_type, double theta, double phi)
{
do_deflection_updates(theta, phi);
do_updates_for_thermal(theta, phi);
auto & system = get_system(theta, phi);
return system.getGapEffectiveLayerConductivities(system_type);
}
double Glazing_System::system_effective_conductivity(Tarcog::ISO15099::System system_type,
double theta,
double phi)
{
do_deflection_updates(theta, phi);
do_updates_for_thermal(theta, phi);
auto & system = get_system(theta, phi);
return system.getEffectiveSystemConductivity(system_type);
}
Expand All @@ -268,7 +281,7 @@ namespace wincalc
// files do not have conductivity and so can be used in optical calcs but not thermal.
// Creating the system is much less expensive than doing the optical calcs so do that first
// to save time if there are any errors.
do_deflection_updates(theta, phi);
do_updates_for_thermal(theta, phi);
auto & system = get_system(theta, phi);

auto solar_front_transmittance = get_solar_transmittance_front(theta, phi);
Expand Down Expand Up @@ -472,13 +485,15 @@ namespace wincalc
void Glazing_System::set_spectral_data_wavelength_range(
Spectal_Data_Wavelength_Range_Method const & type, int visible_bands, int solar_bands)
{
if(this->spectral_data_wavelength_range_method != type || this->number_visible_bands != visible_bands || this->number_solar_bands != solar_bands)
{
this->spectral_data_wavelength_range_method = type;
this->number_visible_bands = visible_bands;
this->number_solar_bands = solar_bands;
this->optical_system_for_thermal_calcs = nullptr;
}
if(this->spectral_data_wavelength_range_method != type
|| this->number_visible_bands != visible_bands
|| this->number_solar_bands != solar_bands)
{
this->spectral_data_wavelength_range_method = type;
this->number_visible_bands = visible_bands;
this->number_solar_bands = solar_bands;
this->optical_system_for_thermal_calcs = nullptr;
}
}

void Glazing_System::enable_deflection(bool enable)
Expand Down
2 changes: 2 additions & 0 deletions src/glazing_system.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ namespace wincalc
std::vector<double> applied_loads;

void do_deflection_updates(double theta, double phi);
void do_layer_absorptance_updates(double theta, double phi);
void do_updates_for_thermal(double theta, double phi);

Tarcog::ISO15099::CIGU & get_igu(double theta, double phi);
Tarcog::ISO15099::CSystem & get_system(double theta, double phi);
Expand Down
59 changes: 42 additions & 17 deletions test/deflection.unit.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
#include <memory>
#include <gtest/gtest.h>
#include <cstdlib>
#include <memory>
#include <iostream>
#include <filesystem>
#include <fstream>

#include "wincalc/wincalc.h"
#include "optical_calcs.h"
Expand All @@ -19,7 +15,8 @@ using namespace window_standards;
class TestDeflection : public testing::Test
{
protected:
std::shared_ptr<Glazing_System> glazing_system;
std::shared_ptr<Glazing_System> glazing_system_u;
std::shared_ptr<Glazing_System> glazing_system_shgc;

virtual void SetUp()
{
Expand All @@ -33,10 +30,10 @@ class TestDeflection : public testing::Test
products.push_back(clear_3);
products.push_back(clear_3);

double gap_thickness = 0.0127;
double gap_pressure = Gases::DefaultPressure;
auto air_gap = std::make_shared<Tarcog::ISO15099::CIGUGapLayer>(
gap_thickness, gap_pressure, Gases::CGas({{1.0, Gases::GasDef::Air}}));
double gap_thickness = 0.0127;
double gap_pressure = Gases::DefaultPressure;
auto air_gap = std::make_shared<Tarcog::ISO15099::CIGUGapLayer>(
gap_thickness, gap_pressure, Gases::CGas({{1.0, Gases::GasDef::Air}}));
std::vector<std::shared_ptr<Tarcog::ISO15099::CIGUGapLayer>> gaps;
gaps.push_back(air_gap);

Expand All @@ -45,23 +42,51 @@ class TestDeflection : public testing::Test
standard_path /= "W5_NFRC_2003.std";
Optical_Standard standard = load_optical_standard(standard_path.string());

glazing_system = std::make_shared<Glazing_System>(
glazing_system_u = std::make_shared<Glazing_System>(
standard, products, gaps, 1.0, 1.0, 90, nfrc_u_environments());

glazing_system_shgc = std::make_shared<Glazing_System>(
standard, products, gaps, 1.0, 1.0, 90, nfrc_shgc_environments());
}
};

TEST_F(TestDeflection, Test_Deflection_Off)
{
test_deflection_results(
"NFRC_102_NFRC_102", "deflection/deflection_off", glazing_system, update_results);
test_deflection_results("NFRC_102_NFRC_102",
"deflection/deflection_off",
glazing_system_u,
Tarcog::ISO15099::System::Uvalue,
update_results);
}

TEST_F(TestDeflection, Test_Deflection_On)
{
glazing_system->enable_deflection(true);
auto deflection_results =
glazing_system->calc_deflection_properties(Tarcog::ISO15099::System::Uvalue);
glazing_system_u->enable_deflection(true);

test_deflection_results("NFRC_102_NFRC_102",
"deflection/deflection_on_winter_u_run",
glazing_system_u,
Tarcog::ISO15099::System::Uvalue,
update_results);

glazing_system_u->enable_deflection(true);

test_deflection_results("NFRC_102_NFRC_102",
"deflection/deflection_on_winter_shgc_run",
glazing_system_u,
Tarcog::ISO15099::System::SHGC,
update_results);

glazing_system_shgc->enable_deflection(true);

test_deflection_results(
"NFRC_102_NFRC_102", "deflection/deflection_on", glazing_system, update_results);
test_deflection_results("NFRC_102_NFRC_102",
"deflection/deflection_on_summer_u_run",
glazing_system_shgc,
Tarcog::ISO15099::System::Uvalue,
update_results);
test_deflection_results("NFRC_102_NFRC_102",
"deflection/deflection_on_summer_shgc_run",
glazing_system_shgc,
Tarcog::ISO15099::System::SHGC,
update_results);
}
14 changes: 10 additions & 4 deletions test/deflection_density.unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,19 @@ class TestDeflectionDensity : public testing::Test

TEST_F(TestDeflectionDensity, Test_Deflection_Off)
{
test_deflection_results(
"NFRC_102_NFRC_102", "deflection/density/deflection_off", glazing_system, update_results);
test_deflection_results("NFRC_102_NFRC_102",
"deflection/density/deflection_off",
glazing_system,
Tarcog::ISO15099::System::Uvalue,
update_results);
}

TEST_F(TestDeflectionDensity, Test_Deflection_On)
{
glazing_system->enable_deflection(true);
test_deflection_results(
"NFRC_102_NFRC_102", "deflection/density/deflection_on", glazing_system, update_results);
test_deflection_results("NFRC_102_NFRC_102",
"deflection/density/deflection_on",
glazing_system,
Tarcog::ISO15099::System::Uvalue,
update_results);
}
17 changes: 11 additions & 6 deletions test/deflection_environment.unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ class TestDeflectionEnvironment : public testing::Test
products.push_back(clear_3);
products.push_back(clear_3);

double gap_thickness = 0.0127;
double gap_pressure = Gases::DefaultPressure;
auto air_gap = std::make_shared<Tarcog::ISO15099::CIGUGapLayer>(
gap_thickness, gap_pressure, Gases::CGas({{1.0, Gases::GasDef::Air}}));
double gap_thickness = 0.0127;
double gap_pressure = Gases::DefaultPressure;
auto air_gap = std::make_shared<Tarcog::ISO15099::CIGUGapLayer>(
gap_thickness, gap_pressure, Gases::CGas({{1.0, Gases::GasDef::Air}}));
std::vector<std::shared_ptr<Tarcog::ISO15099::CIGUGapLayer>> gaps;
gaps.push_back(air_gap);

Expand All @@ -52,8 +52,11 @@ class TestDeflectionEnvironment : public testing::Test

TEST_F(TestDeflectionEnvironment, Test_Deflection_Off)
{
test_deflection_results(
"NFRC_102_NFRC_102", "deflection/environment/deflection_off", glazing_system, update_results);
test_deflection_results("NFRC_102_NFRC_102",
"deflection/environment/deflection_off",
glazing_system,
Tarcog::ISO15099::System::SHGC,
update_results);
}

TEST_F(TestDeflectionEnvironment, Test_Deflection_On)
Expand All @@ -62,6 +65,7 @@ TEST_F(TestDeflectionEnvironment, Test_Deflection_On)
test_deflection_results("NFRC_102_NFRC_102",
"deflection/environment/deflection_on_environment_1",
glazing_system,
Tarcog::ISO15099::System::SHGC,
update_results);
// change environment pressure, make sure deflection results change
auto new_env = nfrc_shgc_environments();
Expand All @@ -72,5 +76,6 @@ TEST_F(TestDeflectionEnvironment, Test_Deflection_On)
test_deflection_results("NFRC_102_NFRC_102",
"deflection/environment/deflection_on_environment_2",
glazing_system,
Tarcog::ISO15099::System::SHGC,
update_results);
}
3 changes: 3 additions & 0 deletions test/deflection_load.unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ TEST_F(TestDeflectionLoad, Test_Deflection_Off)
test_deflection_results("NFRC_102_NFRC_102",
"deflection/applied_loads/deflection_off",
glazing_system,
Tarcog::ISO15099::System::Uvalue,
update_results);
}

Expand All @@ -69,11 +70,13 @@ TEST_F(TestDeflectionLoad, Test_Deflection_On)
test_deflection_results("NFRC_102_NFRC_102",
"deflection/applied_loads/deflection_on_applied_loads_1",
glazing_system,
Tarcog::ISO15099::System::Uvalue,
update_results);
// change applied loads, make sure results change
glazing_system->set_applied_loads({1, 1000});
test_deflection_results("NFRC_102_NFRC_102",
"deflection/applied_loads/deflection_on_applied_loads_2",
glazing_system,
Tarcog::ISO15099::System::Uvalue,
update_results);
}
Loading
Loading