Skip to content

Commit

Permalink
Merge pull request #26 from LBNL-ETA/2024SeptemberFixes
Browse files Browse the repository at this point in the history
2024 september fixes
  • Loading branch information
vidanovic authored Sep 24, 2024
2 parents fecd21e + 7af9dba commit 02a9259
Show file tree
Hide file tree
Showing 333 changed files with 6,197 additions and 3,109 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
Expand All @@ -31,4 +31,4 @@ jobs:

- name: Test
working-directory: ${{github.workspace}}/build
run: ctest -C RELEASE -V
run: ctest -C RELEASE -V
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.47"
GIT_TAG "Version_1.0.48"

UPDATE_COMMAND ""
PATCH_COMMAND ""
Expand Down
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,13 @@ Option(BUILD_WinCalc_tests "Build WinCalc tests." ON)
if(BUILD_WinCalc_tests)
enable_testing()
add_subdirectory( test )

# Set the path to the test directory
set(TEST_DATA_DIR "${CMAKE_CURRENT_SOURCE_DIR}/test")
target_compile_definitions(wincalc-test PRIVATE TEST_DATA_DIR="${TEST_DATA_DIR}")

# Add the test with the specified arguments
add_test(NAME wincalc-test
COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/wincalc-test --gtest_catch_exceptions=0)
endif()

4 changes: 4 additions & 0 deletions src/convert_optics_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,10 @@ namespace wincalc
auto thermal_data = wincalc::Product_Data_Thermal(
data.conductivity, data.thickness.value() * length_conversion, false);

if(data.permeabilityFactor.has_value())
{
thermal_data.permeability_factor = data.permeabilityFactor.value();
}
thermal_data.density = data.density;
thermal_data.youngs_modulus = data.youngsModulus;

Expand Down
16 changes: 9 additions & 7 deletions src/create_wce_objects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1071,13 +1071,15 @@ namespace wincalc
}
auto ir_results = calc_thermal_ir(standard, layer);

auto effective_thermal_values =
layer.optical_data->effective_thermal_values(width,
height,
layer.thermal_data->opening_top,
layer.thermal_data->opening_bottom,
layer.thermal_data->opening_left,
layer.thermal_data->opening_right);
auto effective_thermal_values = layer.optical_data->effective_thermal_values(
width,
height,
layer.thermal_data->opening_top,
layer.thermal_data->opening_bottom,
layer.thermal_data->opening_left,
layer.thermal_data->opening_right,
layer.thermal_data->effective_front_thermal_openness_area,
layer.thermal_data->permeability_factor);

auto tarcog_layer =
Tarcog::ISO15099::Layers::shading(effective_thermal_values->effectiveThickness(),
Expand Down
57 changes: 31 additions & 26 deletions src/glazing_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@ namespace wincalc

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

Tarcog::ISO15099::CSystem & Glazing_System::get_system(double theta, double phi)
{
if(current_system.has_value() && FenestrationCommon::isEqual(theta, last_theta)
&& FenestrationCommon::isEqual(phi, last_phi))
if(current_system.has_value() && is_current_igu_calculated(theta, phi))
{
return current_system.value();
}
Expand Down Expand Up @@ -153,26 +151,7 @@ namespace wincalc
double theta,
double phi)
{
// Don't do deflection updates if theta and phi are unchanged. If this check is not
// present then the CSystem m_solved value will get set to false causing the deflection
// solver to go through another iteration resulting in slightly differnt temperatures
// While these results are not incorrect they will not match the results from
// Windows-CalcEngine unit tests. And also if those temperates from the extra
// iteration are used in the Stephen Morse code it will not result in the same
// deflection values.
//
// The whole interaction involving do_deflection_updates needs to be refactored
//
// Doing deflection updates and creating the system before calculating the optical results
// because there are cases where the thermal system cannot be created. E.G. genSDF XML
// 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(!FenestrationCommon::isEqual(theta, last_theta)
|| !FenestrationCommon::isEqual(phi, last_phi))
{
do_updates_for_thermal(theta, phi);
}
do_updates_for_thermal(theta, phi);
auto & system = get_system(theta, phi);

return system.getTemperatures(system_type);
Expand Down Expand Up @@ -239,6 +218,15 @@ namespace wincalc
}
}

void Glazing_System::do_deflection_updates(std::optional<double> theta,
std::optional<double> phi)
{
if(theta.has_value() && phi.has_value())
{
do_deflection_updates(theta.value(), phi.value());
}
}

void Glazing_System::do_layer_absorptance_updates(double theta, double phi)
{
auto & system = get_system(theta, phi);
Expand Down Expand Up @@ -310,7 +298,8 @@ namespace wincalc
return product_data;
}

void Glazing_System::gap_layers(std::vector<std::shared_ptr<Tarcog::ISO15099::CIGUGapLayer>> const & layers)
void Glazing_System::gap_layers(
std::vector<std::shared_ptr<Tarcog::ISO15099::CIGUGapLayer>> const & layers)
{
reset_igu();
gap_values = layers;
Expand Down Expand Up @@ -510,6 +499,17 @@ namespace wincalc
void Glazing_System::enable_deflection(bool enable)
{
model_deflection = enable;

// If last theta and phi are not set then set them to 0.0 for the deflection updates
if(!last_theta.has_value())
{
last_theta = 0.0;
}
if(!last_phi.has_value())
{
last_phi = 0.0;
}

do_deflection_updates(last_theta, last_phi);
}

Expand Down Expand Up @@ -564,6 +564,12 @@ namespace wincalc
phi);
}

bool Glazing_System::is_current_igu_calculated(double theta, double phi)
{
return last_theta.has_value() && FenestrationCommon::isEqual(theta, last_theta.value())
&& last_phi.has_value() && FenestrationCommon::isEqual(phi, last_phi.value());
}

std::vector<double> Glazing_System::get_solar_abs_front(double theta, double phi)
{
auto & optical_system = get_optical_system_for_thermal_calcs();
Expand All @@ -581,5 +587,4 @@ namespace wincalc
phi);
}


} // namespace wincalc
7 changes: 5 additions & 2 deletions src/glazing_system.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ namespace wincalc
std::vector<double> applied_loads;

void do_deflection_updates(double theta, double phi);
void do_deflection_updates(std::optional<double> theta, std::optional<double> phi);
void do_layer_absorptance_updates(double theta, double phi);
void do_updates_for_thermal(double theta, double phi);

Expand All @@ -164,14 +165,16 @@ namespace wincalc
std::optional<Tarcog::ISO15099::CIGU> current_igu;
std::optional<Tarcog::ISO15099::CSystem> current_system;

bool is_current_igu_calculated(double theta, double phi);

std::vector<double> get_solar_abs_front(double theta, double phi);
double get_solar_transmittance_front(double theta, double phi);
SingleLayerOptics::IScatteringLayer & get_optical_system_for_thermal_calcs();
std::unique_ptr<SingleLayerOptics::IScatteringLayer> optical_system_for_thermal_calcs;


double last_theta = 0;
double last_phi = 0;
std::optional<double> last_theta = std::nullopt;
std::optional<double> last_phi = std::nullopt;
void reset_system();
void reset_igu();
void sort_spectral_data();
Expand Down
Loading

0 comments on commit 02a9259

Please sign in to comment.