From b4f704e0515b2aab0e28ee915b954aae4d7c8c13 Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Tue, 24 Nov 2020 11:22:59 -0700 Subject: [PATCH 01/10] moving DataConvergParams to state --- src/EnergyPlus/CMakeLists.txt | 1 - src/EnergyPlus/Data/CommonIncludes.hh | 1 + src/EnergyPlus/Data/EnergyPlusData.cc | 2 + src/EnergyPlus/Data/EnergyPlusData.hh | 2 + src/EnergyPlus/DataConvergParams.cc | 158 --------- src/EnergyPlus/DataConvergParams.hh | 131 ++++---- src/EnergyPlus/DualDuct.cc | 3 +- src/EnergyPlus/HVACControllers.cc | 6 +- src/EnergyPlus/HVACInterfaceManager.cc | 284 ++++++++--------- src/EnergyPlus/HVACInterfaceManager.hh | 3 +- src/EnergyPlus/HVACManager.cc | 336 +++++++++----------- src/EnergyPlus/Plant/PlantManager.cc | 11 +- src/EnergyPlus/SimAirServingZones.cc | 30 +- src/EnergyPlus/SimulationManager.cc | 54 ++-- src/EnergyPlus/SingleDuct.cc | 3 +- src/EnergyPlus/StateManagement.cc | 3 - src/EnergyPlus/ZoneEquipmentManager.cc | 3 +- tst/EnergyPlus/unit/HVACControllers.unit.cc | 28 +- 18 files changed, 432 insertions(+), 627 deletions(-) delete mode 100644 src/EnergyPlus/DataConvergParams.cc diff --git a/src/EnergyPlus/CMakeLists.txt b/src/EnergyPlus/CMakeLists.txt index 61531ef0454..30cc19bf68e 100644 --- a/src/EnergyPlus/CMakeLists.txt +++ b/src/EnergyPlus/CMakeLists.txt @@ -145,7 +145,6 @@ SET( SRC DataBranchNodeConnections.hh DataComplexFenestration.hh DataContaminantBalance.hh - DataConvergParams.cc DataConvergParams.hh DataConversions.cc DataConversions.hh diff --git a/src/EnergyPlus/Data/CommonIncludes.hh b/src/EnergyPlus/Data/CommonIncludes.hh index 0d1430517ca..d26772db77c 100644 --- a/src/EnergyPlus/Data/CommonIncludes.hh +++ b/src/EnergyPlus/Data/CommonIncludes.hh @@ -82,6 +82,7 @@ #include #include #include +#include #include #include #include diff --git a/src/EnergyPlus/Data/EnergyPlusData.cc b/src/EnergyPlus/Data/EnergyPlusData.cc index 17a2a8d6272..6590e261829 100644 --- a/src/EnergyPlus/Data/EnergyPlusData.cc +++ b/src/EnergyPlus/Data/EnergyPlusData.cc @@ -79,6 +79,7 @@ namespace EnergyPlus { this->dataConstruction = std::make_unique(); this->dataContaminantBalance = std::make_unique(); this->dataConvectionCoefficient = std::make_unique(); + this->dataConvergeParams = std::make_unique(); this->dataCoolTower = std::make_unique(); this->dataCostEstimateManager = std::make_unique(); this->dataCrossVentMgr = std::make_unique(); @@ -162,6 +163,7 @@ namespace EnergyPlus { this->dataConstruction->clear_state(); this->dataContaminantBalance->clear_state(); this->dataConvectionCoefficient->clear_state(); + this->dataConvergeParams->clear_state(); this->dataCoolTower->clear_state(); this->dataCostEstimateManager->clear_state(); this->dataCrossVentMgr->clear_state(); diff --git a/src/EnergyPlus/Data/EnergyPlusData.hh b/src/EnergyPlus/Data/EnergyPlusData.hh index ae19509b2b8..ad2eaf66508 100644 --- a/src/EnergyPlus/Data/EnergyPlusData.hh +++ b/src/EnergyPlus/Data/EnergyPlusData.hh @@ -86,6 +86,7 @@ struct CondenserLoopTowersData; struct ConstructionData; struct ContaminantBalanceData; struct ConvectionCoefficientsData; +struct ConvergParamsData; struct CoolTowerData; struct CostEstimateManagerData; struct CrossVentMgrData; @@ -173,6 +174,7 @@ struct EnergyPlusData : BaseGlobalStruct { std::unique_ptr dataConstruction; std::unique_ptr dataContaminantBalance; std::unique_ptr dataConvectionCoefficient; + std::unique_ptr dataConvergeParams; std::unique_ptr dataCoolTower; std::unique_ptr dataCostEstimateManager; std::unique_ptr dataCrossVentMgr; diff --git a/src/EnergyPlus/DataConvergParams.cc b/src/EnergyPlus/DataConvergParams.cc deleted file mode 100644 index 8b6899df79e..00000000000 --- a/src/EnergyPlus/DataConvergParams.cc +++ /dev/null @@ -1,158 +0,0 @@ -// EnergyPlus, Copyright (c) 1996-2020, The Board of Trustees of the University of Illinois, -// The Regents of the University of California, through Lawrence Berkeley National Laboratory -// (subject to receipt of any required approvals from the U.S. Dept. of Energy), Oak Ridge -// National Laboratory, managed by UT-Battelle, Alliance for Sustainable Energy, LLC, and other -// contributors. All rights reserved. -// -// NOTICE: This Software was developed under funding from the U.S. Department of Energy and the -// U.S. Government consequently retains certain rights. As such, the U.S. Government has been -// granted for itself and others acting on its behalf a paid-up, nonexclusive, irrevocable, -// worldwide license in the Software to reproduce, distribute copies to the public, prepare -// derivative works, and perform publicly and display publicly, and to permit others to do so. -// -// Redistribution and use in source and binary forms, with or without modification, are permitted -// provided that the following conditions are met: -// -// (1) Redistributions of source code must retain the above copyright notice, this list of -// conditions and the following disclaimer. -// -// (2) Redistributions in binary form must reproduce the above copyright notice, this list of -// conditions and the following disclaimer in the documentation and/or other materials -// provided with the distribution. -// -// (3) Neither the name of the University of California, Lawrence Berkeley National Laboratory, -// the University of Illinois, U.S. Dept. of Energy nor the names of its contributors may be -// used to endorse or promote products derived from this software without specific prior -// written permission. -// -// (4) Use of EnergyPlus(TM) Name. If Licensee (i) distributes the software in stand-alone form -// without changes from the version obtained under this License, or (ii) Licensee makes a -// reference solely to the software portion of its product, Licensee must refer to the -// software as "EnergyPlus version X" software, where "X" is the version number Licensee -// obtained under this License and may not use a different name for the software. Except as -// specifically required in this Section (4), Licensee shall not use in a company name, a -// product name, in advertising, publicity, or other promotional activities any name, trade -// name, trademark, logo, or other designation of "EnergyPlus", "E+", "e+" or confusingly -// similar designation, without the U.S. Department of Energy's prior written consent. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY -// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR -// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. - -// ObjexxFCL Headers -#include -#include - -// EnergyPlus Headers -#include -namespace EnergyPlus { - -namespace DataConvergParams { - - // PURPOSE OF THIS MODULE: - // This data-only module sets the parameters that control the convergence - // of the HVAC simulation. - - // Using/Aliasing - // Data - // -only module should be available to other modules and routines. - // Thus, all variables in this module must be PUBLIC. - - // MODULE PARAMETER DEFINITIONS: - - // Note: Unless otherwise noted, the tolerance parameters listed below were chosen - // to represent educated guesses at what the tolerances for individual physical - // parameters should be. - Real64 const HVACEnthalpyToler(260.0); // Tolerance for enthalpy comparisons (in kJ/kgK) - Real64 const HVACFlowRateToler(0.01); // Tolerance for mass flow rate convergence (in kg/s) [~20 CFM] - Real64 const HVACFlowRateSlopeToler(0.001); // Slope tolerance for mass flow, kg/s/iteration - Real64 const HVACFlowRateOscillationToler(0.0000001); // tolerance for detecting duplicate flow rate in stack - Real64 const HVACHumRatToler(0.0001); // Tolerance for humidity ratio comparisons (kg water/kg dryair) - Real64 const HVACHumRatSlopeToler(0.00001); // Slope tolerance for humidity ratio, kg water/kg-dryair/iteration - Real64 const HVACHumRatOscillationToler(0.00000001); // tolerance for detecting duplicate humidity ratio in stack - Real64 const HVACQualityToler(0.01); // Tolerance for fluid quality comparisons (dimensionless) - Real64 const HVACPressToler(10.0); // Tolerance for pressure comparisons (in Pascals) - Real64 const HVACTemperatureToler(0.01); // Tolerance for temperature comparisons (in degrees C or K) - Real64 const HVACTemperatureSlopeToler(0.001); // Slope tolerance for Temperature, Deg C/iteration - Real64 const HVACTemperatureOscillationToler(0.000001); // tolerance for detecting duplicate temps in stack - Real64 const HVACEnergyToler(10.0); // Tolerance for Energy comparisons (in Watts W) - // to be consistent, should be 20.d0 (BG Aug 2012) - - Real64 const HVACCpApprox(1004.844); // Air Cp (20C,0.0Kg/Kg) Only for energy Tolerance Calculation - // Only used to scale the answer for a more intuitive answer for comparison - - Real64 const PlantEnthalpyToler(0.10); // Tolerance for enthalpy comparisons (in kJ/kgK) - Real64 const PlantFlowRateToler(0.001); // Tolerance for mass flow rate convergence (in kg/s) [~2 CFM] - Real64 const PlantFlowRateOscillationToler(0.0000001); - Real64 const PlantFlowRateSlopeToler(0.0001); // Slope tolerance for mass flow, kg/s/iteration - - Real64 const PlantPressToler(10.0); // Tolerance for pressure comparisons (in Pascals) - Real64 const PlantTemperatureToler(0.01); // Tolerance for temperature comparisons (in degrees C or K) - Real64 const PlantTemperatureSlopeToler(0.001); // Slope tolerance for Temperature, Deg C/iteration - Real64 const PlantTemperatureOscillationToler(0.000001); // tolerance for detecting duplicate temps in stack - - Real64 const PlantEnergyToler(10.0); // Tolerance for Energy comparisons (in Watts W) - - Real64 const PlantCpApprox(4180.0); // Approximate Cp used in Interface manager for - // Energy Tolerance Calculation, used to scale the answer - // for a more intuitive answer for comparison - Real64 const PlantFlowFlowRateToler(0.01); // Tolerance for mass flow rate convergence (in kg/s) - Real64 const PlantLowFlowRateToler(0.000001); // Tolerance for low flow rate used for determining when - // plant pumps can be shut down - - int const ConvergLogStackDepth(10); - Array1D const ConvergLogStackARR(ConvergLogStackDepth, {0.0, -1.0, -2.0, -3.0, -4.0, -5.0, -6.0, -7.0, -8.0, -9.0}); - Real64 const sum_ConvergLogStackARR(sum(ConvergLogStackARR)); - Real64 const square_sum_ConvergLogStackARR(pow_2(sum_ConvergLogStackARR)); - Real64 const sum_square_ConvergLogStackARR(sum(pow(ConvergLogStackARR, 2))); - - int const CalledFromAirSystemDemandSide(100); - int const CalledFromAirSystemSupplySideDeck1(101); - int const CalledFromAirSystemSupplySideDeck2(102); - // DERIVED TYPE DEFINITIONS: - // na - - // MODULE VARIABLE DECLARATIONS: - - int AirLoopConvergFail(0); - - Real64 MinTimeStepSys((1.0 / 60.0)); // =1 minute - Real64 MinTimeStepTol(1.0e-4); // = min allowable for ABS(1.-TimeStepSys/(MinTimeStepSys)) - Real64 MaxZoneTempDiff(0.3); // 0.3 C = (1% OF 300 C) = max allowable difference between - - // zone air temp at Time=T and Time=T-1 - Real64 MinSysTimeRemaining((1.0 / 3600.0)); // = 1 second - int MaxIter(20); // maximum number of iterations allowed - - int MaxPlantSubIterations(8); // Iteration Max for Plant Simulation sub iterations - int MinPlantSubIterations(2); // Iteration Min for Plant Simulation sub iterations - - // Object Data - Array1D ZoneInletConvergence; - Array1D AirLoopConvergence; - Array1D PlantConvergence; - - void clear_state() - { - AirLoopConvergFail = 0; - MinTimeStepSys = (1.0 / 60.0); // =1 minute - MinTimeStepTol = 1.0e-4; // = min allowable for ABS(1.-TimeStepSys/(MinTimeStepSys)) - MaxZoneTempDiff = 0.3; // 0.3 C = (1% OF 300 C) = max allowable difference between - MinSysTimeRemaining = (1.0 / 3600.0); // = 1 second - MaxIter = 20; // maximum number of iterations allowed - MaxPlantSubIterations = 8; // Iteration Max for Plant Simulation sub iterations - MinPlantSubIterations = 2; // Iteration Min for Plant Simulation sub iterations - ZoneInletConvergence.deallocate(); - AirLoopConvergence.deallocate(); - PlantConvergence.deallocate(); - } - -} // namespace DataConvergParams - -} // namespace EnergyPlus diff --git a/src/EnergyPlus/DataConvergParams.hh b/src/EnergyPlus/DataConvergParams.hh index ced3b2e9d8f..f0d9404b23c 100644 --- a/src/EnergyPlus/DataConvergParams.hh +++ b/src/EnergyPlus/DataConvergParams.hh @@ -59,82 +59,53 @@ namespace EnergyPlus { namespace DataConvergParams { - // Using/Aliasing - - // Data - // -only module should be available to other modules and routines. - // Thus, all variables in this module must be PUBLIC. - - // MODULE PARAMETER DEFINITIONS: - // Note: Unless otherwise noted, the tolerance parameters listed below were chosen // to represent educated guesses at what the tolerances for individual physical // parameters should be. - extern Real64 const HVACEnthalpyToler; // Tolerance for enthalpy comparisons (in kJ/kgK) - extern Real64 const HVACFlowRateToler; // Tolerance for mass flow rate convergence (in kg/s) [~20 CFM] - extern Real64 const HVACFlowRateSlopeToler; // Slope tolerance for mass flow, kg/s/iteration - extern Real64 const HVACFlowRateOscillationToler; // tolerance for detecting duplicate flow rate in stack - extern Real64 const HVACHumRatToler; // Tolerance for humidity ratio comparisons (kg water/kg dryair) - extern Real64 const HVACHumRatSlopeToler; // Slope tolerance for humidity ratio, kg water/kg-dryair/iteration - extern Real64 const HVACHumRatOscillationToler; // tolerance for detecting duplicate humidity ratio in stack - extern Real64 const HVACQualityToler; // Tolerance for fluid quality comparisons (dimensionless) - extern Real64 const HVACPressToler; // Tolerance for pressure comparisons (in Pascals) - extern Real64 const HVACTemperatureToler; // Tolerance for temperature comparisons (in degrees C or K) - extern Real64 const HVACTemperatureSlopeToler; // Slope tolerance for Temperature, Deg C/iteration - extern Real64 const HVACTemperatureOscillationToler; // tolerance for detecting duplicate temps in stack - extern Real64 const HVACEnergyToler; // Tolerance for Energy comparisons (in Watts W) + constexpr Real64 HVACEnthalpyToler(260.0); // Tolerance for enthalpy comparisons (in kJ/kgK) + constexpr Real64 HVACFlowRateToler(0.01); // Tolerance for mass flow rate convergence (in kg/s) [~20 CFM] + constexpr Real64 HVACFlowRateSlopeToler(0.001); // Slope tolerance for mass flow, kg/s/iteration + constexpr Real64 HVACFlowRateOscillationToler(0.0000001); // tolerance for detecting duplicate flow rate in stack + constexpr Real64 HVACHumRatToler(0.0001); // Tolerance for humidity ratio comparisons (kg water/kg dryair) + constexpr Real64 HVACHumRatSlopeToler(0.00001); // Slope tolerance for humidity ratio, kg water/kg-dryair/iteration + constexpr Real64 HVACHumRatOscillationToler(0.00000001); // tolerance for detecting duplicate humidity ratio in stack + constexpr Real64 HVACQualityToler(0.01); // Tolerance for fluid quality comparisons (dimensionless) + constexpr Real64 HVACPressToler(10.0); // Tolerance for pressure comparisons (in Pascals) + constexpr Real64 HVACTemperatureToler(0.01); // Tolerance for temperature comparisons (in degrees C or K) + constexpr Real64 HVACTemperatureSlopeToler(0.001); // Slope tolerance for Temperature, Deg C/iteration + constexpr Real64 HVACTemperatureOscillationToler(0.000001); // tolerance for detecting duplicate temps in stack + constexpr Real64 HVACEnergyToler(10.0); // Tolerance for Energy comparisons (in Watts W) // to be consistent, should be 20.d0 (BG Aug 2012) - extern Real64 const HVACCpApprox; // Air Cp (20C,0.0Kg/Kg) Only for energy Tolerance Calculation + constexpr Real64 HVACCpApprox(1004.844); // Air Cp (20C,0.0Kg/Kg) Only for energy Tolerance Calculation // Only used to scale the answer for a more intuitive answer for comparison - extern Real64 const PlantEnthalpyToler; // Tolerance for enthalpy comparisons (in kJ/kgK) - extern Real64 const PlantFlowRateToler; // Tolerance for mass flow rate convergence (in kg/s) [~2 CFM] - extern Real64 const PlantLowFlowRateToler; // // Tolerance for low flow rate used for determining when - // plant pumps can be shut down - extern Real64 const PlantFlowRateOscillationToler; - extern Real64 const PlantFlowRateSlopeToler; // Slope tolerance for mass flow, kg/s/iteration + constexpr Real64 PlantEnthalpyToler(0.10); // Tolerance for enthalpy comparisons (in kJ/kgK) + constexpr Real64 PlantFlowRateToler(0.001); // Tolerance for mass flow rate convergence (in kg/s) [~2 CFM] + constexpr Real64 PlantFlowRateOscillationToler(0.0000001); + constexpr Real64 PlantFlowRateSlopeToler(0.0001); // Slope tolerance for mass flow, kg/s/iteration - extern Real64 const PlantPressToler; // Tolerance for pressure comparisons (in Pascals) - extern Real64 const PlantTemperatureToler; // Tolerance for temperature comparisons (in degrees C or K) - extern Real64 const PlantTemperatureSlopeToler; // Slope tolerance for Temperature, Deg C/iteration - extern Real64 const PlantTemperatureOscillationToler; // tolerance for detecting duplicate temps in stack + constexpr Real64 PlantPressToler(10.0); // Tolerance for pressure comparisons (in Pascals) + constexpr Real64 PlantTemperatureToler(0.01); // Tolerance for temperature comparisons (in degrees C or K) + constexpr Real64 PlantTemperatureSlopeToler(0.001); // Slope tolerance for Temperature, Deg C/iteration + constexpr Real64 PlantTemperatureOscillationToler(0.000001); // tolerance for detecting duplicate temps in stack - extern Real64 const PlantEnergyToler; // Tolerance for Energy comparisons (in Watts W) + constexpr Real64 PlantEnergyToler(10.0); // Tolerance for Energy comparisons (in Watts W) - extern Real64 const PlantCpApprox; // Approximate Cp used in Interface manager for + constexpr Real64 PlantCpApprox(4180.0); // Approximate Cp used in Interface manager for // Energy Tolerance Calculation, used to scale the answer // for a more intuitive answer for comparison - extern Real64 const PlantFlowFlowRateToler; // Tolerance for mass flow rate convergence (in kg/s) - - extern int const ConvergLogStackDepth; - extern Array1D const ConvergLogStackARR; - extern Real64 const sum_ConvergLogStackARR; - extern Real64 const square_sum_ConvergLogStackARR; - extern Real64 const sum_square_ConvergLogStackARR; - - extern int const CalledFromAirSystemDemandSide; - extern int const CalledFromAirSystemSupplySideDeck1; - extern int const CalledFromAirSystemSupplySideDeck2; - // DERIVED TYPE DEFINITIONS: - // na - - // MODULE VARIABLE DECLARATIONS: - - extern int AirLoopConvergFail; - - extern Real64 MinTimeStepSys; // =1 minute - extern Real64 MinTimeStepTol; // = min allowable for ABS(1.-TimeStepSys/(MinTimeStepSys)) - extern Real64 MaxZoneTempDiff; // 0.3 C = (1% OF 300 C) = max allowable difference between - - // zone air temp at Time=T and Time=T-1 - extern Real64 MinSysTimeRemaining; // = 1 second - extern int MaxIter; // maximum number of iterations allowed + constexpr Real64 PlantFlowFlowRateToler(0.01); // Tolerance for mass flow rate convergence (in kg/s) + constexpr Real64 PlantLowFlowRateToler(0.000001); // Tolerance for low flow rate used for determining when + // plant pumps can be shut down - extern int MaxPlantSubIterations; // Iteration Max for Plant Simulation sub iterations - extern int MinPlantSubIterations; // Iteration Min for Plant Simulation sub iterations + constexpr int ConvergLogStackDepth(10); - // Types + enum class iCalledFrom { + AirSystemDemandSide, + AirSystemSupplySideDeck1, + AirSystemSupplySideDeck2 + }; struct HVACNodeConvergLogStruct { @@ -235,14 +206,38 @@ namespace DataConvergParams { } }; - // Object Data - extern Array1D ZoneInletConvergence; - extern Array1D AirLoopConvergence; - extern Array1D PlantConvergence; +} // namespace DataConvergParams - void clear_state(); +struct ConvergParamsData : BaseGlobalStruct { -} // namespace DataConvergParams + int AirLoopConvergFail = 0; + + Real64 MinTimeStepSys = (1.0 / 60.0); // =1 minute + Real64 MinTimeStepTol = 1.0e-4; // = min allowable for ABS(1.-TimeStepSys/(MinTimeStepSys)) + Real64 MaxZoneTempDiff = 0.3; // 0.3 C = (1% OF 300 C) = max allowable difference between + int MaxIter = 20; // maximum number of iterations allowed + int MaxPlantSubIterations = 8; // Iteration Max for Plant Simulation sub iterations + int MinPlantSubIterations = 2; // Iteration Min for Plant Simulation sub iterations + + // Object Data + Array1D ZoneInletConvergence; + Array1D AirLoopConvergence; + Array1D PlantConvergence; + + void clear_state() override + { + this->AirLoopConvergFail = 0; + this->MinTimeStepSys = (1.0 / 60.0); // =1 minute + this->MinTimeStepTol = 1.0e-4; // = min allowable for ABS(1.-TimeStepSys/(MinTimeStepSys)) + this->MaxZoneTempDiff = 0.3; // 0.3 C = (1% OF 300 C) = max allowable difference between + this->MaxIter = 20; // maximum number of iterations allowed + this->MaxPlantSubIterations = 8; // Iteration Max for Plant Simulation sub iterations + this->MinPlantSubIterations = 2; // Iteration Min for Plant Simulation sub iterations + this->ZoneInletConvergence.deallocate(); + this->AirLoopConvergence.deallocate(); + this->PlantConvergence.deallocate(); + } +}; } // namespace EnergyPlus diff --git a/src/EnergyPlus/DualDuct.cc b/src/EnergyPlus/DualDuct.cc index 4e4bf94ff25..ccc32d28ea9 100644 --- a/src/EnergyPlus/DualDuct.cc +++ b/src/EnergyPlus/DualDuct.cc @@ -854,7 +854,6 @@ namespace DualDuct { // Uses the status flags to trigger events. // Using/Aliasing - using DataConvergParams::HVACFlowRateToler; using DataDefineEquip::AirDistUnit; using DataHeatBalance::People; using DataHeatBalance::TotPeople; @@ -884,7 +883,7 @@ namespace DualDuct { // MyAirLoopFlag.dimension(NumDDAirTerminal, true); // MyEnvrnFlag = true; // MySizeFlag = true; - MassFlowSetToler = HVACFlowRateToler * 0.00001; + MassFlowSetToler = DataConvergParams::HVACFlowRateToler * 0.00001; InitDualDuctMyOneTimeFlag = false; } diff --git a/src/EnergyPlus/HVACControllers.cc b/src/EnergyPlus/HVACControllers.cc index a944fba951d..0a39c6417e7 100644 --- a/src/EnergyPlus/HVACControllers.cc +++ b/src/EnergyPlus/HVACControllers.cc @@ -1349,8 +1349,6 @@ namespace HVACControllers { // Using/Aliasing using namespace DataSizing; - using DataConvergParams::HVACEnergyToler; - using DataConvergParams::HVACTemperatureToler; // Locals // SUBROUTINE ARGUMENT DEFINITIONS: @@ -1395,9 +1393,9 @@ namespace HVACControllers { // with a temperature tolerance that won't exceed the loop energy error tolerance (10 W). // Finally we need to take into account the fact that somebody might change the energy tolerance. ControllerProps(ControlNum).Offset = - (0.001 / (2100.0 * max(ControllerProps(ControlNum).MaxVolFlowActuated, SmallWaterVolFlow))) * (HVACEnergyToler / 10.0); + (0.001 / (2100.0 * max(ControllerProps(ControlNum).MaxVolFlowActuated, SmallWaterVolFlow))) * (DataConvergParams::HVACEnergyToler / 10.0); // do not let the controller tolerance exceed 1/10 of the loop temperature tolerance. - ControllerProps(ControlNum).Offset = min(0.1 * HVACTemperatureToler, ControllerProps(ControlNum).Offset); + ControllerProps(ControlNum).Offset = min(0.1 * DataConvergParams::HVACTemperatureToler, ControllerProps(ControlNum).Offset); BaseSizer::reportSizerOutput(state, ControllerProps(ControlNum).ControllerType, ControllerProps(ControlNum).ControllerName, "Controller Convergence Tolerance", diff --git a/src/EnergyPlus/HVACInterfaceManager.cc b/src/EnergyPlus/HVACInterfaceManager.cc index 1a451d10d7e..2f1ae5fe6a7 100644 --- a/src/EnergyPlus/HVACInterfaceManager.cc +++ b/src/EnergyPlus/HVACInterfaceManager.cc @@ -122,7 +122,7 @@ namespace HVACInterfaceManager { void UpdateHVACInterface(EnergyPlusData &state, int const AirLoopNum, // airloop number for which air loop this is - int const CalledFrom, + DataConvergParams::iCalledFrom const CalledFrom, int const OutletNode, // Node number for the outlet of the side of the loop just simulated int const InletNode, // Node number for the inlet of the side that needs the outlet node data bool &OutOfToleranceFlag // True when the other side of the loop need to be (re)simulated @@ -144,17 +144,17 @@ namespace HVACInterfaceManager { using DataLoopNode::Node; using namespace DataConvergParams; - static Array1D TmpRealARR(ConvergLogStackDepth); // Tuned Made static + static Array1D TmpRealARR(DataConvergParams::ConvergLogStackDepth); // Tuned Made static Real64 DeltaEnergy; - if ((CalledFrom == CalledFromAirSystemDemandSide) && (OutletNode == 0)) { + if ((CalledFrom == DataConvergParams::iCalledFrom::AirSystemDemandSide) && (OutletNode == 0)) { // Air loop has no return path - only check mass flow and then set return inlet node mass flow to sum of demand side inlet nodes - AirLoopConvergence(AirLoopNum).HVACMassFlowNotConverged(1) = false; - AirLoopConvergence(AirLoopNum).HVACHumRatNotConverged(1) = false; - AirLoopConvergence(AirLoopNum).HVACTempNotConverged(1) = false; - AirLoopConvergence(AirLoopNum).HVACEnergyNotConverged(1) = false; - AirLoopConvergence(AirLoopNum).HVACEnthalpyNotConverged(1) = false; - AirLoopConvergence(AirLoopNum).HVACPressureNotConverged(1) = false; + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACMassFlowNotConverged(1) = false; + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACHumRatNotConverged(1) = false; + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACTempNotConverged(1) = false; + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACEnergyNotConverged(1) = false; + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACEnthalpyNotConverged(1) = false; + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACPressureNotConverged(1) = false; Real64 totDemandSideMassFlow = 0.0; Real64 totDemandSideMinAvail = 0.0; @@ -165,11 +165,11 @@ namespace HVACInterfaceManager { totDemandSideMinAvail += Node(demInNode).MassFlowRateMinAvail; totDemandSideMaxAvail += Node(demInNode).MassFlowRateMaxAvail; } - TmpRealARR = AirLoopConvergence(AirLoopNum).HVACFlowDemandToSupplyTolValue; - AirLoopConvergence(AirLoopNum).HVACFlowDemandToSupplyTolValue(1) = std::abs(totDemandSideMassFlow - Node(InletNode).MassFlowRate); - AirLoopConvergence(AirLoopNum).HVACFlowDemandToSupplyTolValue({2, ConvergLogStackDepth}) = TmpRealARR({1, ConvergLogStackDepth - 1}); - if (AirLoopConvergence(AirLoopNum).HVACFlowDemandToSupplyTolValue(1) > HVACFlowRateToler) { - AirLoopConvergence(AirLoopNum).HVACMassFlowNotConverged(1) = true; + TmpRealARR = state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACFlowDemandToSupplyTolValue; + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACFlowDemandToSupplyTolValue(1) = std::abs(totDemandSideMassFlow - Node(InletNode).MassFlowRate); + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACFlowDemandToSupplyTolValue({2, DataConvergParams::ConvergLogStackDepth}) = TmpRealARR({1, DataConvergParams::ConvergLogStackDepth - 1}); + if (state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACFlowDemandToSupplyTolValue(1) > DataConvergParams::HVACFlowRateToler) { + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACMassFlowNotConverged(1) = true; OutOfToleranceFlag = true; // Something has changed--resimulate the other side of the loop } @@ -181,186 +181,186 @@ namespace HVACInterfaceManager { // Calculate the approximate energy difference across interface for comparison DeltaEnergy = - HVACCpApprox * ((Node(OutletNode).MassFlowRate * Node(OutletNode).Temp) - (Node(InletNode).MassFlowRate * Node(InletNode).Temp)); - - if ((CalledFrom == CalledFromAirSystemDemandSide) && (OutletNode > 0)) { - - AirLoopConvergence(AirLoopNum).HVACMassFlowNotConverged(1) = false; - AirLoopConvergence(AirLoopNum).HVACHumRatNotConverged(1) = false; - AirLoopConvergence(AirLoopNum).HVACTempNotConverged(1) = false; - AirLoopConvergence(AirLoopNum).HVACEnergyNotConverged(1) = false; - AirLoopConvergence(AirLoopNum).HVACEnthalpyNotConverged(1) = false; - AirLoopConvergence(AirLoopNum).HVACPressureNotConverged(1) = false; - - TmpRealARR = AirLoopConvergence(AirLoopNum).HVACFlowDemandToSupplyTolValue; - AirLoopConvergence(AirLoopNum).HVACFlowDemandToSupplyTolValue(1) = std::abs(Node(OutletNode).MassFlowRate - Node(InletNode).MassFlowRate); - AirLoopConvergence(AirLoopNum).HVACFlowDemandToSupplyTolValue({2, ConvergLogStackDepth}) = TmpRealARR({1, ConvergLogStackDepth - 1}); - if (AirLoopConvergence(AirLoopNum).HVACFlowDemandToSupplyTolValue(1) > HVACFlowRateToler) { - AirLoopConvergence(AirLoopNum).HVACMassFlowNotConverged(1) = true; + DataConvergParams::HVACCpApprox * ((Node(OutletNode).MassFlowRate * Node(OutletNode).Temp) - (Node(InletNode).MassFlowRate * Node(InletNode).Temp)); + + if ((CalledFrom == DataConvergParams::iCalledFrom::AirSystemDemandSide) && (OutletNode > 0)) { + + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACMassFlowNotConverged(1) = false; + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACHumRatNotConverged(1) = false; + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACTempNotConverged(1) = false; + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACEnergyNotConverged(1) = false; + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACEnthalpyNotConverged(1) = false; + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACPressureNotConverged(1) = false; + + TmpRealARR = state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACFlowDemandToSupplyTolValue; + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACFlowDemandToSupplyTolValue(1) = std::abs(Node(OutletNode).MassFlowRate - Node(InletNode).MassFlowRate); + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACFlowDemandToSupplyTolValue({2, DataConvergParams::ConvergLogStackDepth}) = TmpRealARR({1, DataConvergParams::ConvergLogStackDepth - 1}); + if (state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACFlowDemandToSupplyTolValue(1) > DataConvergParams::HVACFlowRateToler) { + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACMassFlowNotConverged(1) = true; OutOfToleranceFlag = true; // Something has changed--resimulate the other side of the loop } - TmpRealARR = AirLoopConvergence(AirLoopNum).HVACHumDemandToSupplyTolValue; - AirLoopConvergence(AirLoopNum).HVACHumDemandToSupplyTolValue(1) = std::abs(Node(OutletNode).HumRat - Node(InletNode).HumRat); - AirLoopConvergence(AirLoopNum).HVACHumDemandToSupplyTolValue({2, ConvergLogStackDepth}) = TmpRealARR({1, ConvergLogStackDepth - 1}); - if (AirLoopConvergence(AirLoopNum).HVACHumDemandToSupplyTolValue(1) > HVACHumRatToler) { - AirLoopConvergence(AirLoopNum).HVACHumRatNotConverged(1) = true; + TmpRealARR = state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACHumDemandToSupplyTolValue; + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACHumDemandToSupplyTolValue(1) = std::abs(Node(OutletNode).HumRat - Node(InletNode).HumRat); + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACHumDemandToSupplyTolValue({2, DataConvergParams::ConvergLogStackDepth}) = TmpRealARR({1, DataConvergParams::ConvergLogStackDepth - 1}); + if (state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACHumDemandToSupplyTolValue(1) > DataConvergParams::HVACHumRatToler) { + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACHumRatNotConverged(1) = true; OutOfToleranceFlag = true; // Something has changed--resimulate the other side of the loop } - TmpRealARR = AirLoopConvergence(AirLoopNum).HVACTempDemandToSupplyTolValue; - AirLoopConvergence(AirLoopNum).HVACTempDemandToSupplyTolValue(1) = std::abs(Node(OutletNode).Temp - Node(InletNode).Temp); - AirLoopConvergence(AirLoopNum).HVACTempDemandToSupplyTolValue({2, ConvergLogStackDepth}) = TmpRealARR({1, ConvergLogStackDepth - 1}); - if (AirLoopConvergence(AirLoopNum).HVACTempDemandToSupplyTolValue(1) > HVACTemperatureToler) { - AirLoopConvergence(AirLoopNum).HVACTempNotConverged(1) = true; + TmpRealARR = state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACTempDemandToSupplyTolValue; + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACTempDemandToSupplyTolValue(1) = std::abs(Node(OutletNode).Temp - Node(InletNode).Temp); + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACTempDemandToSupplyTolValue({2, DataConvergParams::ConvergLogStackDepth}) = TmpRealARR({1, DataConvergParams::ConvergLogStackDepth - 1}); + if (state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACTempDemandToSupplyTolValue(1) > DataConvergParams::HVACTemperatureToler) { + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACTempNotConverged(1) = true; OutOfToleranceFlag = true; // Something has changed--resimulate the other side of the loop } - TmpRealARR = AirLoopConvergence(AirLoopNum).HVACEnergyDemandToSupplyTolValue; - AirLoopConvergence(AirLoopNum).HVACEnergyDemandToSupplyTolValue(1) = std::abs(DeltaEnergy); - AirLoopConvergence(AirLoopNum).HVACEnergyDemandToSupplyTolValue({2, ConvergLogStackDepth}) = TmpRealARR({1, ConvergLogStackDepth - 1}); - if (std::abs(DeltaEnergy) > HVACEnergyToler) { - AirLoopConvergence(AirLoopNum).HVACEnergyNotConverged(1) = true; + TmpRealARR = state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACEnergyDemandToSupplyTolValue; + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACEnergyDemandToSupplyTolValue(1) = std::abs(DeltaEnergy); + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACEnergyDemandToSupplyTolValue({2, DataConvergParams::ConvergLogStackDepth}) = TmpRealARR({1, DataConvergParams::ConvergLogStackDepth - 1}); + if (std::abs(DeltaEnergy) > DataConvergParams::HVACEnergyToler) { + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACEnergyNotConverged(1) = true; OutOfToleranceFlag = true; // Something has changed--resimulate the other side of the loop } - TmpRealARR = AirLoopConvergence(AirLoopNum).HVACEnthalpyDemandToSupplyTolValue; - AirLoopConvergence(AirLoopNum).HVACEnthalpyDemandToSupplyTolValue(1) = std::abs(Node(OutletNode).Enthalpy - Node(InletNode).Enthalpy); - AirLoopConvergence(AirLoopNum).HVACEnthalpyDemandToSupplyTolValue({2, ConvergLogStackDepth}) = TmpRealARR({1, ConvergLogStackDepth - 1}); - if (AirLoopConvergence(AirLoopNum).HVACEnthalpyDemandToSupplyTolValue(1) > HVACEnthalpyToler) { - AirLoopConvergence(AirLoopNum).HVACEnthalpyNotConverged(1) = true; + TmpRealARR = state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACEnthalpyDemandToSupplyTolValue; + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACEnthalpyDemandToSupplyTolValue(1) = std::abs(Node(OutletNode).Enthalpy - Node(InletNode).Enthalpy); + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACEnthalpyDemandToSupplyTolValue({2, DataConvergParams::ConvergLogStackDepth}) = TmpRealARR({1, DataConvergParams::ConvergLogStackDepth - 1}); + if (state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACEnthalpyDemandToSupplyTolValue(1) > DataConvergParams::HVACEnthalpyToler) { + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACEnthalpyNotConverged(1) = true; OutOfToleranceFlag = true; // Something has changed--resimulate the other side of the loop } - TmpRealARR = AirLoopConvergence(AirLoopNum).HVACPressureDemandToSupplyTolValue; - AirLoopConvergence(AirLoopNum).HVACPressureDemandToSupplyTolValue(1) = std::abs(Node(OutletNode).Press - Node(InletNode).Press); - AirLoopConvergence(AirLoopNum).HVACPressureDemandToSupplyTolValue({2, ConvergLogStackDepth}) = TmpRealARR({1, ConvergLogStackDepth - 1}); - if (AirLoopConvergence(AirLoopNum).HVACPressureDemandToSupplyTolValue(1) > HVACPressToler) { - AirLoopConvergence(AirLoopNum).HVACPressureNotConverged(1) = true; + TmpRealARR = state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACPressureDemandToSupplyTolValue; + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACPressureDemandToSupplyTolValue(1) = std::abs(Node(OutletNode).Press - Node(InletNode).Press); + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACPressureDemandToSupplyTolValue({2, DataConvergParams::ConvergLogStackDepth}) = TmpRealARR({1, DataConvergParams::ConvergLogStackDepth - 1}); + if (state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACPressureDemandToSupplyTolValue(1) > DataConvergParams::HVACPressToler) { + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACPressureNotConverged(1) = true; OutOfToleranceFlag = true; // Something has changed--resimulate the other side of the loop } - } else if (CalledFrom == CalledFromAirSystemSupplySideDeck1) { + } else if (CalledFrom == DataConvergParams::iCalledFrom::AirSystemSupplySideDeck1) { - AirLoopConvergence(AirLoopNum).HVACMassFlowNotConverged(2) = false; - AirLoopConvergence(AirLoopNum).HVACHumRatNotConverged(2) = false; - AirLoopConvergence(AirLoopNum).HVACTempNotConverged(2) = false; - AirLoopConvergence(AirLoopNum).HVACEnergyNotConverged(2) = false; - AirLoopConvergence(AirLoopNum).HVACEnthalpyNotConverged(2) = false; - AirLoopConvergence(AirLoopNum).HVACPressureNotConverged(2) = false; + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACMassFlowNotConverged(2) = false; + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACHumRatNotConverged(2) = false; + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACTempNotConverged(2) = false; + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACEnergyNotConverged(2) = false; + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACEnthalpyNotConverged(2) = false; + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACPressureNotConverged(2) = false; - TmpRealARR = AirLoopConvergence(AirLoopNum).HVACFlowSupplyDeck1ToDemandTolValue; - AirLoopConvergence(AirLoopNum).HVACFlowSupplyDeck1ToDemandTolValue(1) = + TmpRealARR = state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACFlowSupplyDeck1ToDemandTolValue; + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACFlowSupplyDeck1ToDemandTolValue(1) = std::abs(Node(OutletNode).MassFlowRate - Node(InletNode).MassFlowRate); - AirLoopConvergence(AirLoopNum).HVACFlowSupplyDeck1ToDemandTolValue({2, ConvergLogStackDepth}) = TmpRealARR({1, ConvergLogStackDepth - 1}); - if (AirLoopConvergence(AirLoopNum).HVACFlowSupplyDeck1ToDemandTolValue(1) > HVACFlowRateToler) { - AirLoopConvergence(AirLoopNum).HVACMassFlowNotConverged(2) = true; + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACFlowSupplyDeck1ToDemandTolValue({2, DataConvergParams::ConvergLogStackDepth}) = TmpRealARR({1, DataConvergParams::ConvergLogStackDepth - 1}); + if (state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACFlowSupplyDeck1ToDemandTolValue(1) > DataConvergParams::HVACFlowRateToler) { + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACMassFlowNotConverged(2) = true; OutOfToleranceFlag = true; // Something has changed--resimulate the other side of the loop } - TmpRealARR = AirLoopConvergence(AirLoopNum).HVACHumSupplyDeck1ToDemandTolValue; - AirLoopConvergence(AirLoopNum).HVACHumSupplyDeck1ToDemandTolValue(1) = std::abs(Node(OutletNode).HumRat - Node(InletNode).HumRat); - AirLoopConvergence(AirLoopNum).HVACHumSupplyDeck1ToDemandTolValue({2, ConvergLogStackDepth}) = TmpRealARR({1, ConvergLogStackDepth - 1}); - if (AirLoopConvergence(AirLoopNum).HVACHumSupplyDeck1ToDemandTolValue(1) > HVACHumRatToler) { - AirLoopConvergence(AirLoopNum).HVACHumRatNotConverged(2) = true; + TmpRealARR = state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACHumSupplyDeck1ToDemandTolValue; + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACHumSupplyDeck1ToDemandTolValue(1) = std::abs(Node(OutletNode).HumRat - Node(InletNode).HumRat); + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACHumSupplyDeck1ToDemandTolValue({2, DataConvergParams::ConvergLogStackDepth}) = TmpRealARR({1, DataConvergParams::ConvergLogStackDepth - 1}); + if (state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACHumSupplyDeck1ToDemandTolValue(1) > DataConvergParams::HVACHumRatToler) { + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACHumRatNotConverged(2) = true; OutOfToleranceFlag = true; // Something has changed--resimulate the other side of the loop } - TmpRealARR = AirLoopConvergence(AirLoopNum).HVACTempSupplyDeck1ToDemandTolValue; - AirLoopConvergence(AirLoopNum).HVACTempSupplyDeck1ToDemandTolValue(1) = std::abs(Node(OutletNode).Temp - Node(InletNode).Temp); - AirLoopConvergence(AirLoopNum).HVACTempSupplyDeck1ToDemandTolValue({2, ConvergLogStackDepth}) = TmpRealARR({1, ConvergLogStackDepth - 1}); - if (AirLoopConvergence(AirLoopNum).HVACTempSupplyDeck1ToDemandTolValue(1) > HVACTemperatureToler) { - AirLoopConvergence(AirLoopNum).HVACTempNotConverged(2) = true; + TmpRealARR = state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACTempSupplyDeck1ToDemandTolValue; + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACTempSupplyDeck1ToDemandTolValue(1) = std::abs(Node(OutletNode).Temp - Node(InletNode).Temp); + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACTempSupplyDeck1ToDemandTolValue({2, DataConvergParams::ConvergLogStackDepth}) = TmpRealARR({1, DataConvergParams::ConvergLogStackDepth - 1}); + if (state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACTempSupplyDeck1ToDemandTolValue(1) > DataConvergParams::HVACTemperatureToler) { + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACTempNotConverged(2) = true; OutOfToleranceFlag = true; // Something has changed--resimulate the other side of the loop } - TmpRealARR = AirLoopConvergence(AirLoopNum).HVACEnergySupplyDeck1ToDemandTolValue; - AirLoopConvergence(AirLoopNum).HVACEnergySupplyDeck1ToDemandTolValue(1) = DeltaEnergy; - AirLoopConvergence(AirLoopNum).HVACEnergySupplyDeck1ToDemandTolValue({2, ConvergLogStackDepth}) = - TmpRealARR({1, ConvergLogStackDepth - 1}); - if (std::abs(DeltaEnergy) > HVACEnergyToler) { - AirLoopConvergence(AirLoopNum).HVACEnergyNotConverged(2) = true; + TmpRealARR = state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACEnergySupplyDeck1ToDemandTolValue; + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACEnergySupplyDeck1ToDemandTolValue(1) = DeltaEnergy; + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACEnergySupplyDeck1ToDemandTolValue({2, DataConvergParams::ConvergLogStackDepth}) = + TmpRealARR({1, DataConvergParams::ConvergLogStackDepth - 1}); + if (std::abs(DeltaEnergy) > DataConvergParams::HVACEnergyToler) { + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACEnergyNotConverged(2) = true; OutOfToleranceFlag = true; // Something has changed--resimulate the other side of the loop } - TmpRealARR = AirLoopConvergence(AirLoopNum).HVACEnthalpySupplyDeck1ToDemandTolValue; - AirLoopConvergence(AirLoopNum).HVACEnthalpySupplyDeck1ToDemandTolValue(1) = + TmpRealARR = state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACEnthalpySupplyDeck1ToDemandTolValue; + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACEnthalpySupplyDeck1ToDemandTolValue(1) = std::abs(Node(OutletNode).Enthalpy - Node(InletNode).Enthalpy); - AirLoopConvergence(AirLoopNum).HVACEnthalpySupplyDeck1ToDemandTolValue({2, ConvergLogStackDepth}) = - TmpRealARR({1, ConvergLogStackDepth - 1}); - if (AirLoopConvergence(AirLoopNum).HVACEnthalpySupplyDeck1ToDemandTolValue(1) > HVACEnthalpyToler) { - AirLoopConvergence(AirLoopNum).HVACEnthalpyNotConverged(2) = true; + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACEnthalpySupplyDeck1ToDemandTolValue({2, DataConvergParams::ConvergLogStackDepth}) = + TmpRealARR({1, DataConvergParams::ConvergLogStackDepth - 1}); + if (state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACEnthalpySupplyDeck1ToDemandTolValue(1) > DataConvergParams::HVACEnthalpyToler) { + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACEnthalpyNotConverged(2) = true; OutOfToleranceFlag = true; // Something has changed--resimulate the other side of the loop } - TmpRealARR = AirLoopConvergence(AirLoopNum).HVACPressureSupplyDeck1ToDemandTolValue; - AirLoopConvergence(AirLoopNum).HVACPressureSupplyDeck1ToDemandTolValue(1) = std::abs(Node(OutletNode).Press - Node(InletNode).Press); - AirLoopConvergence(AirLoopNum).HVACPressureSupplyDeck1ToDemandTolValue({2, ConvergLogStackDepth}) = - TmpRealARR({1, ConvergLogStackDepth - 1}); - if (AirLoopConvergence(AirLoopNum).HVACPressureSupplyDeck1ToDemandTolValue(1) > HVACPressToler) { - AirLoopConvergence(AirLoopNum).HVACPressureNotConverged(2) = true; + TmpRealARR = state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACPressureSupplyDeck1ToDemandTolValue; + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACPressureSupplyDeck1ToDemandTolValue(1) = std::abs(Node(OutletNode).Press - Node(InletNode).Press); + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACPressureSupplyDeck1ToDemandTolValue({2, DataConvergParams::ConvergLogStackDepth}) = + TmpRealARR({1, DataConvergParams::ConvergLogStackDepth - 1}); + if (state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACPressureSupplyDeck1ToDemandTolValue(1) > DataConvergParams::HVACPressToler) { + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACPressureNotConverged(2) = true; OutOfToleranceFlag = true; // Something has changed--resimulate the other side of the loop } - } else if (CalledFrom == CalledFromAirSystemSupplySideDeck2) { + } else if (CalledFrom == DataConvergParams::iCalledFrom::AirSystemSupplySideDeck2) { - AirLoopConvergence(AirLoopNum).HVACMassFlowNotConverged(3) = false; - AirLoopConvergence(AirLoopNum).HVACHumRatNotConverged(3) = false; - AirLoopConvergence(AirLoopNum).HVACTempNotConverged(3) = false; - AirLoopConvergence(AirLoopNum).HVACEnergyNotConverged(3) = false; - AirLoopConvergence(AirLoopNum).HVACEnthalpyNotConverged(3) = false; - AirLoopConvergence(AirLoopNum).HVACPressureNotConverged(3) = false; + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACMassFlowNotConverged(3) = false; + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACHumRatNotConverged(3) = false; + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACTempNotConverged(3) = false; + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACEnergyNotConverged(3) = false; + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACEnthalpyNotConverged(3) = false; + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACPressureNotConverged(3) = false; - TmpRealARR = AirLoopConvergence(AirLoopNum).HVACFlowSupplyDeck2ToDemandTolValue; - AirLoopConvergence(AirLoopNum).HVACFlowSupplyDeck2ToDemandTolValue(1) = + TmpRealARR = state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACFlowSupplyDeck2ToDemandTolValue; + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACFlowSupplyDeck2ToDemandTolValue(1) = std::abs(Node(OutletNode).MassFlowRate - Node(InletNode).MassFlowRate); - AirLoopConvergence(AirLoopNum).HVACFlowSupplyDeck2ToDemandTolValue({2, ConvergLogStackDepth}) = TmpRealARR({1, ConvergLogStackDepth - 1}); - if (AirLoopConvergence(AirLoopNum).HVACFlowSupplyDeck2ToDemandTolValue(1) > HVACFlowRateToler) { - AirLoopConvergence(AirLoopNum).HVACMassFlowNotConverged(3) = true; + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACFlowSupplyDeck2ToDemandTolValue({2, DataConvergParams::ConvergLogStackDepth}) = TmpRealARR({1, DataConvergParams::ConvergLogStackDepth - 1}); + if (state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACFlowSupplyDeck2ToDemandTolValue(1) > DataConvergParams::HVACFlowRateToler) { + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACMassFlowNotConverged(3) = true; OutOfToleranceFlag = true; // Something has changed--resimulate the other side of the loop } - TmpRealARR = AirLoopConvergence(AirLoopNum).HVACHumSupplyDeck2ToDemandTolValue; - AirLoopConvergence(AirLoopNum).HVACHumSupplyDeck2ToDemandTolValue(1) = std::abs(Node(OutletNode).HumRat - Node(InletNode).HumRat); - AirLoopConvergence(AirLoopNum).HVACHumSupplyDeck2ToDemandTolValue({2, ConvergLogStackDepth}) = TmpRealARR({1, ConvergLogStackDepth - 1}); - if (AirLoopConvergence(AirLoopNum).HVACHumSupplyDeck2ToDemandTolValue(1) > HVACHumRatToler) { - AirLoopConvergence(AirLoopNum).HVACHumRatNotConverged(3) = true; + TmpRealARR = state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACHumSupplyDeck2ToDemandTolValue; + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACHumSupplyDeck2ToDemandTolValue(1) = std::abs(Node(OutletNode).HumRat - Node(InletNode).HumRat); + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACHumSupplyDeck2ToDemandTolValue({2, DataConvergParams::ConvergLogStackDepth}) = TmpRealARR({1, DataConvergParams::ConvergLogStackDepth - 1}); + if (state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACHumSupplyDeck2ToDemandTolValue(1) > DataConvergParams::HVACHumRatToler) { + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACHumRatNotConverged(3) = true; OutOfToleranceFlag = true; // Something has changed--resimulate the other side of the loop } - TmpRealARR = AirLoopConvergence(AirLoopNum).HVACTempSupplyDeck2ToDemandTolValue; - AirLoopConvergence(AirLoopNum).HVACTempSupplyDeck2ToDemandTolValue(1) = std::abs(Node(OutletNode).Temp - Node(InletNode).Temp); - AirLoopConvergence(AirLoopNum).HVACTempSupplyDeck2ToDemandTolValue({2, ConvergLogStackDepth}) = TmpRealARR({1, ConvergLogStackDepth - 1}); - if (AirLoopConvergence(AirLoopNum).HVACTempSupplyDeck2ToDemandTolValue(1) > HVACTemperatureToler) { - AirLoopConvergence(AirLoopNum).HVACTempNotConverged(3) = true; + TmpRealARR = state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACTempSupplyDeck2ToDemandTolValue; + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACTempSupplyDeck2ToDemandTolValue(1) = std::abs(Node(OutletNode).Temp - Node(InletNode).Temp); + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACTempSupplyDeck2ToDemandTolValue({2, DataConvergParams::ConvergLogStackDepth}) = TmpRealARR({1, DataConvergParams::ConvergLogStackDepth - 1}); + if (state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACTempSupplyDeck2ToDemandTolValue(1) > DataConvergParams::HVACTemperatureToler) { + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACTempNotConverged(3) = true; OutOfToleranceFlag = true; // Something has changed--resimulate the other side of the loop } - TmpRealARR = AirLoopConvergence(AirLoopNum).HVACEnergySupplyDeck2ToDemandTolValue; - AirLoopConvergence(AirLoopNum).HVACEnergySupplyDeck2ToDemandTolValue(1) = DeltaEnergy; - AirLoopConvergence(AirLoopNum).HVACEnergySupplyDeck2ToDemandTolValue({2, ConvergLogStackDepth}) = - TmpRealARR({1, ConvergLogStackDepth - 1}); - if (std::abs(DeltaEnergy) > HVACEnergyToler) { - AirLoopConvergence(AirLoopNum).HVACEnergyNotConverged(3) = true; + TmpRealARR = state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACEnergySupplyDeck2ToDemandTolValue; + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACEnergySupplyDeck2ToDemandTolValue(1) = DeltaEnergy; + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACEnergySupplyDeck2ToDemandTolValue({2, DataConvergParams::ConvergLogStackDepth}) = + TmpRealARR({1, DataConvergParams::ConvergLogStackDepth - 1}); + if (std::abs(DeltaEnergy) > DataConvergParams::HVACEnergyToler) { + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACEnergyNotConverged(3) = true; OutOfToleranceFlag = true; // Something has changed--resimulate the other side of the loop } - TmpRealARR = AirLoopConvergence(AirLoopNum).HVACEnthalpySupplyDeck2ToDemandTolValue; - AirLoopConvergence(AirLoopNum).HVACEnthalpySupplyDeck2ToDemandTolValue(1) = + TmpRealARR = state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACEnthalpySupplyDeck2ToDemandTolValue; + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACEnthalpySupplyDeck2ToDemandTolValue(1) = std::abs(Node(OutletNode).Enthalpy - Node(InletNode).Enthalpy); - AirLoopConvergence(AirLoopNum).HVACEnthalpySupplyDeck2ToDemandTolValue({2, ConvergLogStackDepth}) = - TmpRealARR({1, ConvergLogStackDepth - 1}); - if (AirLoopConvergence(AirLoopNum).HVACEnthalpySupplyDeck2ToDemandTolValue(1) > HVACEnthalpyToler) { - AirLoopConvergence(AirLoopNum).HVACEnthalpyNotConverged(3) = true; + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACEnthalpySupplyDeck2ToDemandTolValue({2, DataConvergParams::ConvergLogStackDepth}) = + TmpRealARR({1, DataConvergParams::ConvergLogStackDepth - 1}); + if (state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACEnthalpySupplyDeck2ToDemandTolValue(1) > DataConvergParams::HVACEnthalpyToler) { + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACEnthalpyNotConverged(3) = true; OutOfToleranceFlag = true; // Something has changed--resimulate the other side of the loop } - TmpRealARR = AirLoopConvergence(AirLoopNum).HVACPressueSupplyDeck2ToDemandTolValue; - AirLoopConvergence(AirLoopNum).HVACPressueSupplyDeck2ToDemandTolValue(1) = std::abs(Node(OutletNode).Press - Node(InletNode).Press); - AirLoopConvergence(AirLoopNum).HVACPressueSupplyDeck2ToDemandTolValue({2, ConvergLogStackDepth}) = - TmpRealARR({1, ConvergLogStackDepth - 1}); - if (AirLoopConvergence(AirLoopNum).HVACPressueSupplyDeck2ToDemandTolValue(1) > HVACPressToler) { - AirLoopConvergence(AirLoopNum).HVACPressureNotConverged(3) = true; + TmpRealARR = state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACPressueSupplyDeck2ToDemandTolValue; + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACPressueSupplyDeck2ToDemandTolValue(1) = std::abs(Node(OutletNode).Press - Node(InletNode).Press); + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACPressueSupplyDeck2ToDemandTolValue({2, DataConvergParams::ConvergLogStackDepth}) = + TmpRealARR({1, DataConvergParams::ConvergLogStackDepth - 1}); + if (state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACPressueSupplyDeck2ToDemandTolValue(1) > DataConvergParams::HVACPressToler) { + state.dataConvergeParams->AirLoopConvergence(AirLoopNum).HVACPressureNotConverged(3) = true; OutOfToleranceFlag = true; // Something has changed--resimulate the other side of the loop } } @@ -458,7 +458,7 @@ namespace HVACInterfaceManager { // FLOW: - auto &convergence(PlantConvergence(LoopNum)); + auto &convergence(state.dataConvergeParams->PlantConvergence(LoopNum)); // reset out of tolerance flags convergence.PlantMassFlowNotConverged = false; @@ -488,13 +488,13 @@ namespace HVACInterfaceManager { if (ThisLoopSideNum == DemandSide) { rshift1(flow_demand_to_supply_tol); flow_demand_to_supply_tol(1) = std::abs(OldOtherLoopSideInletMdot - Node(OtherLoopSideInletNode).MassFlowRate); - if (flow_demand_to_supply_tol(1) > PlantFlowRateToler) { + if (flow_demand_to_supply_tol(1) > DataConvergParams::PlantFlowRateToler) { convergence.PlantMassFlowNotConverged = true; } } else { rshift1(flow_supply_to_demand_tol); flow_supply_to_demand_tol(1) = std::abs(OldOtherLoopSideInletMdot - Node(OtherLoopSideInletNode).MassFlowRate); - if (flow_supply_to_demand_tol(1) > PlantFlowRateToler) { + if (flow_supply_to_demand_tol(1) > DataConvergParams::PlantFlowRateToler) { convergence.PlantMassFlowNotConverged = true; } } @@ -512,13 +512,13 @@ namespace HVACInterfaceManager { if (ThisLoopSideNum == DemandSide) { rshift1(flow_demand_to_supply_tol); flow_demand_to_supply_tol(1) = std::abs(Node(ThisLoopSideOutletNode).MassFlowRate - Node(OtherLoopSideInletNode).MassFlowRate); - if (flow_demand_to_supply_tol(1) > PlantFlowRateToler) { + if (flow_demand_to_supply_tol(1) > DataConvergParams::PlantFlowRateToler) { convergence.PlantMassFlowNotConverged = true; } } else { rshift1(flow_supply_to_demand_tol); flow_supply_to_demand_tol(1) = std::abs(Node(ThisLoopSideOutletNode).MassFlowRate - Node(OtherLoopSideInletNode).MassFlowRate); - if (flow_supply_to_demand_tol(1) > PlantFlowRateToler) { + if (flow_supply_to_demand_tol(1) > DataConvergParams::PlantFlowRateToler) { convergence.PlantMassFlowNotConverged = true; } } @@ -544,14 +544,14 @@ namespace HVACInterfaceManager { auto &temp_demand_to_supply_tol(convergence.PlantTempDemandToSupplyTolValue); rshift1(temp_demand_to_supply_tol); temp_demand_to_supply_tol(1) = std::abs(OldTankOutletTemp - Node(OtherLoopSideInletNode).Temp); - if (temp_demand_to_supply_tol(1) > PlantTemperatureToler) { + if (temp_demand_to_supply_tol(1) > DataConvergParams::PlantTemperatureToler) { convergence.PlantTempNotConverged = true; } } else { auto &temp_supply_to_demand_tol(convergence.PlantTempSupplyToDemandTolValue); rshift1(temp_supply_to_demand_tol); temp_supply_to_demand_tol(1) = std::abs(OldTankOutletTemp - Node(OtherLoopSideInletNode).Temp); - if (temp_supply_to_demand_tol(1) > PlantTemperatureToler) { + if (temp_supply_to_demand_tol(1) > DataConvergParams::PlantTemperatureToler) { convergence.PlantTempNotConverged = true; } } diff --git a/src/EnergyPlus/HVACInterfaceManager.hh b/src/EnergyPlus/HVACInterfaceManager.hh index d96d28cdb37..aee072f092a 100644 --- a/src/EnergyPlus/HVACInterfaceManager.hh +++ b/src/EnergyPlus/HVACInterfaceManager.hh @@ -52,6 +52,7 @@ #include // EnergyPlus Headers +#include #include namespace EnergyPlus { @@ -123,7 +124,7 @@ namespace HVACInterfaceManager { void UpdateHVACInterface(EnergyPlusData &state, int const AirLoopNum, // airloop number for which air loop this is - int const CalledFrom, + DataConvergParams::iCalledFrom const CalledFrom, int const OutletNode, // Node number for the outlet of the side of the loop just simulated int const InletNode, // Node number for the inlet of the side that needs the outlet node data bool &OutOfToleranceFlag // True when the other side of the loop need to be (re)simulated diff --git a/src/EnergyPlus/HVACManager.cc b/src/EnergyPlus/HVACManager.cc index 77bdd05152a..faa73ccb430 100644 --- a/src/EnergyPlus/HVACManager.cc +++ b/src/EnergyPlus/HVACManager.cc @@ -213,10 +213,6 @@ namespace HVACManager { // REFERENCES: // Using/Aliasing - using DataConvergParams::MaxZoneTempDiff; - using DataConvergParams::MinTimeStepSys; // =0.0166667 != 1 minute | 0.3 C = (1% OF 300 C) =max allowable diff between ZoneAirTemp at - // Time=T & T-1 - using ZoneTempPredictorCorrector::DetectOscillatingZoneTemp; using ZoneTempPredictorCorrector::ManageZoneAirUpdates; @@ -381,14 +377,14 @@ namespace HVACManager { ManageZoneAirUpdates(state, iCorrectStep, ZoneTempChange, ShortenTimeStepSys, UseZoneTimeStepHistory, PriorTimeStep); if (state.dataContaminantBalance->Contaminant.SimulateContaminants) ManageZoneContaminanUpdates(state, iCorrectStep, ShortenTimeStepSys, UseZoneTimeStepHistory, PriorTimeStep); - if (ZoneTempChange > MaxZoneTempDiff && !state.dataGlobal->KickOffSimulation) { + if (ZoneTempChange > state.dataConvergeParams->MaxZoneTempDiff && !state.dataGlobal->KickOffSimulation) { // determine value of adaptive system time step // model how many system timesteps we want in zone timestep - ZTempTrendsNumSysSteps = int(ZoneTempChange / MaxZoneTempDiff + 1.0); // add 1 for truncation + ZTempTrendsNumSysSteps = int(ZoneTempChange / state.dataConvergeParams->MaxZoneTempDiff + 1.0); // add 1 for truncation NumOfSysTimeSteps = min(ZTempTrendsNumSysSteps, LimitNumSysSteps); // then determine timestep length for even distribution, protect div by zero if (NumOfSysTimeSteps > 0) TimeStepSys = state.dataGlobal->TimeStepZone / NumOfSysTimeSteps; - TimeStepSys = max(TimeStepSys, MinTimeStepSys); + TimeStepSys = max(TimeStepSys, state.dataConvergeParams->MinTimeStepSys); UseZoneTimeStepHistory = false; ShortenTimeStepSys = true; } else { @@ -660,7 +656,6 @@ namespace HVACManager { // REFERENCES: none // Using/Aliasing - using namespace DataConvergParams; using DataEnvironment::CurMnDy; using DataEnvironment::EnvironmentName; using DataPlant::ConvergenceHistoryARR; @@ -730,6 +725,11 @@ namespace HVACManager { bool MonotonicIncreaseFound; bool MonotonicDecreaseFound; + Array1D const ConvergLogStackARR(DataConvergParams::ConvergLogStackDepth, {0.0, -1.0, -2.0, -3.0, -4.0, -5.0, -6.0, -7.0, -8.0, -9.0}); + Real64 const sum_ConvergLogStackARR(sum(ConvergLogStackARR)); + Real64 const square_sum_ConvergLogStackARR(pow_2(sum_ConvergLogStackARR)); + Real64 const sum_square_ConvergLogStackARR(sum(pow(ConvergLogStackARR, 2))); + // Initialize all of the simulation flags to true for the first iteration SimZoneEquipmentFlag = true; SimNonZoneEquipmentFlag = true; @@ -861,7 +861,7 @@ namespace HVACManager { // Main iteration loop for HVAC. If any of the simulation flags are // true, then specific components must be resimulated. while ((SimAirLoopsFlag || SimZoneEquipmentFlag || SimNonZoneEquipmentFlag || SimPlantLoopsFlag || SimElecCircuitsFlag) && - (HVACManageIteration <= MaxIter)) { + (HVACManageIteration <= state.dataConvergeParams->MaxIter)) { if (state.dataGlobal->stopSimulation) break; @@ -961,13 +961,13 @@ namespace HVACManager { } } - if ((HVACManageIteration > MaxIter) && (!state.dataGlobal->WarmupFlag)) { + if ((HVACManageIteration > state.dataConvergeParams->MaxIter) && (!state.dataGlobal->WarmupFlag)) { ++ErrCount; if (ErrCount < 15) { ErrEnvironmentName = EnvironmentName; ShowWarningError(state, format("SimHVAC: Maximum iterations ({}) exceeded for all HVAC loops, at {}, {} {}", - MaxIter, + state.dataConvergeParams->MaxIter, EnvironmentName, CurMnDy, CreateSysTimeIntervalString(state))); @@ -993,105 +993,105 @@ namespace HVACManager { for (AirSysNum = 1; AirSysNum <= NumPrimaryAirSys; ++AirSysNum) { - if (any(AirLoopConvergence(AirSysNum).HVACMassFlowNotConverged)) { + if (any(state.dataConvergeParams->AirLoopConvergence(AirSysNum).HVACMassFlowNotConverged)) { ShowContinueError(state, "Air System Named = " + state.dataAirLoop->AirToZoneNodeInfo(AirSysNum).AirLoopName + " did not converge for mass flow rate"); ShowContinueError(state, "Check values should be zero. Most Recent values listed first."); HistoryTrace = ""; - for (StackDepth = 1; StackDepth <= ConvergLogStackDepth; ++StackDepth) { - HistoryTrace += format("{:.6R},", AirLoopConvergence(AirSysNum).HVACFlowDemandToSupplyTolValue(StackDepth)); + for (StackDepth = 1; StackDepth <= DataConvergParams::ConvergLogStackDepth; ++StackDepth) { + HistoryTrace += format("{:.6R},", state.dataConvergeParams->AirLoopConvergence(AirSysNum).HVACFlowDemandToSupplyTolValue(StackDepth)); } ShowContinueError(state, "Demand-to-Supply interface mass flow rate check value iteration history trace: " + HistoryTrace); HistoryTrace = ""; - for (StackDepth = 1; StackDepth <= ConvergLogStackDepth; ++StackDepth) { - HistoryTrace += format("{:.6R},", AirLoopConvergence(AirSysNum).HVACFlowSupplyDeck1ToDemandTolValue(StackDepth)); + for (StackDepth = 1; StackDepth <= DataConvergParams::ConvergLogStackDepth; ++StackDepth) { + HistoryTrace += format("{:.6R},", state.dataConvergeParams->AirLoopConvergence(AirSysNum).HVACFlowSupplyDeck1ToDemandTolValue(StackDepth)); } ShowContinueError(state, "Supply-to-demand interface deck 1 mass flow rate check value iteration history trace: " + HistoryTrace); if (state.dataAirLoop->AirToZoneNodeInfo(AirSysNum).NumSupplyNodes >= 2) { HistoryTrace = ""; - for (StackDepth = 1; StackDepth <= ConvergLogStackDepth; ++StackDepth) { - HistoryTrace += format("{:.6R},", AirLoopConvergence(AirSysNum).HVACFlowSupplyDeck2ToDemandTolValue(StackDepth)); + for (StackDepth = 1; StackDepth <= DataConvergParams::ConvergLogStackDepth; ++StackDepth) { + HistoryTrace += format("{:.6R},", state.dataConvergeParams->AirLoopConvergence(AirSysNum).HVACFlowSupplyDeck2ToDemandTolValue(StackDepth)); } ShowContinueError(state, "Supply-to-demand interface deck 2 mass flow rate check value iteration history trace: " + HistoryTrace); } } // mass flow rate not converged - if (any(AirLoopConvergence(AirSysNum).HVACHumRatNotConverged)) { + if (any(state.dataConvergeParams->AirLoopConvergence(AirSysNum).HVACHumRatNotConverged)) { ShowContinueError(state, "Air System Named = " + state.dataAirLoop->AirToZoneNodeInfo(AirSysNum).AirLoopName + " did not converge for humidity ratio"); ShowContinueError(state, "Check values should be zero. Most Recent values listed first."); HistoryTrace = ""; - for (StackDepth = 1; StackDepth <= ConvergLogStackDepth; ++StackDepth) { - HistoryTrace += format("{:.6R},", AirLoopConvergence(AirSysNum).HVACHumDemandToSupplyTolValue(StackDepth)); + for (StackDepth = 1; StackDepth <= DataConvergParams::ConvergLogStackDepth; ++StackDepth) { + HistoryTrace += format("{:.6R},", state.dataConvergeParams->AirLoopConvergence(AirSysNum).HVACHumDemandToSupplyTolValue(StackDepth)); } ShowContinueError(state, "Demand-to-Supply interface humidity ratio check value iteration history trace: " + HistoryTrace); HistoryTrace = ""; - for (StackDepth = 1; StackDepth <= ConvergLogStackDepth; ++StackDepth) { - HistoryTrace += format("{:.6R},", AirLoopConvergence(AirSysNum).HVACHumSupplyDeck1ToDemandTolValue(StackDepth)); + for (StackDepth = 1; StackDepth <= DataConvergParams::ConvergLogStackDepth; ++StackDepth) { + HistoryTrace += format("{:.6R},", state.dataConvergeParams->AirLoopConvergence(AirSysNum).HVACHumSupplyDeck1ToDemandTolValue(StackDepth)); } ShowContinueError(state, "Supply-to-demand interface deck 1 humidity ratio check value iteration history trace: " + HistoryTrace); if (state.dataAirLoop->AirToZoneNodeInfo(AirSysNum).NumSupplyNodes >= 2) { HistoryTrace = ""; - for (StackDepth = 1; StackDepth <= ConvergLogStackDepth; ++StackDepth) { - HistoryTrace += format("{:.6R},", AirLoopConvergence(AirSysNum).HVACHumSupplyDeck2ToDemandTolValue(StackDepth)); + for (StackDepth = 1; StackDepth <= DataConvergParams::ConvergLogStackDepth; ++StackDepth) { + HistoryTrace += format("{:.6R},", state.dataConvergeParams->AirLoopConvergence(AirSysNum).HVACHumSupplyDeck2ToDemandTolValue(StackDepth)); } ShowContinueError(state, "Supply-to-demand interface deck 2 humidity ratio check value iteration history trace: " + HistoryTrace); } } // humidity ratio not converged - if (any(AirLoopConvergence(AirSysNum).HVACTempNotConverged)) { + if (any(state.dataConvergeParams->AirLoopConvergence(AirSysNum).HVACTempNotConverged)) { ShowContinueError(state, "Air System Named = " + state.dataAirLoop->AirToZoneNodeInfo(AirSysNum).AirLoopName + " did not converge for temperature"); ShowContinueError(state, "Check values should be zero. Most Recent values listed first."); HistoryTrace = ""; - for (StackDepth = 1; StackDepth <= ConvergLogStackDepth; ++StackDepth) { - HistoryTrace += format("{:.6R},", AirLoopConvergence(AirSysNum).HVACTempDemandToSupplyTolValue(StackDepth)); + for (StackDepth = 1; StackDepth <= DataConvergParams::ConvergLogStackDepth; ++StackDepth) { + HistoryTrace += format("{:.6R},", state.dataConvergeParams->AirLoopConvergence(AirSysNum).HVACTempDemandToSupplyTolValue(StackDepth)); } ShowContinueError(state, "Demand-to-Supply interface temperature check value iteration history trace: " + HistoryTrace); HistoryTrace = ""; - for (StackDepth = 1; StackDepth <= ConvergLogStackDepth; ++StackDepth) { - HistoryTrace += format("{:.6R},", AirLoopConvergence(AirSysNum).HVACTempSupplyDeck1ToDemandTolValue(StackDepth)); + for (StackDepth = 1; StackDepth <= DataConvergParams::ConvergLogStackDepth; ++StackDepth) { + HistoryTrace += format("{:.6R},", state.dataConvergeParams->AirLoopConvergence(AirSysNum).HVACTempSupplyDeck1ToDemandTolValue(StackDepth)); } ShowContinueError(state, "Supply-to-demand interface deck 1 temperature check value iteration history trace: " + HistoryTrace); if (state.dataAirLoop->AirToZoneNodeInfo(AirSysNum).NumSupplyNodes >= 2) { HistoryTrace = ""; - for (StackDepth = 1; StackDepth <= ConvergLogStackDepth; ++StackDepth) { - HistoryTrace += format("{:.6R},", AirLoopConvergence(AirSysNum).HVACTempSupplyDeck1ToDemandTolValue(StackDepth)); + for (StackDepth = 1; StackDepth <= DataConvergParams::ConvergLogStackDepth; ++StackDepth) { + HistoryTrace += format("{:.6R},", state.dataConvergeParams->AirLoopConvergence(AirSysNum).HVACTempSupplyDeck1ToDemandTolValue(StackDepth)); } ShowContinueError(state, "Supply-to-demand interface deck 2 temperature check value iteration history trace: " + HistoryTrace); } } // Temps not converged - if (any(AirLoopConvergence(AirSysNum).HVACEnergyNotConverged)) { + if (any(state.dataConvergeParams->AirLoopConvergence(AirSysNum).HVACEnergyNotConverged)) { ShowContinueError(state, "Air System Named = " + state.dataAirLoop->AirToZoneNodeInfo(AirSysNum).AirLoopName + " did not converge for energy"); ShowContinueError(state, "Check values should be zero. Most Recent values listed first."); HistoryTrace = ""; - for (StackDepth = 1; StackDepth <= ConvergLogStackDepth; ++StackDepth) { - HistoryTrace += format("{:.6R},", AirLoopConvergence(AirSysNum).HVACEnergyDemandToSupplyTolValue(StackDepth)); + for (StackDepth = 1; StackDepth <= DataConvergParams::ConvergLogStackDepth; ++StackDepth) { + HistoryTrace += format("{:.6R},", state.dataConvergeParams->AirLoopConvergence(AirSysNum).HVACEnergyDemandToSupplyTolValue(StackDepth)); } ShowContinueError(state, "Demand-to-Supply interface energy check value iteration history trace: " + HistoryTrace); HistoryTrace = ""; - for (StackDepth = 1; StackDepth <= ConvergLogStackDepth; ++StackDepth) { - HistoryTrace += format("{:.6R},", AirLoopConvergence(AirSysNum).HVACEnergySupplyDeck1ToDemandTolValue(StackDepth)); + for (StackDepth = 1; StackDepth <= DataConvergParams::ConvergLogStackDepth; ++StackDepth) { + HistoryTrace += format("{:.6R},", state.dataConvergeParams->AirLoopConvergence(AirSysNum).HVACEnergySupplyDeck1ToDemandTolValue(StackDepth)); } ShowContinueError(state, "Supply-to-demand interface deck 1 energy check value iteration history trace: " + HistoryTrace); if (state.dataAirLoop->AirToZoneNodeInfo(AirSysNum).NumSupplyNodes >= 2) { HistoryTrace = ""; - for (StackDepth = 1; StackDepth <= ConvergLogStackDepth; ++StackDepth) { + for (StackDepth = 1; StackDepth <= DataConvergParams::ConvergLogStackDepth; ++StackDepth) { HistoryTrace += - format("{:.6R},", AirLoopConvergence(AirSysNum).HVACEnergySupplyDeck2ToDemandTolValue(StackDepth)); + format("{:.6R},", state.dataConvergeParams->AirLoopConvergence(AirSysNum).HVACEnergySupplyDeck2ToDemandTolValue(StackDepth)); } ShowContinueError(state, "Supply-to-demand interface deck 2 energy check value iteration history trace: " + HistoryTrace); } @@ -1102,42 +1102,42 @@ namespace HVACManager { // loop over zones and check for issues with zone inlet nodes for (ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ++ZoneNum) { - for (NodeIndex = 1; NodeIndex <= ZoneInletConvergence(ZoneNum).NumInletNodes; ++NodeIndex) { + for (NodeIndex = 1; NodeIndex <= state.dataConvergeParams->ZoneInletConvergence(ZoneNum).NumInletNodes; ++NodeIndex) { // Check humidity ratio FoundOscillationByDuplicate = false; MonotonicDecreaseFound = false; MonotonicIncreaseFound = false; - // check for evidence of oscillation by indentify duplicates when latest value not equal to average - AvgValue = sum(ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).HumidityRatio) / double(ConvergLogStackDepth); - if (std::abs(ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).HumidityRatio(1) - AvgValue) > - HVACHumRatOscillationToler) { // last iterate differs from average + // check for evidence of oscillation by identifying duplicates when latest value not equal to average + AvgValue = sum(state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).HumidityRatio) / double(DataConvergParams::ConvergLogStackDepth); + if (std::abs(state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).HumidityRatio(1) - AvgValue) > + DataConvergParams::HVACHumRatOscillationToler) { // last iterate differs from average FoundOscillationByDuplicate = false; - for (StackDepth = 2; StackDepth <= ConvergLogStackDepth; ++StackDepth) { - if (std::abs(ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).HumidityRatio(1) - - ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).HumidityRatio(StackDepth)) < - HVACHumRatOscillationToler) { + for (StackDepth = 2; StackDepth <= DataConvergParams::ConvergLogStackDepth; ++StackDepth) { + if (std::abs(state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).HumidityRatio(1) - + state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).HumidityRatio(StackDepth)) < + DataConvergParams::HVACHumRatOscillationToler) { FoundOscillationByDuplicate = true; ShowContinueError( state, format("Node named {} shows oscillating humidity ratio across iterations with a repeated value of {:.6R}", - NodeID(ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).NodeNum), - ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).HumidityRatio(1))); + NodeID(state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).NodeNum), + state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).HumidityRatio(1))); break; } } if (!FoundOscillationByDuplicate) { - SlopeHumRat = (sum_ConvergLogStackARR * sum(ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).HumidityRatio) - - double(ConvergLogStackDepth) * - sum((ConvergLogStackARR * ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).HumidityRatio))) / - (square_sum_ConvergLogStackARR - double(ConvergLogStackDepth) * sum_square_ConvergLogStackARR); - if (std::abs(SlopeHumRat) > HVACHumRatSlopeToler) { + SlopeHumRat = (sum_ConvergLogStackARR * sum(state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).HumidityRatio) - + double(DataConvergParams::ConvergLogStackDepth) * + sum((ConvergLogStackARR * state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).HumidityRatio))) / + (square_sum_ConvergLogStackARR - double(DataConvergParams::ConvergLogStackDepth) * sum_square_ConvergLogStackARR); + if (std::abs(SlopeHumRat) > DataConvergParams::HVACHumRatSlopeToler) { if (SlopeHumRat < 0.0) { // check for monotic decrease MonotonicDecreaseFound = true; - for (StackDepth = 2; StackDepth <= ConvergLogStackDepth; ++StackDepth) { - if (ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).HumidityRatio(StackDepth - 1) > - ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).HumidityRatio(StackDepth)) { + for (StackDepth = 2; StackDepth <= DataConvergParams::ConvergLogStackDepth; ++StackDepth) { + if (state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).HumidityRatio(StackDepth - 1) > + state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).HumidityRatio(StackDepth)) { MonotonicDecreaseFound = false; break; } @@ -1146,14 +1146,14 @@ namespace HVACManager { ShowContinueError(state, format("Node named {} shows monotonically decreasing humidity ratio with a trend " "rate across iterations of {:.6R} [ kg-water/kg-dryair/iteration]", - NodeID(ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).NodeNum), + NodeID(state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).NodeNum), SlopeHumRat)); } } else { // check for monotic incrase MonotonicIncreaseFound = true; - for (StackDepth = 2; StackDepth <= ConvergLogStackDepth; ++StackDepth) { - if (ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).HumidityRatio(StackDepth - 1) < - ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).HumidityRatio(StackDepth)) { + for (StackDepth = 2; StackDepth <= DataConvergParams::ConvergLogStackDepth; ++StackDepth) { + if (state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).HumidityRatio(StackDepth - 1) < + state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).HumidityRatio(StackDepth)) { MonotonicIncreaseFound = false; break; } @@ -1162,7 +1162,7 @@ namespace HVACManager { ShowContinueError(state, format("Node named {} shows monotonically increasing humidity ratio with a trend " "rate across iterations of {:.6R} [ kg-water/kg-dryair/iteration]", - NodeID(ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).NodeNum), + NodeID(state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).NodeNum), SlopeHumRat)); } } @@ -1172,11 +1172,11 @@ namespace HVACManager { if (MonotonicDecreaseFound || MonotonicIncreaseFound || FoundOscillationByDuplicate) { HistoryTrace = ""; - for (StackDepth = 1; StackDepth <= ConvergLogStackDepth; ++StackDepth) { - HistoryTrace += format("{:.6R},", ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).HumidityRatio(StackDepth)); + for (StackDepth = 1; StackDepth <= DataConvergParams::ConvergLogStackDepth; ++StackDepth) { + HistoryTrace += format("{:.6R},", state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).HumidityRatio(StackDepth)); } ShowContinueError(state, - "Node named " + NodeID(ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).NodeNum) + + "Node named " + NodeID(state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).NodeNum) + " humidity ratio [kg-water/kg-dryair] iteration history trace (most recent first): " + HistoryTrace); } // need to report trace // end humidity ratio @@ -1186,34 +1186,34 @@ namespace HVACManager { MonotonicDecreaseFound = false; MonotonicIncreaseFound = false; // check for evidence of oscillation by indentify duplicates when latest value not equal to average - AvgValue = sum(ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).MassFlowRate) / double(ConvergLogStackDepth); - if (std::abs(ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).MassFlowRate(1) - AvgValue) > - HVACFlowRateOscillationToler) { // last iterate differs from average + AvgValue = sum(state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).MassFlowRate) / double(DataConvergParams::ConvergLogStackDepth); + if (std::abs(state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).MassFlowRate(1) - AvgValue) > + DataConvergParams::HVACFlowRateOscillationToler) { // last iterate differs from average FoundOscillationByDuplicate = false; - for (StackDepth = 2; StackDepth <= ConvergLogStackDepth; ++StackDepth) { - if (std::abs(ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).MassFlowRate(1) - - ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).MassFlowRate(StackDepth)) < - HVACFlowRateOscillationToler) { + for (StackDepth = 2; StackDepth <= DataConvergParams::ConvergLogStackDepth; ++StackDepth) { + if (std::abs(state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).MassFlowRate(1) - + state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).MassFlowRate(StackDepth)) < + DataConvergParams::HVACFlowRateOscillationToler) { FoundOscillationByDuplicate = true; ShowContinueError( state, format("Node named {} shows oscillating mass flow rate across iterations with a repeated value of {:.6R}", - NodeID(ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).NodeNum), - ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).MassFlowRate(1))); + NodeID(state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).NodeNum), + state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).MassFlowRate(1))); break; } } if (!FoundOscillationByDuplicate) { - SlopeMdot = (sum_ConvergLogStackARR * sum(ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).MassFlowRate) - - double(ConvergLogStackDepth) * - sum((ConvergLogStackARR * ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).MassFlowRate))) / - (square_sum_ConvergLogStackARR - double(ConvergLogStackDepth) * sum_square_ConvergLogStackARR); - if (std::abs(SlopeMdot) > HVACFlowRateSlopeToler) { + SlopeMdot = (sum_ConvergLogStackARR * sum(state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).MassFlowRate) - + double(DataConvergParams::ConvergLogStackDepth) * + sum((ConvergLogStackARR * state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).MassFlowRate))) / + (square_sum_ConvergLogStackARR - double(DataConvergParams::ConvergLogStackDepth) * sum_square_ConvergLogStackARR); + if (std::abs(SlopeMdot) > DataConvergParams::HVACFlowRateSlopeToler) { if (SlopeMdot < 0.0) { // check for monotic decrease MonotonicDecreaseFound = true; - for (StackDepth = 2; StackDepth <= ConvergLogStackDepth; ++StackDepth) { - if (ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).MassFlowRate(StackDepth - 1) > - ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).MassFlowRate(StackDepth)) { + for (StackDepth = 2; StackDepth <= DataConvergParams::ConvergLogStackDepth; ++StackDepth) { + if (state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).MassFlowRate(StackDepth - 1) > + state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).MassFlowRate(StackDepth)) { MonotonicDecreaseFound = false; break; } @@ -1222,14 +1222,14 @@ namespace HVACManager { ShowContinueError(state, format("Node named {} shows monotonically decreasing mass flow rate with a trend " "rate across iterations of {:.6R} [kg/s/iteration]", - NodeID(ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).NodeNum), + NodeID(state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).NodeNum), SlopeMdot)); } } else { // check for monotic incrase MonotonicIncreaseFound = true; - for (StackDepth = 2; StackDepth <= ConvergLogStackDepth; ++StackDepth) { - if (ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).MassFlowRate(StackDepth - 1) < - ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).MassFlowRate(StackDepth)) { + for (StackDepth = 2; StackDepth <= DataConvergParams::ConvergLogStackDepth; ++StackDepth) { + if (state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).MassFlowRate(StackDepth - 1) < + state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).MassFlowRate(StackDepth)) { MonotonicIncreaseFound = false; break; } @@ -1238,7 +1238,7 @@ namespace HVACManager { ShowContinueError(state, format("Node named {} shows monotonically increasing mass flow rate with a trend " "rate across iterations of {:.6R} [kg/s/iteration]", - NodeID(ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).NodeNum), + NodeID(state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).NodeNum), SlopeMdot)); } } @@ -1248,10 +1248,10 @@ namespace HVACManager { if (MonotonicDecreaseFound || MonotonicIncreaseFound || FoundOscillationByDuplicate) { HistoryTrace = ""; - for (StackDepth = 1; StackDepth <= ConvergLogStackDepth; ++StackDepth) { - HistoryTrace += format("{:.6R},", ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).MassFlowRate(StackDepth)); + for (StackDepth = 1; StackDepth <= DataConvergParams::ConvergLogStackDepth; ++StackDepth) { + HistoryTrace += format("{:.6R},", state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).MassFlowRate(StackDepth)); } - ShowContinueError(state, "Node named " + NodeID(ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).NodeNum) + + ShowContinueError(state, "Node named " + NodeID(state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).NodeNum) + " mass flow rate [kg/s] iteration history trace (most recent first): " + HistoryTrace); } // need to report trace // end mass flow rate @@ -1261,34 +1261,34 @@ namespace HVACManager { MonotonicDecreaseFound = false; MonotonicIncreaseFound = false; // check for evidence of oscillation by indentify duplicates when latest value not equal to average - AvgValue = sum(ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).Temperature) / double(ConvergLogStackDepth); - if (std::abs(ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).Temperature(1) - AvgValue) > - HVACTemperatureOscillationToler) { // last iterate differs from average + AvgValue = sum(state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).Temperature) / double(DataConvergParams::ConvergLogStackDepth); + if (std::abs(state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).Temperature(1) - AvgValue) > + DataConvergParams::HVACTemperatureOscillationToler) { // last iterate differs from average FoundOscillationByDuplicate = false; - for (StackDepth = 2; StackDepth <= ConvergLogStackDepth; ++StackDepth) { - if (std::abs(ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).Temperature(1) - - ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).Temperature(StackDepth)) < - HVACTemperatureOscillationToler) { + for (StackDepth = 2; StackDepth <= DataConvergParams::ConvergLogStackDepth; ++StackDepth) { + if (std::abs(state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).Temperature(1) - + state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).Temperature(StackDepth)) < + DataConvergParams::HVACTemperatureOscillationToler) { FoundOscillationByDuplicate = true; ShowContinueError( state, format("Node named {} shows oscillating temperatures across iterations with a repeated value of {:.6R}", - NodeID(ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).NodeNum), - ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).Temperature(1))); + NodeID(state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).NodeNum), + state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).Temperature(1))); break; } } if (!FoundOscillationByDuplicate) { - SlopeTemps = (sum_ConvergLogStackARR * sum(ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).Temperature) - - double(ConvergLogStackDepth) * - sum((ConvergLogStackARR * ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).Temperature))) / - (square_sum_ConvergLogStackARR - double(ConvergLogStackDepth) * sum_square_ConvergLogStackARR); - if (std::abs(SlopeTemps) > HVACTemperatureSlopeToler) { - if (SlopeTemps < 0.0) { // check for monotic decrease + SlopeTemps = (sum_ConvergLogStackARR * sum(state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).Temperature) - + double(DataConvergParams::ConvergLogStackDepth) * + sum((ConvergLogStackARR * state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).Temperature))) / + (square_sum_ConvergLogStackARR - double(DataConvergParams::ConvergLogStackDepth) * sum_square_ConvergLogStackARR); + if (std::abs(SlopeTemps) > DataConvergParams::HVACTemperatureSlopeToler) { + if (SlopeTemps < 0.0) { // check for monotonic decrease MonotonicDecreaseFound = true; - for (StackDepth = 2; StackDepth <= ConvergLogStackDepth; ++StackDepth) { - if (ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).Temperature(StackDepth - 1) > - ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).Temperature(StackDepth)) { + for (StackDepth = 2; StackDepth <= DataConvergParams::ConvergLogStackDepth; ++StackDepth) { + if (state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).Temperature(StackDepth - 1) > + state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).Temperature(StackDepth)) { MonotonicDecreaseFound = false; break; } @@ -1297,14 +1297,14 @@ namespace HVACManager { ShowContinueError(state, format("Node named {} shows monotonically decreasing temperature with a trend rate " "across iterations of {:.4R} [C/iteration]", - NodeID(ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).NodeNum), + NodeID(state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).NodeNum), SlopeTemps)); } } else { // check for monotic incrase MonotonicIncreaseFound = true; - for (StackDepth = 2; StackDepth <= ConvergLogStackDepth; ++StackDepth) { - if (ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).Temperature(StackDepth - 1) < - ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).Temperature(StackDepth)) { + for (StackDepth = 2; StackDepth <= DataConvergParams::ConvergLogStackDepth; ++StackDepth) { + if (state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).Temperature(StackDepth - 1) < + state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).Temperature(StackDepth)) { MonotonicIncreaseFound = false; break; } @@ -1313,7 +1313,7 @@ namespace HVACManager { ShowContinueError(state, format("Node named {} shows monotonically increasing temperatures with a trend " "rate across iterations of {:.4R} [C/iteration]", - NodeID(ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).NodeNum), + NodeID(state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).NodeNum), SlopeTemps)); } } @@ -1323,10 +1323,10 @@ namespace HVACManager { if (MonotonicDecreaseFound || MonotonicIncreaseFound || FoundOscillationByDuplicate) { HistoryTrace = ""; - for (StackDepth = 1; StackDepth <= ConvergLogStackDepth; ++StackDepth) { - HistoryTrace += format("{:.6R},", ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).Temperature(StackDepth)); + for (StackDepth = 1; StackDepth <= DataConvergParams::ConvergLogStackDepth; ++StackDepth) { + HistoryTrace += format("{:.6R},", state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).Temperature(StackDepth)); } - ShowContinueError(state, "Node named " + NodeID(ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).NodeNum) + + ShowContinueError(state, "Node named " + NodeID(state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).NodeNum) + " temperature [C] iteration history trace (most recent first): " + HistoryTrace); } // need to report trace // end Temperature checks @@ -1336,17 +1336,17 @@ namespace HVACManager { for (LoopNum = 1; LoopNum <= TotNumLoops; ++LoopNum) { - if (PlantConvergence(LoopNum).PlantMassFlowNotConverged) { + if (state.dataConvergeParams->PlantConvergence(LoopNum).PlantMassFlowNotConverged) { ShowContinueError(state, "Plant System Named = " + PlantLoop(LoopNum).Name + " did not converge for mass flow rate"); ShowContinueError(state, "Check values should be zero. Most Recent values listed first."); HistoryTrace = ""; - for (StackDepth = 1; StackDepth <= ConvergLogStackDepth; ++StackDepth) { - HistoryTrace += format("{:.6R},", PlantConvergence(LoopNum).PlantFlowDemandToSupplyTolValue(StackDepth)); + for (StackDepth = 1; StackDepth <= DataConvergParams::ConvergLogStackDepth; ++StackDepth) { + HistoryTrace += format("{:.6R},", state.dataConvergeParams->PlantConvergence(LoopNum).PlantFlowDemandToSupplyTolValue(StackDepth)); } ShowContinueError(state, "Demand-to-Supply interface mass flow rate check value iteration history trace: " + HistoryTrace); HistoryTrace = ""; - for (StackDepth = 1; StackDepth <= ConvergLogStackDepth; ++StackDepth) { - HistoryTrace += format("{:.6R},", PlantConvergence(LoopNum).PlantFlowSupplyToDemandTolValue(StackDepth)); + for (StackDepth = 1; StackDepth <= DataConvergParams::ConvergLogStackDepth; ++StackDepth) { + HistoryTrace += format("{:.6R},", state.dataConvergeParams->PlantConvergence(LoopNum).PlantFlowSupplyToDemandTolValue(StackDepth)); } ShowContinueError(state, "Supply-to-Demand interface mass flow rate check value iteration history trace: " + HistoryTrace); @@ -1359,12 +1359,12 @@ namespace HVACManager { AvgValue = sum(PlantLoop(LoopNum).LoopSide(ThisLoopSide).InletNode.MassFlowRateHistory) / double(NumConvergenceHistoryTerms); if (std::abs(PlantLoop(LoopNum).LoopSide(ThisLoopSide).InletNode.MassFlowRateHistory(1) - AvgValue) > - PlantFlowRateOscillationToler) { + DataConvergParams::PlantFlowRateOscillationToler) { FoundOscillationByDuplicate = false; for (StackDepth = 2; StackDepth <= NumConvergenceHistoryTerms; ++StackDepth) { if (std::abs(PlantLoop(LoopNum).LoopSide(ThisLoopSide).InletNode.MassFlowRateHistory(1) - PlantLoop(LoopNum).LoopSide(ThisLoopSide).InletNode.MassFlowRateHistory(StackDepth)) < - PlantFlowRateOscillationToler) { + DataConvergParams::PlantFlowRateOscillationToler) { FoundOscillationByDuplicate = true; ShowContinueError( state, @@ -1381,7 +1381,7 @@ namespace HVACManager { double(NumConvergenceHistoryTerms) * sum((ConvergenceHistoryARR * PlantLoop(LoopNum).LoopSide(ThisLoopSide).InletNode.MassFlowRateHistory))) / (square_sum_ConvergenceHistoryARR - double(NumConvergenceHistoryTerms) * sum_square_ConvergenceHistoryARR); - if (std::abs(SlopeMdot) > PlantFlowRateSlopeToler) { + if (std::abs(SlopeMdot) > DataConvergParams::PlantFlowRateSlopeToler) { if (SlopeMdot < 0.0) { // check for monotonic decrease MonotonicDecreaseFound = true; for (StackDepth = 2; StackDepth <= NumConvergenceHistoryTerms; ++StackDepth) { @@ -1436,12 +1436,12 @@ namespace HVACManager { AvgValue = sum(PlantLoop(LoopNum).LoopSide(ThisLoopSide).OutletNode.MassFlowRateHistory) / double(NumConvergenceHistoryTerms); if (std::abs(PlantLoop(LoopNum).LoopSide(ThisLoopSide).OutletNode.MassFlowRateHistory(1) - AvgValue) > - PlantFlowRateOscillationToler) { + DataConvergParams::PlantFlowRateOscillationToler) { FoundOscillationByDuplicate = false; for (StackDepth = 2; StackDepth <= NumConvergenceHistoryTerms; ++StackDepth) { if (std::abs(PlantLoop(LoopNum).LoopSide(ThisLoopSide).OutletNode.MassFlowRateHistory(1) - PlantLoop(LoopNum).LoopSide(ThisLoopSide).OutletNode.MassFlowRateHistory(StackDepth)) < - PlantFlowRateOscillationToler) { + DataConvergParams::PlantFlowRateOscillationToler) { FoundOscillationByDuplicate = true; ShowContinueError( state, @@ -1459,7 +1459,7 @@ namespace HVACManager { sum((ConvergenceHistoryARR * PlantLoop(LoopNum).LoopSide(ThisLoopSide).OutletNode.MassFlowRateHistory))) / (square_sum_ConvergenceHistoryARR - double(NumConvergenceHistoryTerms) * sum_square_ConvergenceHistoryARR); - if (std::abs(SlopeMdot) > PlantFlowRateSlopeToler) { + if (std::abs(SlopeMdot) > DataConvergParams::PlantFlowRateSlopeToler) { if (SlopeMdot < 0.0) { // check for monotonic decrease MonotonicDecreaseFound = true; for (StackDepth = 2; StackDepth <= NumConvergenceHistoryTerms; ++StackDepth) { @@ -1511,17 +1511,17 @@ namespace HVACManager { } // mass flow not converged - if (PlantConvergence(LoopNum).PlantTempNotConverged) { + if (state.dataConvergeParams->PlantConvergence(LoopNum).PlantTempNotConverged) { ShowContinueError(state, "Plant System Named = " + PlantLoop(LoopNum).Name + " did not converge for temperature"); ShowContinueError(state, "Check values should be zero. Most Recent values listed first."); HistoryTrace = ""; - for (StackDepth = 1; StackDepth <= ConvergLogStackDepth; ++StackDepth) { - HistoryTrace += format("{:.6R},", PlantConvergence(LoopNum).PlantTempDemandToSupplyTolValue(StackDepth)); + for (StackDepth = 1; StackDepth <= DataConvergParams::ConvergLogStackDepth; ++StackDepth) { + HistoryTrace += format("{:.6R},", state.dataConvergeParams->PlantConvergence(LoopNum).PlantTempDemandToSupplyTolValue(StackDepth)); } ShowContinueError(state, "Demand-to-Supply interface temperature check value iteration history trace: " + HistoryTrace); HistoryTrace = ""; - for (StackDepth = 1; StackDepth <= ConvergLogStackDepth; ++StackDepth) { - HistoryTrace += format("{:.6R},", PlantConvergence(LoopNum).PlantTempSupplyToDemandTolValue(StackDepth)); + for (StackDepth = 1; StackDepth <= DataConvergParams::ConvergLogStackDepth; ++StackDepth) { + HistoryTrace += format("{:.6R},", state.dataConvergeParams->PlantConvergence(LoopNum).PlantTempSupplyToDemandTolValue(StackDepth)); } ShowContinueError(state, "Supply-to-Demand interface temperature check value iteration history trace: " + HistoryTrace); @@ -1534,12 +1534,12 @@ namespace HVACManager { AvgValue = sum(PlantLoop(LoopNum).LoopSide(ThisLoopSide).InletNode.TemperatureHistory) / double(NumConvergenceHistoryTerms); if (std::abs(PlantLoop(LoopNum).LoopSide(ThisLoopSide).InletNode.TemperatureHistory(1) - AvgValue) > - PlantTemperatureOscillationToler) { + DataConvergParams::PlantTemperatureOscillationToler) { FoundOscillationByDuplicate = false; for (StackDepth = 2; StackDepth <= NumConvergenceHistoryTerms; ++StackDepth) { if (std::abs(PlantLoop(LoopNum).LoopSide(ThisLoopSide).InletNode.TemperatureHistory(1) - PlantLoop(LoopNum).LoopSide(ThisLoopSide).InletNode.TemperatureHistory(StackDepth)) < - PlantTemperatureOscillationToler) { + DataConvergParams::PlantTemperatureOscillationToler) { FoundOscillationByDuplicate = true; ShowContinueError( state, @@ -1557,7 +1557,7 @@ namespace HVACManager { double(NumConvergenceHistoryTerms) * sum((ConvergenceHistoryARR * PlantLoop(LoopNum).LoopSide(ThisLoopSide).InletNode.TemperatureHistory))) / (square_sum_ConvergenceHistoryARR - double(NumConvergenceHistoryTerms) * sum_square_ConvergenceHistoryARR); - if (std::abs(SlopeTemps) > PlantTemperatureSlopeToler) { + if (std::abs(SlopeTemps) > DataConvergParams::PlantTemperatureSlopeToler) { if (SlopeTemps < 0.0) { // check for monotic decrease MonotonicDecreaseFound = true; for (StackDepth = 2; StackDepth <= NumConvergenceHistoryTerms; ++StackDepth) { @@ -1612,12 +1612,12 @@ namespace HVACManager { AvgValue = sum(PlantLoop(LoopNum).LoopSide(ThisLoopSide).OutletNode.TemperatureHistory) / double(NumConvergenceHistoryTerms); if (std::abs(PlantLoop(LoopNum).LoopSide(ThisLoopSide).OutletNode.TemperatureHistory(1) - AvgValue) > - PlantTemperatureOscillationToler) { + DataConvergParams::PlantTemperatureOscillationToler) { FoundOscillationByDuplicate = false; for (StackDepth = 2; StackDepth <= NumConvergenceHistoryTerms; ++StackDepth) { if (std::abs(PlantLoop(LoopNum).LoopSide(ThisLoopSide).OutletNode.TemperatureHistory(1) - PlantLoop(LoopNum).LoopSide(ThisLoopSide).OutletNode.TemperatureHistory(StackDepth)) < - PlantTemperatureOscillationToler) { + DataConvergParams::PlantTemperatureOscillationToler) { FoundOscillationByDuplicate = true; ShowContinueError( state, @@ -1635,7 +1635,7 @@ namespace HVACManager { double(NumConvergenceHistoryTerms) * sum((ConvergenceHistoryARR * PlantLoop(LoopNum).LoopSide(ThisLoopSide).OutletNode.TemperatureHistory))) / (square_sum_ConvergenceHistoryARR - double(NumConvergenceHistoryTerms) * sum_square_ConvergenceHistoryARR); - if (std::abs(SlopeTemps) > PlantFlowRateSlopeToler) { + if (std::abs(SlopeTemps) > DataConvergParams::PlantFlowRateSlopeToler) { if (SlopeTemps < 0.0) { // check for monotic decrease MonotonicDecreaseFound = true; for (StackDepth = 2; StackDepth <= NumConvergenceHistoryTerms; ++StackDepth) { @@ -1876,9 +1876,9 @@ namespace HVACManager { RepIterAir += IterAir; if (IterAir > MaxAir) { - AirLoopConvergFail = 1; + state.dataConvergeParams->AirLoopConvergFail = 1; } else { - AirLoopConvergFail = 0; + state.dataConvergeParams->AirLoopConvergFail = 0; } // Check to see if any components have been locked out. If so, SimAirLoops will be reset to TRUE. ResolveLockoutFlags(state, SimAirLoops); @@ -1985,24 +1985,6 @@ namespace HVACManager { // Sets the MassFlowRateMaxAvail on the terminal unit inlet nodes to match the // maximum available from the primary air loop. - // REFERENCES: - // na - - // Using/Aliasing - using DataConvergParams::HVACFlowRateToler; - - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - - // SUBROUTINE PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS: - // na - - // DERIVED TYPE DEFINITIONS: - // na - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int AirLoopIndex; int ZonesCooledIndex; @@ -2022,7 +2004,7 @@ namespace HVACManager { if (Node(SupplyNode).MassFlowRate > 0.0) { // must include bypass flow for ChangeoverBypass system so that terminal units are not restricted (e.g., MaxAvail is lowered) if ((Node(SupplyNode).MassFlowRateSetPoint - Node(SupplyNode).MassFlowRate - state.dataAirLoop->AirLoopFlow(AirLoopIndex).BypassMassFlow) > - HVACFlowRateToler * 0.01) { + DataConvergParams::HVACFlowRateToler * 0.01) { FlowRatio = Node(SupplyNode).MassFlowRate / Node(SupplyNode).MassFlowRateSetPoint; for (ZonesCooledIndex = 1; ZonesCooledIndex <= state.dataAirLoop->AirToZoneNodeInfo(AirLoopIndex).NumZonesCooled; ++ZonesCooledIndex) { TermInletNode = state.dataAirLoop->AirToZoneNodeInfo(AirLoopIndex).TermUnitCoolInletNodes(ZonesCooledIndex); @@ -2032,7 +2014,7 @@ namespace HVACManager { } } if ((Node(SupplyNode).MassFlowRateSetPoint - Node(SupplyNode).MassFlowRate - state.dataAirLoop->AirLoopFlow(AirLoopIndex).BypassMassFlow) < - -HVACFlowRateToler * 0.01) { + -DataConvergParams::HVACFlowRateToler * 0.01) { if (Node(SupplyNode).MassFlowRateSetPoint == 0.0) { // CALL ShowFatalError('ResolveAirLoopFlowLimits: Node MassFlowRateSetPoint = 0.0, Node='// & // TRIM(NodeID(SupplyNode))// & @@ -2065,7 +2047,7 @@ namespace HVACManager { if (Node(SupplyNode).MassFlowRate > 0.0) { // must include bypass flow for ChangeoverBypass system so that terminal units are not restricted (e.g., MaxAvail is lowered) if ((Node(SupplyNode).MassFlowRateSetPoint - Node(SupplyNode).MassFlowRate - state.dataAirLoop->AirLoopFlow(AirLoopIndex).BypassMassFlow) > - HVACFlowRateToler * 0.01) { + DataConvergParams::HVACFlowRateToler * 0.01) { FlowRatio = Node(SupplyNode).MassFlowRate / Node(SupplyNode).MassFlowRateSetPoint; for (ZonesHeatedIndex = 1; ZonesHeatedIndex <= state.dataAirLoop->AirToZoneNodeInfo(AirLoopIndex).NumZonesHeated; ++ZonesHeatedIndex) { TermInletNode = state.dataAirLoop->AirToZoneNodeInfo(AirLoopIndex).TermUnitHeatInletNodes(ZonesHeatedIndex); @@ -2075,7 +2057,7 @@ namespace HVACManager { } } if ((Node(SupplyNode).MassFlowRateSetPoint - Node(SupplyNode).MassFlowRate - state.dataAirLoop->AirLoopFlow(AirLoopIndex).BypassMassFlow) < - -HVACFlowRateToler * 0.01) { + -DataConvergParams::HVACFlowRateToler * 0.01) { if (Node(SupplyNode).MassFlowRateSetPoint == 0.0) { // CALL ShowFatalError('ResolveAirLoopFlowLimits: Node MassFlowRateSetPoint = 0.0, Node='// & // TRIM(NodeID(SupplyNode))// & @@ -3043,8 +3025,6 @@ namespace HVACManager { // na // Using/Aliasing - using DataConvergParams::ConvergLogStackDepth; - using DataConvergParams::ZoneInletConvergence; using DataLoopNode::Node; // Locals @@ -3068,22 +3048,22 @@ namespace HVACManager { for (ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ++ZoneNum) { - for (NodeIndex = 1; NodeIndex <= ZoneInletConvergence(ZoneNum).NumInletNodes; ++NodeIndex) { - NodeNum = ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).NodeNum; + for (NodeIndex = 1; NodeIndex <= state.dataConvergeParams->ZoneInletConvergence(ZoneNum).NumInletNodes; ++NodeIndex) { + NodeNum = state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).NodeNum; - tmpRealARR = ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).HumidityRatio; - ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).HumidityRatio(1) = Node(NodeNum).HumRat; - ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).HumidityRatio({2, ConvergLogStackDepth}) = - tmpRealARR({1, ConvergLogStackDepth - 1}); + tmpRealARR = state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).HumidityRatio; + state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).HumidityRatio(1) = Node(NodeNum).HumRat; + state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).HumidityRatio({2, DataConvergParams::ConvergLogStackDepth}) = + tmpRealARR({1, DataConvergParams::ConvergLogStackDepth - 1}); - tmpRealARR = ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).MassFlowRate; - ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).MassFlowRate(1) = Node(NodeNum).MassFlowRate; - ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).MassFlowRate({2, ConvergLogStackDepth}) = - tmpRealARR({1, ConvergLogStackDepth - 1}); + tmpRealARR = state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).MassFlowRate; + state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).MassFlowRate(1) = Node(NodeNum).MassFlowRate; + state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).MassFlowRate({2, DataConvergParams::ConvergLogStackDepth}) = + tmpRealARR({1, DataConvergParams::ConvergLogStackDepth - 1}); - tmpRealARR = ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).Temperature; - ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).Temperature(1) = Node(NodeNum).Temp; - ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).Temperature({2, ConvergLogStackDepth}) = tmpRealARR({1, ConvergLogStackDepth - 1}); + tmpRealARR = state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).Temperature; + state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).Temperature(1) = Node(NodeNum).Temp; + state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).Temperature({2, DataConvergParams::ConvergLogStackDepth}) = tmpRealARR({1, DataConvergParams::ConvergLogStackDepth - 1}); } } } diff --git a/src/EnergyPlus/Plant/PlantManager.cc b/src/EnergyPlus/Plant/PlantManager.cc index 08b67581031..43ec0e5055d 100644 --- a/src/EnergyPlus/Plant/PlantManager.cc +++ b/src/EnergyPlus/Plant/PlantManager.cc @@ -192,8 +192,6 @@ namespace EnergyPlus { // Reset the flags as necessary // Using/Aliasing - using DataConvergParams::MaxPlantSubIterations; - using DataConvergParams::MinPlantSubIterations; using PlantUtilities::LogPlantConvergencePoints; // SUBROUTINE VARIABLE DEFINITIONS @@ -210,9 +208,9 @@ namespace EnergyPlus { return (e.CommonPipeType == DataPlant::CommonPipe_Single) || (e.CommonPipeType == DataPlant::CommonPipe_TwoWay); })) { - CurntMinPlantSubIterations = max(7, MinPlantSubIterations); + CurntMinPlantSubIterations = max(7, state.dataConvergeParams->MinPlantSubIterations); } else { - CurntMinPlantSubIterations = MinPlantSubIterations; + CurntMinPlantSubIterations = state.dataConvergeParams->MinPlantSubIterations; } if (TotNumLoops <= 0) { // quick return if no plant in model @@ -223,7 +221,7 @@ namespace EnergyPlus { IterPlant = 0; InitializeLoops(state, FirstHVACIteration); - while ((SimPlantLoops) && (IterPlant <= MaxPlantSubIterations)) { + while ((SimPlantLoops) && (IterPlant <= state.dataConvergeParams->MaxPlantSubIterations)) { // go through half loops in predetermined calling order for (HalfLoopNum = 1; HalfLoopNum <= TotNumHalfLoops; ++HalfLoopNum) { @@ -314,7 +312,6 @@ namespace EnergyPlus { auto localTempSetPt = SetPointManager::iCtrlVarType::Temp; using NodeInputManager::GetOnlySingleNode; using namespace BranchInputManager; - using DataConvergParams::PlantConvergence; using DataSizing::AutoSize; using FluidProperties::CheckFluidPropertyName; using FluidProperties::FindGlycol; @@ -352,7 +349,7 @@ namespace EnergyPlus { if (TotNumLoops > 0) { PlantLoop.allocate(TotNumLoops); - PlantConvergence.allocate(TotNumLoops); + state.dataConvergeParams->PlantConvergence.allocate(TotNumLoops); if (!allocated(PlantAvailMgr)) { PlantAvailMgr.allocate(TotNumLoops); } diff --git a/src/EnergyPlus/SimAirServingZones.cc b/src/EnergyPlus/SimAirServingZones.cc index ab5c2d47468..05c6078fe80 100644 --- a/src/EnergyPlus/SimAirServingZones.cc +++ b/src/EnergyPlus/SimAirServingZones.cc @@ -331,7 +331,6 @@ namespace SimAirServingZones { using BranchInputManager::GetNumSplitterMixerInConntrList; using BranchInputManager::NumBranchesInBranchList; using BranchInputManager::NumCompsInBranch; - using DataConvergParams::AirLoopConvergence; using HVACControllers::CheckCoilWaterInletNode; using HVACControllers::GetControllerActuatorNodeNum; @@ -483,7 +482,7 @@ namespace SimAirServingZones { PackagedUnit.allocate(NumPrimaryAirSys); state.dataAirLoop->AirLoopControlInfo.allocate(NumPrimaryAirSys); state.dataAirLoop->AirLoopFlow.allocate(NumPrimaryAirSys); - AirLoopConvergence.allocate(NumPrimaryAirSys); + state.dataConvergeParams->AirLoopConvergence.allocate(NumPrimaryAirSys); UnitarySysEqSizing.allocate(NumPrimaryAirSys); if (AirflowNetwork::SimulateAirflowNetwork == AirflowNetwork::AirflowNetworkControlMultiADS || AirflowNetwork::SimulateAirflowNetwork == AirflowNetwork::AirflowNetworkControlSimpleADS) { @@ -1458,9 +1457,6 @@ namespace SimAirServingZones { // initialized at the start of an environment (run period or design day). // Using/Aliasing - using DataConvergParams::AirLoopConvergence; - using DataConvergParams::HVACFlowRateToler; - using DataConvergParams::ZoneInletConvergence; using DataEnvironment::OutHumRat; using DataEnvironment::StdBaroPress; using DataEnvironment::StdRhoAir; @@ -1555,7 +1551,7 @@ namespace SimAirServingZones { TermUnitSizingNumsCool.allocate(state.dataGlobal->NumOfZones); TermUnitSizingNumsHeat.allocate(state.dataGlobal->NumOfZones); - MassFlowSetToler = HVACFlowRateToler * 0.00001; + MassFlowSetToler = DataConvergParams::HVACFlowRateToler * 0.00001; for (SupAirPath = 1; SupAirPath <= NumSupplyAirPaths; ++SupAirPath) { @@ -1973,13 +1969,13 @@ namespace SimAirServingZones { } // now register zone inlet nodes as critical demand nodes in the convergence tracking - ZoneInletConvergence.allocate(state.dataGlobal->NumOfZones); + state.dataConvergeParams->ZoneInletConvergence.allocate(state.dataGlobal->NumOfZones); for (ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ++ZoneNum) { if (ZoneEquipConfig(ZoneNum).NumInletNodes > 0) { - ZoneInletConvergence(ZoneNum).NumInletNodes = ZoneEquipConfig(ZoneNum).NumInletNodes; - ZoneInletConvergence(ZoneNum).InletNode.allocate(ZoneEquipConfig(ZoneNum).NumInletNodes); + state.dataConvergeParams->ZoneInletConvergence(ZoneNum).NumInletNodes = ZoneEquipConfig(ZoneNum).NumInletNodes; + state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode.allocate(ZoneEquipConfig(ZoneNum).NumInletNodes); for (nodeLoop = 1; nodeLoop <= ZoneEquipConfig(ZoneNum).NumInletNodes; ++nodeLoop) { - ZoneInletConvergence(ZoneNum).InletNode(nodeLoop).NodeNum = ZoneEquipConfig(ZoneNum).InletNode(nodeLoop); + state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(nodeLoop).NodeNum = ZoneEquipConfig(ZoneNum).InletNode(nodeLoop); } } } @@ -2469,8 +2465,6 @@ namespace SimAirServingZones { // REFERENCES: None // Using/Aliasing - using DataConvergParams::CalledFromAirSystemSupplySideDeck1; - using DataConvergParams::CalledFromAirSystemSupplySideDeck2; using General::GetPreviousHVACTime; using HVACInterfaceManager::UpdateHVACInterface; @@ -2510,7 +2504,7 @@ namespace SimAirServingZones { int AirLoopPass; // Flag set by ResolveSysFlow; if TRUE, mass balance failed and there must be a second pass bool SysReSim; - int CalledFrom; + DataConvergParams::iCalledFrom CalledFrom; // FLOW: @@ -2524,7 +2518,7 @@ namespace SimAirServingZones { // BUG: IterMax should not be aggregated as a Sum output variable // We need a new aggregation scheme to track the max value across HVAC steps - // instead of suming it up. + // instead of summing it up. IterMax = 0; // Reset counters to capture statistics for the current zone time step @@ -2592,8 +2586,8 @@ namespace SimAirServingZones { // the zone equipment side, looping through all supply air paths for this // air loop. for (AirSysOutNum = 1; AirSysOutNum <= state.dataAirLoop->AirToZoneNodeInfo(AirLoopNum).NumSupplyNodes; ++AirSysOutNum) { - if (AirSysOutNum == 1) CalledFrom = CalledFromAirSystemSupplySideDeck1; - if (AirSysOutNum == 2) CalledFrom = CalledFromAirSystemSupplySideDeck2; + if (AirSysOutNum == 1) CalledFrom = DataConvergParams::iCalledFrom::AirSystemSupplySideDeck1; + if (AirSysOutNum == 2) CalledFrom = DataConvergParams::iCalledFrom::AirSystemSupplySideDeck2; UpdateHVACInterface(state, AirLoopNum, CalledFrom, @@ -2666,8 +2660,8 @@ namespace SimAirServingZones { // the zone equipment side, looping through all supply air paths for this // air loop. for (AirSysOutNum = 1; AirSysOutNum <= state.dataAirLoop->AirToZoneNodeInfo(AirLoopNum).NumSupplyNodes; ++AirSysOutNum) { - if (AirSysOutNum == 1) CalledFrom = CalledFromAirSystemSupplySideDeck1; - if (AirSysOutNum == 2) CalledFrom = CalledFromAirSystemSupplySideDeck2; + if (AirSysOutNum == 1) CalledFrom = DataConvergParams::iCalledFrom::AirSystemSupplySideDeck1; + if (AirSysOutNum == 2) CalledFrom = DataConvergParams::iCalledFrom::AirSystemSupplySideDeck2; UpdateHVACInterface(state, AirLoopNum, CalledFrom, diff --git a/src/EnergyPlus/SimulationManager.cc b/src/EnergyPlus/SimulationManager.cc index 03f89566206..9b42f055e15 100644 --- a/src/EnergyPlus/SimulationManager.cc +++ b/src/EnergyPlus/SimulationManager.cc @@ -986,34 +986,34 @@ namespace SimulationManager { if (MinInt < 0 || MinInt > 60) { ShowWarningError(state, format("{}: Requested {} ({}) invalid. Set to 1 minute.", CurrentModuleObject, cNumericFieldNames(1), MinInt)); - MinTimeStepSys = 1.0 / 60.0; + state.dataConvergeParams->MinTimeStepSys = 1.0 / 60.0; } else if (MinInt == 0) { // Set to TimeStepZone - MinTimeStepSys = state.dataGlobal->TimeStepZone; + state.dataConvergeParams->MinTimeStepSys = state.dataGlobal->TimeStepZone; } else { - MinTimeStepSys = double(MinInt) / 60.0; + state.dataConvergeParams->MinTimeStepSys = double(MinInt) / 60.0; } - MaxIter = int(Number(2)); - if (MaxIter <= 0) { - MaxIter = 20; + state.dataConvergeParams->MaxIter = int(Number(2)); + if (state.dataConvergeParams->MaxIter <= 0) { + state.dataConvergeParams->MaxIter = 20; } - if (!lNumericFieldBlanks(3)) MinPlantSubIterations = int(Number(3)); - if (!lNumericFieldBlanks(4)) MaxPlantSubIterations = int(Number(4)); + if (!lNumericFieldBlanks(3)) state.dataConvergeParams->MinPlantSubIterations = int(Number(3)); + if (!lNumericFieldBlanks(4)) state.dataConvergeParams->MaxPlantSubIterations = int(Number(4)); // trap bad values - if (MinPlantSubIterations < 1) MinPlantSubIterations = 1; - if (MaxPlantSubIterations < 3) MaxPlantSubIterations = 3; - if (MinPlantSubIterations > MaxPlantSubIterations) MaxPlantSubIterations = MinPlantSubIterations + 1; + if (state.dataConvergeParams->MinPlantSubIterations < 1) state.dataConvergeParams->MinPlantSubIterations = 1; + if (state.dataConvergeParams->MaxPlantSubIterations < 3) state.dataConvergeParams->MaxPlantSubIterations = 3; + if (state.dataConvergeParams->MinPlantSubIterations > state.dataConvergeParams->MaxPlantSubIterations) state.dataConvergeParams->MaxPlantSubIterations = state.dataConvergeParams->MinPlantSubIterations + 1; } else if (Num == 0) { - MinTimeStepSys = 1.0 / 60.0; - MaxIter = 20; - MinPlantSubIterations = 2; - MaxPlantSubIterations = 8; + state.dataConvergeParams->MinTimeStepSys = 1.0 / 60.0; + state.dataConvergeParams->MaxIter = 20; + state.dataConvergeParams->MinPlantSubIterations = 2; + state.dataConvergeParams->MaxPlantSubIterations = 8; } else { ShowSevereError(state, "Too many " + CurrentModuleObject + " Objects found."); ErrorsFound = true; } - LimitNumSysSteps = int(state.dataGlobal->TimeStepZone / MinTimeStepSys); + LimitNumSysSteps = int(state.dataGlobal->TimeStepZone / state.dataConvergeParams->MinTimeStepSys); DebugOutput = false; EvenDuringWarmup = false; @@ -1269,10 +1269,10 @@ namespace SimulationManager { } else if (overrideModeValue == "ADVANCED") { bool advancedModeUsed = false; if (fields.find("maxzonetempdiff") != fields.end()) { // not required field, has default value - DataConvergParams::MaxZoneTempDiff = fields.at("maxzonetempdiff"); + state.dataConvergeParams->MaxZoneTempDiff = fields.at("maxzonetempdiff"); ShowWarningError(state, format("PerformancePrecisionTradeoffs using the Advanced Override Mode, MaxZoneTempDiff set to: {:.4R}", - DataConvergParams::MaxZoneTempDiff)); + state.dataConvergeParams->MaxZoneTempDiff)); advancedModeUsed = true; } if (fields.find("maxalloweddeltemp") != fields.end()) { // not required field, has default value @@ -1323,13 +1323,13 @@ namespace SimulationManager { if (MinTimeStepSysOverrideValue > state.dataGlobal->MinutesPerTimeStep) { MinTimeStepSysOverrideValue = state.dataGlobal->MinutesPerTimeStep; } - MinTimeStepSys = MinTimeStepSysOverrideValue / 60.0; - LimitNumSysSteps = int(state.dataGlobal->TimeStepZone / MinTimeStepSys); + state.dataConvergeParams->MinTimeStepSys = MinTimeStepSysOverrideValue / 60.0; + LimitNumSysSteps = int(state.dataGlobal->TimeStepZone / state.dataConvergeParams->MinTimeStepSys); } if (overrideMaxZoneTempDiff) { ShowWarningError(state, "Due to PerformancePrecisionTradeoffs Override Mode, internal variable MaxZoneTempDiff will be set to 1.0 ."); - DataConvergParams::MaxZoneTempDiff = 1.0; + state.dataConvergeParams->MaxZoneTempDiff = 1.0; } if (overrideMaxAllowedDelTemp) { ShowWarningError(state, @@ -1356,9 +1356,9 @@ namespace SimulationManager { "{}\n", "! , Minimum System TimeStep {minutes}, Max HVAC Iterations, Minimum Plant " "Iterations, Maximum Plant Iterations"); - MinInt = MinTimeStepSys * 60.0; + MinInt = state.dataConvergeParams->MinTimeStepSys * 60.0; static constexpr auto Format_733(" System Convergence Limits, {}, {}, {}, {}\n"); - print(state.files.eio, Format_733, MinInt, MaxIter, MinPlantSubIterations, MaxPlantSubIterations); + print(state.files.eio, Format_733, MinInt, state.dataConvergeParams->MaxIter, state.dataConvergeParams->MinPlantSubIterations, state.dataConvergeParams->MaxPlantSubIterations); if (state.dataGlobal->DoZoneSizing) { Alphas(1) = "Yes"; @@ -1430,8 +1430,8 @@ namespace SimulationManager { } else { Alphas(7) = "No"; } - Alphas(8) = format("{:.1R}", DataConvergParams::MinTimeStepSys * 60.0); - Alphas(9) = format("{:.3R}", DataConvergParams::MaxZoneTempDiff); + Alphas(8) = format("{:.1R}", state.dataConvergeParams->MinTimeStepSys * 60.0); + Alphas(9) = format("{:.3R}", state.dataConvergeParams->MaxZoneTempDiff); Alphas(10) = format("{:.4R}", DataHeatBalance::MaxAllowedDelTemp); std::string pptHeader = "! , Use Coil Direct Simulation, " "Zone Radiant Exchange Algorithm, Override Mode, Number of Timestep In Hour, " @@ -1489,8 +1489,8 @@ namespace SimulationManager { UtilityRoutines::appendPerfLog(state, "Number of Timesteps per Hour", fmt::to_string(state.dataGlobal->NumOfTimeStepInHour)); UtilityRoutines::appendPerfLog(state, "Minimum Number of Warmup Days", fmt::to_string(DataHeatBalance::MinNumberOfWarmupDays)); UtilityRoutines::appendPerfLog(state, "SuppressAllBeginEnvironmentResets", bool_to_string(DataEnvironment::forceBeginEnvResetSuppress)); - UtilityRoutines::appendPerfLog(state, "Minimum System Timestep", format("{:.1R}", DataConvergParams::MinTimeStepSys * 60.0)); - UtilityRoutines::appendPerfLog(state, "MaxZoneTempDiff", format("{:.2R}", DataConvergParams::MaxZoneTempDiff)); + UtilityRoutines::appendPerfLog(state, "Minimum System Timestep", format("{:.1R}", state.dataConvergeParams->MinTimeStepSys * 60.0)); + UtilityRoutines::appendPerfLog(state, "MaxZoneTempDiff", format("{:.2R}", state.dataConvergeParams->MaxZoneTempDiff)); UtilityRoutines::appendPerfLog(state, "MaxAllowedDelTemp", format("{:.4R}", DataHeatBalance::MaxAllowedDelTemp)); } diff --git a/src/EnergyPlus/SingleDuct.cc b/src/EnergyPlus/SingleDuct.cc index b0ba9be27a5..5978b25a33b 100644 --- a/src/EnergyPlus/SingleDuct.cc +++ b/src/EnergyPlus/SingleDuct.cc @@ -4138,7 +4138,6 @@ namespace EnergyPlus::SingleDuct { // Using/Aliasing using namespace DataZoneEnergyDemands; - using DataConvergParams::HVACFlowRateToler; using General::SolveRoot; using SteamCoils::GetCoilCapacity; using TempSolveRoot::SolveRoot; @@ -4203,7 +4202,7 @@ namespace EnergyPlus::SingleDuct { MaxCoolMassFlow = this->sd_airterminalInlet.AirMassFlowRateMaxAvail; MaxHeatMassFlow = min(this->HeatAirMassFlowRateMax, this->sd_airterminalInlet.AirMassFlowRateMaxAvail); MinMassFlow = MaxCoolMassFlow * this->ZoneMinAirFrac; - UnitFlowToler = 0.001 * HVACFlowRateToler; + UnitFlowToler = 0.001 * DataConvergParams::HVACFlowRateToler; QDelivered = 0.0; HWFlow = 0.0; if (this->sd_airterminalInlet.AirMassFlowRateMaxAvail <= 0.0 || CurDeadBandOrSetback(ZoneNum)) { diff --git a/src/EnergyPlus/StateManagement.cc b/src/EnergyPlus/StateManagement.cc index 7879f59bebb..46e0aa42720 100644 --- a/src/EnergyPlus/StateManagement.cc +++ b/src/EnergyPlus/StateManagement.cc @@ -55,9 +55,7 @@ #include #include #include -#include #include -#include #include #include #include @@ -203,7 +201,6 @@ void EnergyPlus::clearAllStates(EnergyPlusData &state) autosizing_clear_state(); CoilCoolingDX::clear_state(); AirflowNetwork::clear_state(); - DataConvergParams::clear_state(); DataDefineEquip::clear_state(); DataEnvironment::clear_state(); DataErrorTracking::clear_state(); diff --git a/src/EnergyPlus/ZoneEquipmentManager.cc b/src/EnergyPlus/ZoneEquipmentManager.cc index 0fb50f21424..5ba703c6b2c 100644 --- a/src/EnergyPlus/ZoneEquipmentManager.cc +++ b/src/EnergyPlus/ZoneEquipmentManager.cc @@ -4521,7 +4521,6 @@ namespace ZoneEquipmentManager { // to the air loop side, allowing for multiple return air nodes // Using/Aliasing - using DataConvergParams::CalledFromAirSystemDemandSide; using DataHVACGlobals::NumPrimaryAirSys; using HVACInterfaceManager::UpdateHVACInterface; @@ -4535,7 +4534,7 @@ namespace ZoneEquipmentManager { for (RetAirPathNum = 1; RetAirPathNum <= state.dataAirLoop->AirToZoneNodeInfo(ZoneGroupNum).NumReturnNodes; ++RetAirPathNum) { UpdateHVACInterface(state, ZoneGroupNum, - CalledFromAirSystemDemandSide, + DataConvergParams::iCalledFrom::AirSystemDemandSide, state.dataAirLoop->AirToZoneNodeInfo(ZoneGroupNum).ZoneEquipReturnNodeNum(RetAirPathNum), state.dataAirLoop->AirToZoneNodeInfo(ZoneGroupNum).AirLoopReturnNodeNum(RetAirPathNum), SimAir); diff --git a/tst/EnergyPlus/unit/HVACControllers.unit.cc b/tst/EnergyPlus/unit/HVACControllers.unit.cc index c981e0c57b3..8587f63009f 100644 --- a/tst/EnergyPlus/unit/HVACControllers.unit.cc +++ b/tst/EnergyPlus/unit/HVACControllers.unit.cc @@ -230,13 +230,13 @@ TEST_F(EnergyPlusFixture, HVACControllers_TestTempAndHumidityRatioCtrlVarType) state->dataAirLoop->AirToZoneNodeInfo(1).AirLoopSupplyNodeNum(1) = 1; state->dataAirLoop->AirToZoneNodeInfo(1).ZoneEquipSupplyNodeNum.allocate(1); state->dataAirLoop->AirToZoneNodeInfo(1).ZoneEquipSupplyNodeNum(1) = 4; - DataConvergParams::AirLoopConvergence.allocate(1); - DataConvergParams::AirLoopConvergence(1).HVACMassFlowNotConverged.allocate(2); - DataConvergParams::AirLoopConvergence(1).HVACHumRatNotConverged.allocate(2); - DataConvergParams::AirLoopConvergence(1).HVACTempNotConverged.allocate(2); - DataConvergParams::AirLoopConvergence(1).HVACEnergyNotConverged.allocate(2); - DataConvergParams::AirLoopConvergence(1).HVACEnthalpyNotConverged.allocate(2); - DataConvergParams::AirLoopConvergence(1).HVACPressureNotConverged.allocate(2); + state->dataConvergeParams->AirLoopConvergence.allocate(1); + state->dataConvergeParams->AirLoopConvergence(1).HVACMassFlowNotConverged.allocate(2); + state->dataConvergeParams->AirLoopConvergence(1).HVACHumRatNotConverged.allocate(2); + state->dataConvergeParams->AirLoopConvergence(1).HVACTempNotConverged.allocate(2); + state->dataConvergeParams->AirLoopConvergence(1).HVACEnergyNotConverged.allocate(2); + state->dataConvergeParams->AirLoopConvergence(1).HVACEnthalpyNotConverged.allocate(2); + state->dataConvergeParams->AirLoopConvergence(1).HVACPressureNotConverged.allocate(2); state->dataAirSystemsData->PrimaryAirSystems.allocate(1); state->dataAirSystemsData->PrimaryAirSystems(1).NumBranches = 1; state->dataAirSystemsData->PrimaryAirSystems(1).NumControllers = 1; @@ -938,13 +938,13 @@ TEST_F(EnergyPlusFixture, HVACControllers_MaxFlowZero) state->dataAirLoop->AirToZoneNodeInfo(1).AirLoopSupplyNodeNum(1) = 1; state->dataAirLoop->AirToZoneNodeInfo(1).ZoneEquipSupplyNodeNum.allocate(1); state->dataAirLoop->AirToZoneNodeInfo(1).ZoneEquipSupplyNodeNum(1) = 4; - DataConvergParams::AirLoopConvergence.allocate(1); - DataConvergParams::AirLoopConvergence(1).HVACMassFlowNotConverged.allocate(2); - DataConvergParams::AirLoopConvergence(1).HVACHumRatNotConverged.allocate(2); - DataConvergParams::AirLoopConvergence(1).HVACTempNotConverged.allocate(2); - DataConvergParams::AirLoopConvergence(1).HVACEnergyNotConverged.allocate(2); - DataConvergParams::AirLoopConvergence(1).HVACEnthalpyNotConverged.allocate(2); - DataConvergParams::AirLoopConvergence(1).HVACPressureNotConverged.allocate(2); + state->dataConvergeParams->AirLoopConvergence.allocate(1); + state->dataConvergeParams->AirLoopConvergence(1).HVACMassFlowNotConverged.allocate(2); + state->dataConvergeParams->AirLoopConvergence(1).HVACHumRatNotConverged.allocate(2); + state->dataConvergeParams->AirLoopConvergence(1).HVACTempNotConverged.allocate(2); + state->dataConvergeParams->AirLoopConvergence(1).HVACEnergyNotConverged.allocate(2); + state->dataConvergeParams->AirLoopConvergence(1).HVACEnthalpyNotConverged.allocate(2); + state->dataConvergeParams->AirLoopConvergence(1).HVACPressureNotConverged.allocate(2); state->dataAirSystemsData->PrimaryAirSystems.allocate(1); state->dataAirSystemsData->PrimaryAirSystems(1).NumBranches = 1; state->dataAirSystemsData->PrimaryAirSystems(1).NumControllers = 1; From 4c427cc0505bd9e35e85dd2eca405ba64237fa47 Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Tue, 24 Nov 2020 11:35:36 -0700 Subject: [PATCH 02/10] moving DataConversions to state --- src/EnergyPlus/CMakeLists.txt | 1 - src/EnergyPlus/DataConversions.cc | 119 ------------------------------ src/EnergyPlus/DataConversions.hh | 39 +++------- 3 files changed, 11 insertions(+), 148 deletions(-) delete mode 100644 src/EnergyPlus/DataConversions.cc diff --git a/src/EnergyPlus/CMakeLists.txt b/src/EnergyPlus/CMakeLists.txt index 30cc19bf68e..e9a1963c007 100644 --- a/src/EnergyPlus/CMakeLists.txt +++ b/src/EnergyPlus/CMakeLists.txt @@ -146,7 +146,6 @@ SET( SRC DataComplexFenestration.hh DataContaminantBalance.hh DataConvergParams.hh - DataConversions.cc DataConversions.hh DataDElight.cc DataDElight.hh diff --git a/src/EnergyPlus/DataConversions.cc b/src/EnergyPlus/DataConversions.cc deleted file mode 100644 index 4f1714073e4..00000000000 --- a/src/EnergyPlus/DataConversions.cc +++ /dev/null @@ -1,119 +0,0 @@ -// EnergyPlus, Copyright (c) 1996-2020, The Board of Trustees of the University of Illinois, -// The Regents of the University of California, through Lawrence Berkeley National Laboratory -// (subject to receipt of any required approvals from the U.S. Dept. of Energy), Oak Ridge -// National Laboratory, managed by UT-Battelle, Alliance for Sustainable Energy, LLC, and other -// contributors. All rights reserved. -// -// NOTICE: This Software was developed under funding from the U.S. Department of Energy and the -// U.S. Government consequently retains certain rights. As such, the U.S. Government has been -// granted for itself and others acting on its behalf a paid-up, nonexclusive, irrevocable, -// worldwide license in the Software to reproduce, distribute copies to the public, prepare -// derivative works, and perform publicly and display publicly, and to permit others to do so. -// -// Redistribution and use in source and binary forms, with or without modification, are permitted -// provided that the following conditions are met: -// -// (1) Redistributions of source code must retain the above copyright notice, this list of -// conditions and the following disclaimer. -// -// (2) Redistributions in binary form must reproduce the above copyright notice, this list of -// conditions and the following disclaimer in the documentation and/or other materials -// provided with the distribution. -// -// (3) Neither the name of the University of California, Lawrence Berkeley National Laboratory, -// the University of Illinois, U.S. Dept. of Energy nor the names of its contributors may be -// used to endorse or promote products derived from this software without specific prior -// written permission. -// -// (4) Use of EnergyPlus(TM) Name. If Licensee (i) distributes the software in stand-alone form -// without changes from the version obtained under this License, or (ii) Licensee makes a -// reference solely to the software portion of its product, Licensee must refer to the -// software as "EnergyPlus version X" software, where "X" is the version number Licensee -// obtained under this License and may not use a different name for the software. Except as -// specifically required in this Section (4), Licensee shall not use in a company name, a -// product name, in advertising, publicity, or other promotional activities any name, trade -// name, trademark, logo, or other designation of "EnergyPlus", "E+", "e+" or confusingly -// similar designation, without the U.S. Department of Energy's prior written consent. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY -// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR -// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. - -// EnergyPlus Headers -#include -namespace EnergyPlus { - -namespace DataConversions { - - // MODULE INFORMATION: - // AUTHOR Linda Lawrie - // DATE WRITTEN October 1998 - // MODIFIED na - // RE-ENGINEERED na - - // PURPOSE OF THIS MODULE: - // This data-only module is a repository for conversion unit variables which - // strictly "should not be needed" in EnergyPlus but may be used in a few - // places (e.g. Conduction Transfer Functions). We have adopted the "international - // table" for conversions. - - // METHODOLOGY EMPLOYED: - // na - - // REFERENCES: - // Original Reference: DARCOM P 706-470, Engineering Design Handbook, - // Metric Conversion Guide, July 1976. - // Federal Standard 376B, January 27, 1993. Preferred metric units - // for general use by the Federal Government. - // ASHRAE has similar recommendations. - - // OTHER NOTES: - // na - - // Using/Aliasing - // Data - // -only module should be available to other modules and routines. - // Thus, all variables in this module must be PUBLIC. - - // MODULE PARAMETER DEFINITIONS: - // REAL(r64), PARAMETER:: CFC =4.184D0 ! Specific Heat: BTU/(LB*R) * CFC = KJ/(KG*K) - Real64 const CFC(4.1868); // Specific Heat: BTU/(LB*R) * CFC = KJ/(KG*K) - // above is listed in July 1976 publication as "International Table" - Real64 const CFL(0.3048); // Length: FT * CFL = M - Real64 const CFM(0.45359237); // Mass: LB * CFM = KG - // REAL(r64), PARAMETER:: CFP =249.082D0 ! Pressure: IN-H2O * CFP = N/M**2 - // above is listed in July 1976 publication as in-water at 39.2 deg F - Real64 const CFP(248.84); // Pressure: IN-H2O * CFP = N/M**2 - // above is listed in July 1976 publication as in-water at 60 deg F - Real64 const DELTMP(-32.0); // Temperature: (F + DELTMP) * CFT = C - Real64 const CFA(CFL *CFL); // Area: FT**2 * CFA = M**2 - Real64 const CFT(5.0 / 9.0); // Temperature: R * CFT = K - Real64 const CFV(CFA *CFL); // Volume: FT**3 * CFV = M**3 - Real64 const CFE(CFC *CFM *CFT / 3.6); // Energy: BTU * CFE = W-HR - Real64 const CFD(CFM / CFV); // Density: LB/FT**3 * CFD = KG/M**3 - Real64 const CFH(CFC *CFT); // Enthalpy: BTU/LB * CFH = J/KG - Real64 const CFK(CFE / (CFL * CFT)); // Conductivity: BTU/(HR*FT*R) * CFK = W/(M*K) - Real64 const CFMF(CFM / 3600.0); // Mass Flow: LB/HR * CFMF = KG/SEC - Real64 const CFQ(CFE); // Power: BTU/HR * CFQ = W - Real64 const CFU(CFK / CFL); // U-Value: BTU/(HR*FT**2*R) * CFU = W/(M**2*K) - // Note: R-Value = 1/U-Value - Real64 const CFS(CFL / 60.0); // Speed: FT/MIN * CFS = M/SEC - Real64 const CFVF(CFV / 60.0); // Volume Flow: FT**3/MIN * CFVF = M**3/SEC - Real64 const CFHF(CFQ / CFA); // Heat Flux: BTU/(HR*FT**2) * CFHF = W/M**2 - Real64 const CFTMP(DELTMP); // Temperature: Same as DELTMP - - // DERIVED TYPE DEFINITIONS - // na - - // INTERFACE BLOCK SPECIFICATIONS - // na - -} // namespace DataConversions - -} // namespace EnergyPlus diff --git a/src/EnergyPlus/DataConversions.hh b/src/EnergyPlus/DataConversions.hh index 73f12b9d0c2..52b2b1d5f3f 100644 --- a/src/EnergyPlus/DataConversions.hh +++ b/src/EnergyPlus/DataConversions.hh @@ -55,36 +55,19 @@ namespace EnergyPlus { namespace DataConversions { - // Data - // -only module should be available to other modules and routines. - // Thus, all variables in this module must be PUBLIC. - - // MODULE PARAMETER DEFINITIONS: - // REAL(r64), PARAMETER:: CFC =4.184D0 ! Specific Heat: BTU/(LB*R) * CFC = KJ/(KG*K) - extern Real64 const CFC; // Specific Heat: BTU/(LB*R) * CFC = KJ/(KG*K) + constexpr Real64 CFC(4.1868); // Specific Heat: BTU/(LB*R) * CFC = KJ/(KG*K) // above is listed in July 1976 publication as "International Table" - extern Real64 const CFL; // Length: FT * CFL = M - extern Real64 const CFM; // Mass: LB * CFM = KG - // REAL(r64), PARAMETER:: CFP =249.082D0 ! Pressure: IN-H2O * CFP = N/M**2 - // above is listed in July 1976 publication as in-water at 39.2 deg F - extern Real64 const CFP; // Pressure: IN-H2O * CFP = N/M**2 - // above is listed in July 1976 publication as in-water at 60 deg F - extern Real64 const DELTMP; // Temperature: (F + DELTMP) * CFT = C - extern Real64 const CFA; // Area: FT**2 * CFA = M**2 - extern Real64 const CFT; // Temperature: R * CFT = K - extern Real64 const CFV; // Volume: FT**3 * CFV = M**3 - extern Real64 const CFE; // Energy: BTU * CFE = W-HR - extern Real64 const CFD; // Density: LB/FT**3 * CFD = KG/M**3 - extern Real64 const CFH; // Enthalpy: BTU/LB * CFH = J/KG - extern Real64 const CFK; // Conductivity: BTU/(HR*FT*R) * CFK = W/(M*K) - extern Real64 const CFMF; // Mass Flow: LB/HR * CFMF = KG/SEC - extern Real64 const CFQ; // Power: BTU/HR * CFQ = W - extern Real64 const CFU; // U-Value: BTU/(HR*FT**2*R) * CFU = W/(M**2*K) + constexpr Real64 CFL(0.3048); // Length: FT * CFL = M + constexpr Real64 CFM(0.45359237); // Mass: LB * CFM = KG + constexpr Real64 CFA(CFL *CFL); // Area: FT**2 * CFA = M**2 + constexpr Real64 CFT(5.0 / 9.0); // Temperature: R * CFT = K + constexpr Real64 CFV(CFA *CFL); // Volume: FT**3 * CFV = M**3 + constexpr Real64 CFE(CFC *CFM *CFT / 3.6); // Energy: BTU * CFE = W-HR + constexpr Real64 CFD(CFM / CFV); // Density: LB/FT**3 * CFD = KG/M**3 + constexpr Real64 CFK(CFE / (CFL * CFT)); // Conductivity: BTU/(HR*FT*R) * CFK = W/(M*K) + constexpr Real64 CFMF(CFM / 3600.0); // Mass Flow: LB/HR * CFMF = KG/SEC + constexpr Real64 CFU(CFK / CFL); // U-Value: BTU/(HR*FT**2*R) * CFU = W/(M**2*K) // Note: R-Value = 1/U-Value - extern Real64 const CFS; // Speed: FT/MIN * CFS = M/SEC - extern Real64 const CFVF; // Volume Flow: FT**3/MIN * CFVF = M**3/SEC - extern Real64 const CFHF; // Heat Flux: BTU/(HR*FT**2) * CFHF = W/M**2 - extern Real64 const CFTMP; // Temperature: Same as DELTMP } // namespace DataConversions From a54c18e3c78dd8f2bc93440b90424db3b1872305 Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Tue, 24 Nov 2020 14:36:52 -0700 Subject: [PATCH 03/10] moving DataDaylighting to state --- src/EnergyPlus/CMakeLists.txt | 1 - src/EnergyPlus/CostEstimateManager.cc | 8 +- src/EnergyPlus/DElightManagerF.cc | 28 +- src/EnergyPlus/Data/CommonIncludes.hh | 1 + src/EnergyPlus/Data/EnergyPlusData.cc | 2 + src/EnergyPlus/Data/EnergyPlusData.hh | 2 + src/EnergyPlus/DataDaylighting.cc | 129 -- src/EnergyPlus/DataDaylighting.hh | 121 +- src/EnergyPlus/DaylightingManager.cc | 1945 ++++++++--------- src/EnergyPlus/DaylightingManager.hh | 44 +- src/EnergyPlus/HVACInterfaceManager.cc | 3 - src/EnergyPlus/HVACManager.cc | 3 +- src/EnergyPlus/HeatBalanceManager.cc | 6 +- src/EnergyPlus/HeatBalanceSurfaceManager.cc | 50 +- src/EnergyPlus/InternalHeatGains.cc | 15 +- src/EnergyPlus/OutputReportTabular.cc | 2 +- src/EnergyPlus/OutputReports.cc | 26 +- src/EnergyPlus/SimulationManager.cc | 1 - src/EnergyPlus/SolarShading.cc | 3 +- src/EnergyPlus/SurfaceGeometry.cc | 2 +- .../ZoneContaminantPredictorCorrector.cc | 1 - tst/EnergyPlus/unit/DElightManager.unit.cc | 12 +- .../unit/DaylightingManager.unit.cc | 344 +-- tst/EnergyPlus/unit/EMSManager.unit.cc | 2 +- .../unit/HeatBalanceManager.unit.cc | 4 +- .../unit/HeatBalanceSurfaceManager.unit.cc | 14 +- 26 files changed, 1312 insertions(+), 1457 deletions(-) delete mode 100644 src/EnergyPlus/DataDaylighting.cc diff --git a/src/EnergyPlus/CMakeLists.txt b/src/EnergyPlus/CMakeLists.txt index e9a1963c007..b5d3aa54888 100644 --- a/src/EnergyPlus/CMakeLists.txt +++ b/src/EnergyPlus/CMakeLists.txt @@ -149,7 +149,6 @@ SET( SRC DataConversions.hh DataDElight.cc DataDElight.hh - DataDaylighting.cc DataDaylighting.hh DataDaylightingDevices.cc DataDaylightingDevices.hh diff --git a/src/EnergyPlus/CostEstimateManager.cc b/src/EnergyPlus/CostEstimateManager.cc index 4d4bdba03fc..0b9b4105447 100644 --- a/src/EnergyPlus/CostEstimateManager.cc +++ b/src/EnergyPlus/CostEstimateManager.cc @@ -238,7 +238,6 @@ namespace CostEstimateManager { using DataPhotovoltaics::PVarray; using DataSurfaces::Surface; using DXCoils::DXCoil; - using namespace DataDaylighting; using HeatingCoils::HeatingCoil; // SUBROUTINE LOCAL VARIABLE DECLARATIONS: @@ -385,7 +384,7 @@ namespace CostEstimateManager { } else { ThisZoneID = UtilityRoutines::FindItem(state.dataCostEstimateManager->CostLineItem(Item).ParentObjName, Zone); if (ThisZoneID > 0) { - state.dataCostEstimateManager->CostLineItem(Item).Qty = ZoneDaylight(ThisZoneID).TotalDaylRefPoints; + state.dataCostEstimateManager->CostLineItem(Item).Qty = state.dataDaylightingData->ZoneDaylight(ThisZoneID).TotalDaylRefPoints; } else { ShowSevereError(state, "ComponentCost:LineItem: \"" + state.dataCostEstimateManager->CostLineItem(Item).LineName + "\", Daylighting:Controls, need to specify a valid zone name"); @@ -500,7 +499,6 @@ namespace CostEstimateManager { using DataSurfaces::TotSurfaces; using DXCoils::DXCoil; using DXCoils::NumDXCoils; - using namespace DataDaylighting; using HeatingCoils::HeatingCoil; using HeatingCoils::NumHeatingCoils; @@ -708,11 +706,11 @@ namespace CostEstimateManager { } else if (SELECT_CASE_var == "DAYLIGHTING:CONTROLS") { if (state.dataCostEstimateManager->CostLineItem(Item).ParentObjName == "*") { // wildcard, apply to all such components - state.dataCostEstimateManager->CostLineItem(Item).Qty = sum(ZoneDaylight, &ZoneDaylightCalc::TotalDaylRefPoints); + state.dataCostEstimateManager->CostLineItem(Item).Qty = sum(state.dataDaylightingData->ZoneDaylight, &DataDaylighting::ZoneDaylightCalc::TotalDaylRefPoints); } else if (!state.dataCostEstimateManager->CostLineItem(Item).ParentObjName.empty()) { ThisZoneID = UtilityRoutines::FindItem(state.dataCostEstimateManager->CostLineItem(Item).ParentObjName, Zone); if (ThisZoneID > 0) { - state.dataCostEstimateManager->CostLineItem(Item).Qty = ZoneDaylight(ThisZoneID).TotalDaylRefPoints; + state.dataCostEstimateManager->CostLineItem(Item).Qty = state.dataDaylightingData->ZoneDaylight(ThisZoneID).TotalDaylRefPoints; } } diff --git a/src/EnergyPlus/DElightManagerF.cc b/src/EnergyPlus/DElightManagerF.cc index 50b4e624d31..cae48ba703a 100644 --- a/src/EnergyPlus/DElightManagerF.cc +++ b/src/EnergyPlus/DElightManagerF.cc @@ -131,8 +131,6 @@ namespace DElightManagerF { using namespace DataEnvironment; // Gives access to Site data using namespace DataSurfaces; // Gives access to Surface data using namespace DataStringGlobals; // Gives access to Program Path and Current Time/Date - using namespace DataDaylighting; - using InternalHeatGains::CheckLightsReplaceableMinMaxForZone; using InternalHeatGains::GetDesignLightingLevelForZone; @@ -230,8 +228,8 @@ namespace DElightManagerF { SinBldgRelNorth = std::sin(-BuildingAzimuth * DataGlobalConstants::DegToRadians()); // Loop through the Daylighting:Controls objects that use DElight checking for a host Zone - for (auto &znDayl : ZoneDaylight) { - if (znDayl.DaylightMethod == DElightDaylighting) { + for (auto &znDayl : state.dataDaylightingData->ZoneDaylight) { + if (znDayl.DaylightMethod == DataDaylighting::iDaylightingMethod::DElightDaylighting) { // Register Error if 0 DElight RefPts have been input for valid DElight object if (znDayl.TotalDaylRefPoints == 0) { @@ -266,8 +264,8 @@ namespace DElightManagerF { // Loop through the Daylighting:DElight objects searching for a match to the current Zone - for (auto &znDayl : ZoneDaylight) { - if (znDayl.DaylightMethod == DElightDaylighting) { + for (auto &znDayl : state.dataDaylightingData->ZoneDaylight) { + if (znDayl.DaylightMethod == DataDaylighting::iDaylightingMethod::DElightDaylighting) { int const izone = UtilityRoutines::FindItemInList(znDayl.ZoneName, Zone); if (izone != 0) { @@ -382,7 +380,7 @@ namespace DElightManagerF { // Loop through all Doppelganger Surface Names to ignore these Windows lWndoIsDoppelganger = false; - for (auto &cfs : DElightComplexFene) { + for (auto &cfs : state.dataDaylightingData->DElightComplexFene) { // Is the current Window Surface a Doppelganger? if (wndo.Name == cfs.wndwName) { @@ -416,7 +414,7 @@ namespace DElightManagerF { // Loop through all Doppelganger Surface Names to ignore these Windows lWndoIsDoppelganger = false; - for (auto &cfs : DElightComplexFene) { + for (auto &cfs : state.dataDaylightingData->DElightComplexFene) { // Is the current Window Surface a Doppelganger? if (wndo2.Name == cfs.wndwName) { @@ -470,7 +468,7 @@ namespace DElightManagerF { iHostedCFS = 0; // Loop through the input CFS objects searching for a match to the current Opaque Bounding Surface - for (auto &cfs : DElightComplexFene) { + for (auto &cfs : state.dataDaylightingData->DElightComplexFene) { // Does the current Opaque Bounding Surface host the current CFS object? if (surf.Name == cfs.surfName) { @@ -483,7 +481,7 @@ namespace DElightManagerF { // Now write each of the hosted CFS data // Loop through the input CFS objects searching for a match to the current Opaque Bounding Surface - for (auto &cfs : DElightComplexFene) { + for (auto &cfs : state.dataDaylightingData->DElightComplexFene) { // Does the current Opaque Bounding Surface host the current CFS object? if (surf.Name == cfs.surfName) { @@ -538,7 +536,7 @@ namespace DElightManagerF { print(delightInFile, Format_912, znDayl.TotalDaylRefPoints); // Loop through the Daylighting:DElight:Reference Point objects checking for the current DElight Zone host - for (auto &refPt : DaylRefPt) { + for (auto &refPt : state.dataDaylightingData->DaylRefPt) { // Is this RefPt hosted by current DElight Zone? if (izone == refPt.ZoneNum) { @@ -692,7 +690,6 @@ namespace DElightManagerF { // Glazer - July 2016 using namespace DataIPShortCuts; // Gives access to commonly dimensioned field names, etc for getinput - using namespace DataDaylighting; using DataSurfaces::Surface; int NumAlpha; @@ -702,9 +699,9 @@ namespace DElightManagerF { constexpr auto cCurrentModuleObject("Daylighting:DELight:ComplexFenestration"); - TotDElightCFS = inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); - DElightComplexFene.allocate(TotDElightCFS); - for (auto &cfs : DElightComplexFene) { + state.dataDaylightingData->TotDElightCFS = inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); + state.dataDaylightingData->DElightComplexFene.allocate(state.dataDaylightingData->TotDElightCFS); + for (auto &cfs : state.dataDaylightingData->DElightComplexFene) { inputProcessor->getObjectItem(state, cCurrentModuleObject, ++CFSNum, @@ -757,7 +754,6 @@ namespace DElightManagerF { // USE STATEMENTS: // Using/Aliasing using namespace DataIPShortCuts; - using DataDaylighting::ZoneDaylight; using DataSurfaces::AspectTransform; using DataSurfaces::WorldCoordSystem; diff --git a/src/EnergyPlus/Data/CommonIncludes.hh b/src/EnergyPlus/Data/CommonIncludes.hh index d26772db77c..b426dd1effb 100644 --- a/src/EnergyPlus/Data/CommonIncludes.hh +++ b/src/EnergyPlus/Data/CommonIncludes.hh @@ -83,6 +83,7 @@ #include #include #include +#include #include #include #include diff --git a/src/EnergyPlus/Data/EnergyPlusData.cc b/src/EnergyPlus/Data/EnergyPlusData.cc index 6590e261829..817580e47d5 100644 --- a/src/EnergyPlus/Data/EnergyPlusData.cc +++ b/src/EnergyPlus/Data/EnergyPlusData.cc @@ -85,6 +85,7 @@ namespace EnergyPlus { this->dataCrossVentMgr = std::make_unique(); this->dataCTElectricGenerator = std::make_unique(); this->dataCurveManager = std::make_unique(); + this->dataDaylightingData = std::make_unique(); this->dataEIRPlantLoopHeatPump = std::make_unique(); this->dataExteriorEnergyUse = std::make_unique(); this->dataFans = std::make_unique(); @@ -169,6 +170,7 @@ namespace EnergyPlus { this->dataCrossVentMgr->clear_state(); this->dataCTElectricGenerator->clear_state(); this->dataCurveManager->clear_state(); + this->dataDaylightingData->clear_state(); this->dataEIRPlantLoopHeatPump->clear_state(); this->dataExteriorEnergyUse->clear_state(); this->dataFans->clear_state(); diff --git a/src/EnergyPlus/Data/EnergyPlusData.hh b/src/EnergyPlus/Data/EnergyPlusData.hh index ad2eaf66508..ea003309358 100644 --- a/src/EnergyPlus/Data/EnergyPlusData.hh +++ b/src/EnergyPlus/Data/EnergyPlusData.hh @@ -97,6 +97,7 @@ struct DataBranchAirLoopPlantData; struct DataGlobal; struct DataTimingsData; struct DataWaterData; +struct DaylightingData; struct EIRPlantLoopHeatPumpsData; struct ExteriorEnergyUseData; struct FansData; @@ -183,6 +184,7 @@ struct EnergyPlusData : BaseGlobalStruct { std::unique_ptr dataAirLoop; std::unique_ptr dataGlobal; std::unique_ptr dataWaterData; + std::unique_ptr dataDaylightingData; std::unique_ptr dataEIRPlantLoopHeatPump; std::unique_ptr dataExteriorEnergyUse; std::unique_ptr dataFans; diff --git a/src/EnergyPlus/DataDaylighting.cc b/src/EnergyPlus/DataDaylighting.cc deleted file mode 100644 index ca87a05f295..00000000000 --- a/src/EnergyPlus/DataDaylighting.cc +++ /dev/null @@ -1,129 +0,0 @@ -// EnergyPlus, Copyright (c) 1996-2020, The Board of Trustees of the University of Illinois, -// The Regents of the University of California, through Lawrence Berkeley National Laboratory -// (subject to receipt of any required approvals from the U.S. Dept. of Energy), Oak Ridge -// National Laboratory, managed by UT-Battelle, Alliance for Sustainable Energy, LLC, and other -// contributors. All rights reserved. -// -// NOTICE: This Software was developed under funding from the U.S. Department of Energy and the -// U.S. Government consequently retains certain rights. As such, the U.S. Government has been -// granted for itself and others acting on its behalf a paid-up, nonexclusive, irrevocable, -// worldwide license in the Software to reproduce, distribute copies to the public, prepare -// derivative works, and perform publicly and display publicly, and to permit others to do so. -// -// Redistribution and use in source and binary forms, with or without modification, are permitted -// provided that the following conditions are met: -// -// (1) Redistributions of source code must retain the above copyright notice, this list of -// conditions and the following disclaimer. -// -// (2) Redistributions in binary form must reproduce the above copyright notice, this list of -// conditions and the following disclaimer in the documentation and/or other materials -// provided with the distribution. -// -// (3) Neither the name of the University of California, Lawrence Berkeley National Laboratory, -// the University of Illinois, U.S. Dept. of Energy nor the names of its contributors may be -// used to endorse or promote products derived from this software without specific prior -// written permission. -// -// (4) Use of EnergyPlus(TM) Name. If Licensee (i) distributes the software in stand-alone form -// without changes from the version obtained under this License, or (ii) Licensee makes a -// reference solely to the software portion of its product, Licensee must refer to the -// software as "EnergyPlus version X" software, where "X" is the version number Licensee -// obtained under this License and may not use a different name for the software. Except as -// specifically required in this Section (4), Licensee shall not use in a company name, a -// product name, in advertising, publicity, or other promotional activities any name, trade -// name, trademark, logo, or other designation of "EnergyPlus", "E+", "e+" or confusingly -// similar designation, without the U.S. Department of Energy's prior written consent. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY -// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR -// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. - -// EnergyPlus Headers -#include -namespace EnergyPlus { - -namespace DataDaylighting { - - // MODULE INFORMATION: - // AUTHOR Linda Lawrie/Fred Winkelmann (Re-engineered by Peter Graham Ellis) - // DATE WRITTEN May 1998 - // MODIFIED B.Griffith added interior window data for associated exterior windows - // RE-ENGINEERED April 2003 - - // PURPOSE OF THIS MODULE: - // This data-only module is a repository for variables used in daylighting which - // are shared by several modules. - - // METHODOLOGY EMPLOYED: - // na - - // REFERENCES: - // na - - // OTHER NOTES: - // na - - // Using/Aliasing - // Data - // -only module should be available to other modules and routines. - // Thus, all variables in this module must be PUBLIC. - - // MODULE PARAMETER DEFINITIONS: - // Two kinds of reference points: used directly in daylighting, used to show illuminance map of zone - int const MaxRefPoints(2); // Maximum number of daylighting reference points, 2 - int const MaxMapRefPoints(2500); // Maximum number of Illuminance Map Ref Points - - int const NotInOrAdjZoneExtWin(0); // Exterior window is not in a Daylighting:Detailed zone - // or in an adjacent zone with a shared interior window - int const InZoneExtWin(1); // Exterior window is in a Daylighting:Detailed zone - int const AdjZoneExtWin(2); // Exterior window is in a zone adjacent to a Daylighting: - // Detailed zone with which it shares an interior window - - int const CalledForRefPoint(101); - int const CalledForMapPoint(102); - - // Parameters for "DaylightMethod" - int const NoDaylighting(0); - int const SplitFluxDaylighting(1); - int const DElightDaylighting(2); - - // Parameters for "Lighting Control Type" - int const Continuous(1); - int const Stepped(2); - int const ContinuousOff(3); - - // DERIVED TYPE DEFINITIONS: - - // MODULE VARIABLE TYPE DECLARATIONS: - - // INTERFACE BLOCK SPECIFICATIONS: na - - // MODULE VARIABLE DECLARATIONS: - int TotIllumMaps(0); - int TotRefPoints(0); - bool mapResultsToReport(false); // used when only partial hour has "sun up" - bool mapResultsReported(false); // when no map results are ever reported this will still be false - char MapColSep; // Character for separating map columns (tab, space, comma) - - bool DFSReportSizingDays(false); - bool DFSReportAllShadowCalculationDays(false); - - int TotDElightCFS(0); - - // Object Data - Array1D ZoneDaylight; - Array1D IllumMap; - Array1D IllumMapCalc; - Array1D DaylRefPt; - Array1D DElightComplexFene; - -} // namespace DataDaylighting - -} // namespace EnergyPlus diff --git a/src/EnergyPlus/DataDaylighting.hh b/src/EnergyPlus/DataDaylighting.hh index 21e773ebe1a..2789b181666 100644 --- a/src/EnergyPlus/DataDaylighting.hh +++ b/src/EnergyPlus/DataDaylighting.hh @@ -63,6 +63,10 @@ namespace EnergyPlus { namespace DataDaylighting { + // Two kinds of reference points: used directly in daylighting, used to show illuminance map of zone + constexpr int MaxRefPoints(2); // Maximum number of daylighting reference points, 2 + constexpr int MaxMapRefPoints(2500); // Maximum number of Illuminance Map Ref Points + enum class SkyType : int { Clear = 1, @@ -71,53 +75,29 @@ namespace DataDaylighting { Overcast }; - // Using/Aliasing - - // Data - // -only module should be available to other modules and routines. - // Thus, all variables in this module must be PUBLIC. - - // MODULE PARAMETER DEFINITIONS: - // Two kinds of reference points: used directly in daylighting, used to show illuminance map of zone - extern int const MaxRefPoints; // Maximum number of daylighting reference points, 2 - extern int const MaxMapRefPoints; // Maximum number of Illuminance Map Ref Points - extern int TotRefPoints; // number of Daylighting:ReferencePoint objects found - - extern int const NotInOrAdjZoneExtWin; // Exterior window is not in a Daylighting:Detailed zone - // or in an adjacent zone with a shared interior window - extern int const InZoneExtWin; // Exterior window is in a Daylighting:Detailed zone - extern int const AdjZoneExtWin; // Exterior window is in a zone adjacent to a Daylighting: - // Detailed zone with which it shares an interior window + enum class iExtWinType { + NotInOrAdjZoneExtWin, // Exterior window is not in a Daylighting:Detailed zone or in an adjacent zone with a shared interior window + InZoneExtWin, // Exterior window is in a Daylighting:Detailed zone + AdjZoneExtWin // Exterior window is in a zone adjacent to a Daylighting:Detailed zone with which it shares an interior window + }; - extern int const CalledForRefPoint; - extern int const CalledForMapPoint; + enum class iCalledFor { + RefPoint, + MapPoint + }; - // Parameters for "DaylightMethod" - extern int const NoDaylighting; - extern int const SplitFluxDaylighting; - extern int const DElightDaylighting; + enum class iDaylightingMethod { + NoDaylighting, + SplitFluxDaylighting, + DElightDaylighting + }; // Parameters for "Lighting Control Type" - extern int const Continuous; - extern int const Stepped; - extern int const ContinuousOff; - - // DERIVED TYPE DEFINITIONS: - - // MODULE VARIABLE TYPE DECLARATIONS: - - // INTERFACE BLOCK SPECIFICATIONS: na - - // MODULE VARIABLE DECLARATIONS: - extern int TotIllumMaps; - extern bool mapResultsToReport; // used when only partial hour has "sun up" - extern bool mapResultsReported; // when no map results are ever reported this will still be false - extern char MapColSep; // Character for separating map columns (tab, space, comma) - - extern bool DFSReportSizingDays; - extern bool DFSReportAllShadowCalculationDays; - - // Types + enum class iLtgCtrlType { + Continuous, + Stepped, + ContinuousOff + }; struct IntWinAdjZoneExtWinStruct // nested structure for ZoneDaylight { @@ -137,7 +117,7 @@ namespace DataDaylighting { // Members std::string Name; // Name of the daylighting:controls object std::string ZoneName; // name of the zone where the daylighting:controls object is located - int DaylightMethod; // Type of Daylighting (1=SplitFlux, 2=DElight) + DataDaylighting::iDaylightingMethod DaylightMethod; // Type of Daylighting (1=SplitFlux, 2=DElight) int AvailSchedNum; // pointer to availability schedule if present int TotalDaylRefPoints; // Number of daylighting reference points in a zone (0,1 or 2) Array1D_int DaylRefPtNum; // Reference number to DaylRefPt array that stores Daylighting:ReferencePoint @@ -147,7 +127,7 @@ namespace DataDaylighting { Array1D_bool DaylRefPtInBounds; // True when coordinates are in bounds of zone coordinates Array1D FracZoneDaylit; // =0.0 ! Fraction of zone controlled by each reference point Array1D IllumSetPoint; // =0.0 ! Illuminance setpoint at each reference point (lux) - int LightControlType; // Lighting control type (same for all reference points) + iLtgCtrlType LightControlType; // Lighting control type (same for all reference points) // (1=continuous, 2=stepped, 3=continuous/off) int glareRefPtNumber; // from field: Glare Calculation Daylighting Reference Point Name Real64 ViewAzimuthForGlare; // View direction relative to window for glare calculation (deg) @@ -223,10 +203,11 @@ namespace DataDaylighting { // Default Constructor ZoneDaylightCalc() - : DaylightMethod(0), AvailSchedNum(0), TotalDaylRefPoints(0), LightControlType(1), ViewAzimuthForGlare(0.0), MaxGlareallowed(0), - MinPowerFraction(0.0), MinLightFraction(0.0), LightControlSteps(0), LightControlProbability(0.0), TotalExtWindows(0), - AveVisDiffReflect(0.0), ZonePowerReductionFactor(1.0), NumOfIntWinAdjZones(0), NumOfIntWinAdjZoneExtWins(0), NumOfDayltgExtWins(0), - MinIntWinSolidAng(0.0), TotInsSurfArea(0.0), FloorVisRefl(0.0), InterReflIllFrIntWins(0.0), AdjZoneHasDayltgCtrl(false), MapCount(0) + : DaylightMethod(iDaylightingMethod::NoDaylighting), AvailSchedNum(0), TotalDaylRefPoints(0), LightControlType(iLtgCtrlType::Continuous), + glareRefPtNumber(0), ViewAzimuthForGlare(0.0), MaxGlareallowed(0), MinPowerFraction(0.0), MinLightFraction(0.0), LightControlSteps(0), + LightControlProbability(0.0), TotalExtWindows(0), AveVisDiffReflect(0.0), DElightGriddingResolution(0.0), ZonePowerReductionFactor(1.0), + NumOfIntWinAdjZones(0), NumOfIntWinAdjZoneExtWins(0), NumOfDayltgExtWins(0), MinIntWinSolidAng(0.0), TotInsSurfArea(0.0), FloorVisRefl(0.0), + InterReflIllFrIntWins(0.0), AdjZoneHasDayltgCtrl(false), MapCount(0) { } }; @@ -328,17 +309,43 @@ namespace DataDaylighting { std::string wndwName; // Window name Real64 feneRota; // Fenestration Rotation }; - extern int TotDElightCFS; // number of Daylighting:DELight:ComplexFenestration - - // Object Data - extern Array1D ZoneDaylight; - extern Array1D IllumMap; - extern Array1D IllumMapCalc; - extern Array1D DaylRefPt; - extern Array1D DElightComplexFene; } // namespace DataDaylighting +struct DaylightingData : BaseGlobalStruct { + + int TotRefPoints = 0; + int TotIllumMaps = 0; + bool mapResultsToReport = false; // used when only partial hour has "sun up" + bool mapResultsReported = false; // when no map results are ever reported this will still be false + char MapColSep; // Character for separating map columns (tab, space, comma) + bool DFSReportSizingDays = false; + bool DFSReportAllShadowCalculationDays = false; + int TotDElightCFS = 0; + + Array1D ZoneDaylight; + Array1D IllumMap; + Array1D IllumMapCalc; + Array1D DaylRefPt; + Array1D DElightComplexFene; + + void clear_state() override + { + this->TotRefPoints = 0; + this->TotIllumMaps = 0; + this->mapResultsToReport = false; + this->mapResultsReported = false; + this->DFSReportSizingDays = false; + this->DFSReportAllShadowCalculationDays = false; + this->TotDElightCFS = 0; + this->ZoneDaylight.deallocate(); + this->IllumMap.deallocate(); + this->IllumMapCalc.deallocate(); + this->DaylRefPt.deallocate(); + this->DElightComplexFene.deallocate(); + } +}; + } // namespace EnergyPlus #endif diff --git a/src/EnergyPlus/DaylightingManager.cc b/src/EnergyPlus/DaylightingManager.cc index 56e2f18ebd2..8fefde7dff1 100644 --- a/src/EnergyPlus/DaylightingManager.cc +++ b/src/EnergyPlus/DaylightingManager.cc @@ -69,7 +69,6 @@ #include #include #include -#include #include #include #include @@ -149,7 +148,6 @@ namespace DaylightingManager { using namespace DataHeatBalance; using namespace DataSurfaces; using namespace DataEnvironment; - using namespace DataDaylighting; using namespace DataDaylightingDevices; using DataBSDFWindow::BSDFDaylghtPosition; @@ -240,15 +238,12 @@ namespace DaylightingManager { void clear_state() { // this will need a lot more, but it is a start - ZoneDaylight.deallocate(); CalcDayltghCoefficients_firstTime = true; TDDTransVisBeam.deallocate(); TDDFluxInc.deallocate(); TDDFluxTrans.deallocate(); RefErrIndex.deallocate(); refFirstTime = true; - IllumMap.deallocate(); - IllumMapCalc.deallocate(); DayltgInteriorIllum_firstTime = true; FirstTimeDaylFacCalc = true; VeryFirstTime = true; @@ -367,11 +362,11 @@ namespace DaylightingManager { } // Average inside surface reflectance of zone - ZoneDaylight(ZoneNum).AveVisDiffReflect = ARHTOT / AInsTot; + state.dataDaylightingData->ZoneDaylight(ZoneNum).AveVisDiffReflect = ARHTOT / AInsTot; // Total inside surface area of zone - ZoneDaylight(ZoneNum).TotInsSurfArea = AInsTot; + state.dataDaylightingData->ZoneDaylight(ZoneNum).TotInsSurfArea = AInsTot; // Average floor visible reflectance - ZoneDaylight(ZoneNum).FloorVisRefl = ARH(3) / (AR(3) + 1.e-6); + state.dataDaylightingData->ZoneDaylight(ZoneNum).FloorVisRefl = ARH(3) / (AR(3) + 1.e-6); for (int ISurf : thisEnclosure.SurfacePtr) { IType = Surface(ISurf).Class; @@ -567,7 +562,7 @@ namespace DaylightingManager { if (state.dataGlobal->BeginSimFlag) { TotWindowsWithDayl = 0; for (ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ++ZoneNum) { - TotWindowsWithDayl += ZoneDaylight(ZoneNum).NumOfDayltgExtWins; + TotWindowsWithDayl += state.dataDaylightingData->ZoneDaylight(ZoneNum).NumOfDayltgExtWins; } } @@ -596,7 +591,7 @@ namespace DaylightingManager { // Warning if detailed daylighting has been requested for a zone with no associated exterior windows. for (ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ++ZoneNum) { - if (ZoneDaylight(ZoneNum).TotalDaylRefPoints > 0 && ZoneDaylight(ZoneNum).NumOfDayltgExtWins == 0) { + if (state.dataDaylightingData->ZoneDaylight(ZoneNum).TotalDaylRefPoints > 0 && state.dataDaylightingData->ZoneDaylight(ZoneNum).NumOfDayltgExtWins == 0) { ShowWarningError(state, "Detailed daylighting will not be done for zone=" + Zone(ZoneNum).Name); ShowContinueError(state, "because it has no associated exterior windows."); } @@ -606,8 +601,8 @@ namespace DaylightingManager { for (ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ++ZoneNum) { // TH 9/10/2009. Need to calculate for zones without daylighting controls (TotalDaylRefPoints = 0) // but with adjacent zones having daylighting controls. - if ((ZoneDaylight(ZoneNum).TotalDaylRefPoints > 0 && ZoneDaylight(ZoneNum).NumOfDayltgExtWins > 0) || - ZoneDaylight(ZoneNum).AdjZoneHasDayltgCtrl) { + if ((state.dataDaylightingData->ZoneDaylight(ZoneNum).TotalDaylRefPoints > 0 && state.dataDaylightingData->ZoneDaylight(ZoneNum).NumOfDayltgExtWins > 0) || + state.dataDaylightingData->ZoneDaylight(ZoneNum).AdjZoneHasDayltgCtrl) { DayltgAveInteriorReflectance(state, ZoneNum); } } @@ -686,10 +681,10 @@ namespace DaylightingManager { // Skip zones that are not Daylighting:Detailed zones. // TotalDaylRefPoints = 0 means zone has (1) no daylighting or // (3) Daylighting:DElight - if (ZoneDaylight(ZoneNum).TotalDaylRefPoints == 0 || ZoneDaylight(ZoneNum).DaylightMethod != SplitFluxDaylighting) continue; + if (state.dataDaylightingData->ZoneDaylight(ZoneNum).TotalDaylRefPoints == 0 || state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylightMethod != DataDaylighting::iDaylightingMethod::SplitFluxDaylighting) continue; // Skip zones with no exterior windows in the zone or in adjacent zone with which an interior window is shared - if (ZoneDaylight(ZoneNum).NumOfDayltgExtWins == 0) continue; + if (state.dataDaylightingData->ZoneDaylight(ZoneNum).NumOfDayltgExtWins == 0) continue; CalcDayltgCoeffsRefMapPoints(state, ZoneNum); @@ -705,37 +700,37 @@ namespace DaylightingManager { "! , MonthAndDay, Zone Name, Window Name, Reference Point, Daylight Factor\n"); print(state.files.eio, Format_700); for (ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ++ZoneNum) { - if (ZoneDaylight(ZoneNum).NumOfDayltgExtWins == 0 || ZoneDaylight(ZoneNum).DaylightMethod != SplitFluxDaylighting) continue; - for (loop = 1; loop <= ZoneDaylight(ZoneNum).NumOfDayltgExtWins; ++loop) { - IWin = ZoneDaylight(ZoneNum).DayltgExtWinSurfNums(loop); + if (state.dataDaylightingData->ZoneDaylight(ZoneNum).NumOfDayltgExtWins == 0 || state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylightMethod != DataDaylighting::iDaylightingMethod::SplitFluxDaylighting) continue; + for (loop = 1; loop <= state.dataDaylightingData->ZoneDaylight(ZoneNum).NumOfDayltgExtWins; ++loop) { + IWin = state.dataDaylightingData->ZoneDaylight(ZoneNum).DayltgExtWinSurfNums(loop); // For this report, do not include ext wins in zone adjacent to ZoneNum since the inter-reflected // component will not be calculated for these windows until the time-step loop. if (Surface(IWin).SolarEnclIndex == Zone(ZoneNum).SolarEnclosureNum) { // Output for each reference point, for each sky. Group by sky type first - for (const SkyType& skyType: {SkyType::Clear, SkyType::ClearTurbid, SkyType::Intermediate, SkyType::Overcast}) { + for (const DataDaylighting::SkyType& skyType: {DataDaylighting::SkyType::Clear, DataDaylighting::SkyType::ClearTurbid, DataDaylighting::SkyType::Intermediate, DataDaylighting::SkyType::Overcast}) { std::string skyTypeString; - if (skyType == SkyType::Clear) { + if (skyType == DataDaylighting::SkyType::Clear) { skyTypeString = "Clear Sky"; - } else if (skyType == SkyType::ClearTurbid) { + } else if (skyType == DataDaylighting::SkyType::ClearTurbid) { skyTypeString = "Clear Turbid Sky"; - } else if (skyType == SkyType::Intermediate) { + } else if (skyType == DataDaylighting::SkyType::Intermediate) { skyTypeString = "Intermediate Sky"; - } else if (skyType == SkyType::Overcast) { + } else if (skyType == DataDaylighting::SkyType::Overcast) { skyTypeString = "Overcast Sky"; //} else { // // Should never happen // skyTypeString = "ERROR_SKY_TYPE_NOT_HANDLED"; } - for (int refPtNum = 1; refPtNum <= ZoneDaylight(ZoneNum).TotalDaylRefPoints; ++refPtNum) { - DaylFac = ZoneDaylight(ZoneNum).DaylIllFacSky(12, 1, static_cast(skyType), refPtNum, loop); + for (int refPtNum = 1; refPtNum <= state.dataDaylightingData->ZoneDaylight(ZoneNum).TotalDaylRefPoints; ++refPtNum) { + DaylFac = state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylIllFacSky(12, 1, static_cast(skyType), refPtNum, loop); print(state.files.eio, " Sky Daylight Factors,{},{},{},{},{},{:.4R}\n", skyTypeString, CurMnDy, Zone(ZoneNum).Name, Surface(IWin).Name, - DaylRefPt(ZoneDaylight(ZoneNum).DaylRefPtNum(refPtNum)).Name, + state.dataDaylightingData->DaylRefPt(state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylRefPtNum(refPtNum)).Name, DaylFac); } } @@ -752,20 +747,20 @@ namespace DaylightingManager { if (TotWindowsWithDayl == 0) return; // Skip if no request of reporting - if ((!DFSReportSizingDays) && (!DFSReportAllShadowCalculationDays)) return; + if ((!state.dataDaylightingData->DFSReportSizingDays) && (!state.dataDaylightingData->DFSReportAllShadowCalculationDays)) return; // Skip duplicate calls if (state.dataGlobal->KickOffSizing) return; if (state.dataGlobal->DoingSizing) return; if (state.dataGlobal->KickOffSimulation) return; - if (DFSReportSizingDays) { + if (state.dataDaylightingData->DFSReportSizingDays) { if (state.dataGlobal->DoWeathSim && state.dataGlobal->DoDesDaySim) { if (state.dataGlobal->KindOfSim == DataGlobalConstants::KindOfSim::RunPeriodWeather) return; } } - if (DFSReportAllShadowCalculationDays) { + if (state.dataDaylightingData->DFSReportAllShadowCalculationDays) { if (state.dataGlobal->KindOfSim != DataGlobalConstants::KindOfSim::RunPeriodWeather) return; } @@ -781,10 +776,10 @@ namespace DaylightingManager { } for (ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ++ZoneNum) { - if (ZoneDaylight(ZoneNum).NumOfDayltgExtWins == 0) continue; + if (state.dataDaylightingData->ZoneDaylight(ZoneNum).NumOfDayltgExtWins == 0) continue; - for (loop = 1; loop <= ZoneDaylight(ZoneNum).NumOfDayltgExtWins; ++loop) { - IWin = ZoneDaylight(ZoneNum).DayltgExtWinSurfNums(loop); + for (loop = 1; loop <= state.dataDaylightingData->ZoneDaylight(ZoneNum).NumOfDayltgExtWins; ++loop) { + IWin = state.dataDaylightingData->ZoneDaylight(ZoneNum).DayltgExtWinSurfNums(loop); // For this report, do not include ext wins in zone/enclosure adjacent to ZoneNum since the inter-reflected // component will not be calculated for these windows until the time-step loop. @@ -817,17 +812,17 @@ namespace DaylightingManager { for (IHR = 1; IHR <= 24; ++IHR) { // For each Daylight Reference Point - for (int refPtNum = 1; refPtNum <= ZoneDaylight(ZoneNum).TotalDaylRefPoints; ++refPtNum) { - DFClrSky = ZoneDaylight(ZoneNum).DaylIllFacSky(IHR, ISlatAngle, static_cast(SkyType::Clear), refPtNum, loop); - DFClrTbSky = ZoneDaylight(ZoneNum).DaylIllFacSky(IHR, ISlatAngle, static_cast(SkyType::ClearTurbid), refPtNum, loop); - DFIntSky = ZoneDaylight(ZoneNum).DaylIllFacSky(IHR, ISlatAngle, static_cast(SkyType::Intermediate), refPtNum, loop); - DFOcSky = ZoneDaylight(ZoneNum).DaylIllFacSky(IHR, ISlatAngle, static_cast(SkyType::Overcast), refPtNum, loop); + for (int refPtNum = 1; refPtNum <= state.dataDaylightingData->ZoneDaylight(ZoneNum).TotalDaylRefPoints; ++refPtNum) { + DFClrSky = state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylIllFacSky(IHR, ISlatAngle, static_cast(DataDaylighting::SkyType::Clear), refPtNum, loop); + DFClrTbSky = state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylIllFacSky(IHR, ISlatAngle, static_cast(DataDaylighting::SkyType::ClearTurbid), refPtNum, loop); + DFIntSky = state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylIllFacSky(IHR, ISlatAngle, static_cast(DataDaylighting::SkyType::Intermediate), refPtNum, loop); + DFOcSky = state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylIllFacSky(IHR, ISlatAngle, static_cast(DataDaylighting::SkyType::Overcast), refPtNum, loop); // write daylight factors - 4 sky types for each daylight ref point print(state.files.dfs, "{},{},{:.5R},{:.5R},{:.5R},{:.5R}\n", IHR, - DaylRefPt(ZoneDaylight(ZoneNum).DaylRefPtNum(refPtNum)).Name, + state.dataDaylightingData->DaylRefPt(state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylRefPtNum(refPtNum)).Name, DFClrSky, DFClrTbSky, DFIntSky, @@ -889,8 +884,8 @@ namespace DaylightingManager { // make sure all necessary surfaces match to pipes ErrorsFound = false; for (TZoneNum = 1; TZoneNum <= state.dataGlobal->NumOfZones; ++TZoneNum) { - for (loopwin = 1; loopwin <= ZoneDaylight(TZoneNum).NumOfDayltgExtWins; ++loopwin) { - IWin = ZoneDaylight(TZoneNum).DayltgExtWinSurfNums(loopwin); + for (loopwin = 1; loopwin <= state.dataDaylightingData->ZoneDaylight(TZoneNum).NumOfDayltgExtWins; ++loopwin) { + IWin = state.dataDaylightingData->ZoneDaylight(TZoneNum).DayltgExtWinSurfNums(loopwin); if (SurfWinOriginalClass(IWin) != SurfaceClass::TDD_Diffuser) continue; // Look up the TDD:DOME object PipeNum = SurfWinTDDPipeNum(IWin); @@ -913,9 +908,9 @@ namespace DaylightingManager { CalcDayltgCoeffsRefPoints(state, ZoneNum); if (!state.dataGlobal->DoingSizing && !state.dataGlobal->KickOffSimulation) { // Calc for illuminance map - if (TotIllumMaps > 0) { - for (MapNum = 1; MapNum <= TotIllumMaps; ++MapNum) { - if (IllumMapCalc(MapNum).Zone != ZoneNum) continue; + if (state.dataDaylightingData->TotIllumMaps > 0) { + for (MapNum = 1; MapNum <= state.dataDaylightingData->TotIllumMaps; ++MapNum) { + if (state.dataDaylightingData->IllumMapCalc(MapNum).Zone != ZoneNum) continue; if (state.dataGlobal->WarmupFlag) { DisplayString(state, "Calculating Daylighting Coefficients (Map Points), Zone=" + Zone(ZoneNum).Name); } else { @@ -1021,7 +1016,7 @@ namespace DaylightingManager { Real64 DWY; // Vertical dimension of window element (m) Real64 DAXY; // Area of window element Real64 SkyObstructionMult; // Ratio of obstructed to unobstructed sky diffuse at a ground point - int ExtWinType; // Exterior window type (InZoneExtWin, AdjZoneExtWin, NotInOrAdjZoneExtWin) + DataDaylighting::iExtWinType ExtWinType; // Exterior window type (InZoneExtWin, AdjZoneExtWin, NotInOrAdjZoneExtWin) int BRef; int ILB; bool hitIntObs; // True iff interior obstruction hit @@ -1033,76 +1028,76 @@ namespace DaylightingManager { int WinEl; // Current window element if (refFirstTime && - std::any_of(ZoneDaylight.begin(), ZoneDaylight.end(), [](ZoneDaylightCalc const &e) { return e.TotalDaylRefPoints > 0; })) { - RefErrIndex.allocate(maxval(ZoneDaylight, &ZoneDaylightCalc::TotalDaylRefPoints), TotSurfaces); + std::any_of(state.dataDaylightingData->ZoneDaylight.begin(), state.dataDaylightingData->ZoneDaylight.end(), [](DataDaylighting::ZoneDaylightCalc const &e) { return e.TotalDaylRefPoints > 0; })) { + RefErrIndex.allocate(maxval(state.dataDaylightingData->ZoneDaylight, &DataDaylighting::ZoneDaylightCalc::TotalDaylRefPoints), TotSurfaces); RefErrIndex = 0; refFirstTime = false; } // Azimuth of view vector in absolute coord sys - AZVIEW = (ZoneDaylight(ZoneNum).ViewAzimuthForGlare + Zone(ZoneNum).RelNorth + BuildingAzimuth + BuildingRotationAppendixG) * DataGlobalConstants::DegToRadians(); + AZVIEW = (state.dataDaylightingData->ZoneDaylight(ZoneNum).ViewAzimuthForGlare + Zone(ZoneNum).RelNorth + BuildingAzimuth + BuildingRotationAppendixG) * DataGlobalConstants::DegToRadians(); // View vector components in absolute coord sys VIEWVC(1) = std::sin(AZVIEW); VIEWVC(2) = std::cos(AZVIEW); VIEWVC(3) = 0.0; - ZoneDaylight(ZoneNum).DaylIllumAtRefPt = 0.0; // Daylight illuminance at reference points (lux) - ZoneDaylight(ZoneNum).GlareIndexAtRefPt = 0.0; // Glare index at reference points - ZoneDaylight(ZoneNum).SolidAngAtRefPt = 0.0; - ZoneDaylight(ZoneNum).SolidAngAtRefPtWtd = 0.0; - ZoneDaylight(ZoneNum).IllumFromWinAtRefPt = 0.0; - ZoneDaylight(ZoneNum).BackLumFromWinAtRefPt = 0.0; - ZoneDaylight(ZoneNum).SourceLumFromWinAtRefPt = 0.0; + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylIllumAtRefPt = 0.0; // Daylight illuminance at reference points (lux) + state.dataDaylightingData->ZoneDaylight(ZoneNum).GlareIndexAtRefPt = 0.0; // Glare index at reference points + state.dataDaylightingData->ZoneDaylight(ZoneNum).SolidAngAtRefPt = 0.0; + state.dataDaylightingData->ZoneDaylight(ZoneNum).SolidAngAtRefPtWtd = 0.0; + state.dataDaylightingData->ZoneDaylight(ZoneNum).IllumFromWinAtRefPt = 0.0; + state.dataDaylightingData->ZoneDaylight(ZoneNum).BackLumFromWinAtRefPt = 0.0; + state.dataDaylightingData->ZoneDaylight(ZoneNum).SourceLumFromWinAtRefPt = 0.0; if (!DetailedSolarTimestepIntegration) { - ZoneDaylight(ZoneNum).DaylIllFacSky = 0.0; - ZoneDaylight(ZoneNum).DaylSourceFacSky = 0.0; - ZoneDaylight(ZoneNum).DaylBackFacSky = 0.0; - ZoneDaylight(ZoneNum).DaylIllFacSun = 0.0; - ZoneDaylight(ZoneNum).DaylIllFacSunDisk = 0.0; - ZoneDaylight(ZoneNum).DaylSourceFacSun = 0.0; - ZoneDaylight(ZoneNum).DaylSourceFacSunDisk = 0.0; - ZoneDaylight(ZoneNum).DaylBackFacSun = 0.0; - ZoneDaylight(ZoneNum).DaylBackFacSunDisk = 0.0; + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylIllFacSky = 0.0; + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylSourceFacSky = 0.0; + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylBackFacSky = 0.0; + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylIllFacSun = 0.0; + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylIllFacSunDisk = 0.0; + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylSourceFacSun = 0.0; + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylSourceFacSunDisk = 0.0; + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylBackFacSun = 0.0; + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylBackFacSunDisk = 0.0; } else { - int numRefPts = ZoneDaylight(ZoneNum).TotalDaylRefPoints; - ZoneDaylight(ZoneNum).DaylIllFacSky( - state.dataGlobal->HourOfDay, {1, MaxSlatAngs + 1}, {1, 4}, {1, numRefPts}, {1, ZoneDaylight(ZoneNum).NumOfDayltgExtWins}) = 0.0; - ZoneDaylight(ZoneNum).DaylSourceFacSky( - state.dataGlobal->HourOfDay, {1, MaxSlatAngs + 1}, {1, 4}, {1, numRefPts}, {1, ZoneDaylight(ZoneNum).NumOfDayltgExtWins}) = 0.0; - ZoneDaylight(ZoneNum).DaylBackFacSky( - state.dataGlobal->HourOfDay, {1, MaxSlatAngs + 1}, {1, 4}, {1, numRefPts}, {1, ZoneDaylight(ZoneNum).NumOfDayltgExtWins}) = 0.0; - ZoneDaylight(ZoneNum).DaylIllFacSun(state.dataGlobal->HourOfDay, {1, MaxSlatAngs + 1}, {1, numRefPts}, {1, ZoneDaylight(ZoneNum).NumOfDayltgExtWins}) = 0.0; - ZoneDaylight(ZoneNum).DaylIllFacSunDisk(state.dataGlobal->HourOfDay, {1, MaxSlatAngs + 1}, {1, numRefPts}, {1, ZoneDaylight(ZoneNum).NumOfDayltgExtWins}) = + int numRefPts = state.dataDaylightingData->ZoneDaylight(ZoneNum).TotalDaylRefPoints; + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylIllFacSky( + state.dataGlobal->HourOfDay, {1, MaxSlatAngs + 1}, {1, 4}, {1, numRefPts}, {1, state.dataDaylightingData->ZoneDaylight(ZoneNum).NumOfDayltgExtWins}) = 0.0; + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylSourceFacSky( + state.dataGlobal->HourOfDay, {1, MaxSlatAngs + 1}, {1, 4}, {1, numRefPts}, {1, state.dataDaylightingData->ZoneDaylight(ZoneNum).NumOfDayltgExtWins}) = 0.0; + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylBackFacSky( + state.dataGlobal->HourOfDay, {1, MaxSlatAngs + 1}, {1, 4}, {1, numRefPts}, {1, state.dataDaylightingData->ZoneDaylight(ZoneNum).NumOfDayltgExtWins}) = 0.0; + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylIllFacSun(state.dataGlobal->HourOfDay, {1, MaxSlatAngs + 1}, {1, numRefPts}, {1, state.dataDaylightingData->ZoneDaylight(ZoneNum).NumOfDayltgExtWins}) = 0.0; + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylIllFacSunDisk(state.dataGlobal->HourOfDay, {1, MaxSlatAngs + 1}, {1, numRefPts}, {1, state.dataDaylightingData->ZoneDaylight(ZoneNum).NumOfDayltgExtWins}) = 0.0; - ZoneDaylight(ZoneNum).DaylSourceFacSun(state.dataGlobal->HourOfDay, {1, MaxSlatAngs + 1}, {1, numRefPts}, {1, ZoneDaylight(ZoneNum).NumOfDayltgExtWins}) = + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylSourceFacSun(state.dataGlobal->HourOfDay, {1, MaxSlatAngs + 1}, {1, numRefPts}, {1, state.dataDaylightingData->ZoneDaylight(ZoneNum).NumOfDayltgExtWins}) = 0.0; - ZoneDaylight(ZoneNum).DaylSourceFacSunDisk( - state.dataGlobal->HourOfDay, {1, MaxSlatAngs + 1}, {1, numRefPts}, {1, ZoneDaylight(ZoneNum).NumOfDayltgExtWins}) = 0.0; - ZoneDaylight(ZoneNum).DaylBackFacSun(state.dataGlobal->HourOfDay, {1, MaxSlatAngs + 1}, {1, numRefPts}, {1, ZoneDaylight(ZoneNum).NumOfDayltgExtWins}) = + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylSourceFacSunDisk( + state.dataGlobal->HourOfDay, {1, MaxSlatAngs + 1}, {1, numRefPts}, {1, state.dataDaylightingData->ZoneDaylight(ZoneNum).NumOfDayltgExtWins}) = 0.0; + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylBackFacSun(state.dataGlobal->HourOfDay, {1, MaxSlatAngs + 1}, {1, numRefPts}, {1, state.dataDaylightingData->ZoneDaylight(ZoneNum).NumOfDayltgExtWins}) = 0.0; - ZoneDaylight(ZoneNum).DaylBackFacSunDisk(state.dataGlobal->HourOfDay, {1, MaxSlatAngs + 1}, {1, numRefPts}, {1, ZoneDaylight(ZoneNum).NumOfDayltgExtWins}) = + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylBackFacSunDisk(state.dataGlobal->HourOfDay, {1, MaxSlatAngs + 1}, {1, numRefPts}, {1, state.dataDaylightingData->ZoneDaylight(ZoneNum).NumOfDayltgExtWins}) = 0.0; } - NRF = ZoneDaylight(ZoneNum).TotalDaylRefPoints; + NRF = state.dataDaylightingData->ZoneDaylight(ZoneNum).TotalDaylRefPoints; BRef = 0; for (IL = 1; IL <= NRF; ++IL) { // Reference point in absolute coordinate system - RREF = ZoneDaylight(ZoneNum).DaylRefPtAbsCoord({1, 3}, IL); // ( x, y, z ) + RREF = state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylRefPtAbsCoord({1, 3}, IL); // ( x, y, z ) // ------------- // ---------- WINDOW LOOP ---------- // ------------- - for (loopwin = 1; loopwin <= ZoneDaylight(ZoneNum).NumOfDayltgExtWins; ++loopwin) { + for (loopwin = 1; loopwin <= state.dataDaylightingData->ZoneDaylight(ZoneNum).NumOfDayltgExtWins; ++loopwin) { FigureDayltgCoeffsAtPointsSetupForWindow(state, ZoneNum, IL, loopwin, - CalledForRefPoint, + DataDaylighting::iCalledFor::RefPoint, RREF, VIEWVC, IWin, @@ -1152,7 +1147,7 @@ namespace DaylightingManager { ZoneNum, IL, loopwin, - CalledForRefPoint, + DataDaylighting::iCalledFor::RefPoint, WinEl, IWin, IWin2, @@ -1235,7 +1230,7 @@ namespace DaylightingManager { RREF2, hitIntObs, hitExtObs, - CalledForRefPoint, + DataDaylighting::iCalledFor::RefPoint, TVISIntWin, TVISIntWinDisk); @@ -1286,7 +1281,7 @@ namespace DaylightingManager { RREF2, hitIntObs, hitExtObs, - CalledForRefPoint, + DataDaylighting::iCalledFor::RefPoint, TVISIntWin, TVISIntWinDisk); } @@ -1303,7 +1298,7 @@ namespace DaylightingManager { if (!DetailedSolarTimestepIntegration) { ISunPos = 0; for (IHR = 1; IHR <= 24; ++IHR) { - FigureRefPointDayltgFactorsToAddIllums(ZoneNum, ILB, IHR, ISunPos, IWin, loopwin, NWX, NWY, ICtrl); + FigureRefPointDayltgFactorsToAddIllums(state, ZoneNum, ILB, IHR, ISunPos, IWin, loopwin, NWX, NWY, ICtrl); } // End of sun position loop, IHR } else { @@ -1318,7 +1313,7 @@ namespace DaylightingManager { } else if (!SunIsUp && !MySunIsUpFlag) { ISunPos = -1; } - FigureRefPointDayltgFactorsToAddIllums(ZoneNum, ILB, state.dataGlobal->HourOfDay, ISunPos, IWin, loopwin, NWX, NWY, ICtrl); + FigureRefPointDayltgFactorsToAddIllums(state, ZoneNum, ILB, state.dataGlobal->HourOfDay, ISunPos, IWin, loopwin, NWX, NWY, ICtrl); } } // End of window loop, loopwin - IWin @@ -1421,7 +1416,7 @@ namespace DaylightingManager { bool is_Triangle; // True if window is triangular Real64 DAXY; // Area of window element Real64 SkyObstructionMult; // Ratio of obstructed to unobstructed sky diffuse at a ground point - int ExtWinType; // Exterior window type (InZoneExtWin, AdjZoneExtWin, NotInOrAdjZoneExtWin) + DataDaylighting::iExtWinType ExtWinType; // Exterior window type (InZoneExtWin, AdjZoneExtWin, NotInOrAdjZoneExtWin) int ILB; int MapNum; // Loop for map number bool hitIntObs; // True iff interior obstruction hit @@ -1434,71 +1429,71 @@ namespace DaylightingManager { static bool MySunIsUpFlag(false); int WinEl; // window elements counter - if (mapFirstTime && TotIllumMaps > 0) { + if (mapFirstTime && state.dataDaylightingData->TotIllumMaps > 0) { IL = -999; - for (MapNum = 1; MapNum <= TotIllumMaps; ++MapNum) { - IL = max(IL, IllumMapCalc(MapNum).TotalMapRefPoints); + for (MapNum = 1; MapNum <= state.dataDaylightingData->TotIllumMaps; ++MapNum) { + IL = max(IL, state.dataDaylightingData->IllumMapCalc(MapNum).TotalMapRefPoints); } MapErrIndex.dimension(IL, TotSurfaces, 0); mapFirstTime = false; } // Azimuth of view vector in absolute coord sys - AZVIEW = (ZoneDaylight(ZoneNum).ViewAzimuthForGlare + Zone(ZoneNum).RelNorth + BuildingAzimuth + BuildingRotationAppendixG) * DataGlobalConstants::DegToRadians(); + AZVIEW = (state.dataDaylightingData->ZoneDaylight(ZoneNum).ViewAzimuthForGlare + Zone(ZoneNum).RelNorth + BuildingAzimuth + BuildingRotationAppendixG) * DataGlobalConstants::DegToRadians(); // View vector components in absolute coord sys VIEWVC(1) = std::sin(AZVIEW); VIEWVC(2) = std::cos(AZVIEW); VIEWVC(3) = 0.0; - for (MapNum = 1; MapNum <= TotIllumMaps; ++MapNum) { + for (MapNum = 1; MapNum <= state.dataDaylightingData->TotIllumMaps; ++MapNum) { - if (IllumMapCalc(MapNum).Zone != ZoneNum) continue; + if (state.dataDaylightingData->IllumMapCalc(MapNum).Zone != ZoneNum) continue; - IllumMapCalc(MapNum).DaylIllumAtMapPt = 0.0; // Daylight illuminance at reference points (lux) - IllumMapCalc(MapNum).GlareIndexAtMapPt = 0.0; // Glare index at reference points - IllumMapCalc(MapNum).SolidAngAtMapPt = 0.0; - IllumMapCalc(MapNum).SolidAngAtMapPtWtd = 0.0; - IllumMapCalc(MapNum).IllumFromWinAtMapPt = 0.0; - IllumMapCalc(MapNum).BackLumFromWinAtMapPt = 0.0; - IllumMapCalc(MapNum).SourceLumFromWinAtMapPt = 0.0; + state.dataDaylightingData->IllumMapCalc(MapNum).DaylIllumAtMapPt = 0.0; // Daylight illuminance at reference points (lux) + state.dataDaylightingData->IllumMapCalc(MapNum).GlareIndexAtMapPt = 0.0; // Glare index at reference points + state.dataDaylightingData->IllumMapCalc(MapNum).SolidAngAtMapPt = 0.0; + state.dataDaylightingData->IllumMapCalc(MapNum).SolidAngAtMapPtWtd = 0.0; + state.dataDaylightingData->IllumMapCalc(MapNum).IllumFromWinAtMapPt = 0.0; + state.dataDaylightingData->IllumMapCalc(MapNum).BackLumFromWinAtMapPt = 0.0; + state.dataDaylightingData->IllumMapCalc(MapNum).SourceLumFromWinAtMapPt = 0.0; if (!DetailedSolarTimestepIntegration) { - IllumMapCalc(MapNum).DaylIllFacSky = 0.0; - IllumMapCalc(MapNum).DaylSourceFacSky = 0.0; - IllumMapCalc(MapNum).DaylBackFacSky = 0.0; - IllumMapCalc(MapNum).DaylIllFacSun = 0.0; - IllumMapCalc(MapNum).DaylIllFacSunDisk = 0.0; - IllumMapCalc(MapNum).DaylSourceFacSun = 0.0; - IllumMapCalc(MapNum).DaylSourceFacSunDisk = 0.0; - IllumMapCalc(MapNum).DaylBackFacSun = 0.0; - IllumMapCalc(MapNum).DaylBackFacSunDisk = 0.0; + state.dataDaylightingData->IllumMapCalc(MapNum).DaylIllFacSky = 0.0; + state.dataDaylightingData->IllumMapCalc(MapNum).DaylSourceFacSky = 0.0; + state.dataDaylightingData->IllumMapCalc(MapNum).DaylBackFacSky = 0.0; + state.dataDaylightingData->IllumMapCalc(MapNum).DaylIllFacSun = 0.0; + state.dataDaylightingData->IllumMapCalc(MapNum).DaylIllFacSunDisk = 0.0; + state.dataDaylightingData->IllumMapCalc(MapNum).DaylSourceFacSun = 0.0; + state.dataDaylightingData->IllumMapCalc(MapNum).DaylSourceFacSunDisk = 0.0; + state.dataDaylightingData->IllumMapCalc(MapNum).DaylBackFacSun = 0.0; + state.dataDaylightingData->IllumMapCalc(MapNum).DaylBackFacSunDisk = 0.0; } else { - IllumMapCalc(MapNum).DaylIllFacSky( - state.dataGlobal->HourOfDay, {1, MaxSlatAngs + 1}, {1, 4}, {1, MaxRefPoints}, {1, ZoneDaylight(ZoneNum).NumOfDayltgExtWins}) = 0.0; - IllumMapCalc(MapNum).DaylSourceFacSky( - state.dataGlobal->HourOfDay, {1, MaxSlatAngs + 1}, {1, 4}, {1, MaxRefPoints}, {1, ZoneDaylight(ZoneNum).NumOfDayltgExtWins}) = 0.0; - IllumMapCalc(MapNum).DaylBackFacSky( - state.dataGlobal->HourOfDay, {1, MaxSlatAngs + 1}, {1, 4}, {1, MaxRefPoints}, {1, ZoneDaylight(ZoneNum).NumOfDayltgExtWins}) = 0.0; - IllumMapCalc(MapNum).DaylIllFacSun( - state.dataGlobal->HourOfDay, {1, MaxSlatAngs + 1}, {1, MaxRefPoints}, {1, ZoneDaylight(ZoneNum).NumOfDayltgExtWins}) = 0.0; - IllumMapCalc(MapNum).DaylIllFacSunDisk( - state.dataGlobal->HourOfDay, {1, MaxSlatAngs + 1}, {1, MaxRefPoints}, {1, ZoneDaylight(ZoneNum).NumOfDayltgExtWins}) = 0.0; - IllumMapCalc(MapNum).DaylSourceFacSun( - state.dataGlobal->HourOfDay, {1, MaxSlatAngs + 1}, {1, MaxRefPoints}, {1, ZoneDaylight(ZoneNum).NumOfDayltgExtWins}) = 0.0; - IllumMapCalc(MapNum).DaylSourceFacSunDisk( - state.dataGlobal->HourOfDay, {1, MaxSlatAngs + 1}, {1, MaxRefPoints}, {1, ZoneDaylight(ZoneNum).NumOfDayltgExtWins}) = 0.0; - IllumMapCalc(MapNum).DaylBackFacSun( - state.dataGlobal->HourOfDay, {1, MaxSlatAngs + 1}, {1, MaxRefPoints}, {1, ZoneDaylight(ZoneNum).NumOfDayltgExtWins}) = 0.0; - IllumMapCalc(MapNum).DaylBackFacSunDisk( - state.dataGlobal->HourOfDay, {1, MaxSlatAngs + 1}, {1, MaxRefPoints}, {1, ZoneDaylight(ZoneNum).NumOfDayltgExtWins}) = 0.0; - } - NRF = IllumMapCalc(MapNum).TotalMapRefPoints; + state.dataDaylightingData->IllumMapCalc(MapNum).DaylIllFacSky( + state.dataGlobal->HourOfDay, {1, MaxSlatAngs + 1}, {1, 4}, {1, DataDaylighting::MaxRefPoints}, {1, state.dataDaylightingData->ZoneDaylight(ZoneNum).NumOfDayltgExtWins}) = 0.0; + state.dataDaylightingData->IllumMapCalc(MapNum).DaylSourceFacSky( + state.dataGlobal->HourOfDay, {1, MaxSlatAngs + 1}, {1, 4}, {1, DataDaylighting::MaxRefPoints}, {1, state.dataDaylightingData->ZoneDaylight(ZoneNum).NumOfDayltgExtWins}) = 0.0; + state.dataDaylightingData->IllumMapCalc(MapNum).DaylBackFacSky( + state.dataGlobal->HourOfDay, {1, MaxSlatAngs + 1}, {1, 4}, {1, DataDaylighting::MaxRefPoints}, {1, state.dataDaylightingData->ZoneDaylight(ZoneNum).NumOfDayltgExtWins}) = 0.0; + state.dataDaylightingData->IllumMapCalc(MapNum).DaylIllFacSun( + state.dataGlobal->HourOfDay, {1, MaxSlatAngs + 1}, {1, DataDaylighting::MaxRefPoints}, {1, state.dataDaylightingData->ZoneDaylight(ZoneNum).NumOfDayltgExtWins}) = 0.0; + state.dataDaylightingData->IllumMapCalc(MapNum).DaylIllFacSunDisk( + state.dataGlobal->HourOfDay, {1, MaxSlatAngs + 1}, {1, DataDaylighting::MaxRefPoints}, {1, state.dataDaylightingData->ZoneDaylight(ZoneNum).NumOfDayltgExtWins}) = 0.0; + state.dataDaylightingData->IllumMapCalc(MapNum).DaylSourceFacSun( + state.dataGlobal->HourOfDay, {1, MaxSlatAngs + 1}, {1, DataDaylighting::MaxRefPoints}, {1, state.dataDaylightingData->ZoneDaylight(ZoneNum).NumOfDayltgExtWins}) = 0.0; + state.dataDaylightingData->IllumMapCalc(MapNum).DaylSourceFacSunDisk( + state.dataGlobal->HourOfDay, {1, MaxSlatAngs + 1}, {1, DataDaylighting::MaxRefPoints}, {1, state.dataDaylightingData->ZoneDaylight(ZoneNum).NumOfDayltgExtWins}) = 0.0; + state.dataDaylightingData->IllumMapCalc(MapNum).DaylBackFacSun( + state.dataGlobal->HourOfDay, {1, MaxSlatAngs + 1}, {1, DataDaylighting::MaxRefPoints}, {1, state.dataDaylightingData->ZoneDaylight(ZoneNum).NumOfDayltgExtWins}) = 0.0; + state.dataDaylightingData->IllumMapCalc(MapNum).DaylBackFacSunDisk( + state.dataGlobal->HourOfDay, {1, MaxSlatAngs + 1}, {1, DataDaylighting::MaxRefPoints}, {1, state.dataDaylightingData->ZoneDaylight(ZoneNum).NumOfDayltgExtWins}) = 0.0; + } + NRF = state.dataDaylightingData->IllumMapCalc(MapNum).TotalMapRefPoints; // MapWindowSolidAngAtRefPt.allocate( NRF, ZoneDaylight( ZoneNum ).NumOfDayltgExtWins ); //Inactive // MapWindowSolidAngAtRefPtWtd.allocate( NRF, ZoneDaylight( ZoneNum ).NumOfDayltgExtWins ); // Not an array anymore for (IL = 1; IL <= NRF; ++IL) { - RREF = IllumMapCalc(MapNum).MapRefPtAbsCoord({1, 3}, IL); // (x, y, z) + RREF = state.dataDaylightingData->IllumMapCalc(MapNum).MapRefPtAbsCoord({1, 3}, IL); // (x, y, z) // ------------- // ---------- WINDOW LOOP ---------- @@ -1507,13 +1502,13 @@ namespace DaylightingManager { // MapWindowSolidAngAtRefPt = 0.0; //Inactive MapWindowSolidAngAtRefPtWtd = 0.0; - for (loopwin = 1; loopwin <= ZoneDaylight(ZoneNum).NumOfDayltgExtWins; ++loopwin) { + for (loopwin = 1; loopwin <= state.dataDaylightingData->ZoneDaylight(ZoneNum).NumOfDayltgExtWins; ++loopwin) { FigureDayltgCoeffsAtPointsSetupForWindow(state, ZoneNum, IL, loopwin, - CalledForMapPoint, + DataDaylighting::iCalledFor::MapPoint, RREF, VIEWVC, IWin, @@ -1564,7 +1559,7 @@ namespace DaylightingManager { ZoneNum, IL, loopwin, - CalledForMapPoint, + DataDaylighting::iCalledFor::MapPoint, WinEl, IWin, IWin2, @@ -1646,7 +1641,7 @@ namespace DaylightingManager { RREF2, hitIntObs, hitExtObs, - CalledForMapPoint, + DataDaylighting::iCalledFor::MapPoint, TVISIntWin, TVISIntWinDisk, MapNum, @@ -1697,7 +1692,7 @@ namespace DaylightingManager { RREF2, hitIntObs, hitExtObs, - CalledForMapPoint, + DataDaylighting::iCalledFor::MapPoint, TVISIntWin, TVISIntWinDisk, MapNum, @@ -1712,11 +1707,11 @@ namespace DaylightingManager { // Also calculate corresponding glare factors. ILB = IL; for (IHR = 1; IHR <= 24; ++IHR) { - FigureMapPointDayltgFactorsToAddIllums(ZoneNum, MapNum, ILB, IHR, IWin, loopwin, NWX, NWY, ICtrl); + FigureMapPointDayltgFactorsToAddIllums(state, ZoneNum, MapNum, ILB, IHR, IWin, loopwin, NWX, NWY, ICtrl); } // End of sun position loop, IHR } else { ILB = IL; - FigureMapPointDayltgFactorsToAddIllums(ZoneNum, MapNum, ILB, state.dataGlobal->HourOfDay, IWin, loopwin, NWX, NWY, ICtrl); + FigureMapPointDayltgFactorsToAddIllums(state, ZoneNum, MapNum, ILB, state.dataGlobal->HourOfDay, IWin, loopwin, NWX, NWY, ICtrl); } } // End of window loop, loopwin - IWin @@ -1730,7 +1725,7 @@ namespace DaylightingManager { int const ZoneNum, int const iRefPoint, int const loopwin, - int const CalledFrom, // indicate which type of routine called this routine + DataDaylighting::iCalledFor const CalledFrom, // indicate which type of routine called this routine Vector3 const &RREF, // Location of a reference point in absolute coordinate system Vector3 const &VIEWVC, // View vector in absolute coordinate system int &IWin, @@ -1747,7 +1742,7 @@ namespace DaylightingManager { int &ShType, // Window shading type int &BlNum, // Window blind number Vector3 &WNORM2, // Unit vector normal to window - int &ExtWinType, // Exterior window type (InZoneExtWin, AdjZoneExtWin, NotInOrAdjZoneExtWin) + DataDaylighting::iExtWinType &ExtWinType, // Exterior window type (InZoneExtWin, AdjZoneExtWin, NotInOrAdjZoneExtWin) int &IConst, // Construction counter Vector3 &RREF2, // Location of virtual reference point in absolute coordinate system Real64 &DWX, // Horizontal dimension of window element (m) @@ -1843,19 +1838,19 @@ namespace DaylightingManager { // TransBeam = 0.0; //Unused Set but never used NRefPts = 0; - IWin = ZoneDaylight(ZoneNum).DayltgExtWinSurfNums(loopwin); + IWin = state.dataDaylightingData->ZoneDaylight(ZoneNum).DayltgExtWinSurfNums(loopwin); - if (CalledFrom == CalledForRefPoint) { - ZoneDaylight(ZoneNum).SolidAngAtRefPt(loopwin, iRefPoint) = 0.0; - ZoneDaylight(ZoneNum).SolidAngAtRefPtWtd(loopwin, iRefPoint) = 0.0; - } else if (CalledFrom == CalledForMapPoint) { - IllumMapCalc(MapNum).SolidAngAtMapPt(loopwin, iRefPoint) = 0.0; - IllumMapCalc(MapNum).SolidAngAtMapPtWtd(loopwin, iRefPoint) = 0.0; + if (CalledFrom == DataDaylighting::iCalledFor::RefPoint) { + state.dataDaylightingData->ZoneDaylight(ZoneNum).SolidAngAtRefPt(loopwin, iRefPoint) = 0.0; + state.dataDaylightingData->ZoneDaylight(ZoneNum).SolidAngAtRefPtWtd(loopwin, iRefPoint) = 0.0; + } else if (CalledFrom == DataDaylighting::iCalledFor::MapPoint) { + state.dataDaylightingData->IllumMapCalc(MapNum).SolidAngAtMapPt(loopwin, iRefPoint) = 0.0; + state.dataDaylightingData->IllumMapCalc(MapNum).SolidAngAtMapPtWtd(loopwin, iRefPoint) = 0.0; } if (Surface(Surface(IWin).BaseSurf).SolarEnclIndex == Zone(ZoneNum).SolarEnclosureNum) { - ExtWinType = InZoneExtWin; + ExtWinType = DataDaylighting::iExtWinType::InZoneExtWin; } else { - ExtWinType = AdjZoneExtWin; + ExtWinType = DataDaylighting::iExtWinType::AdjZoneExtWin; } IConst = Surface(IWin).Construction; @@ -1946,9 +1941,9 @@ namespace DaylightingManager { // Distance from ref point to window plane ALF = std::abs(dot(WNORM, REFWC)); - if (CalledFrom == CalledForRefPoint) { + if (CalledFrom == DataDaylighting::iCalledFor::RefPoint) { // Check if ref point to close to window due to input error (0.1524 m below is 0.5 ft) - if (ALF < 0.1524 && ExtWinType == InZoneExtWin) { + if (ALF < 0.1524 && ExtWinType == DataDaylighting::iExtWinType::InZoneExtWin) { // Ref pt is close to window plane. Get vector from window // origin to projection of ref pt on window plane. W2REF = RREF + ALF * WNORM - W2; @@ -1967,7 +1962,7 @@ namespace DaylightingManager { ShowContinueError(state, format("Distance=[{:.5R}]. This is too close; check position of reference point.", ALF)); ShowFatalError(state, "Program terminates due to preceding condition."); } - } else if (ALF < 0.1524 && ExtWinType == AdjZoneExtWin) { + } else if (ALF < 0.1524 && ExtWinType == DataDaylighting::iExtWinType::AdjZoneExtWin) { if (RefErrIndex(iRefPoint, IWin) == 0) { // only show error message once ShowWarningError(state, "CalcDaylightCoeffRefPoints: For Zone=\"" + Zone(ZoneNum).Name + "\" External Window=\"" + Surface(IWin).Name + "\"in Zone=\"" + Zone(Surface(IWin).Zone).Name + @@ -1981,8 +1976,8 @@ namespace DaylightingManager { RefErrIndex(iRefPoint, IWin) = 1; } } - } else if (CalledFrom == CalledForMapPoint) { - if (ALF < 0.1524 && ExtWinType == AdjZoneExtWin) { + } else if (CalledFrom == DataDaylighting::iCalledFor::MapPoint) { + if (ALF < 0.1524 && ExtWinType == DataDaylighting::iExtWinType::AdjZoneExtWin) { if (MapErrIndex(iRefPoint, IWin) == 0) { // only show error message once ShowWarningError(state, "CalcDaylightCoeffMapPoints: For Zone=\"" + Zone(ZoneNum).Name + "\" External Window=\"" + Surface(IWin).Name + "\"in Zone=\"" + Zone(Surface(IWin).Zone).Name + "\" map point is less than 0.15m (6\") from window plane "); @@ -2002,11 +1997,11 @@ namespace DaylightingManager { NDIVY = 1 + int(4.0 * HW / ALF); } - if (ExtWinType == AdjZoneExtWin) { + if (ExtWinType == DataDaylighting::iExtWinType::AdjZoneExtWin) { // Adjust number of exterior window elements to give acceptable number of rays through // interior windows in the zone (for accuracy of interior window daylighting calculation) SolidAngExtWin = SafeDivide(((Surface(IWin).Area + SurfWinDividerArea(IWin)) / Surface(IWin).Multiplier), pow_2(ALF)); - SolidAngMinIntWin = ZoneDaylight(ZoneNum).MinIntWinSolidAng; + SolidAngMinIntWin = state.dataDaylightingData->ZoneDaylight(ZoneNum).MinIntWinSolidAng; SolidAngRatio = max(1.0, SolidAngExtWin / SolidAngMinIntWin); NDIVX *= std::sqrt(SolidAngRatio); NDIVY *= std::sqrt(SolidAngRatio); @@ -2128,14 +2123,14 @@ namespace DaylightingManager { // Initialize bsdf daylighting coefficients here. Only one time initialization if (SurfWinWindowModelType(IWin) == WindowBSDFModel) { if (!state.dataBSDFWindow->ComplexWind(IWin).DaylightingInitialized) { - if (CalledFrom == CalledForMapPoint) { - NRefPts = IllumMapCalc(MapNum).TotalMapRefPoints; - } else if (CalledFrom == CalledForRefPoint) { - NRefPts = ZoneDaylight(ZoneNum).TotalDaylRefPoints; + if (CalledFrom == DataDaylighting::iCalledFor::MapPoint) { + NRefPts = state.dataDaylightingData->IllumMapCalc(MapNum).TotalMapRefPoints; + } else if (CalledFrom == DataDaylighting::iCalledFor::RefPoint) { + NRefPts = state.dataDaylightingData->ZoneDaylight(ZoneNum).TotalDaylRefPoints; } InitializeCFSDaylighting(state, ZoneNum, IWin, NWX, NWY, RREF, NRefPts, iRefPoint, CalledFrom, MapNum); // if ((WinEl == (NWX * NWY)).and.(CalledFrom == CalledForMapPoint).and.(NRefPts == iRefPoint)) then - if ((CalledFrom == CalledForMapPoint) && (NRefPts == iRefPoint)) { + if ((CalledFrom == DataDaylighting::iCalledFor::MapPoint) && (NRefPts == iRefPoint)) { state.dataBSDFWindow->ComplexWind(IWin).DaylightingInitialized = true; } } @@ -2158,12 +2153,12 @@ namespace DaylightingManager { AVWLSU(state.dataGlobal->HourOfDay, {1, MaxSlatAngs + 1}) = 0.0; AVWLSUdisk(state.dataGlobal->HourOfDay, {1, MaxSlatAngs + 1}) = 0.0; } - if (CalledFrom == CalledForRefPoint) { + if (CalledFrom == DataDaylighting::iCalledFor::RefPoint) { // Initialize solid angle subtended by window wrt ref pt // and solid angle weighted by glare position factor SurfaceWindow(IWin).SolidAngAtRefPt(iRefPoint) = 0.0; SurfaceWindow(IWin).SolidAngAtRefPtWtd(iRefPoint) = 0.0; - } else if (CalledFrom == CalledForMapPoint) { + } else if (CalledFrom == DataDaylighting::iCalledFor::MapPoint) { // Initialize solid angle subtended by window wrt ref pt // and solid angle weighted by glare position factor // if ( MapWindowSolidAngAtRefPt.present() ) MapWindowSolidAngAtRefPt = 0.0; //Inactive @@ -2183,7 +2178,7 @@ namespace DaylightingManager { int const ZoneNum, int const iRefPoint, int const loopwin, - int const CalledFrom, // indicate which type of routine called this routine + DataDaylighting::iCalledFor const CalledFrom, // indicate which type of routine called this routine int const WinEl, // Current window element number int const IWin, int const IWin2, @@ -2215,7 +2210,7 @@ namespace DaylightingManager { bool &hitIntObs, // True iff interior obstruction hit bool &hitExtObs, // True iff ray from ref pt to ext win hits an exterior obstruction Vector3 const &WNORM2, // Unit vector normal to window - int const ExtWinType, // Exterior window type (InZoneExtWin, AdjZoneExtWin, NotInOrAdjZoneExtWin) + DataDaylighting::iExtWinType const ExtWinType, // Exterior window type (InZoneExtWin, AdjZoneExtWin, NotInOrAdjZoneExtWin) int const IConst, // Construction counter Vector3 const &RREF2, // Location of virtual reference point in absolute coordinate system bool const is_Triangle, @@ -2371,7 +2366,7 @@ namespace DaylightingManager { // regular windows TVISB = 0.0; } - if (ExtWinType == AdjZoneExtWin) { + if (ExtWinType == DataDaylighting::iExtWinType::AdjZoneExtWin) { // Does ray pass through an interior window in zone (ZoneNum) containing the ref point? for (IntWin = Zone(ZoneNum).SurfaceFirst; IntWin <= Zone(ZoneNum).SurfaceLast; ++IntWin) { if (Surface(IntWin).Class == SurfaceClass::Window && Surface(IntWin).ExtBoundCond >= 1) { @@ -2402,7 +2397,7 @@ namespace DaylightingManager { } // End of check if TDD:Diffuser or regular exterior window or complex fenestration // Check for interior obstructions - if (ExtWinType == InZoneExtWin && !hitIntObs) { + if (ExtWinType == DataDaylighting::iExtWinType::InZoneExtWin && !hitIntObs) { // Check for obstruction between reference point and window element // Returns hitIntObs = true iff obstruction is hit // (Example of interior obstruction is a wall in an L-shaped room that lies @@ -2410,7 +2405,7 @@ namespace DaylightingManager { DayltgHitInteriorObstruction(IWin, RREF, RWIN, hitIntObs); } - if (ExtWinType == AdjZoneExtWin && IntWinHitNum > 0 && !hitIntObs) { + if (ExtWinType == DataDaylighting::iExtWinType::AdjZoneExtWin && IntWinHitNum > 0 && !hitIntObs) { // Check for obstruction between ref point and interior window through which ray passes DayltgHitInteriorObstruction(IntWinHitNum, RREF, HitPtIntWin, hitIntObs); if (!hitIntObs) { @@ -2418,25 +2413,25 @@ namespace DaylightingManager { DayltgHitBetWinObstruction(IntWinHitNum, IWin, HitPtIntWin, RWIN, hitIntObs); } } - if (CalledFrom == CalledForRefPoint) { + if (CalledFrom == DataDaylighting::iCalledFor::RefPoint) { if (!hitIntObs) { - if (ExtWinType == InZoneExtWin || (ExtWinType == AdjZoneExtWin && hitIntWin)) { + if (ExtWinType == DataDaylighting::iExtWinType::InZoneExtWin || (ExtWinType == DataDaylighting::iExtWinType::AdjZoneExtWin && hitIntWin)) { // Increment solid angle subtended by portion of window above ref pt SurfaceWindow(IWin).SolidAngAtRefPt(iRefPoint) += DOMEGA; - ZoneDaylight(ZoneNum).SolidAngAtRefPt(loopwin, iRefPoint) += DOMEGA; + state.dataDaylightingData->ZoneDaylight(ZoneNum).SolidAngAtRefPt(loopwin, iRefPoint) += DOMEGA; // Increment position-factor-modified solid angle SurfaceWindow(IWin).SolidAngAtRefPtWtd(iRefPoint) += DOMEGA * POSFAC; - ZoneDaylight(ZoneNum).SolidAngAtRefPtWtd(loopwin, iRefPoint) += DOMEGA * POSFAC; + state.dataDaylightingData->ZoneDaylight(ZoneNum).SolidAngAtRefPtWtd(loopwin, iRefPoint) += DOMEGA * POSFAC; } } - } else if (CalledFrom == CalledForMapPoint) { + } else if (CalledFrom == DataDaylighting::iCalledFor::MapPoint) { if (!hitIntObs) { - if (ExtWinType == InZoneExtWin || (ExtWinType == AdjZoneExtWin && hitIntWin)) { + if (ExtWinType == DataDaylighting::iExtWinType::InZoneExtWin || (ExtWinType == DataDaylighting::iExtWinType::AdjZoneExtWin && hitIntWin)) { // if ( MapWindowSolidAngAtRefPt.present() ) MapWindowSolidAngAtRefPt += DOMEGA; ////Inactive - IllumMapCalc(MapNum).SolidAngAtMapPt(loopwin, iRefPoint) += DOMEGA; + state.dataDaylightingData->IllumMapCalc(MapNum).SolidAngAtMapPt(loopwin, iRefPoint) += DOMEGA; MapWindowSolidAngAtRefPtWtd += DOMEGA * POSFAC; - IllumMapCalc(MapNum).SolidAngAtMapPtWtd(loopwin, iRefPoint) += DOMEGA * POSFAC; + state.dataDaylightingData->IllumMapCalc(MapNum).SolidAngAtMapPtWtd(loopwin, iRefPoint) += DOMEGA * POSFAC; } } } @@ -2459,13 +2454,13 @@ namespace DaylightingManager { // Transmittance from exterior obstruction surfaces is calculated here. This needs to be done for each timestep // in order to account for changes in exterior surface transmittances CplxFenState = SurfaceWindow(IWin).ComplexFen.CurrentState; - if (CalledFrom == CalledForRefPoint) { + if (CalledFrom == DataDaylighting::iCalledFor::RefPoint) { NReflSurf = state.dataBSDFWindow->ComplexWind(IWin).DaylghtGeom(CplxFenState).RefPoint(iRefPoint).NReflSurf(WinEl); } else { NReflSurf = state.dataBSDFWindow->ComplexWind(IWin).DaylghtGeom(CplxFenState).IlluminanceMap(iRefPoint, MapNum).NReflSurf(WinEl); } for (ICplxFen = 1; ICplxFen <= NReflSurf; ++ICplxFen) { - if (CalledFrom == CalledForRefPoint) { + if (CalledFrom == DataDaylighting::iCalledFor::RefPoint) { RayIndex = state.dataBSDFWindow->ComplexWind(IWin).DaylghtGeom(CplxFenState).RefPoint(iRefPoint).RefSurfIndex(ICplxFen, WinEl); } else { RayIndex = state.dataBSDFWindow->ComplexWind(IWin).DaylghtGeom(CplxFenState).IlluminanceMap(iRefPoint, MapNum).RefSurfIndex(ICplxFen, WinEl); @@ -2474,7 +2469,7 @@ namespace DaylightingManager { // It will get product of all transmittances DayltgHitObstruction(state, state.dataGlobal->HourOfDay, IWin, RWIN, RayVector, TransBeam); // IF (TransBeam > 0.0d0) ObTrans = TransBeam - if (CalledFrom == CalledForRefPoint) { + if (CalledFrom == DataDaylighting::iCalledFor::RefPoint) { state.dataBSDFWindow->ComplexWind(IWin).DaylghtGeom(CplxFenState).RefPoint(iRefPoint).TransOutSurf(ICplxFen, WinEl) = TransBeam; } else { state.dataBSDFWindow->ComplexWind(IWin).DaylghtGeom(CplxFenState).IlluminanceMap(iRefPoint, MapNum).TransOutSurf(ICplxFen, WinEl) = TransBeam; @@ -2512,7 +2507,7 @@ namespace DaylightingManager { Vector3 const &RefPoint, // reference point coordinates int const NRefPts, // Number of reference points int const iRefPoint, // Reference points counter - int const CalledFrom, + DataDaylighting::iCalledFor const CalledFrom, Optional_int_const MapNum) { // SUBROUTINE INFORMATION: @@ -2584,7 +2579,7 @@ namespace DaylightingManager { DWX = Surface(IWin).Width / NWX; DWY = Surface(IWin).Height / NWY; - AZVIEW = (ZoneDaylight(ZoneNum).ViewAzimuthForGlare + Zone(ZoneNum).RelNorth + BuildingAzimuth + BuildingRotationAppendixG) * DataGlobalConstants::DegToRadians(); + AZVIEW = (state.dataDaylightingData->ZoneDaylight(ZoneNum).ViewAzimuthForGlare + Zone(ZoneNum).RelNorth + BuildingAzimuth + BuildingRotationAppendixG) * DataGlobalConstants::DegToRadians(); // Perform necessary calculations for window coordinates and vectors. This will be used to calculate centroids for // each window element @@ -2615,15 +2610,15 @@ namespace DaylightingManager { WinElArea *= std::sqrt(1.0 - pow_2(dot(W21, W23))); } - if (CalledFrom == CalledForMapPoint) { + if (CalledFrom == DataDaylighting::iCalledFor::MapPoint) { if (!allocated(state.dataBSDFWindow->ComplexWind(IWin).IlluminanceMap)) { - state.dataBSDFWindow->ComplexWind(IWin).IlluminanceMap.allocate(NRefPts, TotIllumMaps); + state.dataBSDFWindow->ComplexWind(IWin).IlluminanceMap.allocate(NRefPts, state.dataDaylightingData->TotIllumMaps); } AllocateForCFSRefPointsGeometry(state.dataBSDFWindow->ComplexWind(IWin).IlluminanceMap(iRefPoint, MapNum), NumOfWinEl); - } else if (CalledFrom == CalledForRefPoint) { + } else if (CalledFrom == DataDaylighting::iCalledFor::RefPoint) { if (!allocated(state.dataBSDFWindow->ComplexWind(IWin).RefPoint)) { state.dataBSDFWindow->ComplexWind(IWin).RefPoint.allocate(NRefPts); } @@ -2643,11 +2638,11 @@ namespace DaylightingManager { NBasis = state.dataBSDFWindow->ComplexWind(IWin).Geom(CurFenState).Inc.NBasis; NTrnBasis = state.dataBSDFWindow->ComplexWind(IWin).Geom(CurFenState).Trn.NBasis; - if (CalledFrom == CalledForMapPoint) { - if (TotIllumMaps > 0) { + if (CalledFrom == DataDaylighting::iCalledFor::MapPoint) { + if (state.dataDaylightingData->TotIllumMaps > 0) { // illuminance map for each state if (!allocated(state.dataBSDFWindow->ComplexWind(IWin).DaylghtGeom(CurFenState).IlluminanceMap)) { - state.dataBSDFWindow->ComplexWind(IWin).DaylghtGeom(CurFenState).IlluminanceMap.allocate(NRefPts, TotIllumMaps); + state.dataBSDFWindow->ComplexWind(IWin).DaylghtGeom(CurFenState).IlluminanceMap.allocate(NRefPts, state.dataDaylightingData->TotIllumMaps); } AllocateForCFSRefPointsState( @@ -2676,7 +2671,7 @@ namespace DaylightingManager { MapNum); } - } else if (CalledFrom == CalledForRefPoint) { + } else if (CalledFrom == DataDaylighting::iCalledFor::RefPoint) { if (!allocated(state.dataBSDFWindow->ComplexWind(IWin).DaylghtGeom(CurFenState).RefPoint)) { state.dataBSDFWindow->ComplexWind(IWin).DaylghtGeom(CurFenState).RefPoint.allocate(NRefPts); } @@ -2727,7 +2722,7 @@ namespace DaylightingManager { Real64 const DWY, Vector3 const &WNorm, // unit vector from window (point towards outside) Real64 const WinElArea, - [[maybe_unused]] int const CalledFrom, + [[maybe_unused]] DataDaylighting::iCalledFor const CalledFrom, [[maybe_unused]] Optional_int_const MapNum) { // SUBROUTINE INFORMATION: @@ -3382,13 +3377,13 @@ namespace DaylightingManager { int const BlNum, // Window blind number Real64 const THRAY, // Azimuth of ray from reference point to window element (radians) Vector3 const &WNORM2, // Unit vector normal to window - int const ExtWinType, // Exterior window type (InZoneExtWin, AdjZoneExtWin, NotInOrAdjZoneExtWin) + DataDaylighting::iExtWinType const ExtWinType, // Exterior window type (InZoneExtWin, AdjZoneExtWin, NotInOrAdjZoneExtWin) int const IConst, // Construction counter Real64 const AZVIEW, // Azimuth of view vector in absolute coord system for glare calculation (radians) Vector3 const &RREF2, // Location of virtual reference point in absolute coordinate system bool const hitIntObs, // True iff interior obstruction hit bool const hitExtObs, // True iff ray from ref pt to ext win hits an exterior obstruction - int const CalledFrom, // indicate which type of routine called this routine + DataDaylighting::iCalledFor const CalledFrom, // indicate which type of routine called this routine Real64 &TVISIntWin, // Visible transmittance of int win at COSBIntWin for light from ext win Real64 &TVISIntWinDisk, // Visible transmittance of int win at COSBIntWin for sun Optional_int_const MapNum, @@ -3717,14 +3712,14 @@ namespace DaylightingManager { PierceSurface(IWin2, RREF2, RAYCOS, HP, hitWin); hitIntObsDisk = false; if (hitWin) { - if (ExtWinType == InZoneExtWin) { + if (ExtWinType == DataDaylighting::iExtWinType::InZoneExtWin) { // Check for interior obstructions between reference point and HP. DayltgHitInteriorObstruction(IWin2, RREF2, HP, hitIntObsDisk); } ObTransDisk = 0.0; // Init value // Init flag for vector from RP to sun passing through interior window hitIntWinDisk = false; - if (ExtWinType == AdjZoneExtWin) { // This block is for RPs in zones with interior windows + if (ExtWinType == DataDaylighting::iExtWinType::AdjZoneExtWin) { // This block is for RPs in zones with interior windows // adjacent to zones with exterior windows // Does RAYCOS pass through interior window in zone containing RP? // Loop over zone surfaces looking for interior windows between reference point and sun @@ -3780,7 +3775,7 @@ namespace DaylightingManager { // and vector to sun does not pass through interior window // then reset ObTransDisk to 0.0 since it is the key test for adding // contribution of sun to RP below. - if ((ExtWinType == AdjZoneExtWin) && (!hitIntWinDisk)) { + if ((ExtWinType == DataDaylighting::iExtWinType::AdjZoneExtWin) && (!hitIntWinDisk)) { ObTransDisk = 0.0; } } @@ -3801,7 +3796,7 @@ namespace DaylightingManager { // Beam transmittance for bare window and all types of blinds TVISS = POLYF(COSI, state.dataConstruction->Construct(IConst).TransVisBeamCoef) * SurfWinGlazedFrac(IWin) * SurfWinLightWellEff(IWin); - if (ExtWinType == AdjZoneExtWin && hitIntWinDisk) TVISS *= TVISIntWinDisk; + if (ExtWinType == DataDaylighting::iExtWinType::AdjZoneExtWin && hitIntWinDisk) TVISS *= TVISIntWinDisk; } EDIRSUdisk(iHour, 1) = RAYCOS(3) * TVISS * ObTransDisk; // Bare window @@ -3844,9 +3839,9 @@ namespace DaylightingManager { { auto const SELECT_CASE_var(CalledFrom); - if (SELECT_CASE_var == CalledForRefPoint) { + if (SELECT_CASE_var == DataDaylighting::iCalledFor::RefPoint) { WindowSolidAngleDaylightPoint = SurfaceWindow(IWin).SolidAngAtRefPtWtd(iRefPoint); - } else if (SELECT_CASE_var == CalledForMapPoint) { + } else if (SELECT_CASE_var == DataDaylighting::iCalledFor::MapPoint) { WindowSolidAngleDaylightPoint = MapWindowSolidAngAtRefPtWtd; } } @@ -4064,7 +4059,8 @@ namespace DaylightingManager { } } - void FigureRefPointDayltgFactorsToAddIllums(int const ZoneNum, + void FigureRefPointDayltgFactorsToAddIllums(EnergyPlusData &state, + int const ZoneNum, int const iRefPoint, int const iHour, int &ISunPos, @@ -4139,43 +4135,43 @@ namespace DaylightingManager { if (!SurfWinMovableSlats(IWin) && JSH > 2) break; if (GILSK(iHour, ISky) > tmpDFCalc) { - ZoneDaylight(ZoneNum).DaylIllFacSky(iHour, JSH, ISky, iRefPoint, loopwin) = + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylIllFacSky(iHour, JSH, ISky, iRefPoint, loopwin) = (EDIRSK(iHour, JSH, ISky) + EINTSK(iHour, JSH, ISky)) / GILSK(iHour, ISky); - ZoneDaylight(ZoneNum).DaylSourceFacSky(iHour, JSH, ISky, iRefPoint, loopwin) = + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylSourceFacSky(iHour, JSH, ISky, iRefPoint, loopwin) = AVWLSK(iHour, JSH, ISky) / (NWX * NWY * GILSK(iHour, ISky)); - ZoneDaylight(ZoneNum).DaylBackFacSky(iHour, JSH, ISky, iRefPoint, loopwin) = - EINTSK(iHour, JSH, ISky) * ZoneDaylight(ZoneNum).AveVisDiffReflect / (DataGlobalConstants::Pi() * GILSK(iHour, ISky)); + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylBackFacSky(iHour, JSH, ISky, iRefPoint, loopwin) = + EINTSK(iHour, JSH, ISky) * state.dataDaylightingData->ZoneDaylight(ZoneNum).AveVisDiffReflect / (DataGlobalConstants::Pi() * GILSK(iHour, ISky)); } else { - ZoneDaylight(ZoneNum).DaylIllFacSky(iHour, JSH, ISky, iRefPoint, loopwin) = 0.0; - ZoneDaylight(ZoneNum).DaylSourceFacSky(iHour, JSH, ISky, iRefPoint, loopwin) = 0.0; - ZoneDaylight(ZoneNum).DaylBackFacSky(iHour, JSH, ISky, iRefPoint, loopwin) = 0.0; + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylIllFacSky(iHour, JSH, ISky, iRefPoint, loopwin) = 0.0; + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylSourceFacSky(iHour, JSH, ISky, iRefPoint, loopwin) = 0.0; + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylBackFacSky(iHour, JSH, ISky, iRefPoint, loopwin) = 0.0; } if (ISky == 1) { if (GILSU(iHour) > tmpDFCalc) { - ZoneDaylight(ZoneNum).DaylIllFacSun(iHour, JSH, iRefPoint, loopwin) = + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylIllFacSun(iHour, JSH, iRefPoint, loopwin) = (EDIRSU(iHour, JSH) + EINTSU(iHour, JSH)) / (GILSU(iHour) + 0.0001); - ZoneDaylight(ZoneNum).DaylIllFacSunDisk(iHour, JSH, iRefPoint, loopwin) = + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylIllFacSunDisk(iHour, JSH, iRefPoint, loopwin) = (EDIRSUdisk(iHour, JSH) + EINTSUdisk(iHour, JSH)) / (GILSU(iHour) + 0.0001); - ZoneDaylight(ZoneNum).DaylSourceFacSun(iHour, JSH, iRefPoint, loopwin) = + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylSourceFacSun(iHour, JSH, iRefPoint, loopwin) = AVWLSU(iHour, JSH) / (NWX * NWY * (GILSU(iHour) + 0.0001)); - ZoneDaylight(ZoneNum).DaylSourceFacSunDisk(iHour, JSH, iRefPoint, loopwin) = + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylSourceFacSunDisk(iHour, JSH, iRefPoint, loopwin) = AVWLSUdisk(iHour, JSH) / (NWX * NWY * (GILSU(iHour) + 0.0001)); - ZoneDaylight(ZoneNum).DaylBackFacSun(iHour, JSH, iRefPoint, loopwin) = - EINTSU(iHour, JSH) * ZoneDaylight(ZoneNum).AveVisDiffReflect / (DataGlobalConstants::Pi() * (GILSU(iHour) + 0.0001)); - ZoneDaylight(ZoneNum).DaylBackFacSunDisk(iHour, JSH, iRefPoint, loopwin) = - EINTSUdisk(iHour, JSH) * ZoneDaylight(ZoneNum).AveVisDiffReflect / (DataGlobalConstants::Pi() * (GILSU(iHour) + 0.0001)); + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylBackFacSun(iHour, JSH, iRefPoint, loopwin) = + EINTSU(iHour, JSH) * state.dataDaylightingData->ZoneDaylight(ZoneNum).AveVisDiffReflect / (DataGlobalConstants::Pi() * (GILSU(iHour) + 0.0001)); + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylBackFacSunDisk(iHour, JSH, iRefPoint, loopwin) = + EINTSUdisk(iHour, JSH) * state.dataDaylightingData->ZoneDaylight(ZoneNum).AveVisDiffReflect / (DataGlobalConstants::Pi() * (GILSU(iHour) + 0.0001)); } else { - ZoneDaylight(ZoneNum).DaylIllFacSun(iHour, JSH, iRefPoint, loopwin) = 0.0; - ZoneDaylight(ZoneNum).DaylIllFacSunDisk(iHour, JSH, iRefPoint, loopwin) = 0.0; + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylIllFacSun(iHour, JSH, iRefPoint, loopwin) = 0.0; + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylIllFacSunDisk(iHour, JSH, iRefPoint, loopwin) = 0.0; - ZoneDaylight(ZoneNum).DaylSourceFacSun(iHour, JSH, iRefPoint, loopwin) = 0.0; - ZoneDaylight(ZoneNum).DaylSourceFacSunDisk(iHour, JSH, iRefPoint, loopwin) = 0.0; + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylSourceFacSun(iHour, JSH, iRefPoint, loopwin) = 0.0; + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylSourceFacSunDisk(iHour, JSH, iRefPoint, loopwin) = 0.0; - ZoneDaylight(ZoneNum).DaylBackFacSun(iHour, JSH, iRefPoint, loopwin) = 0.0; - ZoneDaylight(ZoneNum).DaylBackFacSunDisk(iHour, JSH, iRefPoint, loopwin) = 0.0; + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylBackFacSun(iHour, JSH, iRefPoint, loopwin) = 0.0; + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylBackFacSunDisk(iHour, JSH, iRefPoint, loopwin) = 0.0; } } } // End of shading index loop, JSH @@ -4184,25 +4180,25 @@ namespace DaylightingManager { if (ICtrl > 0) { if (WindowShadingControl(ICtrl).ShadingType == WSC_ST_SwitchableGlazing) { VTR = SurfWinVisTransRatio(IWin); - ZoneDaylight(ZoneNum).DaylIllFacSky(iHour, 2, ISky, iRefPoint, loopwin) = - ZoneDaylight(ZoneNum).DaylIllFacSky(iHour, 1, ISky, iRefPoint, loopwin) * VTR; - ZoneDaylight(ZoneNum).DaylSourceFacSky(iHour, 2, ISky, iRefPoint, loopwin) = - ZoneDaylight(ZoneNum).DaylSourceFacSky(iHour, 1, ISky, iRefPoint, loopwin) * VTR; - ZoneDaylight(ZoneNum).DaylBackFacSky(iHour, 2, ISky, iRefPoint, loopwin) = - ZoneDaylight(ZoneNum).DaylBackFacSky(iHour, 1, ISky, iRefPoint, loopwin) * VTR; + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylIllFacSky(iHour, 2, ISky, iRefPoint, loopwin) = + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylIllFacSky(iHour, 1, ISky, iRefPoint, loopwin) * VTR; + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylSourceFacSky(iHour, 2, ISky, iRefPoint, loopwin) = + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylSourceFacSky(iHour, 1, ISky, iRefPoint, loopwin) * VTR; + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylBackFacSky(iHour, 2, ISky, iRefPoint, loopwin) = + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylBackFacSky(iHour, 1, ISky, iRefPoint, loopwin) * VTR; if (ISky == 1) { - ZoneDaylight(ZoneNum).DaylIllFacSun(iHour, 2, iRefPoint, loopwin) = - ZoneDaylight(ZoneNum).DaylIllFacSun(iHour, 1, iRefPoint, loopwin) * VTR; - ZoneDaylight(ZoneNum).DaylSourceFacSun(iHour, 2, iRefPoint, loopwin) = - ZoneDaylight(ZoneNum).DaylSourceFacSun(iHour, 1, iRefPoint, loopwin) * VTR; - ZoneDaylight(ZoneNum).DaylBackFacSun(iHour, 2, iRefPoint, loopwin) = - ZoneDaylight(ZoneNum).DaylBackFacSun(iHour, 1, iRefPoint, loopwin) * VTR; - ZoneDaylight(ZoneNum).DaylIllFacSunDisk(iHour, 2, iRefPoint, loopwin) = - ZoneDaylight(ZoneNum).DaylIllFacSunDisk(iHour, 1, iRefPoint, loopwin) * VTR; - ZoneDaylight(ZoneNum).DaylSourceFacSunDisk(iHour, 2, iRefPoint, loopwin) = - ZoneDaylight(ZoneNum).DaylSourceFacSunDisk(iHour, 1, iRefPoint, loopwin) * VTR; - ZoneDaylight(ZoneNum).DaylBackFacSunDisk(iHour, 2, iRefPoint, loopwin) = - ZoneDaylight(ZoneNum).DaylBackFacSunDisk(iHour, 1, iRefPoint, loopwin) * VTR; + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylIllFacSun(iHour, 2, iRefPoint, loopwin) = + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylIllFacSun(iHour, 1, iRefPoint, loopwin) * VTR; + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylSourceFacSun(iHour, 2, iRefPoint, loopwin) = + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylSourceFacSun(iHour, 1, iRefPoint, loopwin) * VTR; + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylBackFacSun(iHour, 2, iRefPoint, loopwin) = + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylBackFacSun(iHour, 1, iRefPoint, loopwin) * VTR; + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylIllFacSunDisk(iHour, 2, iRefPoint, loopwin) = + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylIllFacSunDisk(iHour, 1, iRefPoint, loopwin) * VTR; + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylSourceFacSunDisk(iHour, 2, iRefPoint, loopwin) = + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylSourceFacSunDisk(iHour, 1, iRefPoint, loopwin) * VTR; + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylBackFacSunDisk(iHour, 2, iRefPoint, loopwin) = + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylBackFacSunDisk(iHour, 1, iRefPoint, loopwin) * VTR; } } } // ICtrl > 0 @@ -4210,7 +4206,8 @@ namespace DaylightingManager { } // End of sky type loop, ISky } - void FigureMapPointDayltgFactorsToAddIllums(int const ZoneNum, + void FigureMapPointDayltgFactorsToAddIllums(EnergyPlusData &state, + int const ZoneNum, int const MapNum, int const iMapPoint, int const iHour, @@ -4284,43 +4281,43 @@ namespace DaylightingManager { if (!SurfWinMovableSlats(IWin) && JSH > 2) break; if (GILSK(iHour, ISky) > tmpDFCalc) { - IllumMapCalc(MapNum).DaylIllFacSky(iHour, JSH, ISky, iMapPoint, loopwin) = + state.dataDaylightingData->IllumMapCalc(MapNum).DaylIllFacSky(iHour, JSH, ISky, iMapPoint, loopwin) = (EDIRSK(iHour, JSH, ISky) + EINTSK(iHour, JSH, ISky)) / GILSK(iHour, ISky); - IllumMapCalc(MapNum).DaylSourceFacSky(iHour, JSH, ISky, iMapPoint, loopwin) = + state.dataDaylightingData->IllumMapCalc(MapNum).DaylSourceFacSky(iHour, JSH, ISky, iMapPoint, loopwin) = AVWLSK(iHour, JSH, ISky) / (NWX * NWY * GILSK(iHour, ISky)); - IllumMapCalc(MapNum).DaylBackFacSky(iHour, JSH, ISky, iMapPoint, loopwin) = - EINTSK(iHour, JSH, ISky) * ZoneDaylight(ZoneNum).AveVisDiffReflect / (DataGlobalConstants::Pi() * GILSK(iHour, ISky)); + state.dataDaylightingData->IllumMapCalc(MapNum).DaylBackFacSky(iHour, JSH, ISky, iMapPoint, loopwin) = + EINTSK(iHour, JSH, ISky) * state.dataDaylightingData->ZoneDaylight(ZoneNum).AveVisDiffReflect / (DataGlobalConstants::Pi() * GILSK(iHour, ISky)); } else { - IllumMapCalc(MapNum).DaylIllFacSky(iHour, JSH, ISky, iMapPoint, loopwin) = 0.0; - IllumMapCalc(MapNum).DaylSourceFacSky(iHour, JSH, ISky, iMapPoint, loopwin) = 0.0; - IllumMapCalc(MapNum).DaylBackFacSky(iHour, JSH, ISky, iMapPoint, loopwin) = 0.0; + state.dataDaylightingData->IllumMapCalc(MapNum).DaylIllFacSky(iHour, JSH, ISky, iMapPoint, loopwin) = 0.0; + state.dataDaylightingData->IllumMapCalc(MapNum).DaylSourceFacSky(iHour, JSH, ISky, iMapPoint, loopwin) = 0.0; + state.dataDaylightingData->IllumMapCalc(MapNum).DaylBackFacSky(iHour, JSH, ISky, iMapPoint, loopwin) = 0.0; } if (ISky == 1) { if (GILSU(iHour) > tmpDFCalc) { - IllumMapCalc(MapNum).DaylIllFacSun(iHour, JSH, iMapPoint, loopwin) = + state.dataDaylightingData->IllumMapCalc(MapNum).DaylIllFacSun(iHour, JSH, iMapPoint, loopwin) = (EDIRSU(iHour, JSH) + EINTSU(iHour, JSH)) / (GILSU(iHour) + 0.0001); - IllumMapCalc(MapNum).DaylIllFacSunDisk(iHour, JSH, iMapPoint, loopwin) = + state.dataDaylightingData->IllumMapCalc(MapNum).DaylIllFacSunDisk(iHour, JSH, iMapPoint, loopwin) = (EDIRSUdisk(iHour, JSH) + EINTSUdisk(iHour, JSH)) / (GILSU(iHour) + 0.0001); - IllumMapCalc(MapNum).DaylSourceFacSun(iHour, JSH, iMapPoint, loopwin) = + state.dataDaylightingData->IllumMapCalc(MapNum).DaylSourceFacSun(iHour, JSH, iMapPoint, loopwin) = AVWLSU(iHour, JSH) / (NWX * NWY * (GILSU(iHour) + 0.0001)); - IllumMapCalc(MapNum).DaylSourceFacSunDisk(iHour, JSH, iMapPoint, loopwin) = + state.dataDaylightingData->IllumMapCalc(MapNum).DaylSourceFacSunDisk(iHour, JSH, iMapPoint, loopwin) = AVWLSUdisk(iHour, JSH) / (NWX * NWY * (GILSU(iHour) + 0.0001)); - IllumMapCalc(MapNum).DaylBackFacSun(iHour, JSH, iMapPoint, loopwin) = - EINTSU(iHour, JSH) * ZoneDaylight(ZoneNum).AveVisDiffReflect / (DataGlobalConstants::Pi() * (GILSU(iHour) + 0.0001)); - IllumMapCalc(MapNum).DaylBackFacSunDisk(iHour, JSH, iMapPoint, loopwin) = - EINTSUdisk(iHour, JSH) * ZoneDaylight(ZoneNum).AveVisDiffReflect / (DataGlobalConstants::Pi() * (GILSU(iHour) + 0.0001)); + state.dataDaylightingData->IllumMapCalc(MapNum).DaylBackFacSun(iHour, JSH, iMapPoint, loopwin) = + EINTSU(iHour, JSH) * state.dataDaylightingData->ZoneDaylight(ZoneNum).AveVisDiffReflect / (DataGlobalConstants::Pi() * (GILSU(iHour) + 0.0001)); + state.dataDaylightingData->IllumMapCalc(MapNum).DaylBackFacSunDisk(iHour, JSH, iMapPoint, loopwin) = + EINTSUdisk(iHour, JSH) * state.dataDaylightingData->ZoneDaylight(ZoneNum).AveVisDiffReflect / (DataGlobalConstants::Pi() * (GILSU(iHour) + 0.0001)); } else { - IllumMapCalc(MapNum).DaylIllFacSun(iHour, JSH, iMapPoint, loopwin) = 0.0; - IllumMapCalc(MapNum).DaylIllFacSunDisk(iHour, JSH, iMapPoint, loopwin) = 0.0; + state.dataDaylightingData->IllumMapCalc(MapNum).DaylIllFacSun(iHour, JSH, iMapPoint, loopwin) = 0.0; + state.dataDaylightingData->IllumMapCalc(MapNum).DaylIllFacSunDisk(iHour, JSH, iMapPoint, loopwin) = 0.0; - IllumMapCalc(MapNum).DaylSourceFacSun(iHour, JSH, iMapPoint, loopwin) = 0.0; - IllumMapCalc(MapNum).DaylSourceFacSunDisk(iHour, JSH, iMapPoint, loopwin) = 0.0; + state.dataDaylightingData->IllumMapCalc(MapNum).DaylSourceFacSun(iHour, JSH, iMapPoint, loopwin) = 0.0; + state.dataDaylightingData->IllumMapCalc(MapNum).DaylSourceFacSunDisk(iHour, JSH, iMapPoint, loopwin) = 0.0; - IllumMapCalc(MapNum).DaylBackFacSun(iHour, JSH, iMapPoint, loopwin) = 0.0; - IllumMapCalc(MapNum).DaylBackFacSunDisk(iHour, JSH, iMapPoint, loopwin) = 0.0; + state.dataDaylightingData->IllumMapCalc(MapNum).DaylBackFacSun(iHour, JSH, iMapPoint, loopwin) = 0.0; + state.dataDaylightingData->IllumMapCalc(MapNum).DaylBackFacSunDisk(iHour, JSH, iMapPoint, loopwin) = 0.0; } } } // End of shading index loop, JSH @@ -4329,25 +4326,25 @@ namespace DaylightingManager { if (ICtrl > 0) { if (WindowShadingControl(ICtrl).ShadingType == WSC_ST_SwitchableGlazing) { VTR = SurfWinVisTransRatio(IWin); - IllumMapCalc(MapNum).DaylIllFacSky(iHour, 2, ISky, iMapPoint, loopwin) = - IllumMapCalc(MapNum).DaylIllFacSky(iHour, 1, ISky, iMapPoint, loopwin) * VTR; - IllumMapCalc(MapNum).DaylSourceFacSky(iHour, 2, ISky, iMapPoint, loopwin) = - IllumMapCalc(MapNum).DaylSourceFacSky(iHour, 1, ISky, iMapPoint, loopwin) * VTR; - IllumMapCalc(MapNum).DaylBackFacSky(iHour, 2, ISky, iMapPoint, loopwin) = - IllumMapCalc(MapNum).DaylBackFacSky(iHour, 1, ISky, iMapPoint, loopwin) * VTR; + state.dataDaylightingData->IllumMapCalc(MapNum).DaylIllFacSky(iHour, 2, ISky, iMapPoint, loopwin) = + state.dataDaylightingData->IllumMapCalc(MapNum).DaylIllFacSky(iHour, 1, ISky, iMapPoint, loopwin) * VTR; + state.dataDaylightingData->IllumMapCalc(MapNum).DaylSourceFacSky(iHour, 2, ISky, iMapPoint, loopwin) = + state.dataDaylightingData->IllumMapCalc(MapNum).DaylSourceFacSky(iHour, 1, ISky, iMapPoint, loopwin) * VTR; + state.dataDaylightingData->IllumMapCalc(MapNum).DaylBackFacSky(iHour, 2, ISky, iMapPoint, loopwin) = + state.dataDaylightingData->IllumMapCalc(MapNum).DaylBackFacSky(iHour, 1, ISky, iMapPoint, loopwin) * VTR; if (ISky == 1) { - IllumMapCalc(MapNum).DaylIllFacSun(iHour, 2, iMapPoint, loopwin) = - IllumMapCalc(MapNum).DaylIllFacSun(iHour, 1, iMapPoint, loopwin) * VTR; - IllumMapCalc(MapNum).DaylSourceFacSun(iHour, 2, iMapPoint, loopwin) = - IllumMapCalc(MapNum).DaylSourceFacSun(iHour, 1, iMapPoint, loopwin) * VTR; - IllumMapCalc(MapNum).DaylBackFacSun(iHour, 2, iMapPoint, loopwin) = - IllumMapCalc(MapNum).DaylBackFacSun(iHour, 1, iMapPoint, loopwin) * VTR; - IllumMapCalc(MapNum).DaylIllFacSunDisk(iHour, 2, iMapPoint, loopwin) = - IllumMapCalc(MapNum).DaylIllFacSunDisk(iHour, 1, iMapPoint, loopwin) * VTR; - IllumMapCalc(MapNum).DaylSourceFacSunDisk(iHour, 2, iMapPoint, loopwin) = - IllumMapCalc(MapNum).DaylSourceFacSunDisk(iHour, 1, iMapPoint, loopwin) * VTR; - IllumMapCalc(MapNum).DaylBackFacSunDisk(iHour, 2, iMapPoint, loopwin) = - IllumMapCalc(MapNum).DaylBackFacSunDisk(iHour, 1, iMapPoint, loopwin) * VTR; + state.dataDaylightingData->IllumMapCalc(MapNum).DaylIllFacSun(iHour, 2, iMapPoint, loopwin) = + state.dataDaylightingData->IllumMapCalc(MapNum).DaylIllFacSun(iHour, 1, iMapPoint, loopwin) * VTR; + state.dataDaylightingData->IllumMapCalc(MapNum).DaylSourceFacSun(iHour, 2, iMapPoint, loopwin) = + state.dataDaylightingData->IllumMapCalc(MapNum).DaylSourceFacSun(iHour, 1, iMapPoint, loopwin) * VTR; + state.dataDaylightingData->IllumMapCalc(MapNum).DaylBackFacSun(iHour, 2, iMapPoint, loopwin) = + state.dataDaylightingData->IllumMapCalc(MapNum).DaylBackFacSun(iHour, 1, iMapPoint, loopwin) * VTR; + state.dataDaylightingData->IllumMapCalc(MapNum).DaylIllFacSunDisk(iHour, 2, iMapPoint, loopwin) = + state.dataDaylightingData->IllumMapCalc(MapNum).DaylIllFacSunDisk(iHour, 1, iMapPoint, loopwin) * VTR; + state.dataDaylightingData->IllumMapCalc(MapNum).DaylSourceFacSunDisk(iHour, 2, iMapPoint, loopwin) = + state.dataDaylightingData->IllumMapCalc(MapNum).DaylSourceFacSunDisk(iHour, 1, iMapPoint, loopwin) * VTR; + state.dataDaylightingData->IllumMapCalc(MapNum).DaylBackFacSunDisk(iHour, 2, iMapPoint, loopwin) = + state.dataDaylightingData->IllumMapCalc(MapNum).DaylBackFacSunDisk(iHour, 1, iMapPoint, loopwin) * VTR; } } } // ICtrl > 0 @@ -4403,7 +4400,7 @@ namespace DaylightingManager { int numEnclRefPoints = 0; int surfEnclNum = Surface(SurfNum).SolarEnclIndex; for (int const zoneNum : DataViewFactorInformation::ZoneSolarInfo(surfEnclNum).ZoneNums) { - int numRefPoints = ZoneDaylight(zoneNum).TotalDaylRefPoints; + int numRefPoints = state.dataDaylightingData->ZoneDaylight(zoneNum).TotalDaylRefPoints; numEnclRefPoints += numRefPoints; maxNumRefPtInAnyZone = max(numRefPoints, maxNumRefPtInAnyZone); } @@ -4434,7 +4431,7 @@ namespace DaylightingManager { int numAdjEnclRefPoints = 0; int adjSurfEnclNum = Surface(SurfNumAdj).SolarEnclIndex; for (int const adjZoneNum : DataViewFactorInformation::ZoneSolarInfo(adjSurfEnclNum).ZoneNums) { - numAdjEnclRefPoints += ZoneDaylight(adjZoneNum).TotalDaylRefPoints; + numAdjEnclRefPoints += state.dataDaylightingData->ZoneDaylight(adjZoneNum).TotalDaylRefPoints; } DataViewFactorInformation::ZoneSolarInfo(adjSurfEnclNum).TotalEnclosureDaylRefPoints = numAdjEnclRefPoints; if (numAdjEnclRefPoints > 0) { @@ -4525,9 +4522,9 @@ namespace DaylightingManager { for (int SurfLoop = 1; SurfLoop <= TotSurfaces; ++SurfLoop) { if (Surface(SurfLoop).Class == SurfaceClass::Window && Surface(SurfLoop).ExtSolar) { int const zoneOfSurf = Surface(SurfLoop).Zone; - if (ZoneDaylight(zoneOfSurf).TotalDaylRefPoints > 0 && !Zone(zoneOfSurf).HasInterZoneWindow && - ZoneDaylight(zoneOfSurf).DaylightMethod == SplitFluxDaylighting) { - for (int refPtNum = 1; refPtNum <= ZoneDaylight(zoneOfSurf).TotalDaylRefPoints; ++refPtNum) { + if (state.dataDaylightingData->ZoneDaylight(zoneOfSurf).TotalDaylRefPoints > 0 && !Zone(zoneOfSurf).HasInterZoneWindow && + state.dataDaylightingData->ZoneDaylight(zoneOfSurf).DaylightMethod == DataDaylighting::iDaylightingMethod::SplitFluxDaylighting) { + for (int refPtNum = 1; refPtNum <= state.dataDaylightingData->ZoneDaylight(zoneOfSurf).TotalDaylRefPoints; ++refPtNum) { SetupOutputVariable(state, format("Daylighting Window Reference Point {} Illuminance", refPtNum), OutputProcessor::Unit::lux, @@ -4553,11 +4550,11 @@ namespace DaylightingManager { int refPtCount = 0; for (int const enclZoneNum : DataViewFactorInformation::ZoneSolarInfo(enclNum).ZoneNums) { if (DataViewFactorInformation::ZoneSolarInfo(enclNum).TotalEnclosureDaylRefPoints > 0 && - !Zone(enclZoneNum).HasInterZoneWindow && ZoneDaylight(enclZoneNum).DaylightMethod == SplitFluxDaylighting) { - for (int refPtNum = 1; refPtNum <= ZoneDaylight(enclZoneNum).TotalDaylRefPoints; ++refPtNum) { + !Zone(enclZoneNum).HasInterZoneWindow && state.dataDaylightingData->ZoneDaylight(enclZoneNum).DaylightMethod == DataDaylighting::iDaylightingMethod::SplitFluxDaylighting) { + for (int refPtNum = 1; refPtNum <= state.dataDaylightingData->ZoneDaylight(enclZoneNum).TotalDaylRefPoints; ++refPtNum) { ++refPtCount; // Count reference points across each zone in the same enclosure std::string const varKey = - Surface(enclSurfNum).Name + " to " + DaylRefPt(ZoneDaylight(enclZoneNum).DaylRefPtNum(refPtNum)).Name; + Surface(enclSurfNum).Name + " to " + state.dataDaylightingData->DaylRefPt(state.dataDaylightingData->ZoneDaylight(enclZoneNum).DaylRefPtNum(refPtNum)).Name; SetupOutputVariable(state, "Daylighting Window Reference Point Illuminance", OutputProcessor::Unit::lux, SurfaceWindow(enclSurfNum).IllumFromWinAtRefPtRep(refPtCount), @@ -4579,7 +4576,7 @@ namespace DaylightingManager { } // RJH DElight Modification Begin - Calls to DElight preprocessing subroutines - if (doesDayLightingUseDElight()) { + if (doesDayLightingUseDElight(state)) { dLatitude = Latitude; DisplayString(state, "Calculating DElight Daylighting Factors"); DElightInputGenerator(state); @@ -4656,9 +4653,9 @@ namespace DaylightingManager { cAlphaFieldNames, cNumericFieldNames); if (has_prefix(cAlphaArgs(1), "SIZINGDAYS")) { - DFSReportSizingDays = true; + state.dataDaylightingData->DFSReportSizingDays = true; } else if (has_prefix(cAlphaArgs(1), "ALLSHADOWCALCULATIONDAYS")) { - DFSReportAllShadowCalculationDays = true; + state.dataDaylightingData->DFSReportAllShadowCalculationDays = true; } } @@ -4717,14 +4714,14 @@ namespace DaylightingManager { CheckForGeometricTransform(state, doTransform, OldAspectRatio, NewAspectRatio); cCurrentModuleObject = "Output:IlluminanceMap"; - TotIllumMaps = inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); + state.dataDaylightingData->TotIllumMaps = inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); - IllumMap.allocate(TotIllumMaps); - IllumMapCalc.allocate(TotIllumMaps); + state.dataDaylightingData->IllumMap.allocate(state.dataDaylightingData->TotIllumMaps); + state.dataDaylightingData->IllumMapCalc.allocate(state.dataDaylightingData->TotIllumMaps); ZoneMapCount.dimension(state.dataGlobal->NumOfZones, 0); - if (TotIllumMaps > 0) { - for (MapNum = 1; MapNum <= TotIllumMaps; ++MapNum) { + if (state.dataDaylightingData->TotIllumMaps > 0) { + for (MapNum = 1; MapNum <= state.dataDaylightingData->TotIllumMaps; ++MapNum) { inputProcessor->getObjectItem(state, cCurrentModuleObject, MapNum, @@ -4737,23 +4734,23 @@ namespace DaylightingManager { lAlphaFieldBlanks, cAlphaFieldNames, cNumericFieldNames); - IllumMap(MapNum).Name = cAlphaArgs(1); - IllumMap(MapNum).Zone = UtilityRoutines::FindItemInList(cAlphaArgs(2), Zone); + state.dataDaylightingData->IllumMap(MapNum).Name = cAlphaArgs(1); + state.dataDaylightingData->IllumMap(MapNum).Zone = UtilityRoutines::FindItemInList(cAlphaArgs(2), Zone); - if (IllumMap(MapNum).Zone == 0) { + if (state.dataDaylightingData->IllumMap(MapNum).Zone == 0) { ShowSevereError(state, cCurrentModuleObject + "=\"" + cAlphaArgs(1) + "\", invalid " + cAlphaFieldNames(2) + "=\"" + cAlphaArgs(2) + "\"."); ErrorsFound = true; } - IllumMapCalc(MapNum).Zone = IllumMap(MapNum).Zone; - if (IllumMap(MapNum).Zone != 0) { - ++ZoneMapCount(IllumMap(MapNum).Zone); + state.dataDaylightingData->IllumMapCalc(MapNum).Zone = state.dataDaylightingData->IllumMap(MapNum).Zone; + if (state.dataDaylightingData->IllumMap(MapNum).Zone != 0) { + ++ZoneMapCount(state.dataDaylightingData->IllumMap(MapNum).Zone); } - IllumMap(MapNum).Z = rNumericArgs(1); + state.dataDaylightingData->IllumMap(MapNum).Z = rNumericArgs(1); - IllumMap(MapNum).Xmin = rNumericArgs(2); - IllumMap(MapNum).Xmax = rNumericArgs(3); + state.dataDaylightingData->IllumMap(MapNum).Xmin = rNumericArgs(2); + state.dataDaylightingData->IllumMap(MapNum).Xmax = rNumericArgs(3); if (rNumericArgs(2) > rNumericArgs(3)) { ShowSevereError(state, cCurrentModuleObject + "=\"" + cAlphaArgs(1) + "\", invalid entry."); ShowContinueError( @@ -4761,15 +4758,15 @@ namespace DaylightingManager { format("...{}[:.2R] must be <= {} [:.2R].", cNumericFieldNames(2), rNumericArgs(2), cNumericFieldNames(3), rNumericArgs(3))); ErrorsFound = true; } - IllumMap(MapNum).Xnum = rNumericArgs(4); - if (IllumMap(MapNum).Xnum != 1) { - IllumMap(MapNum).Xinc = (IllumMap(MapNum).Xmax - IllumMap(MapNum).Xmin) / (IllumMap(MapNum).Xnum - 1); + state.dataDaylightingData->IllumMap(MapNum).Xnum = rNumericArgs(4); + if (state.dataDaylightingData->IllumMap(MapNum).Xnum != 1) { + state.dataDaylightingData->IllumMap(MapNum).Xinc = (state.dataDaylightingData->IllumMap(MapNum).Xmax - state.dataDaylightingData->IllumMap(MapNum).Xmin) / (state.dataDaylightingData->IllumMap(MapNum).Xnum - 1); } else { - IllumMap(MapNum).Xinc = 0.0; + state.dataDaylightingData->IllumMap(MapNum).Xinc = 0.0; } - IllumMap(MapNum).Ymin = rNumericArgs(5); - IllumMap(MapNum).Ymax = rNumericArgs(6); + state.dataDaylightingData->IllumMap(MapNum).Ymin = rNumericArgs(5); + state.dataDaylightingData->IllumMap(MapNum).Ymax = rNumericArgs(6); if (rNumericArgs(5) > rNumericArgs(6)) { ShowSevereError(state, cCurrentModuleObject + "=\"" + cAlphaArgs(1) + "\", invalid entry."); ShowContinueError( @@ -4777,22 +4774,22 @@ namespace DaylightingManager { format("...{}[:.2R] must be <= {} [:.2R].", cNumericFieldNames(5), rNumericArgs(5), cNumericFieldNames(6), rNumericArgs(6))); ErrorsFound = true; } - IllumMap(MapNum).Ynum = rNumericArgs(7); - if (IllumMap(MapNum).Ynum != 1) { - IllumMap(MapNum).Yinc = (IllumMap(MapNum).Ymax - IllumMap(MapNum).Ymin) / (IllumMap(MapNum).Ynum - 1); + state.dataDaylightingData->IllumMap(MapNum).Ynum = rNumericArgs(7); + if (state.dataDaylightingData->IllumMap(MapNum).Ynum != 1) { + state.dataDaylightingData->IllumMap(MapNum).Yinc = (state.dataDaylightingData->IllumMap(MapNum).Ymax - state.dataDaylightingData->IllumMap(MapNum).Ymin) / (state.dataDaylightingData->IllumMap(MapNum).Ynum - 1); } else { - IllumMap(MapNum).Yinc = 0.0; + state.dataDaylightingData->IllumMap(MapNum).Yinc = 0.0; } - if (IllumMap(MapNum).Xnum * IllumMap(MapNum).Ynum > MaxMapRefPoints) { + if (state.dataDaylightingData->IllumMap(MapNum).Xnum * state.dataDaylightingData->IllumMap(MapNum).Ynum > DataDaylighting::MaxMapRefPoints) { ShowSevereError(state, cCurrentModuleObject + "=\"" + cAlphaArgs(1) + "\", too many map points specified."); ShowContinueError(state, format("...{}[{}] * {}[{}].= [{}] must be <= [{}].", cNumericFieldNames(4), - IllumMap(MapNum).Xnum, + state.dataDaylightingData->IllumMap(MapNum).Xnum, cNumericFieldNames(7), - IllumMap(MapNum).Ynum, - IllumMap(MapNum).Xnum * IllumMap(MapNum).Ynum, - MaxMapRefPoints)); + state.dataDaylightingData->IllumMap(MapNum).Ynum, + state.dataDaylightingData->IllumMap(MapNum).Xnum * state.dataDaylightingData->IllumMap(MapNum).Ynum, + DataDaylighting::MaxMapRefPoints)); ErrorsFound = true; } } // MapNum @@ -4801,7 +4798,7 @@ namespace DaylightingManager { if (MapStyleIn == 0) { cAlphaArgs(1) = "COMMA"; - MapColSep = CharComma; // comma + state.dataDaylightingData->MapColSep = CharComma; // comma } else if (MapStyleIn == 1) { inputProcessor->getObjectItem(state, cCurrentModuleObject, @@ -4816,13 +4813,13 @@ namespace DaylightingManager { cAlphaFieldNames, cNumericFieldNames); if (cAlphaArgs(1) == "COMMA") { - MapColSep = CharComma; // comma + state.dataDaylightingData->MapColSep = CharComma; // comma } else if (cAlphaArgs(1) == "TAB") { - MapColSep = CharTab; // tab + state.dataDaylightingData->MapColSep = CharTab; // tab } else if (cAlphaArgs(1) == "FIXED" || cAlphaArgs(1) == "SPACE") { - MapColSep = CharSpace; // space + state.dataDaylightingData->MapColSep = CharSpace; // space } else { - MapColSep = CharComma; // comma + state.dataDaylightingData->MapColSep = CharComma; // comma ShowWarningError(state, cCurrentModuleObject + ": invalid " + cAlphaFieldNames(1) + "=\"" + cAlphaArgs(1) + "\", Commas will be used to separate fields."); cAlphaArgs(1) = "COMMA"; @@ -4832,52 +4829,52 @@ namespace DaylightingManager { ConvertCaseToLower(cAlphaArgs(1), cAlphaArgs(2)); cAlphaArgs(1).erase(1); cAlphaArgs(1) += cAlphaArgs(2).substr(1); - print(state.files.eio, "Daylighting:Illuminance Maps,{},{}\n", TotIllumMaps, cAlphaArgs(1)); + print(state.files.eio, "Daylighting:Illuminance Maps,{},{}\n", state.dataDaylightingData->TotIllumMaps, cAlphaArgs(1)); } for (Loop1 = 1; Loop1 <= state.dataGlobal->NumOfZones; ++Loop1) { - ZoneDaylight(Loop1).ZoneToMap.allocate(ZoneMapCount(Loop1)); - ZoneDaylight(Loop1).ZoneToMap = 0; - ZoneDaylight(Loop1).MapCount = 0; + state.dataDaylightingData->ZoneDaylight(Loop1).ZoneToMap.allocate(ZoneMapCount(Loop1)); + state.dataDaylightingData->ZoneDaylight(Loop1).ZoneToMap = 0; + state.dataDaylightingData->ZoneDaylight(Loop1).MapCount = 0; } - for (MapNum = 1; MapNum <= TotIllumMaps; ++MapNum) { - if (IllumMap(MapNum).Zone == 0) continue; - ++ZoneDaylight(IllumMap(MapNum).Zone).MapCount; - ZoneDaylight(IllumMap(MapNum).Zone).ZoneToMap(ZoneDaylight(IllumMap(MapNum).Zone).MapCount) = MapNum; + for (MapNum = 1; MapNum <= state.dataDaylightingData->TotIllumMaps; ++MapNum) { + if (state.dataDaylightingData->IllumMap(MapNum).Zone == 0) continue; + ++state.dataDaylightingData->ZoneDaylight(state.dataDaylightingData->IllumMap(MapNum).Zone).MapCount; + state.dataDaylightingData->ZoneDaylight(state.dataDaylightingData->IllumMap(MapNum).Zone).ZoneToMap(state.dataDaylightingData->ZoneDaylight(state.dataDaylightingData->IllumMap(MapNum).Zone).MapCount) = MapNum; } ZoneMapCount.deallocate(); // Check for illuminance maps associated with this zone - for (MapNum = 1; MapNum <= TotIllumMaps; ++MapNum) { - if (IllumMap(MapNum).Zone > 0) { - auto &zone(Zone(IllumMap(MapNum).Zone)); + for (MapNum = 1; MapNum <= state.dataDaylightingData->TotIllumMaps; ++MapNum) { + if (state.dataDaylightingData->IllumMap(MapNum).Zone > 0) { + auto &zone(Zone(state.dataDaylightingData->IllumMap(MapNum).Zone)); // Calc cos and sin of Zone Relative North values for later use in transforming Reference Point coordinates CosZoneRelNorth = std::cos(-zone.RelNorth * DataGlobalConstants::DegToRadians()); SinZoneRelNorth = std::sin(-zone.RelNorth * DataGlobalConstants::DegToRadians()); - if (IllumMap(MapNum).Xnum * IllumMap(MapNum).Ynum > 0) { + if (state.dataDaylightingData->IllumMap(MapNum).Xnum * state.dataDaylightingData->IllumMap(MapNum).Ynum > 0) { // Add additional daylighting reference points for map - AddMapPoints = IllumMap(MapNum).Xnum * IllumMap(MapNum).Ynum; - IllumMapCalc(MapNum).TotalMapRefPoints = AddMapPoints; - IllumMapCalc(MapNum).MapRefPtAbsCoord.allocate(3, AddMapPoints); - IllumMapCalc(MapNum).MapRefPtAbsCoord = 0.0; - IllumMapCalc(MapNum).MapRefPtInBounds.allocate(AddMapPoints); - IllumMapCalc(MapNum).MapRefPtInBounds = true; - IllumMapCalc(MapNum).DaylIllumAtMapPt.allocate(AddMapPoints); - IllumMapCalc(MapNum).DaylIllumAtMapPt = 0.0; - IllumMapCalc(MapNum).GlareIndexAtMapPt.allocate(AddMapPoints); - IllumMapCalc(MapNum).GlareIndexAtMapPt = 0.0; - IllumMapCalc(MapNum).DaylIllumAtMapPtHr.allocate(AddMapPoints); - IllumMapCalc(MapNum).DaylIllumAtMapPtHr = 0.0; - IllumMapCalc(MapNum).GlareIndexAtMapPtHr.allocate(AddMapPoints); - IllumMapCalc(MapNum).GlareIndexAtMapPtHr = 0.0; - - if (AddMapPoints > MaxMapRefPoints) { + AddMapPoints = state.dataDaylightingData->IllumMap(MapNum).Xnum * state.dataDaylightingData->IllumMap(MapNum).Ynum; + state.dataDaylightingData->IllumMapCalc(MapNum).TotalMapRefPoints = AddMapPoints; + state.dataDaylightingData->IllumMapCalc(MapNum).MapRefPtAbsCoord.allocate(3, AddMapPoints); + state.dataDaylightingData->IllumMapCalc(MapNum).MapRefPtAbsCoord = 0.0; + state.dataDaylightingData->IllumMapCalc(MapNum).MapRefPtInBounds.allocate(AddMapPoints); + state.dataDaylightingData->IllumMapCalc(MapNum).MapRefPtInBounds = true; + state.dataDaylightingData->IllumMapCalc(MapNum).DaylIllumAtMapPt.allocate(AddMapPoints); + state.dataDaylightingData->IllumMapCalc(MapNum).DaylIllumAtMapPt = 0.0; + state.dataDaylightingData->IllumMapCalc(MapNum).GlareIndexAtMapPt.allocate(AddMapPoints); + state.dataDaylightingData->IllumMapCalc(MapNum).GlareIndexAtMapPt = 0.0; + state.dataDaylightingData->IllumMapCalc(MapNum).DaylIllumAtMapPtHr.allocate(AddMapPoints); + state.dataDaylightingData->IllumMapCalc(MapNum).DaylIllumAtMapPtHr = 0.0; + state.dataDaylightingData->IllumMapCalc(MapNum).GlareIndexAtMapPtHr.allocate(AddMapPoints); + state.dataDaylightingData->IllumMapCalc(MapNum).GlareIndexAtMapPtHr = 0.0; + + if (AddMapPoints > DataDaylighting::MaxMapRefPoints) { ShowSevereError(state, "GetDaylighting Parameters: Total Map Reference points entered is greater than maximum allowed."); ShowContinueError(state, "Occurs in Zone=" + zone.Name); ShowContinueError(state, format("Maximum reference points allowed={}, entered amount ( when error first occurred )={}", - MaxMapRefPoints, + DataDaylighting::MaxMapRefPoints, AddMapPoints)); ErrorsFound = true; break; @@ -4886,40 +4883,40 @@ namespace DaylightingManager { // Calc cos and sin of Zone Relative North values for later use in transforming Map Point coordinates // CosZoneRelNorth = std::cos( -zone.RelNorth * DegToRadians ); //Tuned These should not be changing // SinZoneRelNorth = std::sin( -zone.RelNorth * DegToRadians ); - if (IllumMap(MapNum).Xnum != 1) { - IllumMap(MapNum).Xinc = (IllumMap(MapNum).Xmax - IllumMap(MapNum).Xmin) / (IllumMap(MapNum).Xnum - 1); + if (state.dataDaylightingData->IllumMap(MapNum).Xnum != 1) { + state.dataDaylightingData->IllumMap(MapNum).Xinc = (state.dataDaylightingData->IllumMap(MapNum).Xmax - state.dataDaylightingData->IllumMap(MapNum).Xmin) / (state.dataDaylightingData->IllumMap(MapNum).Xnum - 1); } else { - IllumMap(MapNum).Xinc = 0.0; + state.dataDaylightingData->IllumMap(MapNum).Xinc = 0.0; } - if (IllumMap(MapNum).Ynum != 1) { - IllumMap(MapNum).Yinc = (IllumMap(MapNum).Ymax - IllumMap(MapNum).Ymin) / (IllumMap(MapNum).Ynum - 1); + if (state.dataDaylightingData->IllumMap(MapNum).Ynum != 1) { + state.dataDaylightingData->IllumMap(MapNum).Yinc = (state.dataDaylightingData->IllumMap(MapNum).Ymax - state.dataDaylightingData->IllumMap(MapNum).Ymin) / (state.dataDaylightingData->IllumMap(MapNum).Ynum - 1); } else { - IllumMap(MapNum).Yinc = 0.0; + state.dataDaylightingData->IllumMap(MapNum).Yinc = 0.0; } // Map points and increments are stored in AbsCoord and then that is operated on if relative coords entered. - for (Y = 1; Y <= IllumMap(MapNum).Ynum; ++Y) { - for (X = 1; X <= IllumMap(MapNum).Xnum; ++X) { - IllumMapCalc(MapNum).MapRefPtAbsCoord(1, RefPt) = IllumMap(MapNum).Xmin + (X - 1) * IllumMap(MapNum).Xinc; - IllumMapCalc(MapNum).MapRefPtAbsCoord(2, RefPt) = IllumMap(MapNum).Ymin + (Y - 1) * IllumMap(MapNum).Yinc; - IllumMapCalc(MapNum).MapRefPtAbsCoord(3, RefPt) = IllumMap(MapNum).Z; + for (Y = 1; Y <= state.dataDaylightingData->IllumMap(MapNum).Ynum; ++Y) { + for (X = 1; X <= state.dataDaylightingData->IllumMap(MapNum).Xnum; ++X) { + state.dataDaylightingData->IllumMapCalc(MapNum).MapRefPtAbsCoord(1, RefPt) = state.dataDaylightingData->IllumMap(MapNum).Xmin + (X - 1) * state.dataDaylightingData->IllumMap(MapNum).Xinc; + state.dataDaylightingData->IllumMapCalc(MapNum).MapRefPtAbsCoord(2, RefPt) = state.dataDaylightingData->IllumMap(MapNum).Ymin + (Y - 1) * state.dataDaylightingData->IllumMap(MapNum).Yinc; + state.dataDaylightingData->IllumMapCalc(MapNum).MapRefPtAbsCoord(3, RefPt) = state.dataDaylightingData->IllumMap(MapNum).Z; ++RefPt; } } RefPt = 1; - for (Y = 1; Y <= IllumMap(MapNum).Ynum; ++Y) { - for (X = 1; X <= IllumMap(MapNum).Xnum; ++X) { + for (Y = 1; Y <= state.dataDaylightingData->IllumMap(MapNum).Ynum; ++Y) { + for (X = 1; X <= state.dataDaylightingData->IllumMap(MapNum).Xnum; ++X) { if (!DaylRefWorldCoordSystem) { - Xb = IllumMapCalc(MapNum).MapRefPtAbsCoord(1, RefPt) * CosZoneRelNorth - - IllumMapCalc(MapNum).MapRefPtAbsCoord(2, RefPt) * SinZoneRelNorth + zone.OriginX; - Yb = IllumMapCalc(MapNum).MapRefPtAbsCoord(1, RefPt) * SinZoneRelNorth + - IllumMapCalc(MapNum).MapRefPtAbsCoord(2, RefPt) * CosZoneRelNorth + zone.OriginY; - IllumMapCalc(MapNum).MapRefPtAbsCoord(1, RefPt) = Xb * CosBldgRelNorth - Yb * SinBldgRelNorth; - IllumMapCalc(MapNum).MapRefPtAbsCoord(2, RefPt) = Xb * SinBldgRelNorth + Yb * CosBldgRelNorth; - IllumMapCalc(MapNum).MapRefPtAbsCoord(3, RefPt) += zone.OriginZ; + Xb = state.dataDaylightingData->IllumMapCalc(MapNum).MapRefPtAbsCoord(1, RefPt) * CosZoneRelNorth - + state.dataDaylightingData->IllumMapCalc(MapNum).MapRefPtAbsCoord(2, RefPt) * SinZoneRelNorth + zone.OriginX; + Yb = state.dataDaylightingData->IllumMapCalc(MapNum).MapRefPtAbsCoord(1, RefPt) * SinZoneRelNorth + + state.dataDaylightingData->IllumMapCalc(MapNum).MapRefPtAbsCoord(2, RefPt) * CosZoneRelNorth + zone.OriginY; + state.dataDaylightingData->IllumMapCalc(MapNum).MapRefPtAbsCoord(1, RefPt) = Xb * CosBldgRelNorth - Yb * SinBldgRelNorth; + state.dataDaylightingData->IllumMapCalc(MapNum).MapRefPtAbsCoord(2, RefPt) = Xb * SinBldgRelNorth + Yb * CosBldgRelNorth; + state.dataDaylightingData->IllumMapCalc(MapNum).MapRefPtAbsCoord(3, RefPt) += zone.OriginZ; if (doTransform) { - Xo = IllumMapCalc(MapNum).MapRefPtAbsCoord(1, RefPt); // world coordinates.... shifted by relative north angle... - Yo = IllumMapCalc(MapNum).MapRefPtAbsCoord(2, RefPt); + Xo = state.dataDaylightingData->IllumMapCalc(MapNum).MapRefPtAbsCoord(1, RefPt); // world coordinates.... shifted by relative north angle... + Yo = state.dataDaylightingData->IllumMapCalc(MapNum).MapRefPtAbsCoord(2, RefPt); // next derotate the building XnoRot = Xo * CosBldgRelNorth + Yo * SinBldgRelNorth; YnoRot = Yo * CosBldgRelNorth - Xo * SinBldgRelNorth; @@ -4927,46 +4924,46 @@ namespace DaylightingManager { Xtrans = XnoRot * std::sqrt(NewAspectRatio / OldAspectRatio); Ytrans = YnoRot * std::sqrt(OldAspectRatio / NewAspectRatio); // rerotate - IllumMapCalc(MapNum).MapRefPtAbsCoord(1, RefPt) = Xtrans * CosBldgRelNorth - Ytrans * SinBldgRelNorth; + state.dataDaylightingData->IllumMapCalc(MapNum).MapRefPtAbsCoord(1, RefPt) = Xtrans * CosBldgRelNorth - Ytrans * SinBldgRelNorth; - IllumMapCalc(MapNum).MapRefPtAbsCoord(2, RefPt) = Xtrans * SinBldgRelNorth + Ytrans * CosBldgRelNorth; + state.dataDaylightingData->IllumMapCalc(MapNum).MapRefPtAbsCoord(2, RefPt) = Xtrans * SinBldgRelNorth + Ytrans * CosBldgRelNorth; } } else { - Xb = IllumMapCalc(MapNum).MapRefPtAbsCoord(1, RefPt); - Yb = IllumMapCalc(MapNum).MapRefPtAbsCoord(2, RefPt); - IllumMapCalc(MapNum).MapRefPtAbsCoord(1, RefPt) = Xb * CosBldgRotAppGonly - Yb * SinBldgRotAppGonly; - IllumMapCalc(MapNum).MapRefPtAbsCoord(2, RefPt) = Xb * SinBldgRotAppGonly + Yb * CosBldgRotAppGonly; + Xb = state.dataDaylightingData->IllumMapCalc(MapNum).MapRefPtAbsCoord(1, RefPt); + Yb = state.dataDaylightingData->IllumMapCalc(MapNum).MapRefPtAbsCoord(2, RefPt); + state.dataDaylightingData->IllumMapCalc(MapNum).MapRefPtAbsCoord(1, RefPt) = Xb * CosBldgRotAppGonly - Yb * SinBldgRotAppGonly; + state.dataDaylightingData->IllumMapCalc(MapNum).MapRefPtAbsCoord(2, RefPt) = Xb * SinBldgRotAppGonly + Yb * CosBldgRotAppGonly; } if (RefPt == 1) { - IllumMap(MapNum).Xmin = IllumMapCalc(MapNum).MapRefPtAbsCoord(1, RefPt); - IllumMap(MapNum).Ymin = IllumMapCalc(MapNum).MapRefPtAbsCoord(2, RefPt); - IllumMap(MapNum).Xmax = IllumMapCalc(MapNum).MapRefPtAbsCoord(1, RefPt); - IllumMap(MapNum).Ymax = IllumMapCalc(MapNum).MapRefPtAbsCoord(2, RefPt); - IllumMap(MapNum).Z = IllumMapCalc(MapNum).MapRefPtAbsCoord(3, RefPt); + state.dataDaylightingData->IllumMap(MapNum).Xmin = state.dataDaylightingData->IllumMapCalc(MapNum).MapRefPtAbsCoord(1, RefPt); + state.dataDaylightingData->IllumMap(MapNum).Ymin = state.dataDaylightingData->IllumMapCalc(MapNum).MapRefPtAbsCoord(2, RefPt); + state.dataDaylightingData->IllumMap(MapNum).Xmax = state.dataDaylightingData->IllumMapCalc(MapNum).MapRefPtAbsCoord(1, RefPt); + state.dataDaylightingData->IllumMap(MapNum).Ymax = state.dataDaylightingData->IllumMapCalc(MapNum).MapRefPtAbsCoord(2, RefPt); + state.dataDaylightingData->IllumMap(MapNum).Z = state.dataDaylightingData->IllumMapCalc(MapNum).MapRefPtAbsCoord(3, RefPt); } - IllumMap(MapNum).Xmin = min(IllumMap(MapNum).Xmin, IllumMapCalc(MapNum).MapRefPtAbsCoord(1, RefPt)); - IllumMap(MapNum).Ymin = min(IllumMap(MapNum).Ymin, IllumMapCalc(MapNum).MapRefPtAbsCoord(2, RefPt)); - IllumMap(MapNum).Xmax = max(IllumMap(MapNum).Xmax, IllumMapCalc(MapNum).MapRefPtAbsCoord(1, RefPt)); - IllumMap(MapNum).Ymax = max(IllumMap(MapNum).Ymax, IllumMapCalc(MapNum).MapRefPtAbsCoord(2, RefPt)); - if ((IllumMapCalc(MapNum).MapRefPtAbsCoord(1, RefPt) < zone.MinimumX && - (zone.MinimumX - IllumMapCalc(MapNum).MapRefPtAbsCoord(1, RefPt)) > 0.001) || - (IllumMapCalc(MapNum).MapRefPtAbsCoord(1, RefPt) > zone.MaximumX && - (IllumMapCalc(MapNum).MapRefPtAbsCoord(1, RefPt) - zone.MaximumX) > 0.001) || - (IllumMapCalc(MapNum).MapRefPtAbsCoord(2, RefPt) < zone.MinimumY && - (zone.MinimumY - IllumMapCalc(MapNum).MapRefPtAbsCoord(2, RefPt)) > 0.001) || - (IllumMapCalc(MapNum).MapRefPtAbsCoord(2, RefPt) > zone.MaximumY && - (IllumMapCalc(MapNum).MapRefPtAbsCoord(2, RefPt) - zone.MaximumY) > 0.001) || - (IllumMapCalc(MapNum).MapRefPtAbsCoord(3, RefPt) < zone.MinimumZ && - (zone.MinimumZ - IllumMapCalc(MapNum).MapRefPtAbsCoord(3, RefPt)) > 0.001) || - (IllumMapCalc(MapNum).MapRefPtAbsCoord(3, RefPt) > zone.MaximumZ && - (IllumMapCalc(MapNum).MapRefPtAbsCoord(3, RefPt) - zone.MaximumZ) > 0.001)) { - IllumMapCalc(MapNum).MapRefPtInBounds(RefPt) = false; + state.dataDaylightingData->IllumMap(MapNum).Xmin = min(state.dataDaylightingData->IllumMap(MapNum).Xmin, state.dataDaylightingData->IllumMapCalc(MapNum).MapRefPtAbsCoord(1, RefPt)); + state.dataDaylightingData->IllumMap(MapNum).Ymin = min(state.dataDaylightingData->IllumMap(MapNum).Ymin, state.dataDaylightingData->IllumMapCalc(MapNum).MapRefPtAbsCoord(2, RefPt)); + state.dataDaylightingData->IllumMap(MapNum).Xmax = max(state.dataDaylightingData->IllumMap(MapNum).Xmax, state.dataDaylightingData->IllumMapCalc(MapNum).MapRefPtAbsCoord(1, RefPt)); + state.dataDaylightingData->IllumMap(MapNum).Ymax = max(state.dataDaylightingData->IllumMap(MapNum).Ymax, state.dataDaylightingData->IllumMapCalc(MapNum).MapRefPtAbsCoord(2, RefPt)); + if ((state.dataDaylightingData->IllumMapCalc(MapNum).MapRefPtAbsCoord(1, RefPt) < zone.MinimumX && + (zone.MinimumX - state.dataDaylightingData->IllumMapCalc(MapNum).MapRefPtAbsCoord(1, RefPt)) > 0.001) || + (state.dataDaylightingData->IllumMapCalc(MapNum).MapRefPtAbsCoord(1, RefPt) > zone.MaximumX && + (state.dataDaylightingData->IllumMapCalc(MapNum).MapRefPtAbsCoord(1, RefPt) - zone.MaximumX) > 0.001) || + (state.dataDaylightingData->IllumMapCalc(MapNum).MapRefPtAbsCoord(2, RefPt) < zone.MinimumY && + (zone.MinimumY - state.dataDaylightingData->IllumMapCalc(MapNum).MapRefPtAbsCoord(2, RefPt)) > 0.001) || + (state.dataDaylightingData->IllumMapCalc(MapNum).MapRefPtAbsCoord(2, RefPt) > zone.MaximumY && + (state.dataDaylightingData->IllumMapCalc(MapNum).MapRefPtAbsCoord(2, RefPt) - zone.MaximumY) > 0.001) || + (state.dataDaylightingData->IllumMapCalc(MapNum).MapRefPtAbsCoord(3, RefPt) < zone.MinimumZ && + (zone.MinimumZ - state.dataDaylightingData->IllumMapCalc(MapNum).MapRefPtAbsCoord(3, RefPt)) > 0.001) || + (state.dataDaylightingData->IllumMapCalc(MapNum).MapRefPtAbsCoord(3, RefPt) > zone.MaximumZ && + (state.dataDaylightingData->IllumMapCalc(MapNum).MapRefPtAbsCoord(3, RefPt) - zone.MaximumZ) > 0.001)) { + state.dataDaylightingData->IllumMapCalc(MapNum).MapRefPtInBounds(RefPt) = false; } // Test extremes of Map Points against Zone Min/Max - if (RefPt == 1 || RefPt == IllumMapCalc(MapNum).TotalMapRefPoints) { - if ((IllumMapCalc(MapNum).MapRefPtAbsCoord(1, RefPt) < zone.MinimumX || - IllumMapCalc(MapNum).MapRefPtAbsCoord(1, RefPt) > zone.MaximumX) && - !IllumMapCalc(MapNum).MapRefPtInBounds(RefPt)) { + if (RefPt == 1 || RefPt == state.dataDaylightingData->IllumMapCalc(MapNum).TotalMapRefPoints) { + if ((state.dataDaylightingData->IllumMapCalc(MapNum).MapRefPtAbsCoord(1, RefPt) < zone.MinimumX || + state.dataDaylightingData->IllumMapCalc(MapNum).MapRefPtAbsCoord(1, RefPt) > zone.MaximumX) && + !state.dataDaylightingData->IllumMapCalc(MapNum).MapRefPtInBounds(RefPt)) { ShowWarningError( state, format("GetInputIlluminanceMap: Reference Map point #[{}], X Value outside Zone Min/Max X, Zone={}", @@ -4974,22 +4971,22 @@ namespace DaylightingManager { zone.Name)); ShowContinueError(state, format("...X Reference Point= {:.2R}, Zone Minimum X= {:.2R}, Zone Maximum X= {:.2R}", - IllumMapCalc(MapNum).MapRefPtAbsCoord(1, RefPt), + state.dataDaylightingData->IllumMapCalc(MapNum).MapRefPtAbsCoord(1, RefPt), zone.MinimumX, zone.MaximumX)); - if (IllumMapCalc(MapNum).MapRefPtAbsCoord(1, RefPt) < zone.MinimumX) { + if (state.dataDaylightingData->IllumMapCalc(MapNum).MapRefPtAbsCoord(1, RefPt) < zone.MinimumX) { ShowContinueError(state, format("...X Reference Distance Outside MinimumX= {:.4R} m.", - zone.MinimumX - IllumMapCalc(MapNum).MapRefPtAbsCoord(1, RefPt))); + zone.MinimumX - state.dataDaylightingData->IllumMapCalc(MapNum).MapRefPtAbsCoord(1, RefPt))); } else { ShowContinueError(state, format("...X Reference Distance Outside MaximumX= {:.4R} m.", - IllumMapCalc(MapNum).MapRefPtAbsCoord(1, RefPt) - zone.MaximumX)); + state.dataDaylightingData->IllumMapCalc(MapNum).MapRefPtAbsCoord(1, RefPt) - zone.MaximumX)); } } - if ((IllumMapCalc(MapNum).MapRefPtAbsCoord(2, RefPt) < zone.MinimumY || - IllumMapCalc(MapNum).MapRefPtAbsCoord(2, RefPt) > zone.MaximumY) && - !IllumMapCalc(MapNum).MapRefPtInBounds(RefPt)) { + if ((state.dataDaylightingData->IllumMapCalc(MapNum).MapRefPtAbsCoord(2, RefPt) < zone.MinimumY || + state.dataDaylightingData->IllumMapCalc(MapNum).MapRefPtAbsCoord(2, RefPt) > zone.MaximumY) && + !state.dataDaylightingData->IllumMapCalc(MapNum).MapRefPtInBounds(RefPt)) { ShowWarningError( state, format("GetInputIlluminanceMap: Reference Map point #[{}], Y Value outside Zone Min/Max Y, Zone={}", @@ -4997,22 +4994,22 @@ namespace DaylightingManager { zone.Name)); ShowContinueError(state, format("...Y Reference Point= {:.2R}, Zone Minimum Y= {:.2R}, Zone Maximum Y= {:.2R}", - IllumMapCalc(MapNum).MapRefPtAbsCoord(2, RefPt), + state.dataDaylightingData->IllumMapCalc(MapNum).MapRefPtAbsCoord(2, RefPt), zone.MinimumY, zone.MaximumY)); - if (IllumMapCalc(MapNum).MapRefPtAbsCoord(2, RefPt) < zone.MinimumY) { + if (state.dataDaylightingData->IllumMapCalc(MapNum).MapRefPtAbsCoord(2, RefPt) < zone.MinimumY) { ShowContinueError(state, format("...Y Reference Distance Outside MinimumY= {:.4R} m.", - zone.MinimumY - IllumMapCalc(MapNum).MapRefPtAbsCoord(2, RefPt))); + zone.MinimumY - state.dataDaylightingData->IllumMapCalc(MapNum).MapRefPtAbsCoord(2, RefPt))); } else { ShowContinueError(state, format("...Y Reference Distance Outside MaximumY= {:.4R} m.", - IllumMapCalc(MapNum).MapRefPtAbsCoord(2, RefPt) - zone.MaximumY)); + state.dataDaylightingData->IllumMapCalc(MapNum).MapRefPtAbsCoord(2, RefPt) - zone.MaximumY)); } } - if ((IllumMapCalc(MapNum).MapRefPtAbsCoord(3, RefPt) < zone.MinimumZ || - IllumMapCalc(MapNum).MapRefPtAbsCoord(3, RefPt) > zone.MaximumZ) && - !IllumMapCalc(MapNum).MapRefPtInBounds(RefPt)) { + if ((state.dataDaylightingData->IllumMapCalc(MapNum).MapRefPtAbsCoord(3, RefPt) < zone.MinimumZ || + state.dataDaylightingData->IllumMapCalc(MapNum).MapRefPtAbsCoord(3, RefPt) > zone.MaximumZ) && + !state.dataDaylightingData->IllumMapCalc(MapNum).MapRefPtInBounds(RefPt)) { ShowWarningError( state, format("GetInputIlluminanceMap: Reference Map point #[{}], Z Value outside Zone Min/Max Z, Zone={}", @@ -5020,17 +5017,17 @@ namespace DaylightingManager { zone.Name)); ShowContinueError(state, format("...Z Reference Point= {:.2R}, Zone Minimum Z= {:.2R}, Zone Maximum Z= {:.2R}", - IllumMapCalc(MapNum).MapRefPtAbsCoord(3, RefPt), + state.dataDaylightingData->IllumMapCalc(MapNum).MapRefPtAbsCoord(3, RefPt), zone.MinimumZ, zone.MaximumZ)); - if (IllumMapCalc(MapNum).MapRefPtAbsCoord(3, RefPt) < zone.MinimumZ) { + if (state.dataDaylightingData->IllumMapCalc(MapNum).MapRefPtAbsCoord(3, RefPt) < zone.MinimumZ) { ShowContinueError(state, format("...Z Reference Distance Outside MinimumZ= {:.4R} m.", - zone.MinimumZ - IllumMapCalc(MapNum).MapRefPtAbsCoord(3, RefPt))); + zone.MinimumZ - state.dataDaylightingData->IllumMapCalc(MapNum).MapRefPtAbsCoord(3, RefPt))); } else { ShowContinueError(state, format("...Z Reference Distance Outside MaximumZ= {:.4R} m.", - IllumMapCalc(MapNum).MapRefPtAbsCoord(3, RefPt) - zone.MaximumZ)); + state.dataDaylightingData->IllumMapCalc(MapNum).MapRefPtAbsCoord(3, RefPt) - zone.MaximumZ)); } } } @@ -5041,33 +5038,33 @@ namespace DaylightingManager { } } // MapNum ZoneMsgDone.dimension(state.dataGlobal->NumOfZones, false); - for (MapNum = 1; MapNum <= TotIllumMaps; ++MapNum) { - if (IllumMap(MapNum).Zone == 0) continue; - if (ZoneDaylight(IllumMap(MapNum).Zone).DaylightMethod != SplitFluxDaylighting && !ZoneMsgDone(IllumMap(MapNum).Zone)) { - ShowSevereError(state, "Zone Name in Output:IlluminanceMap is not used for Daylighting:Controls=" + Zone(IllumMap(MapNum).Zone).Name); + for (MapNum = 1; MapNum <= state.dataDaylightingData->TotIllumMaps; ++MapNum) { + if (state.dataDaylightingData->IllumMap(MapNum).Zone == 0) continue; + if (state.dataDaylightingData->ZoneDaylight(state.dataDaylightingData->IllumMap(MapNum).Zone).DaylightMethod != DataDaylighting::iDaylightingMethod::SplitFluxDaylighting && !ZoneMsgDone(state.dataDaylightingData->IllumMap(MapNum).Zone)) { + ShowSevereError(state, "Zone Name in Output:IlluminanceMap is not used for Daylighting:Controls=" + Zone(state.dataDaylightingData->IllumMap(MapNum).Zone).Name); ErrorsFound = true; } } ZoneMsgDone.deallocate(); - if (TotIllumMaps > 0) { + if (state.dataDaylightingData->TotIllumMaps > 0) { print(state.files.eio, "! ,Name,Zone,XMin {{m}},XMax {{m}},Xinc {{m}},#X Points,YMin " "{{m}},YMax {{m}},Yinc {{m}},#Y Points,Z {{m}}\n"); } - for (MapNum = 1; MapNum <= TotIllumMaps; ++MapNum) { + for (MapNum = 1; MapNum <= state.dataDaylightingData->TotIllumMaps; ++MapNum) { print(state.files.eio, "Daylighting:Illuminance Maps:Detail,{},{},{:.2R},{:.2R},{:.2R},{},{:.2R},{:.2R},{:.2R},{},{:.2R}\n", - IllumMap(MapNum).Name, - Zone(IllumMap(MapNum).Zone).Name, - IllumMap(MapNum).Xmin, - IllumMap(MapNum).Xmax, - IllumMap(MapNum).Xinc, - IllumMap(MapNum).Xnum, - IllumMap(MapNum).Ymin, - IllumMap(MapNum).Ymax, - IllumMap(MapNum).Yinc, - IllumMap(MapNum).Ynum, - IllumMap(MapNum).Z); + state.dataDaylightingData->IllumMap(MapNum).Name, + Zone(state.dataDaylightingData->IllumMap(MapNum).Zone).Name, + state.dataDaylightingData->IllumMap(MapNum).Xmin, + state.dataDaylightingData->IllumMap(MapNum).Xmax, + state.dataDaylightingData->IllumMap(MapNum).Xinc, + state.dataDaylightingData->IllumMap(MapNum).Xnum, + state.dataDaylightingData->IllumMap(MapNum).Ymin, + state.dataDaylightingData->IllumMap(MapNum).Ymax, + state.dataDaylightingData->IllumMap(MapNum).Yinc, + state.dataDaylightingData->IllumMap(MapNum).Ynum, + state.dataDaylightingData->IllumMap(MapNum).Z); } if (ErrorsFound) return; @@ -5115,16 +5112,16 @@ namespace DaylightingManager { ErrorsFound = true; continue; } - auto &zone_daylight(ZoneDaylight(ZoneFound)); + auto &zone_daylight(state.dataDaylightingData->ZoneDaylight(ZoneFound)); zone_daylight.Name = cAlphaArgs(1); // Field: Name zone_daylight.ZoneName = cAlphaArgs(2); // Field: Zone Name if (UtilityRoutines::SameString(cAlphaArgs(3), "SPLITFLUX")) { // Field: Daylighting Method - zone_daylight.DaylightMethod = SplitFluxDaylighting; + zone_daylight.DaylightMethod = DataDaylighting::iDaylightingMethod::SplitFluxDaylighting; } else if (UtilityRoutines::SameString(cAlphaArgs(3), "DELIGHT")) { - zone_daylight.DaylightMethod = DElightDaylighting; + zone_daylight.DaylightMethod = DataDaylighting::iDaylightingMethod::DElightDaylighting; } else if (lAlphaFieldBlanks(3)) { - zone_daylight.DaylightMethod = SplitFluxDaylighting; + zone_daylight.DaylightMethod = DataDaylighting::iDaylightingMethod::SplitFluxDaylighting; } else { ShowWarningError(state, "Invalid " + cAlphaFieldNames(3) + " = " + cAlphaArgs(3) + ", occurs in " + cCurrentModuleObject + "object for " + cCurrentModuleObject + "=\"" + cAlphaArgs(1)); @@ -5144,13 +5141,13 @@ namespace DaylightingManager { } if (UtilityRoutines::SameString(cAlphaArgs(5), "CONTINUOUS")) { // Field: Lighting Control Type - zone_daylight.LightControlType = Continuous; + zone_daylight.LightControlType = DataDaylighting::iLtgCtrlType::Continuous; } else if (UtilityRoutines::SameString(cAlphaArgs(5), "STEPPED")) { - zone_daylight.LightControlType = Stepped; + zone_daylight.LightControlType = DataDaylighting::iLtgCtrlType::Stepped; } else if (UtilityRoutines::SameString(cAlphaArgs(5), "CONTINUOUSOFF")) { - zone_daylight.LightControlType = ContinuousOff; + zone_daylight.LightControlType = DataDaylighting::iLtgCtrlType::ContinuousOff; } else if (lAlphaFieldBlanks(5)) { - zone_daylight.LightControlType = Continuous; + zone_daylight.LightControlType = DataDaylighting::iLtgCtrlType::Continuous; } else { ShowWarningError(state, "Invalid " + cAlphaFieldNames(5) + " = " + cAlphaArgs(5) + ", occurs in " + cCurrentModuleObject + "object for " + cCurrentModuleObject + "=\"" + cAlphaArgs(1)); @@ -5165,14 +5162,14 @@ namespace DaylightingManager { if (!lAlphaFieldBlanks(6)) { // Field: Glare Calculation Daylighting Reference Point Name zone_daylight.glareRefPtNumber = UtilityRoutines::FindItemInList( - cAlphaArgs(6), DaylRefPt, &RefPointData::Name); // Field: Glare Calculation Daylighting Reference Point Name + cAlphaArgs(6), state.dataDaylightingData->DaylRefPt, &DataDaylighting::RefPointData::Name); // Field: Glare Calculation Daylighting Reference Point Name if (zone_daylight.glareRefPtNumber == 0) { ShowSevereError(state, cCurrentModuleObject + ": invalid " + cAlphaFieldNames(6) + "=\"" + cAlphaArgs(6) + "\" for object named: " + cAlphaArgs(1)); ErrorsFound = true; continue; } - } else if (zone_daylight.DaylightMethod == SplitFluxDaylighting) { + } else if (zone_daylight.DaylightMethod == DataDaylighting::iDaylightingMethod::SplitFluxDaylighting) { ShowWarningError(state, "No " + cAlphaFieldNames(6) + " provided for object named: " + cAlphaArgs(1)); ShowContinueError(state, "No glare calculation performed, and the simulation continues."); } @@ -5226,7 +5223,7 @@ namespace DaylightingManager { int countRefPts = 0; for (int refPtNum = 1; refPtNum <= curTotalDaylRefPts; ++refPtNum) { zone_daylight.DaylRefPtNum(refPtNum) = UtilityRoutines::FindItemInList( - cAlphaArgs(6 + refPtNum), DaylRefPt, &RefPointData::Name); // Field: Daylighting Reference Point Name + cAlphaArgs(6 + refPtNum), state.dataDaylightingData->DaylRefPt, &DataDaylighting::RefPointData::Name); // Field: Daylighting Reference Point Name if (zone_daylight.DaylRefPtNum(refPtNum) == 0) { ShowSevereError(state, cCurrentModuleObject + ": invalid " + cAlphaFieldNames(6 + refPtNum) + "=\"" + cAlphaArgs(6 + refPtNum) + "\" for object named: " + cAlphaArgs(1)); @@ -5238,7 +5235,7 @@ namespace DaylightingManager { zone_daylight.FracZoneDaylit(refPtNum) = rNumericArgs(6 + refPtNum * 2); // Field: Fraction Controlled by Reference Point zone_daylight.IllumSetPoint(refPtNum) = rNumericArgs(7 + refPtNum * 2); // Field: Illuminance Setpoint at Reference Point - if (zone_daylight.DaylightMethod == SplitFluxDaylighting) { + if (zone_daylight.DaylightMethod == DataDaylighting::iDaylightingMethod::SplitFluxDaylighting) { SetupOutputVariable(state, format("Daylighting Reference Point {} Illuminance", refPtNum), OutputProcessor::Unit::lux, @@ -5293,7 +5290,7 @@ namespace DaylightingManager { ErrorsFound = true; } - if (zone_daylight.LightControlType == Stepped && zone_daylight.LightControlSteps <= 0) { + if (zone_daylight.LightControlType == DataDaylighting::iLtgCtrlType::Stepped && zone_daylight.LightControlSteps <= 0) { ShowWarningError(state, "GetDaylightingControls: For Stepped Control, the number of steps must be > 0"); ShowContinueError(state, "..discovered in \"" + cCurrentModuleObject + "\" for Zone=\"" + cAlphaArgs(2) + "\", will use 1"); zone_daylight.LightControlSteps = 1; @@ -5353,7 +5350,7 @@ namespace DaylightingManager { CheckForGeometricTransform(state, doTransform, OldAspectRatio, NewAspectRatio); int zoneIndex = 0; - for (auto &daylCntrl : ZoneDaylight) { + for (auto &daylCntrl : state.dataDaylightingData->ZoneDaylight) { zoneIndex++; if (daylCntrl.TotalDaylRefPoints > 0) { auto &zone(Zone(zoneIndex)); @@ -5366,7 +5363,7 @@ namespace DaylightingManager { CheckLightsReplaceableMinMaxForZone(state, zoneIndex); for (refPtNum = 1; refPtNum <= daylCntrl.TotalDaylRefPoints; ++refPtNum) { - auto &curRefPt(DaylRefPt(daylCntrl.DaylRefPtNum(refPtNum))); // get the active daylighting:referencepoint + auto &curRefPt(state.dataDaylightingData->DaylRefPt(daylCntrl.DaylRefPtNum(refPtNum))); // get the active daylighting:referencepoint curRefPt.indexToFracAndIllum = refPtNum; // back reference to the index to the ZoneDaylight structure arrays related to reference points if (DaylRefWorldCoordSystem) { @@ -5399,17 +5396,17 @@ namespace DaylightingManager { refName = curRefPt.Name; PreDefTableEntry(pdchDyLtZone, refName, daylCntrl.ZoneName); PreDefTableEntry(pdchDyLtCtrlName, refName, daylCntrl.Name); - if (daylCntrl.DaylightMethod == SplitFluxDaylighting) { + if (daylCntrl.DaylightMethod == DataDaylighting::iDaylightingMethod::SplitFluxDaylighting) { PreDefTableEntry(pdchDyLtKind, refName, "SplitFlux"); } else { PreDefTableEntry(pdchDyLtKind, refName, "DElight"); } // ( 1=continuous, 2=stepped, 3=continuous/off ) - if (daylCntrl.LightControlType == Continuous) { + if (daylCntrl.LightControlType == DataDaylighting::iLtgCtrlType::Continuous) { PreDefTableEntry(pdchDyLtCtrlType, refName, "Continuous"); - } else if (daylCntrl.LightControlType == Stepped) { + } else if (daylCntrl.LightControlType == DataDaylighting::iLtgCtrlType::Stepped) { PreDefTableEntry(pdchDyLtCtrlType, refName, "Stepped"); - } else if (daylCntrl.LightControlType == ContinuousOff) { + } else if (daylCntrl.LightControlType == DataDaylighting::iLtgCtrlType::ContinuousOff) { PreDefTableEntry(pdchDyLtCtrlType, refName, "Continuous/Off"); } PreDefTableEntry(pdchDyLtFrac, refName, daylCntrl.FracZoneDaylit(refPtNum)); @@ -5487,9 +5484,9 @@ namespace DaylightingManager { int NumNumber; cCurrentModuleObject = "Daylighting:ReferencePoint"; - TotRefPoints = inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); - DaylRefPt.allocate(TotRefPoints); - for (auto &pt : DaylRefPt) { + state.dataDaylightingData->TotRefPoints = inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); + state.dataDaylightingData->DaylRefPt.allocate(state.dataDaylightingData->TotRefPoints); + for (auto &pt : state.dataDaylightingData->DaylRefPt) { inputProcessor->getObjectItem(state, cCurrentModuleObject, ++RefPtNum, @@ -5514,10 +5511,10 @@ namespace DaylightingManager { } } - bool doesDayLightingUseDElight() + bool doesDayLightingUseDElight(EnergyPlusData &state) { - for (auto &znDayl : ZoneDaylight) { - if (znDayl.DaylightMethod == DElightDaylighting) { + for (auto &znDayl : state.dataDaylightingData->ZoneDaylight) { + if (znDayl.DaylightMethod == DataDaylighting::iDaylightingMethod::DElightDaylighting) { return true; } } @@ -5546,8 +5543,6 @@ namespace DaylightingManager { // na // Using/Aliasing - using DataDaylighting::NoDaylighting; - using DataDaylighting::ZoneDaylight; using DataHeatBalance::Zone; using namespace DataDaylightingDevices; @@ -5577,7 +5572,7 @@ namespace DaylightingManager { bool daylightControlFound = false; int const pipeEnclNum = Zone(Surface(SurfNum).Zone).SolarEnclosureNum; for (int const zoneNum : DataViewFactorInformation::ZoneSolarInfo(pipeEnclNum).ZoneNums) { - if (ZoneDaylight(zoneNum).DaylightMethod != NoDaylighting) { + if (state.dataDaylightingData->ZoneDaylight(zoneNum).DaylightMethod != DataDaylighting::iDaylightingMethod::NoDaylighting) { daylightControlFound = true; } } @@ -5609,7 +5604,7 @@ namespace DaylightingManager { for (int iShadeCtrl = 1; iShadeCtrl <= TotWinShadingControl; ++iShadeCtrl) { int found = -1; for (int jZone = 1; jZone <= state.dataGlobal->NumOfZones; ++jZone) { - if (UtilityRoutines::SameString(WindowShadingControl(iShadeCtrl).DaylightingControlName, ZoneDaylight(jZone).Name)) { + if (UtilityRoutines::SameString(WindowShadingControl(iShadeCtrl).DaylightingControlName, state.dataDaylightingData->ZoneDaylight(jZone).Name)) { found = jZone; break; } @@ -5725,7 +5720,8 @@ namespace DaylightingManager { } // End of loop over light well objects } - void DayltgGlare(int &IL, // Reference point index: 1=first ref pt, 2=second ref pt + void DayltgGlare(EnergyPlusData &state, + int &IL, // Reference point index: 1=first ref pt, 2=second ref pt Real64 &BLUM, // Window background (surround) luminance (cd/m2) Real64 &GLINDX, // Glare index int &ZoneNum // Zone number @@ -5781,18 +5777,18 @@ namespace DaylightingManager { GTOT = 0.0; // Loop over exterior windows associated with zone - for (loop = 1; loop <= ZoneDaylight(ZoneNum).NumOfDayltgExtWins; ++loop) { - IWin = ZoneDaylight(ZoneNum).DayltgExtWinSurfNums(loop); + for (loop = 1; loop <= state.dataDaylightingData->ZoneDaylight(ZoneNum).NumOfDayltgExtWins; ++loop) { + IWin = state.dataDaylightingData->ZoneDaylight(ZoneNum).DayltgExtWinSurfNums(loop); IS = 1; if ((SurfWinWindowModelType(IWin) != WindowBSDFModel) && ((SurfWinShadingFlag(IWin) >= 1 && SurfWinShadingFlag(IWin) <= 9) || SurfWinSolarDiffusing(IWin))) IS = 2; // Conversion from ft-L to cd/m2, with cd/m2 = 0.2936 ft-L, gives the 0.4794 factor // below, which is (0.2936)**0.6 - GTOT1 = 0.4794 * (std::pow(ZoneDaylight(ZoneNum).SourceLumFromWinAtRefPt(loop, IS, IL), 1.6)) * - std::pow(ZoneDaylight(ZoneNum).SolidAngAtRefPtWtd(loop, IL), 0.8); + GTOT1 = 0.4794 * (std::pow(state.dataDaylightingData->ZoneDaylight(ZoneNum).SourceLumFromWinAtRefPt(loop, IS, IL), 1.6)) * + std::pow(state.dataDaylightingData->ZoneDaylight(ZoneNum).SolidAngAtRefPtWtd(loop, IL), 0.8); GTOT2 = BLUM + - 0.07 * (std::sqrt(ZoneDaylight(ZoneNum).SolidAngAtRefPt(loop, IL))) * ZoneDaylight(ZoneNum).SourceLumFromWinAtRefPt(loop, IS, IL); + 0.07 * (std::sqrt(state.dataDaylightingData->ZoneDaylight(ZoneNum).SolidAngAtRefPt(loop, IL))) * state.dataDaylightingData->ZoneDaylight(ZoneNum).SourceLumFromWinAtRefPt(loop, IS, IL); GTOT += GTOT1 / (GTOT2 + 0.000001); } @@ -5802,7 +5798,8 @@ namespace DaylightingManager { GLINDX = max(0.0, GLINDX); } - void DayltgGlareWithIntWins(Array1D &GLINDX, // Glare index + void DayltgGlareWithIntWins(EnergyPlusData &state, + Array1D &GLINDX, // Glare index int const ZoneNum // Zone number ) { @@ -5852,24 +5849,24 @@ namespace DaylightingManager { // Calculate background luminance including effect of inter-reflected illuminance from light // entering zone through its interior windows - RefPoints = ZoneDaylight(ZoneNum).TotalDaylRefPoints; + RefPoints = state.dataDaylightingData->ZoneDaylight(ZoneNum).TotalDaylRefPoints; for (IL = 1; IL <= RefPoints; ++IL) { - BacLum = ZoneDaylight(ZoneNum).BacLum(IL) + ZoneDaylight(ZoneNum).InterReflIllFrIntWins * ZoneDaylight(ZoneNum).AveVisDiffReflect / DataGlobalConstants::Pi(); - BacLum = max(ZoneDaylight(ZoneNum).IllumSetPoint(IL) * ZoneDaylight(ZoneNum).AveVisDiffReflect / DataGlobalConstants::Pi(), BacLum); + BacLum = state.dataDaylightingData->ZoneDaylight(ZoneNum).BacLum(IL) + state.dataDaylightingData->ZoneDaylight(ZoneNum).InterReflIllFrIntWins * state.dataDaylightingData->ZoneDaylight(ZoneNum).AveVisDiffReflect / DataGlobalConstants::Pi(); + BacLum = max(state.dataDaylightingData->ZoneDaylight(ZoneNum).IllumSetPoint(IL) * state.dataDaylightingData->ZoneDaylight(ZoneNum).AveVisDiffReflect / DataGlobalConstants::Pi(), BacLum); // Loop over exterior windows associated with zone - for (loop = 1; loop <= ZoneDaylight(ZoneNum).NumOfDayltgExtWins; ++loop) { - IWin = ZoneDaylight(ZoneNum).DayltgExtWinSurfNums(loop); + for (loop = 1; loop <= state.dataDaylightingData->ZoneDaylight(ZoneNum).NumOfDayltgExtWins; ++loop) { + IWin = state.dataDaylightingData->ZoneDaylight(ZoneNum).DayltgExtWinSurfNums(loop); IS = 1; if ((SurfWinWindowModelType(IWin) != WindowBSDFModel) && ((SurfWinShadingFlag(IWin) >= 1 && SurfWinShadingFlag(IWin) <= 9) || SurfWinSolarDiffusing(IWin))) IS = 2; // Conversion from ft-L to cd/m2, with cd/m2 = 0.2936 ft-L, gives the 0.4794 factor // below, which is (0.2936)**0.6 - GTOT1 = 0.4794 * (std::pow(ZoneDaylight(ZoneNum).SourceLumFromWinAtRefPt(loop, IS, IL), 1.6)) * - std::pow(ZoneDaylight(ZoneNum).SolidAngAtRefPtWtd(loop, IL), 0.8); - GTOT2 = BacLum + 0.07 * (std::sqrt(ZoneDaylight(ZoneNum).SolidAngAtRefPt(loop, IL))) * - ZoneDaylight(ZoneNum).SourceLumFromWinAtRefPt(loop, IS, IL); + GTOT1 = 0.4794 * (std::pow(state.dataDaylightingData->ZoneDaylight(ZoneNum).SourceLumFromWinAtRefPt(loop, IS, IL), 1.6)) * + std::pow(state.dataDaylightingData->ZoneDaylight(ZoneNum).SolidAngAtRefPtWtd(loop, IL), 0.8); + GTOT2 = BacLum + 0.07 * (std::sqrt(state.dataDaylightingData->ZoneDaylight(ZoneNum).SolidAngAtRefPt(loop, IL))) * + state.dataDaylightingData->ZoneDaylight(ZoneNum).SourceLumFromWinAtRefPt(loop, IS, IL); GTOT += GTOT1 / (GTOT2 + 0.000001); } @@ -6334,9 +6331,9 @@ namespace DaylightingManager { int IConstShaded; // Pointer to shaded window construction int ICtrl; // Window shading control pointer Array1D TVIS1( - ZoneDaylight(ZoneNum).ShadeDeployOrderExtWins.size()); // Visible transmittance at normal incidence of unswitched glazing + state.dataDaylightingData->ZoneDaylight(ZoneNum).ShadeDeployOrderExtWins.size()); // Visible transmittance at normal incidence of unswitched glazing Array1D TVIS2( - ZoneDaylight(ZoneNum).ShadeDeployOrderExtWins.size()); // Visible transmittance at normal incidence of fully-switched glazing + state.dataDaylightingData->ZoneDaylight(ZoneNum).ShadeDeployOrderExtWins.size()); // Visible transmittance at normal incidence of fully-switched glazing Real64 VTRAT; // Ratio between switched and unswitched visible transmittance at normal incidence Real64 BACL; // Window background (surround) luminance for glare calc (cd/m2) Real64 SkyWeight; // Weighting factor used to average two different sky types @@ -6367,14 +6364,14 @@ namespace DaylightingManager { bool breakOuterLoop(false); bool continueOuterLoop(false); - if (ZoneDaylight(ZoneNum).DaylightMethod != SplitFluxDaylighting) return; + if (state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylightMethod != DataDaylighting::iDaylightingMethod::SplitFluxDaylighting) return; - NREFPT = ZoneDaylight(ZoneNum).TotalDaylRefPoints; + NREFPT = state.dataDaylightingData->ZoneDaylight(ZoneNum).TotalDaylRefPoints; // Three arrays to save original clear and dark (fully switched) states' // zone/window daylighting properties. if (DayltgInteriorIllum_firstTime) { - int const d1(max(maxval(Zone, &ZoneData::NumSubSurfaces), maxval(ZoneDaylight, &ZoneDaylightCalc::NumOfDayltgExtWins))); + int const d1(max(maxval(Zone, &ZoneData::NumSubSurfaces), maxval(state.dataDaylightingData->ZoneDaylight, &DataDaylighting::ZoneDaylightCalc::NumOfDayltgExtWins))); tmpIllumFromWinAtRefPt.allocate(d1, 2, maxNumRefPtInAnyZone); tmpBackLumFromWinAtRefPt.allocate(d1, 2, maxNumRefPtInAnyZone); tmpSourceLumFromWinAtRefPt.allocate(d1, 2, maxNumRefPtInAnyZone); @@ -6394,9 +6391,9 @@ namespace DaylightingManager { // Initialize reference point illuminance and window background luminance for (IL = 1; IL <= NREFPT; ++IL) { - SetPnt(IL) = ZoneDaylight(ZoneNum).IllumSetPoint(IL); + SetPnt(IL) = state.dataDaylightingData->ZoneDaylight(ZoneNum).IllumSetPoint(IL); DaylIllum(IL) = 0.0; - ZoneDaylight(ZoneNum).BacLum(IL) = 0.0; + state.dataDaylightingData->ZoneDaylight(ZoneNum).BacLum(IL) = 0.0; } if (SkyClearness > 3.0) { // Sky is average of clear and clear turbid @@ -6417,8 +6414,8 @@ namespace DaylightingManager { // the zone or an exterior window in an adjacent zone that shares an interior window with the zone. // Find contribution of each window to the daylight illum and to the glare numerator at each reference point. // Use shading flags set in WindowShadingManager. - for (loop = 1; loop <= ZoneDaylight(ZoneNum).NumOfDayltgExtWins; ++loop) { - IWin = ZoneDaylight(ZoneNum).DayltgExtWinSurfNums(loop); + for (loop = 1; loop <= state.dataDaylightingData->ZoneDaylight(ZoneNum).NumOfDayltgExtWins; ++loop) { + IWin = state.dataDaylightingData->ZoneDaylight(ZoneNum).DayltgExtWinSurfNums(loop); // Added TH 6/29/2009 for thermochromic windows VTRatio = 1.0; @@ -6442,32 +6439,32 @@ namespace DaylightingManager { for (ISky = 1; ISky <= 4; ++ISky) { // ===Bare window=== - DFSKHR(1, ISky) = VTRatio * (state.dataGlobal->WeightNow * ZoneDaylight(ZoneNum).DaylIllFacSky(state.dataGlobal->HourOfDay, 1, ISky, IL, loop) + - state.dataGlobal->WeightPreviousHour * ZoneDaylight(ZoneNum).DaylIllFacSky(state.dataGlobal->PreviousHour, 1, ISky, IL, loop)); + DFSKHR(1, ISky) = VTRatio * (state.dataGlobal->WeightNow * state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylIllFacSky(state.dataGlobal->HourOfDay, 1, ISky, IL, loop) + + state.dataGlobal->WeightPreviousHour * state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylIllFacSky(state.dataGlobal->PreviousHour, 1, ISky, IL, loop)); if (ISky == 1) - DFSUHR(1) = VTRatio * (state.dataGlobal->WeightNow * (ZoneDaylight(ZoneNum).DaylIllFacSun(state.dataGlobal->HourOfDay, 1, IL, loop) + - ZoneDaylight(ZoneNum).DaylIllFacSunDisk(state.dataGlobal->HourOfDay, 1, IL, loop)) + - state.dataGlobal->WeightPreviousHour * (ZoneDaylight(ZoneNum).DaylIllFacSun(state.dataGlobal->PreviousHour, 1, IL, loop) + - ZoneDaylight(ZoneNum).DaylIllFacSunDisk(state.dataGlobal->PreviousHour, 1, IL, loop))); + DFSUHR(1) = VTRatio * (state.dataGlobal->WeightNow * (state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylIllFacSun(state.dataGlobal->HourOfDay, 1, IL, loop) + + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylIllFacSunDisk(state.dataGlobal->HourOfDay, 1, IL, loop)) + + state.dataGlobal->WeightPreviousHour * (state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylIllFacSun(state.dataGlobal->PreviousHour, 1, IL, loop) + + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylIllFacSunDisk(state.dataGlobal->PreviousHour, 1, IL, loop))); - BFSKHR(1, ISky) = VTRatio * (state.dataGlobal->WeightNow * ZoneDaylight(ZoneNum).DaylBackFacSky(state.dataGlobal->HourOfDay, 1, ISky, IL, loop) + - state.dataGlobal->WeightPreviousHour * ZoneDaylight(ZoneNum).DaylBackFacSky(state.dataGlobal->PreviousHour, 1, ISky, IL, loop)); + BFSKHR(1, ISky) = VTRatio * (state.dataGlobal->WeightNow * state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylBackFacSky(state.dataGlobal->HourOfDay, 1, ISky, IL, loop) + + state.dataGlobal->WeightPreviousHour * state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylBackFacSky(state.dataGlobal->PreviousHour, 1, ISky, IL, loop)); if (ISky == 1) - BFSUHR(1) = VTRatio * (state.dataGlobal->WeightNow * (ZoneDaylight(ZoneNum).DaylBackFacSun(state.dataGlobal->HourOfDay, 1, IL, loop) + - ZoneDaylight(ZoneNum).DaylBackFacSunDisk(state.dataGlobal->HourOfDay, 1, IL, loop)) + - state.dataGlobal->WeightPreviousHour * (ZoneDaylight(ZoneNum).DaylBackFacSun(state.dataGlobal->PreviousHour, 1, IL, loop) + - ZoneDaylight(ZoneNum).DaylBackFacSunDisk(state.dataGlobal->PreviousHour, 1, IL, loop))); + BFSUHR(1) = VTRatio * (state.dataGlobal->WeightNow * (state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylBackFacSun(state.dataGlobal->HourOfDay, 1, IL, loop) + + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylBackFacSunDisk(state.dataGlobal->HourOfDay, 1, IL, loop)) + + state.dataGlobal->WeightPreviousHour * (state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylBackFacSun(state.dataGlobal->PreviousHour, 1, IL, loop) + + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylBackFacSunDisk(state.dataGlobal->PreviousHour, 1, IL, loop))); - SFSKHR(1, ISky) = VTRatio * (state.dataGlobal->WeightNow * ZoneDaylight(ZoneNum).DaylSourceFacSky(state.dataGlobal->HourOfDay, 1, ISky, IL, loop) + - state.dataGlobal->WeightPreviousHour * ZoneDaylight(ZoneNum).DaylSourceFacSky(state.dataGlobal->PreviousHour, 1, ISky, IL, loop)); + SFSKHR(1, ISky) = VTRatio * (state.dataGlobal->WeightNow * state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylSourceFacSky(state.dataGlobal->HourOfDay, 1, ISky, IL, loop) + + state.dataGlobal->WeightPreviousHour * state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylSourceFacSky(state.dataGlobal->PreviousHour, 1, ISky, IL, loop)); if (ISky == 1) - SFSUHR(1) = VTRatio * (state.dataGlobal->WeightNow * (ZoneDaylight(ZoneNum).DaylSourceFacSun(state.dataGlobal->HourOfDay, 1, IL, loop) + - ZoneDaylight(ZoneNum).DaylSourceFacSunDisk(state.dataGlobal->HourOfDay, 1, IL, loop)) + - state.dataGlobal->WeightPreviousHour * (ZoneDaylight(ZoneNum).DaylSourceFacSun(state.dataGlobal->PreviousHour, 1, IL, loop) + - ZoneDaylight(ZoneNum).DaylSourceFacSunDisk(state.dataGlobal->PreviousHour, 1, IL, loop))); + SFSUHR(1) = VTRatio * (state.dataGlobal->WeightNow * (state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylSourceFacSun(state.dataGlobal->HourOfDay, 1, IL, loop) + + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylSourceFacSunDisk(state.dataGlobal->HourOfDay, 1, IL, loop)) + + state.dataGlobal->WeightPreviousHour * (state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylSourceFacSun(state.dataGlobal->PreviousHour, 1, IL, loop) + + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylSourceFacSunDisk(state.dataGlobal->PreviousHour, 1, IL, loop))); if ((SurfWinWindowModelType(IWin) != WindowBSDFModel) && (SurfWinShadingFlag(IWin) >= 1 || SurfWinSolarDiffusing(IWin))) { @@ -6475,40 +6472,40 @@ namespace DaylightingManager { // ===Shaded window or window with diffusing glass=== if (!SurfWinMovableSlats(IWin)) { // Shade, screen, blind with fixed slats, or diffusing glass - DFSKHR(2, ISky) = VTRatio * (state.dataGlobal->WeightNow * ZoneDaylight(ZoneNum).DaylIllFacSky(state.dataGlobal->HourOfDay, 2, ISky, IL, loop) + - state.dataGlobal->WeightPreviousHour * ZoneDaylight(ZoneNum).DaylIllFacSky(state.dataGlobal->PreviousHour, 2, ISky, IL, loop)); + DFSKHR(2, ISky) = VTRatio * (state.dataGlobal->WeightNow * state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylIllFacSky(state.dataGlobal->HourOfDay, 2, ISky, IL, loop) + + state.dataGlobal->WeightPreviousHour * state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylIllFacSky(state.dataGlobal->PreviousHour, 2, ISky, IL, loop)); if (ISky == 1) { - DFSUHR(2) = VTRatio * (state.dataGlobal->WeightNow * ZoneDaylight(ZoneNum).DaylIllFacSun(state.dataGlobal->HourOfDay, 2, IL, loop) + - state.dataGlobal->WeightPreviousHour * ZoneDaylight(ZoneNum).DaylIllFacSun(state.dataGlobal->PreviousHour, 2, IL, loop)); + DFSUHR(2) = VTRatio * (state.dataGlobal->WeightNow * state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylIllFacSun(state.dataGlobal->HourOfDay, 2, IL, loop) + + state.dataGlobal->WeightPreviousHour * state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylIllFacSun(state.dataGlobal->PreviousHour, 2, IL, loop)); if (!SurfWinSlatsBlockBeam(IWin)) - DFSUHR(2) += VTRatio * (state.dataGlobal->WeightNow * ZoneDaylight(ZoneNum).DaylIllFacSunDisk(state.dataGlobal->HourOfDay, 2, IL, loop) + - state.dataGlobal->WeightPreviousHour * ZoneDaylight(ZoneNum).DaylIllFacSunDisk(state.dataGlobal->PreviousHour, 2, IL, loop)); + DFSUHR(2) += VTRatio * (state.dataGlobal->WeightNow * state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylIllFacSunDisk(state.dataGlobal->HourOfDay, 2, IL, loop) + + state.dataGlobal->WeightPreviousHour * state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylIllFacSunDisk(state.dataGlobal->PreviousHour, 2, IL, loop)); } - BFSKHR(2, ISky) = VTRatio * (state.dataGlobal->WeightNow * ZoneDaylight(ZoneNum).DaylBackFacSky(state.dataGlobal->HourOfDay, 2, ISky, IL, loop) + - state.dataGlobal->WeightPreviousHour * ZoneDaylight(ZoneNum).DaylBackFacSky(state.dataGlobal->PreviousHour, 2, ISky, IL, loop)); + BFSKHR(2, ISky) = VTRatio * (state.dataGlobal->WeightNow * state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylBackFacSky(state.dataGlobal->HourOfDay, 2, ISky, IL, loop) + + state.dataGlobal->WeightPreviousHour * state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylBackFacSky(state.dataGlobal->PreviousHour, 2, ISky, IL, loop)); if (ISky == 1) { - BFSUHR(2) = VTRatio * (state.dataGlobal->WeightNow * ZoneDaylight(ZoneNum).DaylBackFacSun(state.dataGlobal->HourOfDay, 2, IL, loop) + - state.dataGlobal->WeightPreviousHour * ZoneDaylight(ZoneNum).DaylBackFacSun(state.dataGlobal->PreviousHour, 2, IL, loop)); + BFSUHR(2) = VTRatio * (state.dataGlobal->WeightNow * state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylBackFacSun(state.dataGlobal->HourOfDay, 2, IL, loop) + + state.dataGlobal->WeightPreviousHour * state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylBackFacSun(state.dataGlobal->PreviousHour, 2, IL, loop)); if (!SurfWinSlatsBlockBeam(IWin)) - BFSUHR(2) += VTRatio * (state.dataGlobal->WeightNow * ZoneDaylight(ZoneNum).DaylBackFacSunDisk(state.dataGlobal->HourOfDay, 2, IL, loop) + - state.dataGlobal->WeightPreviousHour * ZoneDaylight(ZoneNum).DaylBackFacSunDisk(state.dataGlobal->PreviousHour, 2, IL, loop)); + BFSUHR(2) += VTRatio * (state.dataGlobal->WeightNow * state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylBackFacSunDisk(state.dataGlobal->HourOfDay, 2, IL, loop) + + state.dataGlobal->WeightPreviousHour * state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylBackFacSunDisk(state.dataGlobal->PreviousHour, 2, IL, loop)); } SFSKHR(2, ISky) = - VTRatio * (state.dataGlobal->WeightNow * ZoneDaylight(ZoneNum).DaylSourceFacSky(state.dataGlobal->HourOfDay, 2, ISky, IL, loop) + - state.dataGlobal->WeightPreviousHour * ZoneDaylight(ZoneNum).DaylSourceFacSky(state.dataGlobal->PreviousHour, 2, ISky, IL, loop)); + VTRatio * (state.dataGlobal->WeightNow * state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylSourceFacSky(state.dataGlobal->HourOfDay, 2, ISky, IL, loop) + + state.dataGlobal->WeightPreviousHour * state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylSourceFacSky(state.dataGlobal->PreviousHour, 2, ISky, IL, loop)); if (ISky == 1) { - SFSUHR(2) = VTRatio * (state.dataGlobal->WeightNow * ZoneDaylight(ZoneNum).DaylSourceFacSun(state.dataGlobal->HourOfDay, 2, IL, loop) + - state.dataGlobal->WeightPreviousHour * ZoneDaylight(ZoneNum).DaylSourceFacSun(state.dataGlobal->PreviousHour, 2, IL, loop)); + SFSUHR(2) = VTRatio * (state.dataGlobal->WeightNow * state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylSourceFacSun(state.dataGlobal->HourOfDay, 2, IL, loop) + + state.dataGlobal->WeightPreviousHour * state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylSourceFacSun(state.dataGlobal->PreviousHour, 2, IL, loop)); if (!SurfWinSlatsBlockBeam(IWin)) SFSUHR(2) += - VTRatio * (state.dataGlobal->WeightNow * ZoneDaylight(ZoneNum).DaylSourceFacSunDisk(state.dataGlobal->HourOfDay, 2, IL, loop) + - state.dataGlobal->WeightPreviousHour * ZoneDaylight(ZoneNum).DaylSourceFacSunDisk(state.dataGlobal->PreviousHour, 2, IL, loop)); + VTRatio * (state.dataGlobal->WeightNow * state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylSourceFacSunDisk(state.dataGlobal->HourOfDay, 2, IL, loop) + + state.dataGlobal->WeightPreviousHour * state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylSourceFacSunDisk(state.dataGlobal->PreviousHour, 2, IL, loop)); } } else { // Blind with movable slats @@ -6519,20 +6516,20 @@ namespace DaylightingManager { VTRatio * (state.dataGlobal->WeightNow * InterpSlatAng(SlatAng, VarSlats, - ZoneDaylight(ZoneNum).DaylIllFacSky(state.dataGlobal->HourOfDay, {2, MaxSlatAngs + 1}, ISky, IL, loop)) + + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylIllFacSky(state.dataGlobal->HourOfDay, {2, MaxSlatAngs + 1}, ISky, IL, loop)) + state.dataGlobal->WeightPreviousHour * InterpSlatAng( - SlatAng, VarSlats, ZoneDaylight(ZoneNum).DaylIllFacSky(state.dataGlobal->PreviousHour, {2, MaxSlatAngs + 1}, ISky, IL, loop))); + SlatAng, VarSlats, state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylIllFacSky(state.dataGlobal->PreviousHour, {2, MaxSlatAngs + 1}, ISky, IL, loop))); if (ISky == 1) { DFSUHR(2) = VTRatio * (state.dataGlobal->WeightNow * InterpSlatAng(SlatAng, VarSlats, - ZoneDaylight(ZoneNum).DaylIllFacSun(state.dataGlobal->HourOfDay, {2, MaxSlatAngs + 1}, IL, loop)) + + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylIllFacSun(state.dataGlobal->HourOfDay, {2, MaxSlatAngs + 1}, IL, loop)) + state.dataGlobal->WeightPreviousHour * InterpSlatAng( - SlatAng, VarSlats, ZoneDaylight(ZoneNum).DaylIllFacSun(state.dataGlobal->PreviousHour, {2, MaxSlatAngs + 1}, IL, loop))); + SlatAng, VarSlats, state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylIllFacSun(state.dataGlobal->PreviousHour, {2, MaxSlatAngs + 1}, IL, loop))); // We add the contribution from the solar disk if slats do not block beam solar // TH CR 8010. DaylIllFacSunDisk needs to be interpolated! @@ -6542,32 +6539,32 @@ namespace DaylightingManager { (state.dataGlobal->WeightNow * InterpSlatAng(SlatAng, VarSlats, - ZoneDaylight(ZoneNum).DaylIllFacSunDisk(state.dataGlobal->HourOfDay, {2, MaxSlatAngs + 1}, IL, loop)) + + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylIllFacSunDisk(state.dataGlobal->HourOfDay, {2, MaxSlatAngs + 1}, IL, loop)) + state.dataGlobal->WeightPreviousHour * InterpSlatAng(SlatAng, VarSlats, - ZoneDaylight(ZoneNum).DaylIllFacSunDisk(state.dataGlobal->PreviousHour, {2, MaxSlatAngs + 1}, IL, loop))); + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylIllFacSunDisk(state.dataGlobal->PreviousHour, {2, MaxSlatAngs + 1}, IL, loop))); } BFSKHR(2, ISky) = VTRatio * (state.dataGlobal->WeightNow * InterpSlatAng(SlatAng, VarSlats, - ZoneDaylight(ZoneNum).DaylBackFacSky(state.dataGlobal->HourOfDay, {2, MaxSlatAngs + 1}, ISky, IL, loop)) + + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylBackFacSky(state.dataGlobal->HourOfDay, {2, MaxSlatAngs + 1}, ISky, IL, loop)) + state.dataGlobal->WeightPreviousHour * InterpSlatAng(SlatAng, VarSlats, - ZoneDaylight(ZoneNum).DaylBackFacSky(state.dataGlobal->PreviousHour, {2, MaxSlatAngs + 1}, ISky, IL, loop))); + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylBackFacSky(state.dataGlobal->PreviousHour, {2, MaxSlatAngs + 1}, ISky, IL, loop))); if (ISky == 1) { BFSUHR(2) = VTRatio * (state.dataGlobal->WeightNow * InterpSlatAng(SlatAng, VarSlats, - ZoneDaylight(ZoneNum).DaylBackFacSun(state.dataGlobal->HourOfDay, {2, MaxSlatAngs + 1}, IL, loop)) + + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylBackFacSun(state.dataGlobal->HourOfDay, {2, MaxSlatAngs + 1}, IL, loop)) + state.dataGlobal->WeightPreviousHour * InterpSlatAng( - SlatAng, VarSlats, ZoneDaylight(ZoneNum).DaylBackFacSun(state.dataGlobal->PreviousHour, {2, MaxSlatAngs + 1}, IL, loop))); + SlatAng, VarSlats, state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylBackFacSun(state.dataGlobal->PreviousHour, {2, MaxSlatAngs + 1}, IL, loop))); // TH CR 8010. DaylBackFacSunDisk needs to be interpolated! if (!SurfWinSlatsBlockBeam(IWin)) { @@ -6576,11 +6573,11 @@ namespace DaylightingManager { (state.dataGlobal->WeightNow * InterpSlatAng(SlatAng, VarSlats, - ZoneDaylight(ZoneNum).DaylBackFacSunDisk(state.dataGlobal->HourOfDay, {2, MaxSlatAngs + 1}, IL, loop)) + + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylBackFacSunDisk(state.dataGlobal->HourOfDay, {2, MaxSlatAngs + 1}, IL, loop)) + state.dataGlobal->WeightPreviousHour * InterpSlatAng(SlatAng, VarSlats, - ZoneDaylight(ZoneNum).DaylBackFacSunDisk(state.dataGlobal->PreviousHour, {2, MaxSlatAngs + 1}, IL, loop))); + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylBackFacSunDisk(state.dataGlobal->PreviousHour, {2, MaxSlatAngs + 1}, IL, loop))); } } @@ -6588,22 +6585,22 @@ namespace DaylightingManager { VTRatio * (state.dataGlobal->WeightNow * InterpSlatAng(SlatAng, VarSlats, - ZoneDaylight(ZoneNum).DaylSourceFacSky(state.dataGlobal->HourOfDay, {2, MaxSlatAngs + 1}, ISky, IL, loop)) + + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylSourceFacSky(state.dataGlobal->HourOfDay, {2, MaxSlatAngs + 1}, ISky, IL, loop)) + state.dataGlobal->WeightPreviousHour * InterpSlatAng(SlatAng, VarSlats, - ZoneDaylight(ZoneNum).DaylSourceFacSky(state.dataGlobal->PreviousHour, {2, MaxSlatAngs + 1}, ISky, IL, loop))); + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylSourceFacSky(state.dataGlobal->PreviousHour, {2, MaxSlatAngs + 1}, ISky, IL, loop))); if (ISky == 1) { SFSUHR(2) = VTRatio * (state.dataGlobal->WeightNow * InterpSlatAng(SlatAng, VarSlats, - ZoneDaylight(ZoneNum).DaylSourceFacSun(state.dataGlobal->HourOfDay, {2, MaxSlatAngs + 1}, IL, loop)) + + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylSourceFacSun(state.dataGlobal->HourOfDay, {2, MaxSlatAngs + 1}, IL, loop)) + state.dataGlobal->WeightPreviousHour * InterpSlatAng(SlatAng, VarSlats, - ZoneDaylight(ZoneNum).DaylSourceFacSun(state.dataGlobal->PreviousHour, {2, MaxSlatAngs + 1}, IL, loop))); + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylSourceFacSun(state.dataGlobal->PreviousHour, {2, MaxSlatAngs + 1}, IL, loop))); // TH CR 8010. DaylSourceFacSunDisk needs to be interpolated! if (!SurfWinSlatsBlockBeam(IWin)) { @@ -6612,11 +6609,11 @@ namespace DaylightingManager { (state.dataGlobal->WeightNow * InterpSlatAng(SlatAng, VarSlats, - ZoneDaylight(ZoneNum).DaylSourceFacSunDisk(state.dataGlobal->HourOfDay, {2, MaxSlatAngs + 1}, IL, loop)) + + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylSourceFacSunDisk(state.dataGlobal->HourOfDay, {2, MaxSlatAngs + 1}, IL, loop)) + state.dataGlobal->WeightPreviousHour * InterpSlatAng(SlatAng, VarSlats, - ZoneDaylight(ZoneNum).DaylSourceFacSunDisk(state.dataGlobal->PreviousHour, {2, MaxSlatAngs + 1}, IL, loop))); + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylSourceFacSunDisk(state.dataGlobal->PreviousHour, {2, MaxSlatAngs + 1}, IL, loop))); } } @@ -6644,25 +6641,25 @@ namespace DaylightingManager { if (IS == 2 && (SurfWinWindowModelType(IWin) == WindowBSDFModel)) break; if (IS == 2 && SurfWinShadingFlag(IWin) <= 0 && !SurfWinSolarDiffusing(IWin)) break; - ZoneDaylight(ZoneNum).IllumFromWinAtRefPt(loop, IS, IL) = + state.dataDaylightingData->ZoneDaylight(ZoneNum).IllumFromWinAtRefPt(loop, IS, IL) = DFSUHR(IS) * HISUNF + HorIllSkyFac * (DFSKHR(IS, ISky1) * SkyWeight * HorIllSky(ISky1) + DFSKHR(IS, ISky2) * (1.0 - SkyWeight) * HorIllSky(ISky2)); - ZoneDaylight(ZoneNum).BackLumFromWinAtRefPt(loop, IS, IL) = + state.dataDaylightingData->ZoneDaylight(ZoneNum).BackLumFromWinAtRefPt(loop, IS, IL) = BFSUHR(IS) * HISUNF + HorIllSkyFac * (BFSKHR(IS, ISky1) * SkyWeight * HorIllSky(ISky1) + BFSKHR(IS, ISky2) * (1.0 - SkyWeight) * HorIllSky(ISky2)); - ZoneDaylight(ZoneNum).SourceLumFromWinAtRefPt(loop, IS, IL) = + state.dataDaylightingData->ZoneDaylight(ZoneNum).SourceLumFromWinAtRefPt(loop, IS, IL) = SFSUHR(IS) * HISUNF + HorIllSkyFac * (SFSKHR(IS, ISky1) * SkyWeight * HorIllSky(ISky1) + SFSKHR(IS, ISky2) * (1.0 - SkyWeight) * HorIllSky(ISky2)); - ZoneDaylight(ZoneNum).SourceLumFromWinAtRefPt(loop, IS, IL) = - max(ZoneDaylight(ZoneNum).SourceLumFromWinAtRefPt(loop, IS, IL), 0.0); + state.dataDaylightingData->ZoneDaylight(ZoneNum).SourceLumFromWinAtRefPt(loop, IS, IL) = + max(state.dataDaylightingData->ZoneDaylight(ZoneNum).SourceLumFromWinAtRefPt(loop, IS, IL), 0.0); // Added TH 1/21/2010 - save the original clear and dark (fully switched) states' // zone daylighting values, needed for switachable glazings - tmpIllumFromWinAtRefPt(loop, IS, IL) = ZoneDaylight(ZoneNum).IllumFromWinAtRefPt(loop, IS, IL); - tmpBackLumFromWinAtRefPt(loop, IS, IL) = ZoneDaylight(ZoneNum).BackLumFromWinAtRefPt(loop, IS, IL); - tmpSourceLumFromWinAtRefPt(loop, IS, IL) = ZoneDaylight(ZoneNum).SourceLumFromWinAtRefPt(loop, IS, IL); + tmpIllumFromWinAtRefPt(loop, IS, IL) = state.dataDaylightingData->ZoneDaylight(ZoneNum).IllumFromWinAtRefPt(loop, IS, IL); + tmpBackLumFromWinAtRefPt(loop, IS, IL) = state.dataDaylightingData->ZoneDaylight(ZoneNum).BackLumFromWinAtRefPt(loop, IS, IL); + tmpSourceLumFromWinAtRefPt(loop, IS, IL) = state.dataDaylightingData->ZoneDaylight(ZoneNum).SourceLumFromWinAtRefPt(loop, IS, IL); } // IS } // End of reference point loop, IL @@ -6678,8 +6675,8 @@ namespace DaylightingManager { // This illuminance excludes contribution of inter-reflected illuminance produced by solar // entering the zone through interior windows (which is calculated in DayltgInterReflIllFrIntWins. - for (loop = 1; loop <= ZoneDaylight(ZoneNum).NumOfDayltgExtWins; ++loop) { - IWin = ZoneDaylight(ZoneNum).DayltgExtWinSurfNums(loop); + for (loop = 1; loop <= state.dataDaylightingData->ZoneDaylight(ZoneNum).NumOfDayltgExtWins; ++loop) { + IWin = state.dataDaylightingData->ZoneDaylight(ZoneNum).DayltgExtWinSurfNums(loop); ICtrl = Surface(IWin).activeWindowShadingControl; if (Surface(IWin).HasShadeControl && ISWFLG == 0) { if (WindowShadingControl(ICtrl).ShadingControlType == WSCT_MeetDaylIlumSetp && @@ -6698,8 +6695,8 @@ namespace DaylightingManager { IS = 2; for (IL = 1; IL <= NREFPT; ++IL) { - DaylIllum(IL) += ZoneDaylight(ZoneNum).IllumFromWinAtRefPt(loop, IS, IL); - ZoneDaylight(ZoneNum).BacLum(IL) += ZoneDaylight(ZoneNum).BackLumFromWinAtRefPt(loop, IS, IL); + DaylIllum(IL) += state.dataDaylightingData->ZoneDaylight(ZoneNum).IllumFromWinAtRefPt(loop, IS, IL); + state.dataDaylightingData->ZoneDaylight(ZoneNum).BacLum(IL) += state.dataDaylightingData->ZoneDaylight(ZoneNum).BackLumFromWinAtRefPt(loop, IS, IL); } } // End of second window loop over exterior windows associated with this zone @@ -6713,9 +6710,9 @@ namespace DaylightingManager { Array1D DILLSW; // Illuminance a ref point from a group of windows that can be switched together, Array1D DILLUN; // and from those that aren't (lux) Array1D_bool previously_shaded; // array of flags to indicate that previously groups would have already shaded this window - DILLSW.allocate(ZoneDaylight(ZoneNum).ShadeDeployOrderExtWins.size()); - DILLUN.allocate(ZoneDaylight(ZoneNum).ShadeDeployOrderExtWins.size()); - previously_shaded.allocate(ZoneDaylight(ZoneNum).NumOfDayltgExtWins); + DILLSW.allocate(state.dataDaylightingData->ZoneDaylight(ZoneNum).ShadeDeployOrderExtWins.size()); + DILLUN.allocate(state.dataDaylightingData->ZoneDaylight(ZoneNum).ShadeDeployOrderExtWins.size()); + previously_shaded.allocate(state.dataDaylightingData->ZoneDaylight(ZoneNum).NumOfDayltgExtWins); // If daylight illuminance is above setpoint, allow switching if (ISWFLG != 0 && DaylIllum(1) > SetPnt(1)) { @@ -6729,12 +6726,12 @@ namespace DaylightingManager { previously_shaded = false; int count = 0; - for (std::size_t igroup = 1; igroup <= ZoneDaylight(ZoneNum).ShadeDeployOrderExtWins.size(); igroup++) { - std::vector listOfExtWin = ZoneDaylight(ZoneNum).ShadeDeployOrderExtWins[igroup - 1]; + for (std::size_t igroup = 1; igroup <= state.dataDaylightingData->ZoneDaylight(ZoneNum).ShadeDeployOrderExtWins.size(); igroup++) { + std::vector listOfExtWin = state.dataDaylightingData->ZoneDaylight(ZoneNum).ShadeDeployOrderExtWins[igroup - 1]; for (const auto IWin : listOfExtWin) { ++count; // need to map back to the original order of the "loop" to not change all the other data structures - loop = ZoneDaylight(ZoneNum).MapShdOrdToLoopNum(count); + loop = state.dataDaylightingData->ZoneDaylight(ZoneNum).MapShdOrdToLoopNum(count); ICtrl = Surface(IWin).activeWindowShadingControl; IS = 1; @@ -6744,13 +6741,13 @@ namespace DaylightingManager { if (Surface(IWin).HasShadeControl) { if (SurfWinShadingFlag(IWin) == GlassConditionallyLightened && WindowShadingControl(ICtrl).ShadingControlType == WSCT_MeetDaylIlumSetp && !previously_shaded(loop)) { - DILLSW(igroup) += ZoneDaylight(ZoneNum).IllumFromWinAtRefPt(loop, IS, 1); + DILLSW(igroup) += state.dataDaylightingData->ZoneDaylight(ZoneNum).IllumFromWinAtRefPt(loop, IS, 1); previously_shaded(loop) = true; } else { if (!previously_shaded(loop)) { - DILLUN(igroup) += ZoneDaylight(ZoneNum).IllumFromWinAtRefPt(loop, IS, 1); + DILLUN(igroup) += state.dataDaylightingData->ZoneDaylight(ZoneNum).IllumFromWinAtRefPt(loop, IS, 1); } else { - DILLUN(igroup) += ZoneDaylight(ZoneNum).IllumFromWinAtRefPt(loop, 2, 1); // use the shaded state if previously shaded + DILLUN(igroup) += state.dataDaylightingData->ZoneDaylight(ZoneNum).IllumFromWinAtRefPt(loop, 2, 1); // use the shaded state if previously shaded } } } @@ -6758,10 +6755,10 @@ namespace DaylightingManager { } // End of third window loop, IWin Array1D ASETIL; // Illuminance ratio (lux) - ASETIL.allocate(ZoneDaylight(ZoneNum).ShadeDeployOrderExtWins.size()); + ASETIL.allocate(state.dataDaylightingData->ZoneDaylight(ZoneNum).ShadeDeployOrderExtWins.size()); // Transmittance multiplier - for (std::size_t igroup = 1; igroup <= ZoneDaylight(ZoneNum).ShadeDeployOrderExtWins.size(); igroup++) { + for (std::size_t igroup = 1; igroup <= state.dataDaylightingData->ZoneDaylight(ZoneNum).ShadeDeployOrderExtWins.size(); igroup++) { ASETIL(igroup) = (SetPnt(1) - DILLUN(igroup)) / (DILLSW(igroup) + 0.00001); } @@ -6772,14 +6769,14 @@ namespace DaylightingManager { count = 0; breakOuterLoop = false; continueOuterLoop = false; - for (std::size_t igroup = 1; igroup <= ZoneDaylight(ZoneNum).ShadeDeployOrderExtWins.size(); igroup++) { + for (std::size_t igroup = 1; igroup <= state.dataDaylightingData->ZoneDaylight(ZoneNum).ShadeDeployOrderExtWins.size(); igroup++) { - std::vector listOfExtWin = ZoneDaylight(ZoneNum).ShadeDeployOrderExtWins[igroup - 1]; + std::vector listOfExtWin = state.dataDaylightingData->ZoneDaylight(ZoneNum).ShadeDeployOrderExtWins[igroup - 1]; for (const auto IWin : listOfExtWin) { ++count; // need to map back to the original order of the "loop" to not change all the other data structures - loop = ZoneDaylight(ZoneNum).MapShdOrdToLoopNum(count); + loop = state.dataDaylightingData->ZoneDaylight(ZoneNum).MapShdOrdToLoopNum(count); if (ASETIL(igroup) < 1.0) { ICtrl = Surface(IWin).activeWindowShadingControl; @@ -6828,16 +6825,16 @@ namespace DaylightingManager { // and need to adjusted for intermediate switched state at VisTransSelected: IS = 2 IS = 1; VTRAT = SurfWinVisTransSelected(IWin) / (TVIS1(igroup) + 0.000001); - DaylIllum(IL) += (VTRAT - 1.0) * ZoneDaylight(ZoneNum).IllumFromWinAtRefPt(loop, IS, IL); - ZoneDaylight(ZoneNum).BacLum(IL) += (VTRAT - 1.0) * ZoneDaylight(ZoneNum).BackLumFromWinAtRefPt(loop, IS, IL); + DaylIllum(IL) += (VTRAT - 1.0) * state.dataDaylightingData->ZoneDaylight(ZoneNum).IllumFromWinAtRefPt(loop, IS, IL); + state.dataDaylightingData->ZoneDaylight(ZoneNum).BacLum(IL) += (VTRAT - 1.0) * state.dataDaylightingData->ZoneDaylight(ZoneNum).BackLumFromWinAtRefPt(loop, IS, IL); // Adjust illum, background illum and source luminance for this window in intermediate switched state // for later use in the DayltgGlare calc because SurfaceWindow(IWin)%ShadingFlag = SwitchableGlazing = 2 IS = 2; VTRAT = SurfWinVisTransSelected(IWin) / (TVIS2(igroup) + 0.000001); - ZoneDaylight(ZoneNum).IllumFromWinAtRefPt(loop, IS, IL) = VTRAT * tmpIllumFromWinAtRefPt(loop, IS, IL); - ZoneDaylight(ZoneNum).BackLumFromWinAtRefPt(loop, IS, IL) = VTRAT * tmpBackLumFromWinAtRefPt(loop, IS, IL); - ZoneDaylight(ZoneNum).SourceLumFromWinAtRefPt(loop, IS, IL) = VTRAT * tmpSourceLumFromWinAtRefPt(loop, IS, IL); + state.dataDaylightingData->ZoneDaylight(ZoneNum).IllumFromWinAtRefPt(loop, IS, IL) = VTRAT * tmpIllumFromWinAtRefPt(loop, IS, IL); + state.dataDaylightingData->ZoneDaylight(ZoneNum).BackLumFromWinAtRefPt(loop, IS, IL) = VTRAT * tmpBackLumFromWinAtRefPt(loop, IS, IL); + state.dataDaylightingData->ZoneDaylight(ZoneNum).SourceLumFromWinAtRefPt(loop, IS, IL) = VTRAT * tmpSourceLumFromWinAtRefPt(loop, IS, IL); } // IL } // ASETIL < 1 // If new daylight does not exceed the illuminance setpoint, done, no more checking other groups of switchable glazings @@ -6855,10 +6852,10 @@ namespace DaylightingManager { // Calculate glare index at each reference point assuming the daylight illuminance setpoint is // met at both reference points, either by daylight or electric lights for (IL = 1; IL <= NREFPT; ++IL) { - BACL = max(SetPnt(IL) * ZoneDaylight(ZoneNum).AveVisDiffReflect / DataGlobalConstants::Pi(), ZoneDaylight(ZoneNum).BacLum(IL)); + BACL = max(SetPnt(IL) * state.dataDaylightingData->ZoneDaylight(ZoneNum).AveVisDiffReflect / DataGlobalConstants::Pi(), state.dataDaylightingData->ZoneDaylight(ZoneNum).BacLum(IL)); // DayltgGlare uses ZoneDaylight(ZoneNum)%SourceLumFromWinAtRefPt(IL,1,loop) for unshaded windows, and // ZoneDaylight(ZoneNum)%SourceLumFromWinAtRefPt(IL,2,loop) for shaded windows - DayltgGlare(IL, BACL, GLRNDX(IL), ZoneNum); + DayltgGlare(state, IL, BACL, GLRNDX(IL), ZoneNum); } // Check if glare level is less than maximum allowed at each ref pt. If maximum @@ -6866,32 +6863,32 @@ namespace DaylightingManager { // shading device on windows that have shades that have not already been closed. GlareFlag = false; for (IL = 1; IL <= NREFPT; ++IL) { - if (GLRNDX(IL) > ZoneDaylight(ZoneNum).MaxGlareallowed) { + if (GLRNDX(IL) > state.dataDaylightingData->ZoneDaylight(ZoneNum).MaxGlareallowed) { GlareFlag = true; break; } } Array3D WDAYIL( - 2, NREFPT, ZoneDaylight(ZoneNum).ShadeDeployOrderExtWins.size()); // Illuminance from window at reference point (second index) + 2, NREFPT, state.dataDaylightingData->ZoneDaylight(ZoneNum).ShadeDeployOrderExtWins.size()); // Illuminance from window at reference point (second index) // for shade open/closed (first index), the number of shade deployment groups (third index) Array3D WBACLU( - 2, NREFPT, ZoneDaylight(ZoneNum).ShadeDeployOrderExtWins.size()); // Background illuminance from window at reference point (second index) + 2, NREFPT, state.dataDaylightingData->ZoneDaylight(ZoneNum).ShadeDeployOrderExtWins.size()); // Background illuminance from window at reference point (second index) // for shade open/closed (first index), the number of shade deployment groups (third index) Array2D RDAYIL( - NREFPT, ZoneDaylight(ZoneNum).ShadeDeployOrderExtWins.size()); // Illuminance from window at reference point after closing shade + NREFPT, state.dataDaylightingData->ZoneDaylight(ZoneNum).ShadeDeployOrderExtWins.size()); // Illuminance from window at reference point after closing shade Array2D RBACLU( NREFPT, - ZoneDaylight(ZoneNum).ShadeDeployOrderExtWins.size()); // Background illuminance from window at reference point after closing shade + state.dataDaylightingData->ZoneDaylight(ZoneNum).ShadeDeployOrderExtWins.size()); // Background illuminance from window at reference point after closing shade if (GlareFlag) { // Glare is too high at a ref pt. Loop through windows. int count = 0; continueOuterLoop = false; - for (std::size_t igroup = 1; igroup <= ZoneDaylight(ZoneNum).ShadeDeployOrderExtWins.size(); igroup++) { + for (std::size_t igroup = 1; igroup <= state.dataDaylightingData->ZoneDaylight(ZoneNum).ShadeDeployOrderExtWins.size(); igroup++) { - std::vector listOfExtWin = ZoneDaylight(ZoneNum).ShadeDeployOrderExtWins[igroup - 1]; + std::vector listOfExtWin = state.dataDaylightingData->ZoneDaylight(ZoneNum).ShadeDeployOrderExtWins[igroup - 1]; int countBeforeListOfExtWinLoop = count; bool atLeastOneGlareControlIsActive = false; @@ -6899,7 +6896,7 @@ namespace DaylightingManager { for (const auto IWin : listOfExtWin) { ++count; // need to map back to the original order of the "loop" to not change all the other data structures - loop = ZoneDaylight(ZoneNum).MapShdOrdToLoopNum(count); + loop = state.dataDaylightingData->ZoneDaylight(ZoneNum).MapShdOrdToLoopNum(count); // Check if window is eligible for glare control // TH 1/21/2010. Switchable glazings already in partially switched state @@ -6921,8 +6918,8 @@ namespace DaylightingManager { // For switchable windows, this may be partially switched rather than fully dark for (IL = 1; IL <= NREFPT; ++IL) { for (IS = 1; IS <= 2; ++IS) { - WDAYIL(IS, IL, igroup) = ZoneDaylight(ZoneNum).IllumFromWinAtRefPt(loop, IS, IL); - WBACLU(IS, IL, igroup) = ZoneDaylight(ZoneNum).BackLumFromWinAtRefPt(loop, IS, IL); + WDAYIL(IS, IL, igroup) = state.dataDaylightingData->ZoneDaylight(ZoneNum).IllumFromWinAtRefPt(loop, IS, IL); + WBACLU(IS, IL, igroup) = state.dataDaylightingData->ZoneDaylight(ZoneNum).BackLumFromWinAtRefPt(loop, IS, IL); } } @@ -6933,11 +6930,11 @@ namespace DaylightingManager { // for non switchable glazings or switchable glazings not switched yet (still in clear state) // SurfaceWindow(IWin)%ShadingFlag = GlassConditionallyLightened RDAYIL(IL, igroup) = DaylIllum(IL) - WDAYIL(1, IL, igroup) + WDAYIL(2, IL, igroup); - RBACLU(IL, igroup) = ZoneDaylight(ZoneNum).BacLum(IL) - WBACLU(1, IL, igroup) + WBACLU(2, IL, igroup); + RBACLU(IL, igroup) = state.dataDaylightingData->ZoneDaylight(ZoneNum).BacLum(IL) - WBACLU(1, IL, igroup) + WBACLU(2, IL, igroup); } else { // switchable glazings already in partially switched state when calc the RDAYIL(IL) & RBACLU(IL) RDAYIL(IL, igroup) = DaylIllum(IL) - WDAYIL(2, IL, igroup) + tmpIllumFromWinAtRefPt(loop, 2, IL); - RBACLU(IL, igroup) = ZoneDaylight(ZoneNum).BacLum(IL) - WBACLU(2, IL, igroup) + tmpBackLumFromWinAtRefPt(loop, 2, IL); + RBACLU(IL, igroup) = state.dataDaylightingData->ZoneDaylight(ZoneNum).BacLum(IL) - WBACLU(2, IL, igroup) + tmpBackLumFromWinAtRefPt(loop, 2, IL); } } @@ -6947,9 +6944,9 @@ namespace DaylightingManager { // update ZoneDaylight(ZoneNum)%SourceLumFromWinAtRefPt(IL,2,loop) for use in DayltgGlare if (SurfWinShadingFlag(IWin) == SwitchableGlazing) { for (IL = 1; IL <= NREFPT; ++IL) { - ZoneDaylight(ZoneNum).SourceLumFromWinAtRefPt(loop, 2, IL) = tmpSourceLumFromWinAtRefPt(loop, 2, IL); - ZoneDaylight(ZoneNum).IllumFromWinAtRefPt(loop, 2, IL) = tmpIllumFromWinAtRefPt(loop, 2, IL); - ZoneDaylight(ZoneNum).BackLumFromWinAtRefPt(loop, 2, IL) = tmpBackLumFromWinAtRefPt(loop, 2, IL); + state.dataDaylightingData->ZoneDaylight(ZoneNum).SourceLumFromWinAtRefPt(loop, 2, IL) = tmpSourceLumFromWinAtRefPt(loop, 2, IL); + state.dataDaylightingData->ZoneDaylight(ZoneNum).IllumFromWinAtRefPt(loop, 2, IL) = tmpIllumFromWinAtRefPt(loop, 2, IL); + state.dataDaylightingData->ZoneDaylight(ZoneNum).BackLumFromWinAtRefPt(loop, 2, IL) = tmpBackLumFromWinAtRefPt(loop, 2, IL); } IConst = Surface(IWin).Construction; @@ -6968,9 +6965,9 @@ namespace DaylightingManager { // Re-calc daylight and glare at shaded state. For switchable glazings, it is the fully dark state. for (IL = 1; IL <= NREFPT; ++IL) { - BACL = max(SetPnt(IL) * ZoneDaylight(ZoneNum).AveVisDiffReflect / DataGlobalConstants::Pi(), RBACLU(IL, igroup)); + BACL = max(SetPnt(IL) * state.dataDaylightingData->ZoneDaylight(ZoneNum).AveVisDiffReflect / DataGlobalConstants::Pi(), RBACLU(IL, igroup)); // DayltgGlare uses ZoneDaylight(ZoneNum)%SourceLumFromWinAtRefPt(IL,2,loop) for shaded state - DayltgGlare(IL, BACL, GLRNEW(IL), ZoneNum); + DayltgGlare(state, IL, BACL, GLRNEW(IL), ZoneNum); } // Check if the shading did not improve the glare conditions @@ -6999,8 +6996,8 @@ namespace DaylightingManager { int numRefPtOldAboveMaxNewBelowOld = 0; int numRefPtOldBelowMaxNewBelowMax = 0; for (IL = 1; IL <= NREFPT; ++IL) { - if (GLRNDX(IL) > ZoneDaylight(ZoneNum).MaxGlareallowed && GLRNEW(IL) <= GLRNDX(IL)) ++numRefPtOldAboveMaxNewBelowOld; - if (GLRNDX(IL) <= ZoneDaylight(ZoneNum).MaxGlareallowed && GLRNEW(IL) <= ZoneDaylight(ZoneNum).MaxGlareallowed) + if (GLRNDX(IL) > state.dataDaylightingData->ZoneDaylight(ZoneNum).MaxGlareallowed && GLRNEW(IL) <= GLRNDX(IL)) ++numRefPtOldAboveMaxNewBelowOld; + if (GLRNDX(IL) <= state.dataDaylightingData->ZoneDaylight(ZoneNum).MaxGlareallowed && GLRNEW(IL) <= state.dataDaylightingData->ZoneDaylight(ZoneNum).MaxGlareallowed) ++numRefPtOldBelowMaxNewBelowMax; } blnCycle = true; @@ -7014,7 +7011,7 @@ namespace DaylightingManager { for (const auto IWin : listOfExtWin) { ++count; // need to map back to the original order of the "loop" to not change all the other data structures - loop = ZoneDaylight(ZoneNum).MapShdOrdToLoopNum(count); + loop = state.dataDaylightingData->ZoneDaylight(ZoneNum).MapShdOrdToLoopNum(count); if (SurfWinShadingFlag(IWin) < 10 && SurfWinShadingFlag(IWin) != SwitchableGlazing) continue; ICtrl = Surface(IWin).activeWindowShadingControl; @@ -7031,9 +7028,9 @@ namespace DaylightingManager { // RESET properties for fully dark state for (IL = 1; IL <= NREFPT; ++IL) { - ZoneDaylight(ZoneNum).IllumFromWinAtRefPt(loop, 2, IL) = tmpIllumFromWinAtRefPt(loop, 2, IL); - ZoneDaylight(ZoneNum).BackLumFromWinAtRefPt(loop, 2, IL) = tmpBackLumFromWinAtRefPt(loop, 2, IL); - ZoneDaylight(ZoneNum).SourceLumFromWinAtRefPt(loop, 2, IL) = tmpSourceLumFromWinAtRefPt(loop, 2, IL); + state.dataDaylightingData->ZoneDaylight(ZoneNum).IllumFromWinAtRefPt(loop, 2, IL) = tmpIllumFromWinAtRefPt(loop, 2, IL); + state.dataDaylightingData->ZoneDaylight(ZoneNum).BackLumFromWinAtRefPt(loop, 2, IL) = tmpBackLumFromWinAtRefPt(loop, 2, IL); + state.dataDaylightingData->ZoneDaylight(ZoneNum).SourceLumFromWinAtRefPt(loop, 2, IL) = tmpSourceLumFromWinAtRefPt(loop, 2, IL); } } @@ -7045,7 +7042,7 @@ namespace DaylightingManager { // Reset background luminance, glare index, and daylight illuminance at each ref pt. // For switchable glazings, this is fully switched, dark state for (IL = 1; IL <= NREFPT; ++IL) { - ZoneDaylight(ZoneNum).BacLum(IL) = RBACLU(IL, igroup); + state.dataDaylightingData->ZoneDaylight(ZoneNum).BacLum(IL) = RBACLU(IL, igroup); GLRNDX(IL) = GLRNEW(IL); DaylIllum(IL) = RDAYIL(IL, igroup); } @@ -7069,18 +7066,18 @@ namespace DaylightingManager { for (IL = 1; IL <= NREFPT; ++IL) { WDAYIL(2, IL, igroup) = tmpIllumFromWinAtRefPt(loop, 2, IL); WBACLU(2, IL, igroup) = tmpBackLumFromWinAtRefPt(loop, 2, IL); - ZoneDaylight(ZoneNum).IllumFromWinAtRefPt(loop, 2, IL) = tmpIllumFromWinAtRefPt(loop, 2, IL); - ZoneDaylight(ZoneNum).BackLumFromWinAtRefPt(loop, 2, IL) = tmpBackLumFromWinAtRefPt(loop, 2, IL); - ZoneDaylight(ZoneNum).SourceLumFromWinAtRefPt(loop, 2, IL) = tmpSourceLumFromWinAtRefPt(loop, 2, IL); + state.dataDaylightingData->ZoneDaylight(ZoneNum).IllumFromWinAtRefPt(loop, 2, IL) = tmpIllumFromWinAtRefPt(loop, 2, IL); + state.dataDaylightingData->ZoneDaylight(ZoneNum).BackLumFromWinAtRefPt(loop, 2, IL) = tmpBackLumFromWinAtRefPt(loop, 2, IL); + state.dataDaylightingData->ZoneDaylight(ZoneNum).SourceLumFromWinAtRefPt(loop, 2, IL) = tmpSourceLumFromWinAtRefPt(loop, 2, IL); } } // Check if glare now acceptable at each ref pt. GlareOK = false; if (NREFPT == 1) { - if (GLRNDX(1) <= ZoneDaylight(ZoneNum).MaxGlareallowed) GlareOK = true; + if (GLRNDX(1) <= state.dataDaylightingData->ZoneDaylight(ZoneNum).MaxGlareallowed) GlareOK = true; } else if (NREFPT > 1) { - if (GLRNDX(1) <= ZoneDaylight(ZoneNum).MaxGlareallowed && GLRNDX(2) <= ZoneDaylight(ZoneNum).MaxGlareallowed) + if (GLRNDX(1) <= state.dataDaylightingData->ZoneDaylight(ZoneNum).MaxGlareallowed && GLRNDX(2) <= state.dataDaylightingData->ZoneDaylight(ZoneNum).MaxGlareallowed) GlareOK = true; } @@ -7104,25 +7101,25 @@ namespace DaylightingManager { for (IL = 1; IL <= NREFPT; ++IL) { RDAYIL(IL, igroup) = DaylIllum(IL) + (WDAYIL(1, IL, igroup) - WDAYIL(2, IL, igroup)) * (1.0 - tmpSWFactor); RBACLU(IL, igroup) = - ZoneDaylight(ZoneNum).BacLum(IL) + (WBACLU(1, IL, igroup) - WBACLU(2, IL, igroup)) * (1.0 - tmpSWFactor); - BACL = max(SetPnt(IL) * ZoneDaylight(ZoneNum).AveVisDiffReflect / DataGlobalConstants::Pi(), RBACLU(IL, igroup)); + state.dataDaylightingData->ZoneDaylight(ZoneNum).BacLum(IL) + (WBACLU(1, IL, igroup) - WBACLU(2, IL, igroup)) * (1.0 - tmpSWFactor); + BACL = max(SetPnt(IL) * state.dataDaylightingData->ZoneDaylight(ZoneNum).AveVisDiffReflect / DataGlobalConstants::Pi(), RBACLU(IL, igroup)); // needs to update SourceLumFromWinAtRefPt(IL,2,loop) before re-calc DayltgGlare tmpMult = (TVIS1(igroup) - (TVIS1(igroup) - TVIS2(igroup)) * tmpSWFactor) / TVIS2(igroup); if (IL == 1) { - ZoneDaylight(ZoneNum).SourceLumFromWinAtRefPt(loop, 2, IL) = tmpSWSL1 * tmpMult; + state.dataDaylightingData->ZoneDaylight(ZoneNum).SourceLumFromWinAtRefPt(loop, 2, IL) = tmpSWSL1 * tmpMult; } else { - ZoneDaylight(ZoneNum).SourceLumFromWinAtRefPt(loop, 2, IL) = tmpSWSL2 * tmpMult; + state.dataDaylightingData->ZoneDaylight(ZoneNum).SourceLumFromWinAtRefPt(loop, 2, IL) = tmpSWSL2 * tmpMult; } // Calc new glare - DayltgGlare(IL, BACL, GLRNEW(IL), ZoneNum); + DayltgGlare(state, IL, BACL, GLRNEW(IL), ZoneNum); } // Check whether new glare is OK GlareOK = false; if (NREFPT == 1) { - if (GLRNEW(1) <= ZoneDaylight(ZoneNum).MaxGlareallowed) GlareOK = true; + if (GLRNEW(1) <= state.dataDaylightingData->ZoneDaylight(ZoneNum).MaxGlareallowed) GlareOK = true; } else if (NREFPT > 1) { - if (GLRNEW(1) <= ZoneDaylight(ZoneNum).MaxGlareallowed && GLRNEW(2) <= ZoneDaylight(ZoneNum).MaxGlareallowed) + if (GLRNEW(1) <= state.dataDaylightingData->ZoneDaylight(ZoneNum).MaxGlareallowed && GLRNEW(2) <= state.dataDaylightingData->ZoneDaylight(ZoneNum).MaxGlareallowed) GlareOK = true; } @@ -7150,30 +7147,30 @@ namespace DaylightingManager { for (IL = 1; IL <= NREFPT; ++IL) { RDAYIL(IL, igroup) = DaylIllum(IL) + (WDAYIL(1, IL, igroup) - WDAYIL(2, IL, igroup)) * (1.0 - tmpSWFactor); RBACLU(IL, igroup) = - ZoneDaylight(ZoneNum).BacLum(IL) + (WBACLU(1, IL, igroup) - WBACLU(2, IL, igroup)) * (1.0 - tmpSWFactor); - BACL = max(SetPnt(IL) * ZoneDaylight(ZoneNum).AveVisDiffReflect / DataGlobalConstants::Pi(), RBACLU(IL, igroup)); + state.dataDaylightingData->ZoneDaylight(ZoneNum).BacLum(IL) + (WBACLU(1, IL, igroup) - WBACLU(2, IL, igroup)) * (1.0 - tmpSWFactor); + BACL = max(SetPnt(IL) * state.dataDaylightingData->ZoneDaylight(ZoneNum).AveVisDiffReflect / DataGlobalConstants::Pi(), RBACLU(IL, igroup)); // needs to update SourceLumFromWinAtRefPt(IL,2,IWin) before re-calc DayltgGlare tmpMult = (TVIS1(igroup) - (TVIS1(igroup) - TVIS2(igroup)) * tmpSWFactor) / TVIS2(igroup); if (IL == 1) { - ZoneDaylight(ZoneNum).SourceLumFromWinAtRefPt(loop, 2, 1) = tmpSWSL1 * tmpMult; + state.dataDaylightingData->ZoneDaylight(ZoneNum).SourceLumFromWinAtRefPt(loop, 2, 1) = tmpSWSL1 * tmpMult; } else { - ZoneDaylight(ZoneNum).SourceLumFromWinAtRefPt(loop, 2, 2) = tmpSWSL2 * tmpMult; + state.dataDaylightingData->ZoneDaylight(ZoneNum).SourceLumFromWinAtRefPt(loop, 2, 2) = tmpSWSL2 * tmpMult; } - DayltgGlare(IL, BACL, GLRNEW(IL), ZoneNum); + DayltgGlare(state, IL, BACL, GLRNEW(IL), ZoneNum); } } // Update final results for (IL = 1; IL <= NREFPT; ++IL) { - ZoneDaylight(ZoneNum).BacLum(IL) = RBACLU(IL, igroup); + state.dataDaylightingData->ZoneDaylight(ZoneNum).BacLum(IL) = RBACLU(IL, igroup); GLRNDX(IL) = GLRNEW(IL); DaylIllum(IL) = RDAYIL(IL, igroup); tmpMult = (TVIS1(igroup) - (TVIS1(igroup) - TVIS2(igroup)) * tmpSWFactor) / TVIS2(igroup); // update report variables - ZoneDaylight(ZoneNum).IllumFromWinAtRefPt(loop, 2, IL) = tmpIllumFromWinAtRefPt(loop, 2, IL) * tmpMult; - ZoneDaylight(ZoneNum).BackLumFromWinAtRefPt(loop, 2, IL) = tmpBackLumFromWinAtRefPt(loop, 2, IL) * tmpMult; + state.dataDaylightingData->ZoneDaylight(ZoneNum).IllumFromWinAtRefPt(loop, 2, IL) = tmpIllumFromWinAtRefPt(loop, 2, IL) * tmpMult; + state.dataDaylightingData->ZoneDaylight(ZoneNum).BackLumFromWinAtRefPt(loop, 2, IL) = tmpBackLumFromWinAtRefPt(loop, 2, IL) * tmpMult; } SurfWinSwitchingFactor(IWin) = tmpSWFactor; SurfWinVisTransSelected(IWin) = TVIS1(igroup) - (TVIS1(igroup) - TVIS2(igroup)) * tmpSWFactor; @@ -7202,37 +7199,37 @@ namespace DaylightingManager { // Variables for reporting for (IL = 1; IL <= NREFPT; ++IL) { - ZoneDaylight(ZoneNum).DaylIllumAtRefPt(IL) = DaylIllum(IL); - ZoneDaylight(ZoneNum).GlareIndexAtRefPt(IL) = GLRNDX(IL); + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylIllumAtRefPt(IL) = DaylIllum(IL); + state.dataDaylightingData->ZoneDaylight(ZoneNum).GlareIndexAtRefPt(IL) = GLRNDX(IL); // added TH 12/2/2008 - if (GLRNDX(IL) > ZoneDaylight(ZoneNum).MaxGlareallowed) { - ZoneDaylight(ZoneNum).TimeExceedingGlareIndexSPAtRefPt(IL) = state.dataGlobal->TimeStepZone; // fraction of hours + if (GLRNDX(IL) > state.dataDaylightingData->ZoneDaylight(ZoneNum).MaxGlareallowed) { + state.dataDaylightingData->ZoneDaylight(ZoneNum).TimeExceedingGlareIndexSPAtRefPt(IL) = state.dataGlobal->TimeStepZone; // fraction of hours } else { - ZoneDaylight(ZoneNum).TimeExceedingGlareIndexSPAtRefPt(IL) = 0.0; + state.dataDaylightingData->ZoneDaylight(ZoneNum).TimeExceedingGlareIndexSPAtRefPt(IL) = 0.0; } // added TH 7/6/2009 - if (DaylIllum(IL) > ZoneDaylight(ZoneNum).IllumSetPoint(IL)) { - ZoneDaylight(ZoneNum).TimeExceedingDaylightIlluminanceSPAtRefPt(IL) = state.dataGlobal->TimeStepZone; // fraction of hours + if (DaylIllum(IL) > state.dataDaylightingData->ZoneDaylight(ZoneNum).IllumSetPoint(IL)) { + state.dataDaylightingData->ZoneDaylight(ZoneNum).TimeExceedingDaylightIlluminanceSPAtRefPt(IL) = state.dataGlobal->TimeStepZone; // fraction of hours } else { - ZoneDaylight(ZoneNum).TimeExceedingDaylightIlluminanceSPAtRefPt(IL) = 0.0; + state.dataDaylightingData->ZoneDaylight(ZoneNum).TimeExceedingDaylightIlluminanceSPAtRefPt(IL) = 0.0; } } // The following report variables are valid only for daylit zones without interior windows if (!Zone(ZoneNum).HasInterZoneWindow) { - for (loop = 1; loop <= ZoneDaylight(ZoneNum).NumOfDayltgExtWins; ++loop) { - IWin = ZoneDaylight(ZoneNum).DayltgExtWinSurfNums(loop); + for (loop = 1; loop <= state.dataDaylightingData->ZoneDaylight(ZoneNum).NumOfDayltgExtWins; ++loop) { + IWin = state.dataDaylightingData->ZoneDaylight(ZoneNum).DayltgExtWinSurfNums(loop); IS = 1; if (SurfWinShadingFlag(IWin) > 0 || SurfWinSolarDiffusing(IWin)) IS = 2; - if (ZoneDaylight(ZoneNum).DaylightMethod == SplitFluxDaylighting) { + if (state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylightMethod == DataDaylighting::iDaylightingMethod::SplitFluxDaylighting) { int refPtCount = 0; for (int const enclZoneNum : DataViewFactorInformation::ZoneSolarInfo(Zone(ZoneNum).SolarEnclosureNum).ZoneNums) { - for (int refPtNum = 1; refPtNum <= ZoneDaylight(enclZoneNum).TotalDaylRefPoints; ++refPtNum) { + for (int refPtNum = 1; refPtNum <= state.dataDaylightingData->ZoneDaylight(enclZoneNum).TotalDaylRefPoints; ++refPtNum) { ++refPtCount; // Count reference points across each zone in the same enclosure - SurfaceWindow(IWin).IllumFromWinAtRefPtRep(refPtCount) = ZoneDaylight(enclZoneNum).IllumFromWinAtRefPt(loop, IS, refPtNum); - SurfaceWindow(IWin).LumWinFromRefPtRep(refPtCount) = ZoneDaylight(enclZoneNum).SourceLumFromWinAtRefPt(loop, IS, refPtNum); + SurfaceWindow(IWin).IllumFromWinAtRefPtRep(refPtCount) = state.dataDaylightingData->ZoneDaylight(enclZoneNum).IllumFromWinAtRefPt(loop, IS, refPtNum); + SurfaceWindow(IWin).LumWinFromRefPtRep(refPtCount) = state.dataDaylightingData->ZoneDaylight(enclZoneNum).SourceLumFromWinAtRefPt(loop, IS, refPtNum); } } } @@ -7368,7 +7365,7 @@ namespace DaylightingManager { int NREFPT; // Number of daylighting reference points in a zone Real64 ZFTOT = 0.; // Fraction of zone's floor area that has daylighting controls int IL; // Reference point index - int LSYSTP; // Lighting control type: 1=continuous dimming, 2=stepped, + DataDaylighting::iLtgCtrlType LSYSTP; // Lighting control type: 1=continuous dimming, 2=stepped, // 3=continuous dimming then off Real64 ZFRAC; // Fraction of zone controlled by a reference point Real64 FL; // Fraction electric lighting output required to meet setpoint @@ -7380,14 +7377,14 @@ namespace DaylightingManager { // FLOW: - if (ZoneDaylight(ZoneNum).DaylightMethod != SplitFluxDaylighting) return; + if (state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylightMethod != DataDaylighting::iDaylightingMethod::SplitFluxDaylighting) return; TotReduction = 0.0; // ScheduledAvailable = .TRUE. // check if scheduled to be available // IF (ZoneDaylight(ZoneNum)%AvailSchedNum > 0) THEN - if (GetCurrentScheduleValue(state, ZoneDaylight(ZoneNum).AvailSchedNum) > 0.0) { + if (GetCurrentScheduleValue(state, state.dataDaylightingData->ZoneDaylight(ZoneNum).AvailSchedNum) > 0.0) { ScheduledAvailable = true; } else { ScheduledAvailable = false; @@ -7395,60 +7392,60 @@ namespace DaylightingManager { // ENDIF if (ScheduledAvailable) { - NREFPT = ZoneDaylight(ZoneNum).TotalDaylRefPoints; + NREFPT = state.dataDaylightingData->ZoneDaylight(ZoneNum).TotalDaylRefPoints; // Loop over reference points for (IL = 1; IL <= NREFPT; ++IL) { // Total fraction of zone that is daylit - ZFTOT += ZoneDaylight(ZoneNum).FracZoneDaylit(IL); + ZFTOT += state.dataDaylightingData->ZoneDaylight(ZoneNum).FracZoneDaylit(IL); - DaylIllum(IL) = ZoneDaylight(ZoneNum).DaylIllumAtRefPt(IL); - if (DaylIllum(IL) >= ZoneDaylight(ZoneNum).IllumSetPoint(IL)) { + DaylIllum(IL) = state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylIllumAtRefPt(IL); + if (DaylIllum(IL) >= state.dataDaylightingData->ZoneDaylight(ZoneNum).IllumSetPoint(IL)) { FL = 0.0; } else { - FL = (ZoneDaylight(ZoneNum).IllumSetPoint(IL) - DaylIllum(IL)) / ZoneDaylight(ZoneNum).IllumSetPoint(IL); + FL = (state.dataDaylightingData->ZoneDaylight(ZoneNum).IllumSetPoint(IL) - DaylIllum(IL)) / state.dataDaylightingData->ZoneDaylight(ZoneNum).IllumSetPoint(IL); } // BRANCH ON LIGHTING SYSTEM TYPE - LSYSTP = ZoneDaylight(ZoneNum).LightControlType; - if (LSYSTP != 2) { + LSYSTP = state.dataDaylightingData->ZoneDaylight(ZoneNum).LightControlType; + if (LSYSTP != DataDaylighting::iLtgCtrlType::Stepped) { // Continuously dimmable system with linear power curve // Fractional output power required to meet setpoint FP = 1.0; // LIGHT-CTRL-TYPE = CONTINUOUS (LSYSTP = 1) - if (FL <= ZoneDaylight(ZoneNum).MinLightFraction) FP = ZoneDaylight(ZoneNum).MinPowerFraction; + if (FL <= state.dataDaylightingData->ZoneDaylight(ZoneNum).MinLightFraction) FP = state.dataDaylightingData->ZoneDaylight(ZoneNum).MinPowerFraction; // LIGHT-CTRL-TYPE = CONTINUOUS/OFF (LSYSTP = 3) - if (FL <= ZoneDaylight(ZoneNum).MinLightFraction && LSYSTP == 3) FP = 0.0; - if (FL > ZoneDaylight(ZoneNum).MinLightFraction && FL < 1.0) - FP = (FL + (1.0 - FL) * ZoneDaylight(ZoneNum).MinPowerFraction - ZoneDaylight(ZoneNum).MinLightFraction) / - (1.0 - ZoneDaylight(ZoneNum).MinLightFraction); + if (FL <= state.dataDaylightingData->ZoneDaylight(ZoneNum).MinLightFraction && LSYSTP == DataDaylighting::iLtgCtrlType::ContinuousOff) FP = 0.0; + if (FL > state.dataDaylightingData->ZoneDaylight(ZoneNum).MinLightFraction && FL < 1.0) + FP = (FL + (1.0 - FL) * state.dataDaylightingData->ZoneDaylight(ZoneNum).MinPowerFraction - state.dataDaylightingData->ZoneDaylight(ZoneNum).MinLightFraction) / + (1.0 - state.dataDaylightingData->ZoneDaylight(ZoneNum).MinLightFraction); } else { // LSYSTP = 2 // Stepped system FP = 0.0; - if (DaylIllum(IL) > 0.0 && DaylIllum(IL) < ZoneDaylight(ZoneNum).IllumSetPoint(IL)) - FP = double(int(ZoneDaylight(ZoneNum).LightControlSteps * FL) + 1) / double(ZoneDaylight(ZoneNum).LightControlSteps); + if (DaylIllum(IL) > 0.0 && DaylIllum(IL) < state.dataDaylightingData->ZoneDaylight(ZoneNum).IllumSetPoint(IL)) + FP = double(int(state.dataDaylightingData->ZoneDaylight(ZoneNum).LightControlSteps * FL) + 1) / double(state.dataDaylightingData->ZoneDaylight(ZoneNum).LightControlSteps); if (DaylIllum(IL) == 0.0) FP = 1.0; - if (ZoneDaylight(ZoneNum).LightControlProbability < 1.0) { + if (state.dataDaylightingData->ZoneDaylight(ZoneNum).LightControlProbability < 1.0) { // Manual operation. Occupant sets lights one level too high a fraction of the time equal to // 1. - ZoneDaylight(ZoneNum)%LightControlProbability. RANDOM_NUMBER returns a random number // between 0 and 1. RANDOM_NUMBER(XRAN); - if (XRAN >= ZoneDaylight(ZoneNum).LightControlProbability) { + if (XRAN >= state.dataDaylightingData->ZoneDaylight(ZoneNum).LightControlProbability) { // Set level one higher - if (FP < 1.0) FP += (1.0 / double(ZoneDaylight(ZoneNum).LightControlSteps)); + if (FP < 1.0) FP += (1.0 / double(state.dataDaylightingData->ZoneDaylight(ZoneNum).LightControlSteps)); } // XRAN } // Light Control Probability < 1 } // Lighting System Type - ZoneDaylight(ZoneNum).RefPtPowerReductionFactor(IL) = FP; + state.dataDaylightingData->ZoneDaylight(ZoneNum).RefPtPowerReductionFactor(IL) = FP; // Accumulate net ltg power reduction factor for entire zone - ZFRAC = ZoneDaylight(ZoneNum).FracZoneDaylit(IL); - TotReduction += ZoneDaylight(ZoneNum).RefPtPowerReductionFactor(IL) * ZFRAC; + ZFRAC = state.dataDaylightingData->ZoneDaylight(ZoneNum).FracZoneDaylit(IL); + TotReduction += state.dataDaylightingData->ZoneDaylight(ZoneNum).RefPtPowerReductionFactor(IL) * ZFRAC; } // End of loop over reference points, IL @@ -7460,25 +7457,25 @@ namespace DaylightingManager { } else { // controls not currently available TotReduction = 1.0; } - ZoneDaylight(ZoneNum).ZonePowerReductionFactor = TotReduction; + state.dataDaylightingData->ZoneDaylight(ZoneNum).ZonePowerReductionFactor = TotReduction; - // IF(TotIllumMaps > 0 .and. .not. state.dataGlobal->DoingSizing .and. .not. WarmupFlag .and. .not. KickoffSimulation) THEN - if (TotIllumMaps > 0 && !state.dataGlobal->DoingSizing && !state.dataGlobal->WarmupFlag) { + // IF(DataDaylighting::TotIllumMaps > 0 .and. .not. state.dataGlobal->DoingSizing .and. .not. WarmupFlag .and. .not. KickoffSimulation) THEN + if (state.dataDaylightingData->TotIllumMaps > 0 && !state.dataGlobal->DoingSizing && !state.dataGlobal->WarmupFlag) { // If an illuminance map is associated with this zone, generate the map - if (state.dataGlobal->TimeStep == 1) mapResultsToReport = false; - for (ILM = 1; ILM <= ZoneDaylight(ZoneNum).MapCount; ++ILM) { - MapNum = ZoneDaylight(ZoneNum).ZoneToMap(ILM); - for (IL = 1; IL <= IllumMapCalc(MapNum).TotalMapRefPoints; ++IL) { - IllumMapCalc(MapNum).DaylIllumAtMapPtHr(IL) += IllumMapCalc(MapNum).DaylIllumAtMapPt(IL) / double(state.dataGlobal->NumOfTimeStepInHour); - if (IllumMapCalc(MapNum).DaylIllumAtMapPtHr(IL) > 0.0) { - mapResultsToReport = true; - mapResultsReported = true; + if (state.dataGlobal->TimeStep == 1) state.dataDaylightingData->mapResultsToReport = false; + for (ILM = 1; ILM <= state.dataDaylightingData->ZoneDaylight(ZoneNum).MapCount; ++ILM) { + MapNum = state.dataDaylightingData->ZoneDaylight(ZoneNum).ZoneToMap(ILM); + for (IL = 1; IL <= state.dataDaylightingData->IllumMapCalc(MapNum).TotalMapRefPoints; ++IL) { + state.dataDaylightingData->IllumMapCalc(MapNum).DaylIllumAtMapPtHr(IL) += state.dataDaylightingData->IllumMapCalc(MapNum).DaylIllumAtMapPt(IL) / double(state.dataGlobal->NumOfTimeStepInHour); + if (state.dataDaylightingData->IllumMapCalc(MapNum).DaylIllumAtMapPtHr(IL) > 0.0) { + state.dataDaylightingData->mapResultsToReport = true; + state.dataDaylightingData->mapResultsReported = true; } } ReportIllumMap(state, MapNum); if (state.dataGlobal->TimeStep == state.dataGlobal->NumOfTimeStepInHour) { - IllumMapCalc(MapNum).DaylIllumAtMapPtHr = 0.0; - IllumMapCalc(MapNum).DaylIllumAtMapPt = 0.0; + state.dataDaylightingData->IllumMapCalc(MapNum).DaylIllumAtMapPtHr = 0.0; + state.dataDaylightingData->IllumMapCalc(MapNum).DaylIllumAtMapPt = 0.0; } } } @@ -7759,7 +7756,7 @@ namespace DaylightingManager { // due to specular reflection from exterior surfaces int ZoneNumThisWin; // temporary to check if this window is actually in adjacent zone - int ExtWinType; // Exterior window type (InZoneExtWin, AdjZoneExtWin, NotInOrAdjZoneExtWin) + DataDaylighting::iExtWinType ExtWinType; // Exterior window type (InZoneExtWin, AdjZoneExtWin, NotInOrAdjZoneExtWin) Real64 ZoneInsideSurfArea; // temporary for calculations, total surface area of zone surfaces m2 int IntWinAdjZoneExtWinNum; // the index of the exterior window in IntWinAdjZoneExtWin nested struct int AdjExtWinLoop; // loop index for searching IntWinAdjZoneExtWin @@ -7771,16 +7768,16 @@ namespace DaylightingManager { // The inside surface area, ZoneDaylight(ZoneNum)%TotInsSurfArea was calculated in subr DayltgAveInteriorReflectance if (Surface(Surface(IWin).BaseSurf).SolarEnclIndex == Zone(ZoneNum).SolarEnclosureNum) { - ExtWinType = InZoneExtWin; - ZoneInsideSurfArea = ZoneDaylight(ZoneNum).TotInsSurfArea; + ExtWinType = DataDaylighting::iExtWinType::InZoneExtWin; + ZoneInsideSurfArea = state.dataDaylightingData->ZoneDaylight(ZoneNum).TotInsSurfArea; IntWinAdjZoneExtWinNum = 0; } else { - ExtWinType = AdjZoneExtWin; + ExtWinType = DataDaylighting::iExtWinType::AdjZoneExtWin; // If window is exterior window in adjacent zone, then use areas of both zones - ZoneInsideSurfArea = ZoneDaylight(ZoneNum).TotInsSurfArea + ZoneDaylight(ZoneNumThisWin).TotInsSurfArea; + ZoneInsideSurfArea = state.dataDaylightingData->ZoneDaylight(ZoneNum).TotInsSurfArea + state.dataDaylightingData->ZoneDaylight(ZoneNumThisWin).TotInsSurfArea; // find index in IntWinAdjZoneExtWin - for (AdjExtWinLoop = 1; AdjExtWinLoop <= ZoneDaylight(ZoneNum).NumOfIntWinAdjZoneExtWins; ++AdjExtWinLoop) { - if (IWin == ZoneDaylight(ZoneNum).IntWinAdjZoneExtWin(AdjExtWinLoop).SurfNum) { // found it + for (AdjExtWinLoop = 1; AdjExtWinLoop <= state.dataDaylightingData->ZoneDaylight(ZoneNum).NumOfIntWinAdjZoneExtWins; ++AdjExtWinLoop) { + if (IWin == state.dataDaylightingData->ZoneDaylight(ZoneNum).IntWinAdjZoneExtWin(AdjExtWinLoop).SurfNum) { // found it IntWinAdjZoneExtWinNum = AdjExtWinLoop; break; // added TH 4/13/2010 } @@ -8046,13 +8043,13 @@ namespace DaylightingManager { } else { // Normal window // CR 7869 correct TVISBR if disk beam passes thru interior window - if (ExtWinType == AdjZoneExtWin) { + if (ExtWinType == DataDaylighting::iExtWinType::AdjZoneExtWin) { // modify TVISBR by second window transmission // first determine if ray from point passes thru any interior window hitObs = false; - for (IntWinLoop = 1; IntWinLoop <= ZoneDaylight(ZoneNum).IntWinAdjZoneExtWin(IntWinAdjZoneExtWinNum).NumOfIntWindows; + for (IntWinLoop = 1; IntWinLoop <= state.dataDaylightingData->ZoneDaylight(ZoneNum).IntWinAdjZoneExtWin(IntWinAdjZoneExtWinNum).NumOfIntWindows; ++IntWinLoop) { - IntWinNum = ZoneDaylight(ZoneNum).IntWinAdjZoneExtWin(IntWinAdjZoneExtWinNum).IntWinNum(IntWinLoop); + IntWinNum = state.dataDaylightingData->ZoneDaylight(ZoneNum).IntWinAdjZoneExtWin(IntWinAdjZoneExtWinNum).IntWinNum(IntWinLoop); PierceSurface(IntWinNum, SurfaceWindow(IntWinNum).WinCenter, SUNCOS_IHR, ObsHitPt, hitObs); if (hitObs) { // disk passes thru // cosine of incidence angle of light from sky or ground element for @@ -8272,7 +8269,7 @@ namespace DaylightingManager { // effective window transmittance has already been accounted for in calc of FLFWSK and FLCWSK. EINTSK(IHR, JSH, ISky) = (FLFWSK(JSH, ISky) * SurfWinRhoFloorWall(IWin) + FLCWSK(JSH, ISky) * SurfWinRhoCeilingWall(IWin)) * - (Surface(IWin).Area / SurfWinGlazedFrac(IWin)) / (ZoneInsideSurfArea * (1.0 - ZoneDaylight(ZoneNum).AveVisDiffReflect)); + (Surface(IWin).Area / SurfWinGlazedFrac(IWin)) / (ZoneInsideSurfArea * (1.0 - state.dataDaylightingData->ZoneDaylight(ZoneNum).AveVisDiffReflect)); } // JSH } // ISKY @@ -8507,10 +8504,10 @@ namespace DaylightingManager { // added inside surface area of adjacent zone EINTSU(IHR, JSH) = (FLFWSU(JSH) * SurfWinRhoFloorWall(IWin) + FLCWSU(JSH) * SurfWinRhoCeilingWall(IWin)) * (Surface(IWin).Area / SurfWinGlazedFrac(IWin)) / - (ZoneInsideSurfArea * (1.0 - ZoneDaylight(ZoneNum).AveVisDiffReflect)); + (ZoneInsideSurfArea * (1.0 - state.dataDaylightingData->ZoneDaylight(ZoneNum).AveVisDiffReflect)); EINTSUdisk(IHR, JSH) = FLFWSUdisk(JSH) * SurfWinRhoFloorWall(IWin) * (Surface(IWin).Area / SurfWinGlazedFrac(IWin)) / - (ZoneInsideSurfArea * (1.0 - ZoneDaylight(ZoneNum).AveVisDiffReflect)); + (ZoneInsideSurfArea * (1.0 - state.dataDaylightingData->ZoneDaylight(ZoneNum).AveVisDiffReflect)); } } @@ -8523,7 +8520,7 @@ namespace DaylightingManager { Array2 &ElementLuminanceSky, // sky related luminance at window element (exterior side) Array1D &ElementLuminanceSun, // sun related luminance at window element (exterior side), Array1D &ElementLuminanceSunDisk, // sun related luminance at window element (exterior side), - int const CalledFrom, + DataDaylighting::iCalledFor const CalledFrom, Optional_int_const MapNum) { @@ -8609,13 +8606,13 @@ namespace DaylightingManager { } // add exterior obstructions transmittances to calculated luminances - if (CalledFrom == CalledForRefPoint) { + if (CalledFrom == DataDaylighting::iCalledFor::RefPoint) { NRefl = state.dataBSDFWindow->ComplexWind(IWin).DaylghtGeom(CurCplxFenState).RefPoint(iRefPoint).NReflSurf(WinEl); } else { NRefl = state.dataBSDFWindow->ComplexWind(IWin).DaylghtGeom(CurCplxFenState).IlluminanceMap(iRefPoint, MapNum).NReflSurf(WinEl); } for (iReflElem = 1; iReflElem <= NRefl; ++iReflElem) { - if (CalledFrom == CalledForRefPoint) { + if (CalledFrom == DataDaylighting::iCalledFor::RefPoint) { ObstrTrans = state.dataBSDFWindow->ComplexWind(IWin).DaylghtGeom(CurCplxFenState).RefPoint(iRefPoint).TransOutSurf(iReflElem, WinEl); iReflElemIndex = state.dataBSDFWindow->ComplexWind(IWin).DaylghtGeom(CurCplxFenState).RefPoint(iRefPoint).RefSurfIndex(iReflElem, WinEl); } else { @@ -8632,7 +8629,7 @@ namespace DaylightingManager { // add exterior ground element obstruction multipliers to calculated luminances. For sun reflection, calculate if // sun reaches the ground for that point - if (CalledFrom == CalledForRefPoint) { + if (CalledFrom == DataDaylighting::iCalledFor::RefPoint) { NGnd = state.dataBSDFWindow->ComplexWind(IWin).DaylghtGeom(CurCplxFenState).RefPoint(iRefPoint).NGnd(WinEl); } else { NGnd = state.dataBSDFWindow->ComplexWind(IWin).DaylghtGeom(CurCplxFenState).IlluminanceMap(iRefPoint, MapNum).NGnd(WinEl); @@ -8641,7 +8638,7 @@ namespace DaylightingManager { for (iGndElem = 1; iGndElem <= NGnd; ++iGndElem) { // case for sky elements. Integration is done over upper ground hemisphere to determine how many obstructions // were hit in the process - if (CalledFrom == CalledForRefPoint) { + if (CalledFrom == DataDaylighting::iCalledFor::RefPoint) { BeamObstrMultiplier = state.dataBSDFWindow->ComplexWind(IWin).DaylghtGeom(CurCplxFenState).RefPoint(iRefPoint).GndObstrMultiplier(iGndElem, WinEl); iGndElemIndex = state.dataBSDFWindow->ComplexWind(IWin).DaylghtGeom(CurCplxFenState).RefPoint(iRefPoint).GndIndex(iGndElem, WinEl); } else { @@ -8660,7 +8657,7 @@ namespace DaylightingManager { hitObs = false; for (ObsSurfNum = 1; ObsSurfNum <= TotSurfaces; ++ObsSurfNum) { if (!Surface(ObsSurfNum).ShadowSurfPossibleObstruction) continue; - if (CalledFrom == CalledForRefPoint) { + if (CalledFrom == DataDaylighting::iCalledFor::RefPoint) { GroundHitPt(1) = state.dataBSDFWindow->ComplexWind(IWin).DaylghtGeom(CurCplxFenState).RefPoint(iRefPoint).GndPt(iGndElem, WinEl).x; GroundHitPt(2) = state.dataBSDFWindow->ComplexWind(IWin).DaylghtGeom(CurCplxFenState).RefPoint(iRefPoint).GndPt(iGndElem, WinEl).y; GroundHitPt(3) = state.dataBSDFWindow->ComplexWind(IWin).DaylghtGeom(CurCplxFenState).RefPoint(iRefPoint).GndPt(iGndElem, WinEl).z; @@ -8685,7 +8682,7 @@ namespace DaylightingManager { int const IHR, // Hour of day int const ZoneNum, // Zone number int const iRefPoint, // reference point counter - int const CalledFrom, + DataDaylighting::iCalledFor const CalledFrom, Optional_int_const MapNum) { @@ -8820,15 +8817,15 @@ namespace DaylightingManager { FLSUdiskTot += FLSUdisk(iBackElem); } - ZoneInsideSurfArea = ZoneDaylight(ZoneNum).TotInsSurfArea; + ZoneInsideSurfArea = state.dataDaylightingData->ZoneDaylight(ZoneNum).TotInsSurfArea; for (iSky = 1; iSky <= 4; ++iSky) { EINTSK(IHR, 1, iSky) = FFSKTot(iSky) * (Surface(IWin).Area / SurfWinGlazedFrac(IWin)) / - (ZoneInsideSurfArea * (1.0 - ZoneDaylight(ZoneNum).AveVisDiffReflect)); + (ZoneInsideSurfArea * (1.0 - state.dataDaylightingData->ZoneDaylight(ZoneNum).AveVisDiffReflect)); } EINTSU(IHR, 1) = - FFSUTot * (Surface(IWin).Area / SurfWinGlazedFrac(IWin)) / (ZoneInsideSurfArea * (1.0 - ZoneDaylight(ZoneNum).AveVisDiffReflect)); + FFSUTot * (Surface(IWin).Area / SurfWinGlazedFrac(IWin)) / (ZoneInsideSurfArea * (1.0 - state.dataDaylightingData->ZoneDaylight(ZoneNum).AveVisDiffReflect)); EINTSUdisk(IHR, 1) = FFSUdiskTot * (Surface(IWin).Area / SurfWinGlazedFrac(IWin)) / - (ZoneInsideSurfArea * (1.0 - ZoneDaylight(ZoneNum).AveVisDiffReflect)); + (ZoneInsideSurfArea * (1.0 - state.dataDaylightingData->ZoneDaylight(ZoneNum).AveVisDiffReflect)); if (allocated(FLSK)) FLSK.deallocate(); if (allocated(FLSU)) FLSU.deallocate(); @@ -8849,7 +8846,7 @@ namespace DaylightingManager { int const IHR, // Hour of day [[maybe_unused]] int const ZoneNum, // Zone number int const iRefPoint, // reference point index - int const CalledFrom, + DataDaylighting::iCalledFor const CalledFrom, Optional_int_const MapNum) { @@ -8915,7 +8912,7 @@ namespace DaylightingManager { IWin, WinEl, NIncBasis, IHR, iRefPoint, ElementLuminanceSky, ElementLuminanceSun, ElementLuminanceSunDisk, CalledFrom, MapNum); // find number of outgoing basis towards current reference point - if (CalledFrom == CalledForRefPoint) { + if (CalledFrom == DataDaylighting::iCalledFor::RefPoint) { RefPointIndex = state.dataBSDFWindow->ComplexWind(IWin).DaylghtGeom(CurCplxFenState).RefPoint(iRefPoint).RefPointIndex(WinEl); dOmega = state.dataBSDFWindow->ComplexWind(IWin).RefPoint(iRefPoint).SolidAngle(WinEl); zProjection = state.dataBSDFWindow->ComplexWind(IWin).RefPoint(iRefPoint).SolidAngleVec(WinEl).z; @@ -8970,7 +8967,7 @@ namespace DaylightingManager { int const iRefPoint, int const NumEl, // Total number of window elements Real64 const AZVIEW, // Azimuth of view vector in absolute coord system for - int const CalledFrom, // indicate which type of routine called this routine + DataDaylighting::iCalledFor const CalledFrom, // indicate which type of routine called this routine Optional_int_const MapNum, Optional MapWindowSolidAngAtRefPtWtd) { @@ -9022,9 +9019,9 @@ namespace DaylightingManager { { auto const SELECT_CASE_var(CalledFrom); - if (SELECT_CASE_var == CalledForRefPoint) { + if (SELECT_CASE_var == DataDaylighting::iCalledFor::RefPoint) { WindowSolidAngleDaylightPoint = SurfaceWindow(iWin).SolidAngAtRefPtWtd(iRefPoint); - } else if (SELECT_CASE_var == CalledForMapPoint) { + } else if (SELECT_CASE_var == DataDaylighting::iCalledFor::MapPoint) { WindowSolidAngleDaylightPoint = MapWindowSolidAngAtRefPtWtd; } else { assert(false); // Bad CalledFrom argument @@ -9038,13 +9035,13 @@ namespace DaylightingManager { NTrnBasis = state.dataBSDFWindow->ComplexWind(iWin).Geom(CurCplxFenState).Trn.NBasis; for (iTrnElem = 1; iTrnElem <= NTrnBasis; ++iTrnElem) { // if ray from any part of the window can reach reference point - if (CalledFrom == CalledForRefPoint) { + if (CalledFrom == DataDaylighting::iCalledFor::RefPoint) { refPointIntersect = state.dataBSDFWindow->ComplexWind(iWin).DaylghtGeom(CurCplxFenState).RefPoint(iRefPoint).RefPointIntersection(iTrnElem); } else { refPointIntersect = state.dataBSDFWindow->ComplexWind(iWin).DaylghtGeom(CurCplxFenState).IlluminanceMap(iRefPoint, MapNum).RefPointIntersection(iTrnElem); } if (refPointIntersect) { - if (CalledFrom == CalledForRefPoint) { + if (CalledFrom == DataDaylighting::iCalledFor::RefPoint) { PosFac = state.dataBSDFWindow->ComplexWind(iWin).DaylghtGeom(CurCplxFenState).RefPoint(iRefPoint).RefPtIntPosFac(iTrnElem); } else { PosFac = state.dataBSDFWindow->ComplexWind(iWin).DaylghtGeom(CurCplxFenState).IlluminanceMap(iRefPoint, MapNum).RefPtIntPosFac(iTrnElem); @@ -9574,19 +9571,19 @@ namespace DaylightingManager { int ILM; if (DayltgInteriorMapIllum_FirstTimeFlag) { - daylight_illum.allocate(MaxMapRefPoints); - BACLUM.allocate(MaxMapRefPoints); - GLRNDX.allocate(MaxMapRefPoints); + daylight_illum.allocate(DataDaylighting::MaxMapRefPoints); + BACLUM.allocate(DataDaylighting::MaxMapRefPoints); + GLRNDX.allocate(DataDaylighting::MaxMapRefPoints); DayltgInteriorMapIllum_FirstTimeFlag = false; } if (state.dataGlobal->WarmupFlag) return; // Initialize reference point illuminance and window background luminance - for (ILM = 1; ILM <= ZoneDaylight(ZoneNum).MapCount; ++ILM) { + for (ILM = 1; ILM <= state.dataDaylightingData->ZoneDaylight(ZoneNum).MapCount; ++ILM) { - MapNum = ZoneDaylight(ZoneNum).ZoneToMap(ILM); - NREFPT = IllumMapCalc(MapNum).TotalMapRefPoints; + MapNum = state.dataDaylightingData->ZoneDaylight(ZoneNum).ZoneToMap(ILM); + NREFPT = state.dataDaylightingData->IllumMapCalc(MapNum).TotalMapRefPoints; daylight_illum = 0.0; BACLUM = 0.0; @@ -9611,8 +9608,8 @@ namespace DaylightingManager { // and to the glare numerator at each reference point. // Use shading flags set in WindowShadingManager. - for (loop = 1; loop <= ZoneDaylight(ZoneNum).NumOfDayltgExtWins; ++loop) { - IWin = ZoneDaylight(ZoneNum).DayltgExtWinSurfNums(loop); + for (loop = 1; loop <= state.dataDaylightingData->ZoneDaylight(ZoneNum).NumOfDayltgExtWins; ++loop) { + IWin = state.dataDaylightingData->ZoneDaylight(ZoneNum).DayltgExtWinSurfNums(loop); // Added TH 6/29/2009 for thermochromic windows VTRatio = 1.0; @@ -9635,34 +9632,34 @@ namespace DaylightingManager { // Daylight factors for current sun position for (ISky = 1; ISky <= 4; ++ISky) { // ===Bare window=== - DFSKHR(1, ISky) = VTRatio * (state.dataGlobal->WeightNow * IllumMapCalc(MapNum).DaylIllFacSky(state.dataGlobal->HourOfDay, 1, ISky, ILB, loop) + - state.dataGlobal->WeightPreviousHour * IllumMapCalc(MapNum).DaylIllFacSky(state.dataGlobal->PreviousHour, 1, ISky, ILB, loop)); + DFSKHR(1, ISky) = VTRatio * (state.dataGlobal->WeightNow * state.dataDaylightingData->IllumMapCalc(MapNum).DaylIllFacSky(state.dataGlobal->HourOfDay, 1, ISky, ILB, loop) + + state.dataGlobal->WeightPreviousHour * state.dataDaylightingData->IllumMapCalc(MapNum).DaylIllFacSky(state.dataGlobal->PreviousHour, 1, ISky, ILB, loop)); if (ISky == 1) { - DFSUHR(1) = VTRatio * (state.dataGlobal->WeightNow * (IllumMapCalc(MapNum).DaylIllFacSun(state.dataGlobal->HourOfDay, 1, ILB, loop) + - IllumMapCalc(MapNum).DaylIllFacSunDisk(state.dataGlobal->HourOfDay, 1, ILB, loop)) + - state.dataGlobal->WeightPreviousHour * (IllumMapCalc(MapNum).DaylIllFacSun(state.dataGlobal->PreviousHour, 1, ILB, loop) + - IllumMapCalc(MapNum).DaylIllFacSunDisk(state.dataGlobal->PreviousHour, 1, ILB, loop))); + DFSUHR(1) = VTRatio * (state.dataGlobal->WeightNow * (state.dataDaylightingData->IllumMapCalc(MapNum).DaylIllFacSun(state.dataGlobal->HourOfDay, 1, ILB, loop) + + state.dataDaylightingData->IllumMapCalc(MapNum).DaylIllFacSunDisk(state.dataGlobal->HourOfDay, 1, ILB, loop)) + + state.dataGlobal->WeightPreviousHour * (state.dataDaylightingData->IllumMapCalc(MapNum).DaylIllFacSun(state.dataGlobal->PreviousHour, 1, ILB, loop) + + state.dataDaylightingData->IllumMapCalc(MapNum).DaylIllFacSunDisk(state.dataGlobal->PreviousHour, 1, ILB, loop))); } - BFSKHR(1, ISky) = VTRatio * (state.dataGlobal->WeightNow * IllumMapCalc(MapNum).DaylBackFacSky(state.dataGlobal->HourOfDay, 1, ISky, ILB, loop) + - state.dataGlobal->WeightPreviousHour * IllumMapCalc(MapNum).DaylBackFacSky(state.dataGlobal->PreviousHour, 1, ISky, ILB, loop)); + BFSKHR(1, ISky) = VTRatio * (state.dataGlobal->WeightNow * state.dataDaylightingData->IllumMapCalc(MapNum).DaylBackFacSky(state.dataGlobal->HourOfDay, 1, ISky, ILB, loop) + + state.dataGlobal->WeightPreviousHour * state.dataDaylightingData->IllumMapCalc(MapNum).DaylBackFacSky(state.dataGlobal->PreviousHour, 1, ISky, ILB, loop)); if (ISky == 1) { - BFSUHR(1) = VTRatio * (state.dataGlobal->WeightNow * (IllumMapCalc(MapNum).DaylBackFacSun(state.dataGlobal->HourOfDay, 1, ILB, loop) + - IllumMapCalc(MapNum).DaylBackFacSunDisk(state.dataGlobal->HourOfDay, 1, ILB, loop)) + - state.dataGlobal->WeightPreviousHour * (IllumMapCalc(MapNum).DaylBackFacSun(state.dataGlobal->PreviousHour, 1, ILB, loop) + - IllumMapCalc(MapNum).DaylBackFacSunDisk(state.dataGlobal->PreviousHour, 1, ILB, loop))); + BFSUHR(1) = VTRatio * (state.dataGlobal->WeightNow * (state.dataDaylightingData->IllumMapCalc(MapNum).DaylBackFacSun(state.dataGlobal->HourOfDay, 1, ILB, loop) + + state.dataDaylightingData->IllumMapCalc(MapNum).DaylBackFacSunDisk(state.dataGlobal->HourOfDay, 1, ILB, loop)) + + state.dataGlobal->WeightPreviousHour * (state.dataDaylightingData->IllumMapCalc(MapNum).DaylBackFacSun(state.dataGlobal->PreviousHour, 1, ILB, loop) + + state.dataDaylightingData->IllumMapCalc(MapNum).DaylBackFacSunDisk(state.dataGlobal->PreviousHour, 1, ILB, loop))); } - SFSKHR(1, ISky) = VTRatio * (state.dataGlobal->WeightNow * IllumMapCalc(MapNum).DaylSourceFacSky(state.dataGlobal->HourOfDay, 1, ISky, ILB, loop) + - state.dataGlobal->WeightPreviousHour * IllumMapCalc(MapNum).DaylSourceFacSky(state.dataGlobal->PreviousHour, 1, ISky, ILB, loop)); + SFSKHR(1, ISky) = VTRatio * (state.dataGlobal->WeightNow * state.dataDaylightingData->IllumMapCalc(MapNum).DaylSourceFacSky(state.dataGlobal->HourOfDay, 1, ISky, ILB, loop) + + state.dataGlobal->WeightPreviousHour * state.dataDaylightingData->IllumMapCalc(MapNum).DaylSourceFacSky(state.dataGlobal->PreviousHour, 1, ISky, ILB, loop)); if (ISky == 1) { - SFSUHR(1) = VTRatio * (state.dataGlobal->WeightNow * (IllumMapCalc(MapNum).DaylSourceFacSun(state.dataGlobal->HourOfDay, 1, ILB, loop) + - IllumMapCalc(MapNum).DaylSourceFacSunDisk(state.dataGlobal->HourOfDay, 1, ILB, loop)) + - state.dataGlobal->WeightPreviousHour * (IllumMapCalc(MapNum).DaylSourceFacSun(state.dataGlobal->PreviousHour, 1, ILB, loop) + - IllumMapCalc(MapNum).DaylSourceFacSunDisk(state.dataGlobal->PreviousHour, 1, ILB, loop))); + SFSUHR(1) = VTRatio * (state.dataGlobal->WeightNow * (state.dataDaylightingData->IllumMapCalc(MapNum).DaylSourceFacSun(state.dataGlobal->HourOfDay, 1, ILB, loop) + + state.dataDaylightingData->IllumMapCalc(MapNum).DaylSourceFacSunDisk(state.dataGlobal->HourOfDay, 1, ILB, loop)) + + state.dataGlobal->WeightPreviousHour * (state.dataDaylightingData->IllumMapCalc(MapNum).DaylSourceFacSun(state.dataGlobal->PreviousHour, 1, ILB, loop) + + state.dataDaylightingData->IllumMapCalc(MapNum).DaylSourceFacSunDisk(state.dataGlobal->PreviousHour, 1, ILB, loop))); } if ((SurfWinWindowModelType(IWin) != WindowBSDFModel) && @@ -9672,45 +9669,45 @@ namespace DaylightingManager { if (!SurfWinMovableSlats(IWin)) { // Shade, screen, blind with fixed slats, or diffusing glass DFSKHR(2, ISky) = - VTRatio * (state.dataGlobal->WeightNow * IllumMapCalc(MapNum).DaylIllFacSky(state.dataGlobal->HourOfDay, 2, ISky, ILB, loop) + - state.dataGlobal->WeightPreviousHour * IllumMapCalc(MapNum).DaylIllFacSky(state.dataGlobal->PreviousHour, 2, ISky, ILB, loop)); + VTRatio * (state.dataGlobal->WeightNow * state.dataDaylightingData->IllumMapCalc(MapNum).DaylIllFacSky(state.dataGlobal->HourOfDay, 2, ISky, ILB, loop) + + state.dataGlobal->WeightPreviousHour * state.dataDaylightingData->IllumMapCalc(MapNum).DaylIllFacSky(state.dataGlobal->PreviousHour, 2, ISky, ILB, loop)); if (ISky == 1) { - DFSUHR(2) = VTRatio * (state.dataGlobal->WeightNow * IllumMapCalc(MapNum).DaylIllFacSun(state.dataGlobal->HourOfDay, 2, ILB, loop) + - state.dataGlobal->WeightPreviousHour * IllumMapCalc(MapNum).DaylIllFacSun(state.dataGlobal->PreviousHour, 2, ILB, loop)); + DFSUHR(2) = VTRatio * (state.dataGlobal->WeightNow * state.dataDaylightingData->IllumMapCalc(MapNum).DaylIllFacSun(state.dataGlobal->HourOfDay, 2, ILB, loop) + + state.dataGlobal->WeightPreviousHour * state.dataDaylightingData->IllumMapCalc(MapNum).DaylIllFacSun(state.dataGlobal->PreviousHour, 2, ILB, loop)); if (!SurfWinSlatsBlockBeam(IWin)) { DFSUHR(2) += - VTRatio * (state.dataGlobal->WeightNow * IllumMapCalc(MapNum).DaylIllFacSunDisk(state.dataGlobal->HourOfDay, 2, ILB, loop) + - state.dataGlobal->WeightPreviousHour * IllumMapCalc(MapNum).DaylIllFacSunDisk(state.dataGlobal->PreviousHour, 2, ILB, loop)); + VTRatio * (state.dataGlobal->WeightNow * state.dataDaylightingData->IllumMapCalc(MapNum).DaylIllFacSunDisk(state.dataGlobal->HourOfDay, 2, ILB, loop) + + state.dataGlobal->WeightPreviousHour * state.dataDaylightingData->IllumMapCalc(MapNum).DaylIllFacSunDisk(state.dataGlobal->PreviousHour, 2, ILB, loop)); } } BFSKHR(2, ISky) = - VTRatio * (state.dataGlobal->WeightNow * IllumMapCalc(MapNum).DaylBackFacSky(state.dataGlobal->HourOfDay, 2, ISky, ILB, loop) + - state.dataGlobal->WeightPreviousHour * IllumMapCalc(MapNum).DaylBackFacSky(state.dataGlobal->PreviousHour, 2, ISky, ILB, loop)); + VTRatio * (state.dataGlobal->WeightNow * state.dataDaylightingData->IllumMapCalc(MapNum).DaylBackFacSky(state.dataGlobal->HourOfDay, 2, ISky, ILB, loop) + + state.dataGlobal->WeightPreviousHour * state.dataDaylightingData->IllumMapCalc(MapNum).DaylBackFacSky(state.dataGlobal->PreviousHour, 2, ISky, ILB, loop)); if (ISky == 1) { - BFSUHR(2) = VTRatio * (state.dataGlobal->WeightNow * IllumMapCalc(MapNum).DaylBackFacSun(state.dataGlobal->HourOfDay, 2, ILB, loop) + - state.dataGlobal->WeightPreviousHour * IllumMapCalc(MapNum).DaylBackFacSun(state.dataGlobal->PreviousHour, 2, ILB, loop)); + BFSUHR(2) = VTRatio * (state.dataGlobal->WeightNow * state.dataDaylightingData->IllumMapCalc(MapNum).DaylBackFacSun(state.dataGlobal->HourOfDay, 2, ILB, loop) + + state.dataGlobal->WeightPreviousHour * state.dataDaylightingData->IllumMapCalc(MapNum).DaylBackFacSun(state.dataGlobal->PreviousHour, 2, ILB, loop)); if (!SurfWinSlatsBlockBeam(IWin)) { BFSUHR(2) += - VTRatio * (state.dataGlobal->WeightNow * IllumMapCalc(MapNum).DaylBackFacSunDisk(state.dataGlobal->HourOfDay, 2, ILB, loop) + - state.dataGlobal->WeightPreviousHour * IllumMapCalc(MapNum).DaylBackFacSunDisk(state.dataGlobal->PreviousHour, 2, ILB, loop)); + VTRatio * (state.dataGlobal->WeightNow * state.dataDaylightingData->IllumMapCalc(MapNum).DaylBackFacSunDisk(state.dataGlobal->HourOfDay, 2, ILB, loop) + + state.dataGlobal->WeightPreviousHour * state.dataDaylightingData->IllumMapCalc(MapNum).DaylBackFacSunDisk(state.dataGlobal->PreviousHour, 2, ILB, loop)); } } SFSKHR(2, ISky) = - VTRatio * (state.dataGlobal->WeightNow * IllumMapCalc(MapNum).DaylSourceFacSky(state.dataGlobal->HourOfDay, 2, ISky, ILB, loop) + - state.dataGlobal->WeightPreviousHour * IllumMapCalc(MapNum).DaylSourceFacSky(state.dataGlobal->PreviousHour, 2, ISky, ILB, loop)); + VTRatio * (state.dataGlobal->WeightNow * state.dataDaylightingData->IllumMapCalc(MapNum).DaylSourceFacSky(state.dataGlobal->HourOfDay, 2, ISky, ILB, loop) + + state.dataGlobal->WeightPreviousHour * state.dataDaylightingData->IllumMapCalc(MapNum).DaylSourceFacSky(state.dataGlobal->PreviousHour, 2, ISky, ILB, loop)); if (ISky == 1) { - SFSUHR(2) = VTRatio * (state.dataGlobal->WeightNow * IllumMapCalc(MapNum).DaylSourceFacSun(state.dataGlobal->HourOfDay, 2, ILB, loop) + - state.dataGlobal->WeightPreviousHour * IllumMapCalc(MapNum).DaylSourceFacSun(state.dataGlobal->PreviousHour, 2, ILB, loop)); + SFSUHR(2) = VTRatio * (state.dataGlobal->WeightNow * state.dataDaylightingData->IllumMapCalc(MapNum).DaylSourceFacSun(state.dataGlobal->HourOfDay, 2, ILB, loop) + + state.dataGlobal->WeightPreviousHour * state.dataDaylightingData->IllumMapCalc(MapNum).DaylSourceFacSun(state.dataGlobal->PreviousHour, 2, ILB, loop)); if (!SurfWinSlatsBlockBeam(IWin)) { SFSUHR(2) += - VTRatio * (state.dataGlobal->WeightNow * IllumMapCalc(MapNum).DaylSourceFacSunDisk(state.dataGlobal->HourOfDay, 2, ILB, loop) + - state.dataGlobal->WeightPreviousHour * IllumMapCalc(MapNum).DaylSourceFacSunDisk(state.dataGlobal->PreviousHour, 2, ILB, loop)); + VTRatio * (state.dataGlobal->WeightNow * state.dataDaylightingData->IllumMapCalc(MapNum).DaylSourceFacSunDisk(state.dataGlobal->HourOfDay, 2, ILB, loop) + + state.dataGlobal->WeightPreviousHour * state.dataDaylightingData->IllumMapCalc(MapNum).DaylSourceFacSunDisk(state.dataGlobal->PreviousHour, 2, ILB, loop)); } } @@ -9722,22 +9719,22 @@ namespace DaylightingManager { VTRatio * (state.dataGlobal->WeightNow * InterpSlatAng(SlatAng, VarSlats, - IllumMapCalc(MapNum).DaylIllFacSky(state.dataGlobal->HourOfDay, {2, MaxSlatAngs + 1}, ISky, ILB, loop)) + + state.dataDaylightingData->IllumMapCalc(MapNum).DaylIllFacSky(state.dataGlobal->HourOfDay, {2, MaxSlatAngs + 1}, ISky, ILB, loop)) + state.dataGlobal->WeightPreviousHour * InterpSlatAng(SlatAng, VarSlats, - IllumMapCalc(MapNum).DaylIllFacSky(state.dataGlobal->PreviousHour, {2, MaxSlatAngs + 1}, ISky, ILB, loop))); + state.dataDaylightingData->IllumMapCalc(MapNum).DaylIllFacSky(state.dataGlobal->PreviousHour, {2, MaxSlatAngs + 1}, ISky, ILB, loop))); if (ISky == 1) { DFSUHR(2) = VTRatio * (state.dataGlobal->WeightNow * InterpSlatAng(SlatAng, VarSlats, - IllumMapCalc(MapNum).DaylIllFacSun(state.dataGlobal->HourOfDay, {2, MaxSlatAngs + 1}, ILB, loop)) + + state.dataDaylightingData->IllumMapCalc(MapNum).DaylIllFacSun(state.dataGlobal->HourOfDay, {2, MaxSlatAngs + 1}, ILB, loop)) + state.dataGlobal->WeightPreviousHour * InterpSlatAng(SlatAng, VarSlats, - IllumMapCalc(MapNum).DaylIllFacSun(state.dataGlobal->PreviousHour, {2, MaxSlatAngs + 1}, ILB, loop))); + state.dataDaylightingData->IllumMapCalc(MapNum).DaylIllFacSun(state.dataGlobal->PreviousHour, {2, MaxSlatAngs + 1}, ILB, loop))); // We add the contribution from the solar disk if slats do not block beam solar // TH CR 8010, DaylIllFacSunDisk needs to be interpolated @@ -9745,11 +9742,11 @@ namespace DaylightingManager { DFSUHR(2) += VTRatio * (state.dataGlobal->WeightNow * InterpSlatAng(SlatAng, VarSlats, - IllumMapCalc(MapNum).DaylIllFacSunDisk( + state.dataDaylightingData->IllumMapCalc(MapNum).DaylIllFacSunDisk( state.dataGlobal->HourOfDay, {2, MaxSlatAngs + 1}, ILB, loop)) + state.dataGlobal->WeightPreviousHour * InterpSlatAng(SlatAng, VarSlats, - IllumMapCalc(MapNum).DaylIllFacSunDisk( + state.dataDaylightingData->IllumMapCalc(MapNum).DaylIllFacSunDisk( state.dataGlobal->PreviousHour, {2, MaxSlatAngs + 1}, ILB, loop))); } } @@ -9759,33 +9756,33 @@ namespace DaylightingManager { (state.dataGlobal->WeightNow * InterpSlatAng(SlatAng, VarSlats, - IllumMapCalc(MapNum).DaylBackFacSky(state.dataGlobal->HourOfDay, {2, MaxSlatAngs + 1}, ISky, ILB, loop)) + + state.dataDaylightingData->IllumMapCalc(MapNum).DaylBackFacSky(state.dataGlobal->HourOfDay, {2, MaxSlatAngs + 1}, ISky, ILB, loop)) + state.dataGlobal->WeightPreviousHour * InterpSlatAng(SlatAng, VarSlats, - IllumMapCalc(MapNum).DaylBackFacSky(state.dataGlobal->PreviousHour, {2, MaxSlatAngs + 1}, ISky, ILB, loop))); + state.dataDaylightingData->IllumMapCalc(MapNum).DaylBackFacSky(state.dataGlobal->PreviousHour, {2, MaxSlatAngs + 1}, ISky, ILB, loop))); if (ISky == 1) { BFSUHR(2) = VTRatio * (state.dataGlobal->WeightNow * InterpSlatAng(SlatAng, VarSlats, - IllumMapCalc(MapNum).DaylBackFacSun(state.dataGlobal->HourOfDay, {2, MaxSlatAngs + 1}, ILB, loop)) + + state.dataDaylightingData->IllumMapCalc(MapNum).DaylBackFacSun(state.dataGlobal->HourOfDay, {2, MaxSlatAngs + 1}, ILB, loop)) + state.dataGlobal->WeightPreviousHour * InterpSlatAng(SlatAng, VarSlats, - IllumMapCalc(MapNum).DaylBackFacSun(state.dataGlobal->PreviousHour, {2, MaxSlatAngs + 1}, ILB, loop))); + state.dataDaylightingData->IllumMapCalc(MapNum).DaylBackFacSun(state.dataGlobal->PreviousHour, {2, MaxSlatAngs + 1}, ILB, loop))); // TH CR 8010, DaylBackFacSunDisk needs to be interpolated if (!SurfWinSlatsBlockBeam(IWin)) { BFSUHR(2) += VTRatio * (state.dataGlobal->WeightNow * InterpSlatAng(SlatAng, VarSlats, - IllumMapCalc(MapNum).DaylBackFacSunDisk( + state.dataDaylightingData->IllumMapCalc(MapNum).DaylBackFacSunDisk( state.dataGlobal->HourOfDay, {2, MaxSlatAngs + 1}, ILB, loop)) + state.dataGlobal->WeightPreviousHour * InterpSlatAng(SlatAng, VarSlats, - IllumMapCalc(MapNum).DaylBackFacSunDisk( + state.dataDaylightingData->IllumMapCalc(MapNum).DaylBackFacSunDisk( state.dataGlobal->PreviousHour, {2, MaxSlatAngs + 1}, ILB, loop))); } } @@ -9795,11 +9792,11 @@ namespace DaylightingManager { (state.dataGlobal->WeightNow * InterpSlatAng(SlatAng, VarSlats, - IllumMapCalc(MapNum).DaylSourceFacSky(state.dataGlobal->HourOfDay, {2, MaxSlatAngs + 1}, ISky, ILB, loop)) + + state.dataDaylightingData->IllumMapCalc(MapNum).DaylSourceFacSky(state.dataGlobal->HourOfDay, {2, MaxSlatAngs + 1}, ISky, ILB, loop)) + state.dataGlobal->WeightPreviousHour * InterpSlatAng(SlatAng, VarSlats, - IllumMapCalc(MapNum).DaylSourceFacSky(state.dataGlobal->PreviousHour, {2, MaxSlatAngs + 1}, ISky, ILB, loop))); + state.dataDaylightingData->IllumMapCalc(MapNum).DaylSourceFacSky(state.dataGlobal->PreviousHour, {2, MaxSlatAngs + 1}, ISky, ILB, loop))); if (ISky == 1) { SFSUHR(2) = @@ -9807,22 +9804,22 @@ namespace DaylightingManager { (state.dataGlobal->WeightNow * InterpSlatAng(SlatAng, VarSlats, - IllumMapCalc(MapNum).DaylSourceFacSun(state.dataGlobal->HourOfDay, {2, MaxSlatAngs + 1}, ILB, loop)) + + state.dataDaylightingData->IllumMapCalc(MapNum).DaylSourceFacSun(state.dataGlobal->HourOfDay, {2, MaxSlatAngs + 1}, ILB, loop)) + state.dataGlobal->WeightPreviousHour * InterpSlatAng(SlatAng, VarSlats, - IllumMapCalc(MapNum).DaylSourceFacSun(state.dataGlobal->PreviousHour, {2, MaxSlatAngs + 1}, ILB, loop))); + state.dataDaylightingData->IllumMapCalc(MapNum).DaylSourceFacSun(state.dataGlobal->PreviousHour, {2, MaxSlatAngs + 1}, ILB, loop))); // TH CR 8010, DaylSourceFacSunDisk needs to be interpolated if (!SurfWinSlatsBlockBeam(IWin)) { SFSUHR(2) += VTRatio * (state.dataGlobal->WeightNow * InterpSlatAng(SlatAng, VarSlats, - IllumMapCalc(MapNum).DaylSourceFacSunDisk( + state.dataDaylightingData->IllumMapCalc(MapNum).DaylSourceFacSunDisk( state.dataGlobal->HourOfDay, {2, MaxSlatAngs + 1}, ILB, loop)) + state.dataGlobal->WeightPreviousHour * InterpSlatAng(SlatAng, VarSlats, - IllumMapCalc(MapNum).DaylSourceFacSunDisk( + state.dataDaylightingData->IllumMapCalc(MapNum).DaylSourceFacSunDisk( state.dataGlobal->PreviousHour, {2, MaxSlatAngs + 1}, ILB, loop))); } } @@ -9849,19 +9846,19 @@ namespace DaylightingManager { for (IS = 1; IS <= 2; ++IS) { if (IS == 2 && SurfWinShadingFlag(IWin) <= 0 && !SurfWinSolarDiffusing(IWin)) break; - IllumMapCalc(MapNum).IllumFromWinAtMapPt(loop, IS, ILB) = + state.dataDaylightingData->IllumMapCalc(MapNum).IllumFromWinAtMapPt(loop, IS, ILB) = DFSUHR(IS) * HISUNF + HorIllSkyFac * (DFSKHR(IS, ISky1) * SkyWeight * HorIllSky(ISky1) + DFSKHR(IS, ISky2) * (1.0 - SkyWeight) * HorIllSky(ISky2)); - IllumMapCalc(MapNum).BackLumFromWinAtMapPt(loop, IS, ILB) = + state.dataDaylightingData->IllumMapCalc(MapNum).BackLumFromWinAtMapPt(loop, IS, ILB) = BFSUHR(IS) * HISUNF + HorIllSkyFac * (BFSKHR(IS, ISky1) * SkyWeight * HorIllSky(ISky1) + BFSKHR(IS, ISky2) * (1.0 - SkyWeight) * HorIllSky(ISky2)); - IllumMapCalc(MapNum).SourceLumFromWinAtMapPt(loop, IS, ILB) = + state.dataDaylightingData->IllumMapCalc(MapNum).SourceLumFromWinAtMapPt(loop, IS, ILB) = SFSUHR(IS) * HISUNF + HorIllSkyFac * (SFSKHR(IS, ISky1) * SkyWeight * HorIllSky(ISky1) + SFSKHR(IS, ISky2) * (1.0 - SkyWeight) * HorIllSky(ISky2)); - IllumMapCalc(MapNum).SourceLumFromWinAtMapPt(loop, IS, ILB) = - max(IllumMapCalc(MapNum).SourceLumFromWinAtMapPt(loop, IS, ILB), 0.0); + state.dataDaylightingData->IllumMapCalc(MapNum).SourceLumFromWinAtMapPt(loop, IS, ILB) = + max(state.dataDaylightingData->IllumMapCalc(MapNum).SourceLumFromWinAtMapPt(loop, IS, ILB), 0.0); } } // End of reference point loop @@ -9871,8 +9868,8 @@ namespace DaylightingManager { // and background luminance for each ref pt from all windows in // the space. Use shading flags. - for (loop = 1; loop <= ZoneDaylight(ZoneNum).NumOfDayltgExtWins; ++loop) { - IWin = ZoneDaylight(ZoneNum).DayltgExtWinSurfNums(loop); + for (loop = 1; loop <= state.dataDaylightingData->ZoneDaylight(ZoneNum).NumOfDayltgExtWins; ++loop) { + IWin = state.dataDaylightingData->ZoneDaylight(ZoneNum).DayltgExtWinSurfNums(loop); IS = 1; if ((SurfWinWindowModelType(IWin) != WindowBSDFModel) && @@ -9897,8 +9894,8 @@ namespace DaylightingManager { for (IL = 1; IL <= NREFPT; ++IL) { // Determine if illuminance contribution is from bare or shaded window - daylight_illum(IL) += VTMULT * IllumMapCalc(MapNum).IllumFromWinAtMapPt(loop, IS, IL); - BACLUM(IL) += VTMULT * IllumMapCalc(MapNum).BackLumFromWinAtMapPt(loop, IS, IL); + daylight_illum(IL) += VTMULT * state.dataDaylightingData->IllumMapCalc(MapNum).IllumFromWinAtMapPt(loop, IS, IL); + BACLUM(IL) += VTMULT * state.dataDaylightingData->IllumMapCalc(MapNum).BackLumFromWinAtMapPt(loop, IS, IL); } } // End of second window loop @@ -9910,8 +9907,8 @@ namespace DaylightingManager { GTOT = 0.0; // Loop over exterior windows associated with zone - for (loop = 1; loop <= ZoneDaylight(ZoneNum).NumOfDayltgExtWins; ++loop) { - IWin = ZoneDaylight(ZoneNum).DayltgExtWinSurfNums(loop); + for (loop = 1; loop <= state.dataDaylightingData->ZoneDaylight(ZoneNum).NumOfDayltgExtWins; ++loop) { + IWin = state.dataDaylightingData->ZoneDaylight(ZoneNum).DayltgExtWinSurfNums(loop); IS = 1; if ((SurfWinWindowModelType(IWin) != WindowBSDFModel) && ((SurfWinShadingFlag(IWin) >= 1 && SurfWinShadingFlag(IWin) <= 9) || SurfWinSolarDiffusing(IWin))) @@ -9934,10 +9931,10 @@ namespace DaylightingManager { // Conversion from ft-L to cd/m2, with cd/m2 = 0.2936 ft-L, gives the 0.4794 factor // below, which is (0.2936)**0.6 - GTOT1 = 0.4794 * (std::pow(VTMULT * IllumMapCalc(MapNum).SourceLumFromWinAtMapPt(loop, IS, IL), 1.6)) * - std::pow(IllumMapCalc(MapNum).SolidAngAtMapPtWtd(loop, IL), 0.8); - GTOT2 = BACLUM(IL) + 0.07 * (std::sqrt(IllumMapCalc(MapNum).SolidAngAtMapPt(loop, IL))) * VTMULT * - IllumMapCalc(MapNum).SourceLumFromWinAtMapPt(loop, IS, IL); + GTOT1 = 0.4794 * (std::pow(VTMULT * state.dataDaylightingData->IllumMapCalc(MapNum).SourceLumFromWinAtMapPt(loop, IS, IL), 1.6)) * + std::pow(state.dataDaylightingData->IllumMapCalc(MapNum).SolidAngAtMapPtWtd(loop, IL), 0.8); + GTOT2 = BACLUM(IL) + 0.07 * (std::sqrt(state.dataDaylightingData->IllumMapCalc(MapNum).SolidAngAtMapPt(loop, IL))) * VTMULT * + state.dataDaylightingData->IllumMapCalc(MapNum).SourceLumFromWinAtMapPt(loop, IS, IL); GTOT += GTOT1 / (GTOT2 + 0.000001); } @@ -9949,8 +9946,8 @@ namespace DaylightingManager { // Variables for reporting for (IL = 1; IL <= NREFPT; ++IL) { - IllumMapCalc(MapNum).DaylIllumAtMapPt(IL) = max(daylight_illum(IL), 0.0); - IllumMapCalc(MapNum).GlareIndexAtMapPt(IL) = GLRNDX(IL); + state.dataDaylightingData->IllumMapCalc(MapNum).DaylIllumAtMapPt(IL) = max(daylight_illum(IL), 0.0); + state.dataDaylightingData->IllumMapCalc(MapNum).GlareIndexAtMapPt(IL) = GLRNDX(IL); } } } @@ -10020,10 +10017,10 @@ namespace DaylightingManager { // FLOW: if (ReportIllumMap_firstTime) { ReportIllumMap_firstTime = false; - FirstTimeMaps.dimension(TotIllumMaps, true); - EnvrnPrint.dimension(TotIllumMaps, true); - RefPts.allocate(state.dataGlobal->NumOfZones, MaxRefPoints); - SavedMnDy.allocate(TotIllumMaps); + FirstTimeMaps.dimension(state.dataDaylightingData->TotIllumMaps, true); + EnvrnPrint.dimension(state.dataDaylightingData->TotIllumMaps, true); + RefPts.allocate(state.dataGlobal->NumOfZones, DataDaylighting::MaxRefPoints); + SavedMnDy.allocate(state.dataDaylightingData->TotIllumMaps); } if (FirstTimeMaps(MapNum)) { @@ -10031,15 +10028,15 @@ namespace DaylightingManager { FirstTimeMaps(MapNum) = false; auto openMapFile = [&](const std::string &fileName) -> InputOutputFile & { - auto &outputFile = *IllumMap(MapNum).mapFile; + auto &outputFile = *state.dataDaylightingData->IllumMap(MapNum).mapFile; outputFile.fileName = fileName + fmt::to_string(MapNum); outputFile.ensure_open(state, "ReportIllumMap"); return outputFile; }; - if (MapColSep == CharTab) { + if (state.dataDaylightingData->MapColSep == CharTab) { if (!openMapFile(state.files.outputMapTabFileName).good()) return; // CommaDelimited = false; //Unused Set but never used - } else if (MapColSep == CharComma) { + } else if (state.dataDaylightingData->MapColSep == CharComma) { if (!openMapFile(state.files.outputMapCsvFileName).good()) return; // CommaDelimited = true; //Unused Set but never used } else { @@ -10049,13 +10046,13 @@ namespace DaylightingManager { SavedMnDy(MapNum) = CurMnDyHr.substr(0, 5); - IllumMap(MapNum).Name = format("{} at {:.2R}m", IllumMap(MapNum).Name, IllumMap(MapNum).Z); + state.dataDaylightingData->IllumMap(MapNum).Name = format("{} at {:.2R}m", state.dataDaylightingData->IllumMap(MapNum).Name, state.dataDaylightingData->IllumMap(MapNum).Z); - for (R = 1; R <= ZoneDaylight(IllumMap(MapNum).Zone).TotalDaylRefPoints; ++R) { - RefPts(IllumMap(MapNum).Zone, R) = format("RefPt{}=({:.2R}:{:.2R}:{:.2R})", R, - ZoneDaylight(IllumMap(MapNum).Zone).DaylRefPtAbsCoord(1, R), - ZoneDaylight(IllumMap(MapNum).Zone).DaylRefPtAbsCoord(2, R) , - ZoneDaylight(IllumMap(MapNum).Zone).DaylRefPtAbsCoord(3, R) ); + for (R = 1; R <= state.dataDaylightingData->ZoneDaylight(state.dataDaylightingData->IllumMap(MapNum).Zone).TotalDaylRefPoints; ++R) { + RefPts(state.dataDaylightingData->IllumMap(MapNum).Zone, R) = format("RefPt{}=({:.2R}:{:.2R}:{:.2R})", R, + state.dataDaylightingData->ZoneDaylight(state.dataDaylightingData->IllumMap(MapNum).Zone).DaylRefPtAbsCoord(1, R), + state.dataDaylightingData->ZoneDaylight(state.dataDaylightingData->IllumMap(MapNum).Zone).DaylRefPtAbsCoord(2, R) , + state.dataDaylightingData->ZoneDaylight(state.dataDaylightingData->IllumMap(MapNum).Zone).DaylRefPtAbsCoord(3, R) ); } } if (SavedMnDy(MapNum) != CurMnDyHr.substr(0, 5)) { @@ -10063,14 +10060,15 @@ namespace DaylightingManager { SavedMnDy(MapNum) = CurMnDyHr.substr(0, 5); } if (EnvrnPrint(MapNum)) { - WriteDaylightMapTitle(MapNum, - *IllumMap(MapNum).mapFile, - IllumMap(MapNum).Name, + WriteDaylightMapTitle(state, + MapNum, + *state.dataDaylightingData->IllumMap(MapNum).mapFile, + state.dataDaylightingData->IllumMap(MapNum).Name, EnvironmentName, - IllumMap(MapNum).Zone, - RefPts(IllumMap(MapNum).Zone, 1), - RefPts(IllumMap(MapNum).Zone, 2), - IllumMap(MapNum).Z); + state.dataDaylightingData->IllumMap(MapNum).Zone, + RefPts(state.dataDaylightingData->IllumMap(MapNum).Zone, 1), + RefPts(state.dataDaylightingData->IllumMap(MapNum).Zone, 2), + state.dataDaylightingData->IllumMap(MapNum).Z); EnvrnPrint(MapNum) = false; } @@ -10079,58 +10077,58 @@ namespace DaylightingManager { // Write X scale column header auto mapLine = format(" {} {:02}:00", SavedMnDy(MapNum), state.dataGlobal->HourOfDay); - if (IllumMap(MapNum).HeaderXLineLengthNeeded) linelen = int(len(mapLine)); + if (state.dataDaylightingData->IllumMap(MapNum).HeaderXLineLengthNeeded) linelen = int(len(mapLine)); RefPt = 1; - for (X = 1; X <= IllumMap(MapNum).Xnum; ++X) { + for (X = 1; X <= state.dataDaylightingData->IllumMap(MapNum).Xnum; ++X) { const auto AddXorYString = format("{}({:.2R};{:.2R})=", - MapColSep, - IllumMapCalc(MapNum).MapRefPtAbsCoord(1, RefPt), - IllumMapCalc(MapNum).MapRefPtAbsCoord(2, RefPt)); - if (IllumMap(MapNum).HeaderXLineLengthNeeded) linelen += int(len(AddXorYString)); + state.dataDaylightingData->MapColSep, + state.dataDaylightingData->IllumMapCalc(MapNum).MapRefPtAbsCoord(1, RefPt), + state.dataDaylightingData->IllumMapCalc(MapNum).MapRefPtAbsCoord(2, RefPt)); + if (state.dataDaylightingData->IllumMap(MapNum).HeaderXLineLengthNeeded) linelen += int(len(AddXorYString)); mapLine += AddXorYString; ++RefPt; } // X - if (IllumMap(MapNum).HeaderXLineLengthNeeded) { - IllumMap(MapNum).HeaderXLineLength = linelen; - if (static_cast(IllumMap(MapNum).HeaderXLineLength) > len(mapLine)) { + if (state.dataDaylightingData->IllumMap(MapNum).HeaderXLineLengthNeeded) { + state.dataDaylightingData->IllumMap(MapNum).HeaderXLineLength = linelen; + if (static_cast(state.dataDaylightingData->IllumMap(MapNum).HeaderXLineLength) > len(mapLine)) { ShowWarningError(state, format("ReportIllumMap: Map=\"{}\" -- the X Header overflows buffer -- will be truncated at {} characters.", - IllumMap(MapNum).Name, + state.dataDaylightingData->IllumMap(MapNum).Name, int(len(mapLine)))); ShowContinueError(state, - format("...needed {} characters. Please contact EnergyPlus support.", IllumMap(MapNum).HeaderXLineLength)); + format("...needed {} characters. Please contact EnergyPlus support.", state.dataDaylightingData->IllumMap(MapNum).HeaderXLineLength)); } - IllumMap(MapNum).HeaderXLineLengthNeeded = false; + state.dataDaylightingData->IllumMap(MapNum).HeaderXLineLengthNeeded = false; } - print(*IllumMap(MapNum).mapFile, "{}\n", mapLine); + print(*state.dataDaylightingData->IllumMap(MapNum).mapFile, "{}\n", mapLine); // Write Y scale prefix and illuminance values RefPt = 1; - for (Y = 1; Y <= IllumMap(MapNum).Ynum; ++Y) { + for (Y = 1; Y <= state.dataDaylightingData->IllumMap(MapNum).Ynum; ++Y) { mapLine = - format("({:.2R};{:.2R})=", IllumMapCalc(MapNum).MapRefPtAbsCoord(1, RefPt), IllumMapCalc(MapNum).MapRefPtAbsCoord(2, RefPt)); - for (R = RefPt; R <= RefPt + IllumMap(MapNum).Xnum - 1; ++R) { - IllumOut = nint(IllumMapCalc(MapNum).DaylIllumAtMapPtHr(R)); - if (IllumMapCalc(MapNum).MapRefPtInBounds(R)) { + format("({:.2R};{:.2R})=", state.dataDaylightingData->IllumMapCalc(MapNum).MapRefPtAbsCoord(1, RefPt), state.dataDaylightingData->IllumMapCalc(MapNum).MapRefPtAbsCoord(2, RefPt)); + for (R = RefPt; R <= RefPt + state.dataDaylightingData->IllumMap(MapNum).Xnum - 1; ++R) { + IllumOut = nint(state.dataDaylightingData->IllumMapCalc(MapNum).DaylIllumAtMapPtHr(R)); + if (state.dataDaylightingData->IllumMapCalc(MapNum).MapRefPtInBounds(R)) { String = fmt::to_string(IllumOut); } else { String = fmt::to_string(IllumOut); String = "*" + String; } - mapLine += MapColSep + String; + mapLine += state.dataDaylightingData->MapColSep + String; } - print(*IllumMap(MapNum).mapFile, "{}\n", mapLine); + print(*state.dataDaylightingData->IllumMap(MapNum).mapFile, "{}\n", mapLine); - RefPt += IllumMap(MapNum).Xnum; + RefPt += state.dataDaylightingData->IllumMap(MapNum).Xnum; } // X if (sqlite) { if (SQFirstTime) { - int const nX(maxval(IllumMap, &IllumMapData::Xnum)); - int const nY(maxval(IllumMap, &IllumMapData::Ynum)); + int const nX(maxval(state.dataDaylightingData->IllumMap, &DataDaylighting::IllumMapData::Xnum)); + int const nY(maxval(state.dataDaylightingData->IllumMap, &DataDaylighting::IllumMapData::Ynum)); XValue.allocate(nX); YValue.allocate(nY); IllumValue.allocate(nX, nY); @@ -10143,20 +10141,20 @@ namespace DaylightingManager { SQMonth = Month; SQDayOfMonth = DayOfMonth; - for (Y = 1; Y <= IllumMap(MapNum).Ynum; ++Y) { - YValue(Y) = IllumMap(MapNum).Ymin + (Y - 1) * IllumMap(MapNum).Yinc; - for (X = 1; X <= IllumMap(MapNum).Xnum; ++X) { - XValue(X) = IllumMap(MapNum).Xmin + (X - 1) * IllumMap(MapNum).Xinc; - IllumIndex = X + (Y - 1) * IllumMap(MapNum).Xnum; - IllumValue(X, Y) = nint(IllumMapCalc(MapNum).DaylIllumAtMapPtHr(IllumIndex)); - if (!IllumMapCalc(MapNum).MapRefPtInBounds(IllumIndex)) { + for (Y = 1; Y <= state.dataDaylightingData->IllumMap(MapNum).Ynum; ++Y) { + YValue(Y) = state.dataDaylightingData->IllumMap(MapNum).Ymin + (Y - 1) * state.dataDaylightingData->IllumMap(MapNum).Yinc; + for (X = 1; X <= state.dataDaylightingData->IllumMap(MapNum).Xnum; ++X) { + XValue(X) = state.dataDaylightingData->IllumMap(MapNum).Xmin + (X - 1) * state.dataDaylightingData->IllumMap(MapNum).Xinc; + IllumIndex = X + (Y - 1) * state.dataDaylightingData->IllumMap(MapNum).Xnum; + IllumValue(X, Y) = nint(state.dataDaylightingData->IllumMapCalc(MapNum).DaylIllumAtMapPtHr(IllumIndex)); + if (!state.dataDaylightingData->IllumMapCalc(MapNum).MapRefPtInBounds(IllumIndex)) { IllumValue(X, Y) = -IllumValue(X, Y); } } // X Loop } // Y Loop sqlite->createSQLiteDaylightMap( - MapNum, SQYear, SQMonth, SQDayOfMonth, state.dataGlobal->HourOfDay, IllumMap(MapNum).Xnum, XValue, IllumMap(MapNum).Ynum, YValue, IllumValue); + MapNum, SQYear, SQMonth, SQDayOfMonth, state.dataGlobal->HourOfDay, state.dataDaylightingData->IllumMap(MapNum).Xnum, XValue, state.dataDaylightingData->IllumMap(MapNum).Ynum, YValue, IllumValue); } // WriteOutputToSQLite } // end time step @@ -10201,11 +10199,11 @@ namespace DaylightingManager { // na // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - if (TotIllumMaps > 0) { + if (state.dataDaylightingData->TotIllumMaps > 0) { // Write map header - if (MapColSep == CharTab) { + if (state.dataDaylightingData->MapColSep == CharTab) { state.files.map.fileName = state.files.outputMapTabFileName; - } else if (MapColSep == CharComma) { + } else if (state.dataDaylightingData->MapColSep == CharComma) { state.files.map.fileName = state.files.outputMapCsvFileName; } else { state.files.map.fileName = state.files.outputMapTxtFileName; @@ -10213,21 +10211,21 @@ namespace DaylightingManager { state.files.map.ensure_open(state, "CloseReportIllumMaps"); - for (int MapNum = 1; MapNum <= TotIllumMaps; ++MapNum) { - if (!IllumMap(MapNum).mapFile->good()) continue; // fatal error processing + for (int MapNum = 1; MapNum <= state.dataDaylightingData->TotIllumMaps; ++MapNum) { + if (!state.dataDaylightingData->IllumMap(MapNum).mapFile->good()) continue; // fatal error processing - const auto mapLines = IllumMap(MapNum).mapFile->getLines(); + const auto mapLines = state.dataDaylightingData->IllumMap(MapNum).mapFile->getLines(); if (mapLines.empty()) { - ShowSevereError(state, "CloseReportIllumMaps: IllumMap=\"" + IllumMap(MapNum).Name + "\" is empty."); + ShowSevereError(state, "CloseReportIllumMaps: IllumMap=\"" + state.dataDaylightingData->IllumMap(MapNum).Name + "\" is empty."); break; } for(const auto &mapLine : mapLines) { print(state.files.map, "{}\n", mapLine); } - IllumMap(MapNum).mapFile->del(); + state.dataDaylightingData->IllumMap(MapNum).mapFile->del(); } - if (!mapResultsReported && !AbortProcessing) { + if (!state.dataDaylightingData->mapResultsReported && !AbortProcessing) { const auto message = "CloseReportIllumMaps: Illuminance maps requested but no data ever reported. Likely cause is no solar."; ShowSevereError(state, message); @@ -10306,14 +10304,14 @@ namespace DaylightingManager { for (int const surfNum : DataViewFactorInformation::ZoneSolarInfo(Zone(ZoneNum).SolarEnclosureNum).SurfacePtr) { if ((Surface(surfNum).Class == SurfaceClass::Window && Surface(surfNum).ExtBoundCond == ExternalEnvironment) || SurfWinOriginalClass(surfNum) == SurfaceClass::TDD_Diffuser) { - ++ZoneDaylight(ZoneNum).TotalExtWindows; + ++state.dataDaylightingData->ZoneDaylight(ZoneNum).TotalExtWindows; } } } for (int ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ++ZoneNum) { int NumList = 0; - if (ZoneDaylight(ZoneNum).TotalDaylRefPoints == 0) continue; + if (state.dataDaylightingData->ZoneDaylight(ZoneNum).TotalDaylRefPoints == 0) continue; // This is a Daylighting:Detailed zone // Find adjacent zones/enclosures int const thisZoneEnclNum = Zone(ZoneNum).SolarEnclosureNum; @@ -10342,13 +10340,13 @@ namespace DaylightingManager { } } } - ZoneDaylight(ZoneNum).AdjIntWinZoneNums.allocate(NumList); - ZoneDaylight(ZoneNum).AdjIntWinZoneNums = 0; + state.dataDaylightingData->ZoneDaylight(ZoneNum).AdjIntWinZoneNums.allocate(NumList); + state.dataDaylightingData->ZoneDaylight(ZoneNum).AdjIntWinZoneNums = 0; } for (int ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ++ZoneNum) { int NumList = 0; - if (ZoneDaylight(ZoneNum).TotalDaylRefPoints == 0) continue; + if (state.dataDaylightingData->ZoneDaylight(ZoneNum).TotalDaylRefPoints == 0) continue; // This is a Daylighting:Detailed zone // Find adjacent zones int const thisZoneEnclNum = Zone(ZoneNum).SolarEnclosureNum; @@ -10372,44 +10370,44 @@ namespace DaylightingManager { if (Surface(Surface(SurfNumAdj).ExtBoundCond).SolarEnclIndex == thisZoneEnclNum) { // This interior window is adjacent to ZoneNum ++NumList; - ZoneDaylight(ZoneNum).AdjIntWinZoneNums(NumList) = ZoneNumAdj; - ZoneDaylight(ZoneNumAdj).AdjZoneHasDayltgCtrl = true; + state.dataDaylightingData->ZoneDaylight(ZoneNum).AdjIntWinZoneNums(NumList) = ZoneNumAdj; + state.dataDaylightingData->ZoneDaylight(ZoneNumAdj).AdjZoneHasDayltgCtrl = true; break; } } } } } - ZoneDaylight(ZoneNum).NumOfIntWinAdjZones = NumList; + state.dataDaylightingData->ZoneDaylight(ZoneNum).NumOfIntWinAdjZones = NumList; } // now fill out information on relationship between adjacent exterior windows and associated interior windows for (int ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ++ZoneNum) { // first find count of exterior windows - if (ZoneDaylight(ZoneNum).NumOfIntWinAdjZones <= 0) { - ZoneDaylight(ZoneNum).NumOfIntWinAdjZoneExtWins = 0; + if (state.dataDaylightingData->ZoneDaylight(ZoneNum).NumOfIntWinAdjZones <= 0) { + state.dataDaylightingData->ZoneDaylight(ZoneNum).NumOfIntWinAdjZoneExtWins = 0; continue; } int const thisZoneEnclNum = Zone(ZoneNum).SolarEnclosureNum; - for (int ZoneAdjLoop = 1; ZoneAdjLoop <= ZoneDaylight(ZoneNum).NumOfIntWinAdjZones; ++ZoneAdjLoop) { - int ZoneNumAdj = ZoneDaylight(ZoneNum).AdjIntWinZoneNums(ZoneAdjLoop); + for (int ZoneAdjLoop = 1; ZoneAdjLoop <= state.dataDaylightingData->ZoneDaylight(ZoneNum).NumOfIntWinAdjZones; ++ZoneAdjLoop) { + int ZoneNumAdj = state.dataDaylightingData->ZoneDaylight(ZoneNum).AdjIntWinZoneNums(ZoneAdjLoop); for (int SurfNumAdj = Zone(ZoneNumAdj).SurfaceFirst; SurfNumAdj <= Zone(ZoneNumAdj).SurfaceLast; ++SurfNumAdj) { if (Surface(SurfNumAdj).Class == SurfaceClass::Window && Surface(SurfNumAdj).ExtBoundCond == ExternalEnvironment) { - ++ZoneDaylight(ZoneNum).NumOfIntWinAdjZoneExtWins; + ++state.dataDaylightingData->ZoneDaylight(ZoneNum).NumOfIntWinAdjZoneExtWins; } } } // now allocate nested struct based on exterior window count - ZoneDaylight(ZoneNum).IntWinAdjZoneExtWin.allocate(ZoneDaylight(ZoneNum).NumOfIntWinAdjZoneExtWins); + state.dataDaylightingData->ZoneDaylight(ZoneNum).IntWinAdjZoneExtWin.allocate(state.dataDaylightingData->ZoneDaylight(ZoneNum).NumOfIntWinAdjZoneExtWins); // now fill nested structure int ExtWinIndex = 0; - for (int ZoneAdjLoop = 1; ZoneAdjLoop <= ZoneDaylight(ZoneNum).NumOfIntWinAdjZones; ++ZoneAdjLoop) { - int const ZoneNumAdj = ZoneDaylight(ZoneNum).AdjIntWinZoneNums(ZoneAdjLoop); + for (int ZoneAdjLoop = 1; ZoneAdjLoop <= state.dataDaylightingData->ZoneDaylight(ZoneNum).NumOfIntWinAdjZones; ++ZoneAdjLoop) { + int const ZoneNumAdj = state.dataDaylightingData->ZoneDaylight(ZoneNum).AdjIntWinZoneNums(ZoneAdjLoop); for (int SurfNumAdj = Zone(ZoneNumAdj).SurfaceFirst; SurfNumAdj <= Zone(ZoneNumAdj).SurfaceLast; ++SurfNumAdj) { if (Surface(SurfNumAdj).Class == SurfaceClass::Window && Surface(SurfNumAdj).ExtBoundCond == ExternalEnvironment) { ++ExtWinIndex; - ZoneDaylight(ZoneNum).IntWinAdjZoneExtWin(ExtWinIndex).SurfNum = SurfNumAdj; + state.dataDaylightingData->ZoneDaylight(ZoneNum).IntWinAdjZoneExtWin(ExtWinIndex).SurfNum = SurfNumAdj; // now count interior windows shared by both zones int NumOfIntWindowsCount = 0; @@ -10423,8 +10421,8 @@ namespace DaylightingManager { } } // allocate nested array - ZoneDaylight(ZoneNum).IntWinAdjZoneExtWin(ExtWinIndex).IntWinNum.allocate(NumOfIntWindowsCount); - ZoneDaylight(ZoneNum).IntWinAdjZoneExtWin(ExtWinIndex).IntWinNum = 0; + state.dataDaylightingData->ZoneDaylight(ZoneNum).IntWinAdjZoneExtWin(ExtWinIndex).IntWinNum.allocate(NumOfIntWindowsCount); + state.dataDaylightingData->ZoneDaylight(ZoneNum).IntWinAdjZoneExtWin(ExtWinIndex).IntWinNum = 0; int IntWinIndex = 0; for (int SurfNumAdj2 = Zone(ZoneNumAdj).SurfaceFirst; SurfNumAdj2 <= Zone(ZoneNumAdj).SurfaceLast; ++SurfNumAdj2) { if (Surface(SurfNumAdj2).Class == SurfaceClass::Window && Surface(SurfNumAdj2).ExtBoundCond >= 1) { @@ -10432,7 +10430,7 @@ namespace DaylightingManager { if (Surface(Surface(SurfNumAdj2).ExtBoundCond).SolarEnclIndex == thisZoneEnclNum) { // This interior window is adjacent to ZoneNum and associated with this ++IntWinIndex; - ZoneDaylight(ZoneNum).IntWinAdjZoneExtWin(ExtWinIndex).IntWinNum(IntWinIndex) = SurfNumAdj2; + state.dataDaylightingData->ZoneDaylight(ZoneNum).IntWinAdjZoneExtWin(ExtWinIndex).IntWinNum(IntWinIndex) = SurfNumAdj2; } } } @@ -10444,7 +10442,7 @@ namespace DaylightingManager { ZoneExtWin.dimension(state.dataGlobal->NumOfZones, 0); for (int ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ++ZoneNum) { - if (ZoneDaylight(ZoneNum).TotalDaylRefPoints > 0) { + if (state.dataDaylightingData->ZoneDaylight(ZoneNum).TotalDaylRefPoints > 0) { // This is a Daylighting:Detailed zone // Get exterior windows in this zone or shared solar enclosure @@ -10456,9 +10454,9 @@ namespace DaylightingManager { } // Get exterior windows in adjacent zones that share interior windows with ZoneNum - if (ZoneDaylight(ZoneNum).NumOfIntWinAdjZones > 0) { - for (int loop = 1; loop <= ZoneDaylight(ZoneNum).NumOfIntWinAdjZones; ++loop) { - int ZoneNumAdj = ZoneDaylight(ZoneNum).AdjIntWinZoneNums(loop); + if (state.dataDaylightingData->ZoneDaylight(ZoneNum).NumOfIntWinAdjZones > 0) { + for (int loop = 1; loop <= state.dataDaylightingData->ZoneDaylight(ZoneNum).NumOfIntWinAdjZones; ++loop) { + int ZoneNumAdj = state.dataDaylightingData->ZoneDaylight(ZoneNum).AdjIntWinZoneNums(loop); // Get exterior windows in ZoneNumAdj -- there must be at least one, otherwise // it would not be an "AdjIntWinZone" for (int SurfNumAdj = Zone(ZoneNumAdj).SurfaceFirst; SurfNumAdj <= Zone(ZoneNumAdj).SurfaceLast; ++SurfNumAdj) { @@ -10474,43 +10472,43 @@ namespace DaylightingManager { } // End of primary zone loop for (int ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ++ZoneNum) { - ZoneDaylight(ZoneNum).NumOfDayltgExtWins = 0; - if (ZoneDaylight(ZoneNum).TotalDaylRefPoints > 0) { + state.dataDaylightingData->ZoneDaylight(ZoneNum).NumOfDayltgExtWins = 0; + if (state.dataDaylightingData->ZoneDaylight(ZoneNum).TotalDaylRefPoints > 0) { // This is a Daylighting:Detailed zone // Get exterior windows in this zone if (ZoneExtWin(ZoneNum) == 0) continue; - ZoneDaylight(ZoneNum).DayltgExtWinSurfNums.allocate(ZoneExtWin(ZoneNum)); - ZoneDaylight(ZoneNum).DayltgExtWinSurfNums = 0; - ZoneDaylight(ZoneNum).MapShdOrdToLoopNum.allocate(ZoneExtWin(ZoneNum)); - ZoneDaylight(ZoneNum).MapShdOrdToLoopNum = 0; - - ZoneDaylight(ZoneNum).SolidAngAtRefPt.allocate(ZoneExtWin(ZoneNum), ZoneDaylight(ZoneNum).TotalDaylRefPoints); - ZoneDaylight(ZoneNum).SolidAngAtRefPt = 0.0; - ZoneDaylight(ZoneNum).SolidAngAtRefPtWtd.allocate(ZoneExtWin(ZoneNum), ZoneDaylight(ZoneNum).TotalDaylRefPoints); - ZoneDaylight(ZoneNum).SolidAngAtRefPtWtd = 0.0; - ZoneDaylight(ZoneNum).IllumFromWinAtRefPt.allocate(ZoneExtWin(ZoneNum), 2, ZoneDaylight(ZoneNum).TotalDaylRefPoints); - ZoneDaylight(ZoneNum).IllumFromWinAtRefPt = 0.0; - ZoneDaylight(ZoneNum).BackLumFromWinAtRefPt.allocate(ZoneExtWin(ZoneNum), 2, ZoneDaylight(ZoneNum).TotalDaylRefPoints); - ZoneDaylight(ZoneNum).BackLumFromWinAtRefPt = 0.0; - ZoneDaylight(ZoneNum).SourceLumFromWinAtRefPt.allocate(ZoneExtWin(ZoneNum), 2, ZoneDaylight(ZoneNum).TotalDaylRefPoints); - ZoneDaylight(ZoneNum).SourceLumFromWinAtRefPt = 0.0; - - for (int loop = 1; loop <= ZoneDaylight(ZoneNum).MapCount; ++loop) { - MapNum = ZoneDaylight(ZoneNum).ZoneToMap(loop); - - if (IllumMapCalc(MapNum).TotalMapRefPoints > 0) { + state.dataDaylightingData->ZoneDaylight(ZoneNum).DayltgExtWinSurfNums.allocate(ZoneExtWin(ZoneNum)); + state.dataDaylightingData->ZoneDaylight(ZoneNum).DayltgExtWinSurfNums = 0; + state.dataDaylightingData->ZoneDaylight(ZoneNum).MapShdOrdToLoopNum.allocate(ZoneExtWin(ZoneNum)); + state.dataDaylightingData->ZoneDaylight(ZoneNum).MapShdOrdToLoopNum = 0; + + state.dataDaylightingData->ZoneDaylight(ZoneNum).SolidAngAtRefPt.allocate(ZoneExtWin(ZoneNum), state.dataDaylightingData->ZoneDaylight(ZoneNum).TotalDaylRefPoints); + state.dataDaylightingData->ZoneDaylight(ZoneNum).SolidAngAtRefPt = 0.0; + state.dataDaylightingData->ZoneDaylight(ZoneNum).SolidAngAtRefPtWtd.allocate(ZoneExtWin(ZoneNum), state.dataDaylightingData->ZoneDaylight(ZoneNum).TotalDaylRefPoints); + state.dataDaylightingData->ZoneDaylight(ZoneNum).SolidAngAtRefPtWtd = 0.0; + state.dataDaylightingData->ZoneDaylight(ZoneNum).IllumFromWinAtRefPt.allocate(ZoneExtWin(ZoneNum), 2, state.dataDaylightingData->ZoneDaylight(ZoneNum).TotalDaylRefPoints); + state.dataDaylightingData->ZoneDaylight(ZoneNum).IllumFromWinAtRefPt = 0.0; + state.dataDaylightingData->ZoneDaylight(ZoneNum).BackLumFromWinAtRefPt.allocate(ZoneExtWin(ZoneNum), 2, state.dataDaylightingData->ZoneDaylight(ZoneNum).TotalDaylRefPoints); + state.dataDaylightingData->ZoneDaylight(ZoneNum).BackLumFromWinAtRefPt = 0.0; + state.dataDaylightingData->ZoneDaylight(ZoneNum).SourceLumFromWinAtRefPt.allocate(ZoneExtWin(ZoneNum), 2, state.dataDaylightingData->ZoneDaylight(ZoneNum).TotalDaylRefPoints); + state.dataDaylightingData->ZoneDaylight(ZoneNum).SourceLumFromWinAtRefPt = 0.0; + + for (int loop = 1; loop <= state.dataDaylightingData->ZoneDaylight(ZoneNum).MapCount; ++loop) { + MapNum = state.dataDaylightingData->ZoneDaylight(ZoneNum).ZoneToMap(loop); + + if (state.dataDaylightingData->IllumMapCalc(MapNum).TotalMapRefPoints > 0) { // might be able to use TotalMapRefPoints for zone in below. - IllumMapCalc(MapNum).SolidAngAtMapPt.allocate(ZoneExtWin(ZoneNum), IllumMapCalc(MapNum).TotalMapRefPoints); - IllumMapCalc(MapNum).SolidAngAtMapPt = 0.0; - IllumMapCalc(MapNum).SolidAngAtMapPtWtd.allocate(ZoneExtWin(ZoneNum), IllumMapCalc(MapNum).TotalMapRefPoints); - IllumMapCalc(MapNum).SolidAngAtMapPtWtd = 0.0; - IllumMapCalc(MapNum).IllumFromWinAtMapPt.allocate(ZoneExtWin(ZoneNum), 2, IllumMapCalc(MapNum).TotalMapRefPoints); - IllumMapCalc(MapNum).IllumFromWinAtMapPt = 0.0; - IllumMapCalc(MapNum).BackLumFromWinAtMapPt.allocate(ZoneExtWin(ZoneNum), 2, IllumMapCalc(MapNum).TotalMapRefPoints); - IllumMapCalc(MapNum).BackLumFromWinAtMapPt = 0.0; - IllumMapCalc(MapNum).SourceLumFromWinAtMapPt.allocate(ZoneExtWin(ZoneNum), 2, IllumMapCalc(MapNum).TotalMapRefPoints); - IllumMapCalc(MapNum).SourceLumFromWinAtMapPt = 0.0; + state.dataDaylightingData->IllumMapCalc(MapNum).SolidAngAtMapPt.allocate(ZoneExtWin(ZoneNum), state.dataDaylightingData->IllumMapCalc(MapNum).TotalMapRefPoints); + state.dataDaylightingData->IllumMapCalc(MapNum).SolidAngAtMapPt = 0.0; + state.dataDaylightingData->IllumMapCalc(MapNum).SolidAngAtMapPtWtd.allocate(ZoneExtWin(ZoneNum), state.dataDaylightingData->IllumMapCalc(MapNum).TotalMapRefPoints); + state.dataDaylightingData->IllumMapCalc(MapNum).SolidAngAtMapPtWtd = 0.0; + state.dataDaylightingData->IllumMapCalc(MapNum).IllumFromWinAtMapPt.allocate(ZoneExtWin(ZoneNum), 2, state.dataDaylightingData->IllumMapCalc(MapNum).TotalMapRefPoints); + state.dataDaylightingData->IllumMapCalc(MapNum).IllumFromWinAtMapPt = 0.0; + state.dataDaylightingData->IllumMapCalc(MapNum).BackLumFromWinAtMapPt.allocate(ZoneExtWin(ZoneNum), 2, state.dataDaylightingData->IllumMapCalc(MapNum).TotalMapRefPoints); + state.dataDaylightingData->IllumMapCalc(MapNum).BackLumFromWinAtMapPt = 0.0; + state.dataDaylightingData->IllumMapCalc(MapNum).SourceLumFromWinAtMapPt.allocate(ZoneExtWin(ZoneNum), 2, state.dataDaylightingData->IllumMapCalc(MapNum).TotalMapRefPoints); + state.dataDaylightingData->IllumMapCalc(MapNum).SourceLumFromWinAtMapPt = 0.0; } } @@ -10520,34 +10518,34 @@ namespace DaylightingManager { if ((Surface(surfNum).Class == SurfaceClass::Window && Surface(surfNum).ExtBoundCond == ExternalEnvironment) || SurfWinOriginalClass(surfNum) == SurfaceClass::TDD_Diffuser) { ++ZoneExtWinCtr; - ZoneDaylight(ZoneNum).DayltgExtWinSurfNums(ZoneExtWinCtr) = surfNum; + state.dataDaylightingData->ZoneDaylight(ZoneNum).DayltgExtWinSurfNums(ZoneExtWinCtr) = surfNum; } } // Get exterior windows in adjacent zones that share interior windows with ZoneNum - if (ZoneDaylight(ZoneNum).NumOfIntWinAdjZones > 0) { - for (int loop = 1; loop <= ZoneDaylight(ZoneNum).NumOfIntWinAdjZones; ++loop) { - int const ZoneNumAdj = ZoneDaylight(ZoneNum).AdjIntWinZoneNums(loop); + if (state.dataDaylightingData->ZoneDaylight(ZoneNum).NumOfIntWinAdjZones > 0) { + for (int loop = 1; loop <= state.dataDaylightingData->ZoneDaylight(ZoneNum).NumOfIntWinAdjZones; ++loop) { + int const ZoneNumAdj = state.dataDaylightingData->ZoneDaylight(ZoneNum).AdjIntWinZoneNums(loop); // Get exterior windows in ZoneNumAdj -- there must be at least one, otherwise // it would not be an "AdjIntWinZone" for (int SurfNumAdj = Zone(ZoneNumAdj).SurfaceFirst; SurfNumAdj <= Zone(ZoneNumAdj).SurfaceLast; ++SurfNumAdj) { if ((Surface(SurfNumAdj).Class == SurfaceClass::Window && Surface(SurfNumAdj).ExtBoundCond == ExternalEnvironment) || SurfWinOriginalClass(SurfNumAdj) == SurfaceClass::TDD_Diffuser) { ++ZoneExtWinCtr; - ZoneDaylight(ZoneNum).DayltgExtWinSurfNums(ZoneExtWinCtr) = SurfNumAdj; + state.dataDaylightingData->ZoneDaylight(ZoneNum).DayltgExtWinSurfNums(ZoneExtWinCtr) = SurfNumAdj; // If no daylighting in that zone, set up variables anyway: - if (ZoneDaylight(ZoneNumAdj).TotalDaylRefPoints == 0) { + if (state.dataDaylightingData->ZoneDaylight(ZoneNumAdj).TotalDaylRefPoints == 0) { if (!SurfWinSurfDayLightInit(SurfNumAdj)) { - SurfaceWindow(SurfNumAdj).SolidAngAtRefPt.allocate(ZoneDaylight(ZoneNum).TotalDaylRefPoints); + SurfaceWindow(SurfNumAdj).SolidAngAtRefPt.allocate(state.dataDaylightingData->ZoneDaylight(ZoneNum).TotalDaylRefPoints); SurfaceWindow(SurfNumAdj).SolidAngAtRefPt = 0.0; - SurfaceWindow(SurfNumAdj).SolidAngAtRefPtWtd.allocate(ZoneDaylight(ZoneNum).TotalDaylRefPoints); + SurfaceWindow(SurfNumAdj).SolidAngAtRefPtWtd.allocate(state.dataDaylightingData->ZoneDaylight(ZoneNum).TotalDaylRefPoints); SurfaceWindow(SurfNumAdj).SolidAngAtRefPtWtd = 0.0; - SurfaceWindow(SurfNumAdj).IllumFromWinAtRefPt.allocate(2, ZoneDaylight(ZoneNum).TotalDaylRefPoints); + SurfaceWindow(SurfNumAdj).IllumFromWinAtRefPt.allocate(2, state.dataDaylightingData->ZoneDaylight(ZoneNum).TotalDaylRefPoints); SurfaceWindow(SurfNumAdj).IllumFromWinAtRefPt = 0.0; - SurfaceWindow(SurfNumAdj).BackLumFromWinAtRefPt.allocate(2, ZoneDaylight(ZoneNum).TotalDaylRefPoints); + SurfaceWindow(SurfNumAdj).BackLumFromWinAtRefPt.allocate(2, state.dataDaylightingData->ZoneDaylight(ZoneNum).TotalDaylRefPoints); SurfaceWindow(SurfNumAdj).BackLumFromWinAtRefPt = 0.0; - SurfaceWindow(SurfNumAdj).SourceLumFromWinAtRefPt.allocate(2, ZoneDaylight(ZoneNum).TotalDaylRefPoints); + SurfaceWindow(SurfNumAdj).SourceLumFromWinAtRefPt.allocate(2, state.dataDaylightingData->ZoneDaylight(ZoneNum).TotalDaylRefPoints); SurfaceWindow(SurfNumAdj).SourceLumFromWinAtRefPt = 0.0; SurfWinSurfDayLightInit(SurfNumAdj) = true; } @@ -10557,37 +10555,37 @@ namespace DaylightingManager { } } - ZoneDaylight(ZoneNum).NumOfDayltgExtWins = ZoneExtWin(ZoneNum); + state.dataDaylightingData->ZoneDaylight(ZoneNum).NumOfDayltgExtWins = ZoneExtWin(ZoneNum); WinSize = ZoneExtWin(ZoneNum); - RefSize = ZoneDaylight(ZoneNum).TotalDaylRefPoints; - ZoneDaylight(ZoneNum).DaylIllFacSky.allocate(24, MaxSlatAngs + 1, 4, RefSize, WinSize); - ZoneDaylight(ZoneNum).DaylSourceFacSky.allocate(24, MaxSlatAngs + 1, 4, RefSize, WinSize); - ZoneDaylight(ZoneNum).DaylBackFacSky.allocate(24, MaxSlatAngs + 1, 4, RefSize, WinSize); - ZoneDaylight(ZoneNum).DaylIllFacSun.allocate(24, MaxSlatAngs + 1, RefSize, WinSize); - ZoneDaylight(ZoneNum).DaylIllFacSunDisk.allocate(24, MaxSlatAngs + 1, RefSize, WinSize); - ZoneDaylight(ZoneNum).DaylSourceFacSun.allocate(24, MaxSlatAngs + 1, RefSize, WinSize); - ZoneDaylight(ZoneNum).DaylSourceFacSunDisk.allocate(24, MaxSlatAngs + 1, RefSize, WinSize); - ZoneDaylight(ZoneNum).DaylBackFacSun.allocate(24, MaxSlatAngs + 1, RefSize, WinSize); - ZoneDaylight(ZoneNum).DaylBackFacSunDisk.allocate(24, MaxSlatAngs + 1, RefSize, WinSize); - - for (int loop = 1; loop <= ZoneDaylight(ZoneNum).MapCount; ++loop) { - MapNum = ZoneDaylight(ZoneNum).ZoneToMap(loop); - RefSize = IllumMapCalc(MapNum).TotalMapRefPoints; - IllumMapCalc(MapNum).DaylIllFacSky.allocate(24, MaxSlatAngs + 1, 4, RefSize, WinSize); - IllumMapCalc(MapNum).DaylSourceFacSky.allocate(24, MaxSlatAngs + 1, 4, RefSize, WinSize); - IllumMapCalc(MapNum).DaylBackFacSky.allocate(24, MaxSlatAngs + 1, 4, RefSize, WinSize); - IllumMapCalc(MapNum).DaylIllFacSun.allocate(24, MaxSlatAngs + 1, RefSize, WinSize); - IllumMapCalc(MapNum).DaylIllFacSunDisk.allocate(24, MaxSlatAngs + 1, RefSize, WinSize); - IllumMapCalc(MapNum).DaylSourceFacSun.allocate(24, MaxSlatAngs + 1, RefSize, WinSize); - IllumMapCalc(MapNum).DaylSourceFacSunDisk.allocate(24, MaxSlatAngs + 1, RefSize, WinSize); - IllumMapCalc(MapNum).DaylBackFacSun.allocate(24, MaxSlatAngs + 1, RefSize, WinSize); - IllumMapCalc(MapNum).DaylBackFacSunDisk.allocate(24, MaxSlatAngs + 1, RefSize, WinSize); + RefSize = state.dataDaylightingData->ZoneDaylight(ZoneNum).TotalDaylRefPoints; + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylIllFacSky.allocate(24, MaxSlatAngs + 1, 4, RefSize, WinSize); + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylSourceFacSky.allocate(24, MaxSlatAngs + 1, 4, RefSize, WinSize); + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylBackFacSky.allocate(24, MaxSlatAngs + 1, 4, RefSize, WinSize); + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylIllFacSun.allocate(24, MaxSlatAngs + 1, RefSize, WinSize); + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylIllFacSunDisk.allocate(24, MaxSlatAngs + 1, RefSize, WinSize); + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylSourceFacSun.allocate(24, MaxSlatAngs + 1, RefSize, WinSize); + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylSourceFacSunDisk.allocate(24, MaxSlatAngs + 1, RefSize, WinSize); + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylBackFacSun.allocate(24, MaxSlatAngs + 1, RefSize, WinSize); + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylBackFacSunDisk.allocate(24, MaxSlatAngs + 1, RefSize, WinSize); + + for (int loop = 1; loop <= state.dataDaylightingData->ZoneDaylight(ZoneNum).MapCount; ++loop) { + MapNum = state.dataDaylightingData->ZoneDaylight(ZoneNum).ZoneToMap(loop); + RefSize = state.dataDaylightingData->IllumMapCalc(MapNum).TotalMapRefPoints; + state.dataDaylightingData->IllumMapCalc(MapNum).DaylIllFacSky.allocate(24, MaxSlatAngs + 1, 4, RefSize, WinSize); + state.dataDaylightingData->IllumMapCalc(MapNum).DaylSourceFacSky.allocate(24, MaxSlatAngs + 1, 4, RefSize, WinSize); + state.dataDaylightingData->IllumMapCalc(MapNum).DaylBackFacSky.allocate(24, MaxSlatAngs + 1, 4, RefSize, WinSize); + state.dataDaylightingData->IllumMapCalc(MapNum).DaylIllFacSun.allocate(24, MaxSlatAngs + 1, RefSize, WinSize); + state.dataDaylightingData->IllumMapCalc(MapNum).DaylIllFacSunDisk.allocate(24, MaxSlatAngs + 1, RefSize, WinSize); + state.dataDaylightingData->IllumMapCalc(MapNum).DaylSourceFacSun.allocate(24, MaxSlatAngs + 1, RefSize, WinSize); + state.dataDaylightingData->IllumMapCalc(MapNum).DaylSourceFacSunDisk.allocate(24, MaxSlatAngs + 1, RefSize, WinSize); + state.dataDaylightingData->IllumMapCalc(MapNum).DaylBackFacSun.allocate(24, MaxSlatAngs + 1, RefSize, WinSize); + state.dataDaylightingData->IllumMapCalc(MapNum).DaylBackFacSunDisk.allocate(24, MaxSlatAngs + 1, RefSize, WinSize); } } // End of check if a Daylighting:Detailed zone if (TotWinShadingControl > 0) { - CreateShadeDeploymentOrder(ZoneNum); + CreateShadeDeploymentOrder(state, ZoneNum); MapShadeDeploymentOrderToLoopNumber(state, ZoneNum); } @@ -10595,20 +10593,20 @@ namespace DaylightingManager { static constexpr auto Format_700("! , Zone Name, Number of Exterior Windows, Number of Exterior Windows in Adjacent Zones\n"); print(state.files.eio, Format_700); for (int ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ++ZoneNum) { - if (ZoneDaylight(ZoneNum).TotalDaylRefPoints == 0 || ZoneDaylight(ZoneNum).DaylightMethod != SplitFluxDaylighting) continue; + if (state.dataDaylightingData->ZoneDaylight(ZoneNum).TotalDaylRefPoints == 0 || state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylightMethod != DataDaylighting::iDaylightingMethod::SplitFluxDaylighting) continue; static constexpr auto Format_701("Zone/Window Adjacency Daylighting Counts, {},{},{}\n"); - print(state.files.eio, Format_701, Zone(ZoneNum).Name, ZoneDaylight(ZoneNum).TotalExtWindows, - (ZoneDaylight(ZoneNum).NumOfDayltgExtWins - ZoneDaylight(ZoneNum).TotalExtWindows)); + print(state.files.eio, Format_701, Zone(ZoneNum).Name, state.dataDaylightingData->ZoneDaylight(ZoneNum).TotalExtWindows, + (state.dataDaylightingData->ZoneDaylight(ZoneNum).NumOfDayltgExtWins - state.dataDaylightingData->ZoneDaylight(ZoneNum).TotalExtWindows)); } static constexpr auto Format_702("! , Zone Name, Number of Adjacent Zones with Windows,Adjacent " "Zone Names - 1st 100 (max)\n"); print(state.files.eio, Format_702); for (int ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ++ZoneNum) { - if (ZoneDaylight(ZoneNum).TotalDaylRefPoints == 0 || ZoneDaylight(ZoneNum).DaylightMethod != SplitFluxDaylighting) continue; + if (state.dataDaylightingData->ZoneDaylight(ZoneNum).TotalDaylRefPoints == 0 || state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylightMethod != DataDaylighting::iDaylightingMethod::SplitFluxDaylighting) continue; static constexpr auto Format_703("Zone/Window Adjacency Daylighting Matrix, {},{}"); - print(state.files.eio, Format_703, Zone(ZoneNum).Name, ZoneDaylight(ZoneNum).NumOfIntWinAdjZones); - for (int loop = 1, loop_end = min(ZoneDaylight(ZoneNum).NumOfIntWinAdjZones, 100); loop <= loop_end; ++loop) { - print(state.files.eio, ",{}", Zone(ZoneDaylight(ZoneNum).AdjIntWinZoneNums(loop)).Name); + print(state.files.eio, Format_703, Zone(ZoneNum).Name, state.dataDaylightingData->ZoneDaylight(ZoneNum).NumOfIntWinAdjZones); + for (int loop = 1, loop_end = min(state.dataDaylightingData->ZoneDaylight(ZoneNum).NumOfIntWinAdjZones, 100); loop <= loop_end; ++loop) { + print(state.files.eio, ",{}", Zone(state.dataDaylightingData->ZoneDaylight(ZoneNum).AdjIntWinZoneNums(loop)).Name); } print(state.files.eio, "\n"); } @@ -10616,7 +10614,7 @@ namespace DaylightingManager { ZoneExtWin.deallocate(); } - void CreateShadeDeploymentOrder(int &ZoneNum) + void CreateShadeDeploymentOrder(EnergyPlusData &state, int &ZoneNum) { // J. Glazer - 2018 // create sorted list for shade deployment order @@ -10640,13 +10638,13 @@ namespace DaylightingManager { for (int i = 1; i <= WindowShadingControl(curShadeControl).FenestrationCount; i++) { group.push_back(WindowShadingControl(curShadeControl).FenestrationIndex(i)); } - ZoneDaylight(ZoneNum).ShadeDeployOrderExtWins.push_back(group); + state.dataDaylightingData->ZoneDaylight(ZoneNum).ShadeDeployOrderExtWins.push_back(group); } else { // add each individial surface as a separate list so they are deployed individually for (int i = 1; i <= WindowShadingControl(curShadeControl).FenestrationCount; i++) { std::vector singleMemberVector; singleMemberVector.push_back(WindowShadingControl(curShadeControl).FenestrationIndex(i)); - ZoneDaylight(ZoneNum).ShadeDeployOrderExtWins.push_back(singleMemberVector); + state.dataDaylightingData->ZoneDaylight(ZoneNum).ShadeDeployOrderExtWins.push_back(singleMemberVector); } } } @@ -10657,19 +10655,19 @@ namespace DaylightingManager { // J. Glazer - 2018 // Allow a way to map back to the original "loop" index that is used in many other places in the // ZoneDayLight data structure when traversing the list in the order of the window shaded deployment - if (ZoneDaylight(ZoneNum).TotalDaylRefPoints > 0 && ZoneDaylight(ZoneNum).NumOfDayltgExtWins > 0 && - ZoneDaylight(ZoneNum).ShadeDeployOrderExtWins.size() > 0) { + if (state.dataDaylightingData->ZoneDaylight(ZoneNum).TotalDaylRefPoints > 0 && state.dataDaylightingData->ZoneDaylight(ZoneNum).NumOfDayltgExtWins > 0 && + state.dataDaylightingData->ZoneDaylight(ZoneNum).ShadeDeployOrderExtWins.size() > 0) { int count = 0; - for (auto listOfExtWin : ZoneDaylight(ZoneNum).ShadeDeployOrderExtWins) { + for (auto listOfExtWin : state.dataDaylightingData->ZoneDaylight(ZoneNum).ShadeDeployOrderExtWins) { for (auto IWinShdOrd : listOfExtWin) { ++count; - if (count > ZoneDaylight(ZoneNum).NumOfDayltgExtWins) + if (count > state.dataDaylightingData->ZoneDaylight(ZoneNum).NumOfDayltgExtWins) ShowWarningError(state, "MapShadeDeploymentOrderToLoopNumber: too many controlled shaded windows in zone " + Zone(ZoneNum).Name); bool found = false; - for (int loop = 1; loop <= ZoneDaylight(ZoneNum).NumOfDayltgExtWins; ++loop) { - int IWinLoop = ZoneDaylight(ZoneNum).DayltgExtWinSurfNums(loop); + for (int loop = 1; loop <= state.dataDaylightingData->ZoneDaylight(ZoneNum).NumOfDayltgExtWins; ++loop) { + int IWinLoop = state.dataDaylightingData->ZoneDaylight(ZoneNum).DayltgExtWinSurfNums(loop); if (IWinShdOrd == IWinLoop) { - ZoneDaylight(ZoneNum).MapShdOrdToLoopNum(count) = loop; + state.dataDaylightingData->ZoneDaylight(ZoneNum).MapShdOrdToLoopNum(count) = loop; found = true; break; } @@ -10679,8 +10677,8 @@ namespace DaylightingManager { } } // double check MapShdOrdToLoopNum array, this should be unnessary but.. - for (int loop = 1; loop <= ZoneDaylight(ZoneNum).NumOfDayltgExtWins; ++loop) { - if (ZoneDaylight(ZoneNum).MapShdOrdToLoopNum(loop) == 0) { + for (int loop = 1; loop <= state.dataDaylightingData->ZoneDaylight(ZoneNum).NumOfDayltgExtWins; ++loop) { + if (state.dataDaylightingData->ZoneDaylight(ZoneNum).MapShdOrdToLoopNum(loop) == 0) { ShowWarningError(state, "MapShadeDeploymentOrderToLoopNumber: found empty map for window in zone " + Zone(ZoneNum).Name); } } @@ -10707,7 +10705,7 @@ namespace DaylightingManager { Real64 BmInterReflIll; // Inter-reflected illuminance due to beam solar entering ZoneNum's enclosure // through its interior windows (lux) - ZoneDaylight(ZoneNum).InterReflIllFrIntWins = 0.0; + state.dataDaylightingData->ZoneDaylight(ZoneNum).InterReflIllFrIntWins = 0.0; auto &thisEnclSurfaces(DataViewFactorInformation::ZoneSolarInfo(Zone(ZoneNum).SolarEnclosureNum).SurfacePtr); for (int const IWin : thisEnclSurfaces) { @@ -10718,25 +10716,25 @@ namespace DaylightingManager { QDifTrans = QSDifSol(adjEnclNum) * state.dataConstruction->Construct(ConstrNum).TransDiffVis * Surface(IWin).Area * PDIFLW; QDifTransUp = QDifTrans * SurfWinFractionUpgoing(IWin); QDifTransDn = QDifTrans * (1.0 - SurfWinFractionUpgoing(IWin)); - if (ZoneDaylight(ZoneNum).TotInsSurfArea * (1.0 - ZoneDaylight(ZoneNum).AveVisDiffReflect) != 0.0) { + if (state.dataDaylightingData->ZoneDaylight(ZoneNum).TotInsSurfArea * (1.0 - state.dataDaylightingData->ZoneDaylight(ZoneNum).AveVisDiffReflect) != 0.0) { DifInterReflIllThisWin = (QDifTransDn * SurfWinRhoFloorWall(IWin) + QDifTransUp * SurfWinRhoCeilingWall(IWin)) / - (ZoneDaylight(ZoneNum).TotInsSurfArea * (1.0 - ZoneDaylight(ZoneNum).AveVisDiffReflect)); + (state.dataDaylightingData->ZoneDaylight(ZoneNum).TotInsSurfArea * (1.0 - state.dataDaylightingData->ZoneDaylight(ZoneNum).AveVisDiffReflect)); } else { DifInterReflIllThisWin = 0.0; } - ZoneDaylight(ZoneNum).InterReflIllFrIntWins += DifInterReflIllThisWin; + state.dataDaylightingData->ZoneDaylight(ZoneNum).InterReflIllFrIntWins += DifInterReflIllThisWin; } } // Add inter-reflected illuminance from beam solar entering ZoneNum through interior windows // TH, CR 7873, 9/17/2009 BmInterReflIll = 0.0; - if (ZoneDaylight(ZoneNum).TotInsSurfArea > 0) { - BmInterReflIll = (EnclSolDBIntWin(ZoneNum) * BeamSolarRad * PDIRLW * ZoneDaylight(ZoneNum).FloorVisRefl) / - (ZoneDaylight(ZoneNum).TotInsSurfArea * (1.0 - ZoneDaylight(ZoneNum).AveVisDiffReflect)); + if (state.dataDaylightingData->ZoneDaylight(ZoneNum).TotInsSurfArea > 0) { + BmInterReflIll = (EnclSolDBIntWin(ZoneNum) * BeamSolarRad * PDIRLW * state.dataDaylightingData->ZoneDaylight(ZoneNum).FloorVisRefl) / + (state.dataDaylightingData->ZoneDaylight(ZoneNum).TotInsSurfArea * (1.0 - state.dataDaylightingData->ZoneDaylight(ZoneNum).AveVisDiffReflect)); } - ZoneDaylight(ZoneNum).InterReflIllFrIntWins += BmInterReflIll; + state.dataDaylightingData->ZoneDaylight(ZoneNum).InterReflIllFrIntWins += BmInterReflIll; } void CalcMinIntWinSolidAngs(EnergyPlusData &state) @@ -10795,23 +10793,23 @@ namespace DaylightingManager { // FLOW: for (ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ++ZoneNum) { - ZoneDaylight(ZoneNum).MinIntWinSolidAng = 2.0 * DataGlobalConstants::Pi(); - if (ZoneDaylight(ZoneNum).TotalDaylRefPoints == 0) continue; - if (ZoneDaylight(ZoneNum).NumOfIntWinAdjZones == 0) continue; + state.dataDaylightingData->ZoneDaylight(ZoneNum).MinIntWinSolidAng = 2.0 * DataGlobalConstants::Pi(); + if (state.dataDaylightingData->ZoneDaylight(ZoneNum).TotalDaylRefPoints == 0) continue; + if (state.dataDaylightingData->ZoneDaylight(ZoneNum).NumOfIntWinAdjZones == 0) continue; for (IWin = Zone(ZoneNum).SurfaceFirst; IWin <= Zone(ZoneNum).SurfaceLast; ++IWin) { if (Surface(IWin).Class == SurfaceClass::Window && Surface(IWin).ExtBoundCond >= 1) { ZoneNumAdj = Surface(Surface(IWin).ExtBoundCond).Zone; IntWinNextToIntWinAdjZone = false; - for (loop = 1; loop <= ZoneDaylight(ZoneNum).NumOfIntWinAdjZones; ++loop) { - if (Zone(ZoneNumAdj).SolarEnclosureNum == Zone(ZoneDaylight(ZoneNum).AdjIntWinZoneNums(loop)).SolarEnclosureNum) { + for (loop = 1; loop <= state.dataDaylightingData->ZoneDaylight(ZoneNum).NumOfIntWinAdjZones; ++loop) { + if (Zone(ZoneNumAdj).SolarEnclosureNum == Zone(state.dataDaylightingData->ZoneDaylight(ZoneNum).AdjIntWinZoneNums(loop)).SolarEnclosureNum) { IntWinNextToIntWinAdjZone = true; break; } } if (IntWinNextToIntWinAdjZone) { - for (IL = 1; IL <= ZoneDaylight(ZoneNum).TotalDaylRefPoints; ++IL) { + for (IL = 1; IL <= state.dataDaylightingData->ZoneDaylight(ZoneNum).TotalDaylRefPoints; ++IL) { // Reference point in absolute coordinate system - RREF = ZoneDaylight(ZoneNum).DaylRefPtAbsCoord({1, 3}, IL); + RREF = state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylRefPtAbsCoord({1, 3}, IL); is_Triangle = (Surface(IWin).Sides == 3); is_Rectangle = (Surface(IWin).Sides == 4); if (is_Rectangle) { @@ -10853,7 +10851,7 @@ namespace DaylightingManager { // Above test avoids case where ref point cannot receive daylight directly from the // interior window IntWinSolidAng = COSB * Surface(IWin).Area / (pow_2(DIS) + 0.001); - ZoneDaylight(ZoneNum).MinIntWinSolidAng = min(ZoneDaylight(ZoneNum).MinIntWinSolidAng, IntWinSolidAng); + state.dataDaylightingData->ZoneDaylight(ZoneNum).MinIntWinSolidAng = min(state.dataDaylightingData->ZoneDaylight(ZoneNum).MinIntWinSolidAng, IntWinSolidAng); } } // End of loop over reference points } @@ -10884,8 +10882,6 @@ namespace DaylightingManager { // Using/Aliasing using namespace DataIPShortCuts; - using DataDaylighting::ZoneDaylight; - // Locals // SUBROUTINE ARGUMENT DEFINITIONS: @@ -10940,7 +10936,8 @@ namespace DaylightingManager { } } - void WriteDaylightMapTitle(int const mapNum, + void WriteDaylightMapTitle(EnergyPlusData &state, + int const mapNum, InputOutputFile &mapFile, std::string const &mapName, std::string const &environmentName, @@ -10962,7 +10959,7 @@ namespace DaylightingManager { const auto fullmapName = fmt::format("{}:{}:{} Illuminance [lux] (Hourly)", Zone(ZoneNum).Name, environmentName, mapName); print(mapFile, "Date/Time{Sep}{FullMapName}{Sep}{RefPt1}{Sep}{RefPt2}{Sep}{Sep}\n", - fmt::arg("Sep", MapColSep), + fmt::arg("Sep", state.dataDaylightingData->MapColSep), fmt::arg("FullMapName", fullmapName), fmt::arg("RefPt1", refPt1), fmt::arg("RefPt2", refPt2)); diff --git a/src/EnergyPlus/DaylightingManager.hh b/src/EnergyPlus/DaylightingManager.hh index 3cce9561235..09c38712d94 100644 --- a/src/EnergyPlus/DaylightingManager.hh +++ b/src/EnergyPlus/DaylightingManager.hh @@ -57,6 +57,7 @@ #include // EnergyPlus Headers +#include #include #include @@ -140,7 +141,7 @@ namespace DaylightingManager { int const ZoneNum, int const iRefPoint, int const loopwin, - int const CalledFrom, // indicate which type of routine called this routine + DataDaylighting::iCalledFor const CalledFrom, // indicate which type of routine called this routine Vector3 const &RREF, // Location of a reference point in absolute coordinate system Vector3 const &VIEWVC, // View vector in absolute coordinate system int &IWin, @@ -157,7 +158,7 @@ namespace DaylightingManager { int &ShType, // Window shading type int &BlNum, // Window blind number Vector3 &WNORM2, // Unit vector normal to window - int &ExtWinType, // Exterior window type (InZoneExtWin, AdjZoneExtWin, NotInOrAdjZoneExtWin) + DataDaylighting::iExtWinType &ExtWinType, // Exterior window type (InZoneExtWin, AdjZoneExtWin, NotInOrAdjZoneExtWin) int &IConst, // Construction counter Vector3 &RREF2, // Location of virtual reference point in absolute coordinate system Real64 &DWX, // Horizontal dimension of window element (m) @@ -178,7 +179,7 @@ namespace DaylightingManager { int const ZoneNum, int const iRefPoint, int const loopwin, - int const CalledFrom, // indicate which type of routine called this routine + DataDaylighting::iCalledFor const CalledFrom, // indicate which type of routine called this routine int const WinEl, // Current window element number int const IWin, int const IWin2, @@ -210,7 +211,7 @@ namespace DaylightingManager { bool &hitIntObs, // True iff interior obstruction hit bool &hitExtObs, // True iff ray from ref pt to ext win hits an exterior obstruction Vector3 const &WNORM2, // Unit vector normal to window - int const ExtWinType, // Exterior window type (InZoneExtWin, AdjZoneExtWin, NotInOrAdjZoneExtWin) + DataDaylighting::iExtWinType const ExtWinType, // Exterior window type (InZoneExtWin, AdjZoneExtWin, NotInOrAdjZoneExtWin) int const IConst, // Construction counter Vector3 const &RREF2, // Location of virtual reference point in absolute coordinate system bool const Triangle, @@ -228,7 +229,7 @@ namespace DaylightingManager { Vector3 const &RefPoint, // reference point coordinates int const NRefPts, // Number of reference points int const iRefPoint, // Reference points counter - int const CalledFrom, + DataDaylighting::iCalledFor const CalledFrom, Optional_int_const MapNum = _); void InitializeCFSStateData(EnergyPlusData &state, @@ -250,7 +251,7 @@ namespace DaylightingManager { Real64 const DWY, Vector3 const &WNorm, // unit vector from window (point towards outside) Real64 const WinElArea, - int const CalledFrom, + DataDaylighting::iCalledFor const CalledFrom, Optional_int_const MapNum = _); void AllocateForCFSRefPointsState(BSDFRefPoints &StateRefPoint, int const NumOfWinEl, int const NBasis, int const NTrnBasis); @@ -305,19 +306,20 @@ namespace DaylightingManager { int const BlNum, // Window blind number Real64 const THRAY, // Azimuth of ray from reference point to window element (radians) Vector3 const &WNORM2, // Unit vector normal to window - int const ExtWinType, // Exterior window type (InZoneExtWin, AdjZoneExtWin, NotInOrAdjZoneExtWin) + DataDaylighting::iExtWinType const ExtWinType, // Exterior window type (InZoneExtWin, AdjZoneExtWin, NotInOrAdjZoneExtWin) int const IConst, // Construction counter Real64 const AZVIEW, // Azimuth of view vector in absolute coord system for glare calculation (radians) Vector3 const &RREF2, // Location of virtual reference point in absolute coordinate system bool const hitIntObs, // True iff interior obstruction hit bool const hitExtObs, // True iff ray from ref pt to ext win hits an exterior obstruction - int const CalledFrom, // indicate which type of routine called this routine + DataDaylighting::iCalledFor const CalledFrom, // indicate which type of routine called this routine Real64 &TVISIntWin, // Visible transmittance of int win at COSBIntWin for light from ext win Real64 &TVISIntWinDisk, // Visible transmittance of int win at COSBIntWin for sun Optional_int_const MapNum = _, Optional MapWindowSolidAngAtRefPtWtd = _); - void FigureRefPointDayltgFactorsToAddIllums(int const ZoneNum, + void FigureRefPointDayltgFactorsToAddIllums(EnergyPlusData &state, + int const ZoneNum, int const iRefPoint, int const iHour, int &ISunPos, @@ -328,7 +330,8 @@ namespace DaylightingManager { int const ICtrl // Window control counter ); - void FigureMapPointDayltgFactorsToAddIllums(int const ZoneNum, + void FigureMapPointDayltgFactorsToAddIllums(EnergyPlusData &state, + int const ZoneNum, int const MapNum, int const iMapPoint, int const iHour, @@ -351,7 +354,7 @@ namespace DaylightingManager { void GetInputDayliteRefPt(EnergyPlusData &state, bool &ErrorsFound); - bool doesDayLightingUseDElight(); + bool doesDayLightingUseDElight(EnergyPlusData &state); void CheckTDDsAndLightShelvesInDaylitZones(EnergyPlusData &state); @@ -359,13 +362,15 @@ namespace DaylightingManager { void GetLightWellData(EnergyPlusData &state, bool &ErrorsFound); // If errors found in input - void DayltgGlare(int &IL, // Reference point index: 1=first ref pt, 2=second ref pt + void DayltgGlare(EnergyPlusData &state, + int &IL, // Reference point index: 1=first ref pt, 2=second ref pt Real64 &BLUM, // Window background (surround) luminance (cd/m2) Real64 &GLINDX, // Glare index int &ZoneNum // Zone number ); - void DayltgGlareWithIntWins(Array1D &GLINDX, // Glare index + void DayltgGlareWithIntWins(EnergyPlusData &state, + Array1D &GLINDX, // Glare index int const ZoneNum // Zone number ); @@ -419,7 +424,7 @@ namespace DaylightingManager { Array2 &ElementLuminanceSky, // sky related luminance at window element (exterior side) Array1D &ElementLuminanceSun, // sun related luminance at window element (exterior side), Array1D &ElementLuminanceSunDisk, // sun related luminance at window element (exterior side), - int const CalledFrom, + DataDaylighting::iCalledFor const CalledFrom, Optional_int_const MapNum = _); void DayltgInterReflectedIllumComplexFenestration(EnergyPlusData &state, @@ -428,7 +433,7 @@ namespace DaylightingManager { int const IHR, // Hour of day int const ZoneNum, // Zone number int const iRefPoint, // reference point counter - int const CalledFrom, + DataDaylighting::iCalledFor const CalledFrom, Optional_int_const MapNum = _); void DayltgDirectIllumComplexFenestration(EnergyPlusData &state, @@ -437,7 +442,7 @@ namespace DaylightingManager { int const IHR, // Hour of day int const ZoneNum, // Zone number int const iRefPoint, // reference point index - int const CalledFrom, + DataDaylighting::iCalledFor const CalledFrom, Optional_int_const MapNum = _); void DayltgDirectSunDiskComplexFenestration(EnergyPlusData &state, @@ -447,7 +452,7 @@ namespace DaylightingManager { int const iRefPoint, int const NumEl, // Total number of window elements Real64 const AZVIEW, // Azimuth of view vector in absolute coord system for - int const CalledFrom, // indicate which type of routine called this routine + DataDaylighting::iCalledFor const CalledFrom, // indicate which type of routine called this routine Optional_int_const MapNum = _, Optional MapWindowSolidAngAtRefPtWtd = _); @@ -485,7 +490,7 @@ namespace DaylightingManager { void DayltgSetupAdjZoneListsAndPointers(EnergyPlusData &state); - void CreateShadeDeploymentOrder(int &ZoneNum); + void CreateShadeDeploymentOrder(EnergyPlusData &state, int &ZoneNum); void MapShadeDeploymentOrderToLoopNumber(EnergyPlusData &state, int &ZoneNum); @@ -495,7 +500,8 @@ namespace DaylightingManager { void CheckForGeometricTransform(EnergyPlusData &state, bool &doTransform, Real64 &OldAspectRatio, Real64 &NewAspectRatio); - void WriteDaylightMapTitle(int const mapNum, + void WriteDaylightMapTitle(EnergyPlusData &state, + int const mapNum, InputOutputFile &mapFile, std::string const &mapName, std::string const &environmentName, diff --git a/src/EnergyPlus/HVACInterfaceManager.cc b/src/EnergyPlus/HVACInterfaceManager.cc index 2f1ae5fe6a7..49cc67a8ae7 100644 --- a/src/EnergyPlus/HVACInterfaceManager.cc +++ b/src/EnergyPlus/HVACInterfaceManager.cc @@ -142,8 +142,6 @@ namespace HVACInterfaceManager { // to the inlet node of the corresponding other side of the loop. using DataLoopNode::Node; - using namespace DataConvergParams; - static Array1D TmpRealARR(DataConvergParams::ConvergLogStackDepth); // Tuned Made static Real64 DeltaEnergy; @@ -431,7 +429,6 @@ namespace HVACInterfaceManager { // Using/Aliasing using DataLoopNode::Node; - using namespace DataConvergParams; using DataPlant::DemandSide; using DataPlant::PlantLoop; using FluidProperties::GetSpecificHeatGlycol; diff --git a/src/EnergyPlus/HVACManager.cc b/src/EnergyPlus/HVACManager.cc index faa73ccb430..dd3ec9302ef 100644 --- a/src/EnergyPlus/HVACManager.cc +++ b/src/EnergyPlus/HVACManager.cc @@ -138,7 +138,6 @@ namespace HVACManager { using namespace DataHVACGlobals; using namespace DataLoopNode; using namespace DataAirLoop; - using namespace DataConvergParams; using namespace DataReportingFlags; // Data @@ -3044,7 +3043,7 @@ namespace HVACManager { int ZoneNum; int NodeIndex; int NodeNum; - Array1D tmpRealARR(ConvergLogStackDepth); + Array1D tmpRealARR(DataConvergParams::ConvergLogStackDepth); for (ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ++ZoneNum) { diff --git a/src/EnergyPlus/HeatBalanceManager.cc b/src/EnergyPlus/HeatBalanceManager.cc index acb6b347806..0047a292434 100644 --- a/src/EnergyPlus/HeatBalanceManager.cc +++ b/src/EnergyPlus/HeatBalanceManager.cc @@ -4735,8 +4735,6 @@ namespace HeatBalanceManager { // IDD Definition for Zone object // Using/Aliasing - using DataDaylighting::ZoneDaylight; - // Locals // SUBROUTINE ARGUMENT DEFINITIONS: @@ -4768,7 +4766,7 @@ namespace HeatBalanceManager { Zone.allocate(state.dataGlobal->NumOfZones); DataViewFactorInformation::ZoneRadiantInfo.allocate(state.dataGlobal->NumOfZones); DataViewFactorInformation::ZoneSolarInfo.allocate(state.dataGlobal->NumOfZones); - ZoneDaylight.allocate(state.dataGlobal->NumOfZones); + state.dataDaylightingData->ZoneDaylight.allocate(state.dataGlobal->NumOfZones); ZoneLoop = 0; @@ -5110,8 +5108,6 @@ namespace HeatBalanceManager { // IDD Definition for Zone object // Using/Aliasing - using DataDaylighting::ZoneDaylight; - // Locals // SUBROUTINE ARGUMENT DEFINITIONS: diff --git a/src/EnergyPlus/HeatBalanceSurfaceManager.cc b/src/EnergyPlus/HeatBalanceSurfaceManager.cc index 3cd5eca77a8..3cb067bccf8 100644 --- a/src/EnergyPlus/HeatBalanceSurfaceManager.cc +++ b/src/EnergyPlus/HeatBalanceSurfaceManager.cc @@ -353,10 +353,6 @@ namespace HeatBalanceSurfaceManager { // na // Using/Aliasing - using DataDaylighting::mapResultsToReport; - using DataDaylighting::NoDaylighting; - using DataDaylighting::TotIllumMaps; - using DataDaylighting::ZoneDaylight; using DataDaylightingDevices::NumOfTDDPipes; using DataDElight::LUX2FC; using namespace SolarShading; @@ -543,17 +539,17 @@ namespace HeatBalanceSurfaceManager { } for (int NZ = 1; NZ <= state.dataGlobal->NumOfZones; ++NZ) { - if (ZoneDaylight(NZ).DaylightMethod == NoDaylighting) continue; - ZoneDaylight(NZ).DaylIllumAtRefPt = 0.0; - ZoneDaylight(NZ).GlareIndexAtRefPt = 0.0; - ZoneDaylight(NZ).ZonePowerReductionFactor = 1.0; - ZoneDaylight(NZ).InterReflIllFrIntWins = 0.0; // inter-reflected illuminance from interior windows - if (ZoneDaylight(NZ).TotalDaylRefPoints != 0) { - ZoneDaylight(NZ).TimeExceedingGlareIndexSPAtRefPt = 0.0; - ZoneDaylight(NZ).TimeExceedingDaylightIlluminanceSPAtRefPt = 0.0; + if (state.dataDaylightingData->ZoneDaylight(NZ).DaylightMethod == DataDaylighting::iDaylightingMethod::NoDaylighting) continue; + state.dataDaylightingData->ZoneDaylight(NZ).DaylIllumAtRefPt = 0.0; + state.dataDaylightingData->ZoneDaylight(NZ).GlareIndexAtRefPt = 0.0; + state.dataDaylightingData->ZoneDaylight(NZ).ZonePowerReductionFactor = 1.0; + state.dataDaylightingData->ZoneDaylight(NZ).InterReflIllFrIntWins = 0.0; // inter-reflected illuminance from interior windows + if (state.dataDaylightingData->ZoneDaylight(NZ).TotalDaylRefPoints != 0) { + state.dataDaylightingData->ZoneDaylight(NZ).TimeExceedingGlareIndexSPAtRefPt = 0.0; + state.dataDaylightingData->ZoneDaylight(NZ).TimeExceedingDaylightIlluminanceSPAtRefPt = 0.0; } - if (SunIsUp && ZoneDaylight(NZ).TotalDaylRefPoints != 0) { + if (SunIsUp && state.dataDaylightingData->ZoneDaylight(NZ).TotalDaylRefPoints != 0) { if (InitSurfaceHeatBalancefirstTime) DisplayString(state, "Computing Interior Daylighting Illumination"); DayltgInteriorIllum(state, NZ); if (!state.dataGlobal->DoingSizing) DayltgInteriorMapIllum(state, NZ); @@ -566,7 +562,7 @@ namespace HeatBalanceSurfaceManager { // RJH DElight Modification Begin - Call to DElight electric lighting control subroutine // Check if the sun is up and the current Thermal Zone hosts a Daylighting:DElight object - if (SunIsUp && ZoneDaylight(NZ).TotalDaylRefPoints != 0 && (ZoneDaylight(NZ).DaylightMethod == DataDaylighting::DElightDaylighting)) { + if (SunIsUp && state.dataDaylightingData->ZoneDaylight(NZ).TotalDaylRefPoints != 0 && (state.dataDaylightingData->ZoneDaylight(NZ).DaylightMethod == DataDaylighting::iDaylightingMethod::DElightDaylighting)) { // Call DElight interior illuminance and electric lighting control subroutine Real64 dPowerReducFac = 1.0; // Return value Electric Lighting Power Reduction Factor for current Zone and Timestep Real64 dHISKFFC = HISKF * LUX2FC; @@ -670,8 +666,8 @@ namespace HeatBalanceSurfaceManager { // Increment refpt counter ++iDElightRefPt; // Assure refpt index does not exceed number of refpts in this zone - if (iDElightRefPt <= ZoneDaylight(NZ).TotalDaylRefPoints) { - ZoneDaylight(NZ).DaylIllumAtRefPt(iDElightRefPt) = dRefPtIllum; + if (iDElightRefPt <= state.dataDaylightingData->ZoneDaylight(NZ).TotalDaylRefPoints) { + state.dataDaylightingData->ZoneDaylight(NZ).DaylIllumAtRefPt(iDElightRefPt) = dRefPtIllum; } } @@ -683,7 +679,7 @@ namespace HeatBalanceSurfaceManager { } // Store the calculated total zone Power Reduction Factor due to DElight daylighting // in the ZoneDaylight structure for later use - ZoneDaylight(NZ).ZonePowerReductionFactor = dPowerReducFac; + state.dataDaylightingData->ZoneDaylight(NZ).ZonePowerReductionFactor = dPowerReducFac; } // RJH DElight Modification End - Call to DElight electric lighting control subroutine } @@ -713,19 +709,19 @@ namespace HeatBalanceSurfaceManager { InitSolarHeatGains(state); if (SunIsUp && (BeamSolarRad + GndSolarRad + DifSolarRad > 0.0)) { for (int NZ = 1; NZ <= state.dataGlobal->NumOfZones; ++NZ) { - if (ZoneDaylight(NZ).TotalDaylRefPoints > 0) { + if (state.dataDaylightingData->ZoneDaylight(NZ).TotalDaylRefPoints > 0) { if (Zone(NZ).HasInterZoneWindow) { DayltgInterReflIllFrIntWins(state, NZ); - DayltgGlareWithIntWins(ZoneDaylight(NZ).GlareIndexAtRefPt, NZ); + DayltgGlareWithIntWins(state, state.dataDaylightingData->ZoneDaylight(NZ).GlareIndexAtRefPt, NZ); } DayltgElecLightingControl(state, NZ); } } - } else if (mapResultsToReport && state.dataGlobal->TimeStep == state.dataGlobal->NumOfTimeStepInHour) { - for (int MapNum = 1; MapNum <= TotIllumMaps; ++MapNum) { + } else if (state.dataDaylightingData->mapResultsToReport && state.dataGlobal->TimeStep == state.dataGlobal->NumOfTimeStepInHour) { + for (int MapNum = 1; MapNum <= state.dataDaylightingData->TotIllumMaps; ++MapNum) { ReportIllumMap(state, MapNum); } - mapResultsToReport = false; + state.dataDaylightingData->mapResultsToReport = false; } if (InitSurfaceHeatBalancefirstTime) DisplayString(state, "Initializing Internal Heat Gains"); @@ -5307,7 +5303,7 @@ namespace HeatBalanceSurfaceManager { reportVisualResilienceFirstTime = false; bool hasDayLighting = false; for (int ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ++ZoneNum) { - if (DataDaylighting::ZoneDaylight(ZoneNum).DaylightMethod != DataDaylighting::NoDaylighting) { + if (state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylightMethod != DataDaylighting::iDaylightingMethod::NoDaylighting) { hasDayLighting = true; break; } @@ -5330,18 +5326,18 @@ namespace HeatBalanceSurfaceManager { } for (int ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ++ZoneNum) { // Place holder - if (DataDaylighting::ZoneDaylight(ZoneNum).DaylightMethod == DataDaylighting::NoDaylighting) + if (state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylightMethod == DataDaylighting::iDaylightingMethod::NoDaylighting) continue; - Array1D ZoneIllumRef = DataDaylighting::ZoneDaylight(ZoneNum).DaylIllumAtRefPt; + Array1D ZoneIllumRef = state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylIllumAtRefPt; Real64 ZoneIllum = 0.0; for (size_t i = 1; i <= ZoneIllumRef.size(); i++) { ZoneIllum += ZoneIllumRef(i); } ZoneIllum /= ZoneIllumRef.size(); - if (DataDaylighting::ZoneDaylight(ZoneNum).ZonePowerReductionFactor > 0) { - Array1D ZoneIllumSetpoint = DataDaylighting::ZoneDaylight(ZoneNum).IllumSetPoint; + if (state.dataDaylightingData->ZoneDaylight(ZoneNum).ZonePowerReductionFactor > 0) { + Array1D ZoneIllumSetpoint = state.dataDaylightingData->ZoneDaylight(ZoneNum).IllumSetPoint; ZoneIllum = 0.0; for (size_t i = 1; i <= ZoneIllumSetpoint.size(); i++) { ZoneIllum += ZoneIllumSetpoint(i); diff --git a/src/EnergyPlus/InternalHeatGains.cc b/src/EnergyPlus/InternalHeatGains.cc index d3f19d9ab6f..df7a1ed3349 100644 --- a/src/EnergyPlus/InternalHeatGains.cc +++ b/src/EnergyPlus/InternalHeatGains.cc @@ -5260,7 +5260,6 @@ namespace InternalHeatGains { using DataHeatBalFanSys::SumConvHTRadSys; using DataHeatBalFanSys::ZoneLatentGain; using DataHeatBalFanSys::ZoneLatentGainExceptPeople; - using namespace DataDaylighting; using DataRoomAirModel::IsZoneDV; using DataRoomAirModel::IsZoneUI; using DataRoomAirModel::TCMF; @@ -5436,10 +5435,10 @@ namespace InternalHeatGains { int NZ = Lights(Loop).ZonePtr; Q = Lights(Loop).DesignLevel * GetCurrentScheduleValue(state, Lights(Loop).SchedPtr); - if (ZoneDaylight(NZ).DaylightMethod == SplitFluxDaylighting || ZoneDaylight(NZ).DaylightMethod == DElightDaylighting) { + if (state.dataDaylightingData->ZoneDaylight(NZ).DaylightMethod == DataDaylighting::iDaylightingMethod::SplitFluxDaylighting || state.dataDaylightingData->ZoneDaylight(NZ).DaylightMethod == DataDaylighting::iDaylightingMethod::DElightDaylighting) { if (Lights(Loop).FractionReplaceable > 0.0) { // FractionReplaceable can only be 0 or 1 for these models - Q *= ZoneDaylight(NZ).ZonePowerReductionFactor; + Q *= state.dataDaylightingData->ZoneDaylight(NZ).ZonePowerReductionFactor; } } @@ -6445,8 +6444,6 @@ namespace InternalHeatGains { // level for a zone. // Using/Aliasing - using namespace DataDaylighting; - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int Loop; Real64 LightsRepMin; // Minimum Lighting replacement fraction for any lights statement for this zone @@ -6466,8 +6463,8 @@ namespace InternalHeatGains { LightsRepMin = min(LightsRepMin, Lights(Loop).FractionReplaceable); LightsRepMax = max(LightsRepMax, Lights(Loop).FractionReplaceable); ++NumLights; - if ((ZoneDaylight(Lights(Loop).ZonePtr).DaylightMethod == SplitFluxDaylighting || - ZoneDaylight(Lights(Loop).ZonePtr).DaylightMethod == DElightDaylighting) && + if ((state.dataDaylightingData->ZoneDaylight(Lights(Loop).ZonePtr).DaylightMethod == DataDaylighting::iDaylightingMethod::SplitFluxDaylighting || + state.dataDaylightingData->ZoneDaylight(Lights(Loop).ZonePtr).DaylightMethod == DataDaylighting::iDaylightingMethod::DElightDaylighting) && (Lights(Loop).FractionReplaceable > 0.0 && Lights(Loop).FractionReplaceable < 1.0)) { ShowWarningError(state, "CheckLightsReplaceableMinMaxForZone: Fraction Replaceable must be 0.0 or 1.0 if used with daylighting."); ShowContinueError(state, "..Lights=\"" + Lights(Loop).Name + "\", Fraction Replaceable will be reset to 1.0 to allow dimming controls"); @@ -6476,7 +6473,7 @@ namespace InternalHeatGains { } } - if (ZoneDaylight(WhichZone).DaylightMethod == SplitFluxDaylighting) { + if (state.dataDaylightingData->ZoneDaylight(WhichZone).DaylightMethod == DataDaylighting::iDaylightingMethod::SplitFluxDaylighting) { if (LightsRepMax == 0.0) { ShowWarningError(state, "CheckLightsReplaceable: Zone \"" + Zone(WhichZone).Name + "\" has Daylighting:Controls."); ShowContinueError(state, "but all of the LIGHTS object in that zone have zero Fraction Replaceable."); @@ -6487,7 +6484,7 @@ namespace InternalHeatGains { ShowContinueError(state, "but there are no LIGHTS objects in that zone."); ShowContinueError(state, "The daylighting controls will have no effect."); } - } else if (ZoneDaylight(WhichZone).DaylightMethod == DElightDaylighting) { + } else if (state.dataDaylightingData->ZoneDaylight(WhichZone).DaylightMethod == DataDaylighting::iDaylightingMethod::DElightDaylighting) { if (LightsRepMax == 0.0) { ShowWarningError(state, "CheckLightsReplaceable: Zone \"" + Zone(WhichZone).Name + "\" has Daylighting:Controls."); ShowContinueError(state, "but all of the LIGHTS object in that zone have zero Fraction Replaceable."); diff --git a/src/EnergyPlus/OutputReportTabular.cc b/src/EnergyPlus/OutputReportTabular.cc index ac28537986d..29dc49a8357 100644 --- a/src/EnergyPlus/OutputReportTabular.cc +++ b/src/EnergyPlus/OutputReportTabular.cc @@ -11341,7 +11341,7 @@ namespace OutputReportTabular { using DataHeatBalFanSys::ZoneLightingLevelOccuHourBins; for (int ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ++ZoneNum) { - if (DataDaylighting::ZoneDaylight(ZoneNum).DaylightMethod == DataDaylighting::NoDaylighting) { + if (state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylightMethod == DataDaylighting::iDaylightingMethod::NoDaylighting) { if (displayVisualResilienceSummaryExplicitly) { ShowWarningError(state, "Writing Annual Visual Resilience Summary - Lighting Level Hours reports: " "Zone Average Daylighting Reference Point Illuminance output is required, " diff --git a/src/EnergyPlus/OutputReports.cc b/src/EnergyPlus/OutputReports.cc index 0a3c7cedc0b..d83b6c3e6ae 100644 --- a/src/EnergyPlus/OutputReports.cc +++ b/src/EnergyPlus/OutputReports.cc @@ -453,7 +453,6 @@ static void WriteDXFCommon(EnergyPlusData &state, InputOutputFile &of, const std static void DXFDaylightingReferencePoints(EnergyPlusData &state, InputOutputFile &of, bool const DELight) { using namespace DataSurfaceColors; - using DataDaylighting::ZoneDaylight; using DataHeatBalance::Zone; static constexpr auto Format_709(" 0\nCIRCLE\n 8\n{}\n 62\n{:3}\n 10\n{:15.5F}\n 20\n{:15.5F}\n 30\n{:15.5F}\n 40\n{:15.5F}\n"); @@ -462,15 +461,15 @@ static void DXFDaylightingReferencePoints(EnergyPlusData &state, InputOutputFile for (int zones = 1; zones <= state.dataGlobal->NumOfZones; ++zones) { auto curcolorno = ColorNo_DaylSensor1; - for (int refpt = 1; refpt <= ZoneDaylight(zones).TotalDaylRefPoints; ++refpt) { + for (int refpt = 1; refpt <= state.dataDaylightingData->ZoneDaylight(zones).TotalDaylRefPoints; ++refpt) { print(of, "999\n{}:{}:{}\n", Zone(zones).Name, DELight ? "DEDayRefPt" : "DayRefPt", refpt); print(of, Format_709, normalizeName(Zone(zones).Name), DXFcolorno(curcolorno), - ZoneDaylight(zones).DaylRefPtAbsCoord(1, refpt), - ZoneDaylight(zones).DaylRefPtAbsCoord(2, refpt), - ZoneDaylight(zones).DaylRefPtAbsCoord(3, refpt), + state.dataDaylightingData->ZoneDaylight(zones).DaylRefPtAbsCoord(1, refpt), + state.dataDaylightingData->ZoneDaylight(zones).DaylRefPtAbsCoord(2, refpt), + state.dataDaylightingData->ZoneDaylight(zones).DaylRefPtAbsCoord(3, refpt), 0.2); curcolorno = ColorNo_DaylSensor2; // ref pts 2 and later are this color } @@ -503,8 +502,6 @@ void DXFOut(EnergyPlusData &state, using DataHeatBalance::Zone; using namespace DataSurfaces; using namespace DataSurfaceColors; - using DataDaylighting::IllumMapCalc; - using DataDaylighting::TotIllumMaps; using DataStringGlobals::VerString; using namespace DXFEarClipping; @@ -836,17 +833,17 @@ void DXFOut(EnergyPlusData &state, for (int zones = 1; zones <= state.dataGlobal->NumOfZones; ++zones) { const auto curcolorno = ColorNo_DaylSensor1; - for (int mapnum = 1; mapnum <= TotIllumMaps; ++mapnum) { - if (IllumMapCalc(mapnum).Zone != zones) continue; - for (int refpt = 1; refpt <= IllumMapCalc(mapnum).TotalMapRefPoints; ++refpt) { + for (int mapnum = 1; mapnum <= state.dataDaylightingData->TotIllumMaps; ++mapnum) { + if (state.dataDaylightingData->IllumMapCalc(mapnum).Zone != zones) continue; + for (int refpt = 1; refpt <= state.dataDaylightingData->IllumMapCalc(mapnum).TotalMapRefPoints; ++refpt) { print(dxffile, Format_710, format("{}:MapRefPt:{}", Zone(zones).Name, refpt)); print(dxffile, Format_709, normalizeName(Zone(zones).Name), DXFcolorno(curcolorno), - IllumMapCalc(mapnum).MapRefPtAbsCoord(1, refpt), - IllumMapCalc(mapnum).MapRefPtAbsCoord(2, refpt), - IllumMapCalc(mapnum).MapRefPtAbsCoord(3, refpt), + state.dataDaylightingData->IllumMapCalc(mapnum).MapRefPtAbsCoord(1, refpt), + state.dataDaylightingData->IllumMapCalc(mapnum).MapRefPtAbsCoord(2, refpt), + state.dataDaylightingData->IllumMapCalc(mapnum).MapRefPtAbsCoord(3, refpt), 0.05); } } @@ -881,7 +878,6 @@ void DXFOutLines(EnergyPlusData &state, std::string const &ColorScheme) using DataHeatBalance::Zone; using namespace DataSurfaces; using namespace DataSurfaceColors; - using DataDaylighting::ZoneDaylight; using DataStringGlobals::VerString; // Locals @@ -1092,7 +1088,6 @@ void DXFOutWireFrame(EnergyPlusData &state, std::string const &ColorScheme) using DataHeatBalance::Zone; using namespace DataSurfaces; using namespace DataSurfaceColors; - using DataDaylighting::ZoneDaylight; using DataStringGlobals::VerString; // Locals @@ -1831,7 +1826,6 @@ void VRMLOut(EnergyPlusData &state, const std::string &PolygonAction, const std: using DataHeatBalance::BuildingName; using DataHeatBalance::Zone; using namespace DataSurfaces; - using DataDaylighting::ZoneDaylight; using DataStringGlobals::VerString; using namespace DXFEarClipping; diff --git a/src/EnergyPlus/SimulationManager.cc b/src/EnergyPlus/SimulationManager.cc index 9b42f055e15..706fc4a1129 100644 --- a/src/EnergyPlus/SimulationManager.cc +++ b/src/EnergyPlus/SimulationManager.cc @@ -703,7 +703,6 @@ namespace SimulationManager { // Using/Aliasing using DataStringGlobals::MatchVersion; - using namespace DataConvergParams; using namespace DataSystemVariables; using DataEnvironment::DisplayWeatherMissingDataWarnings; using DataEnvironment::IgnoreBeamRadiation; diff --git a/src/EnergyPlus/SolarShading.cc b/src/EnergyPlus/SolarShading.cc index 156519bacae..260b2b24c3e 100644 --- a/src/EnergyPlus/SolarShading.cc +++ b/src/EnergyPlus/SolarShading.cc @@ -8836,7 +8836,6 @@ namespace SolarShading { // na // Using/Aliasing - using DataDaylighting::ZoneDaylight; using DataHeatBalFanSys::MAT; using DataWindowEquivalentLayer::CFS; using General::POLYF; @@ -8967,7 +8966,7 @@ namespace SolarShading { SchedAllowsControl = false; } - Real64 GlareControlIsActive = (ZoneDaylight(IZone).TotalDaylRefPoints > 0 && SunIsUp && + Real64 GlareControlIsActive = (state.dataDaylightingData->ZoneDaylight(IZone).TotalDaylRefPoints > 0 && SunIsUp && WindowShadingControl(IShadingCtrl).GlareControlIsActive); // True if glare control is active Real64 SolarOnWindow = 0.0; // Direct plus diffuse solar intensity on window (W/m2) diff --git a/src/EnergyPlus/SurfaceGeometry.cc b/src/EnergyPlus/SurfaceGeometry.cc index e760f803268..e441489d981 100644 --- a/src/EnergyPlus/SurfaceGeometry.cc +++ b/src/EnergyPlus/SurfaceGeometry.cc @@ -2246,7 +2246,7 @@ namespace SurfaceGeometry { int TotShadSurf = TotDetachedFixed + TotDetachedBldg + TotRectDetachedFixed + TotRectDetachedBldg + TotShdSubs + TotOverhangs + TotOverhangsProjection + TotFins + TotFinsProjection; int NumDElightCmplxFen = inputProcessor->getNumObjectsFound(state, "Daylighting:DElight:ComplexFenestration"); - if (TotShadSurf > 0 && (NumDElightCmplxFen > 0 || DaylightingManager::doesDayLightingUseDElight())) { + if (TotShadSurf > 0 && (NumDElightCmplxFen > 0 || DaylightingManager::doesDayLightingUseDElight(state))) { ShowWarningError(state, RoutineName + "When using DElight daylighting the presence of exterior shading surfaces is ignored."); } } diff --git a/src/EnergyPlus/ZoneContaminantPredictorCorrector.cc b/src/EnergyPlus/ZoneContaminantPredictorCorrector.cc index c0658c84355..ad245013915 100644 --- a/src/EnergyPlus/ZoneContaminantPredictorCorrector.cc +++ b/src/EnergyPlus/ZoneContaminantPredictorCorrector.cc @@ -105,7 +105,6 @@ namespace ZoneContaminantPredictorCorrector { using DataEnvironment::OutBaroPress; using DataEnvironment::OutHumRat; using namespace Psychrometrics; - using namespace DataContaminantBalance; using namespace HybridModel; using ScheduleManager::GetCurrentScheduleValue; using ZoneTempPredictorCorrector::DownInterpolate4HistoryValues; diff --git a/tst/EnergyPlus/unit/DElightManager.unit.cc b/tst/EnergyPlus/unit/DElightManager.unit.cc index 135fd8317d7..e2e695d0ea0 100644 --- a/tst/EnergyPlus/unit/DElightManager.unit.cc +++ b/tst/EnergyPlus/unit/DElightManager.unit.cc @@ -351,11 +351,11 @@ TEST_F(EnergyPlusFixture, DElightManagerF_GetInputDElightComplexFenestration_Tes compare_err_stream(""); EXPECT_FALSE(foundErrors); // expect no errors - EXPECT_EQ(1, TotDElightCFS); + EXPECT_EQ(1, state->dataDaylightingData->TotDElightCFS); - EXPECT_EQ("TEST CFS", DElightComplexFene(1).Name); - EXPECT_EQ("BTDF^GEN^LIGHTSHELF^1.0^20.0", DElightComplexFene(1).ComplexFeneType); - EXPECT_EQ("ZN001:WALL001", DElightComplexFene(1).surfName); - EXPECT_EQ("ZN001:WALL001:WIN001", DElightComplexFene(1).wndwName); - EXPECT_EQ(0., DElightComplexFene(1).feneRota); + EXPECT_EQ("TEST CFS", state->dataDaylightingData->DElightComplexFene(1).Name); + EXPECT_EQ("BTDF^GEN^LIGHTSHELF^1.0^20.0", state->dataDaylightingData->DElightComplexFene(1).ComplexFeneType); + EXPECT_EQ("ZN001:WALL001", state->dataDaylightingData->DElightComplexFene(1).surfName); + EXPECT_EQ("ZN001:WALL001:WIN001", state->dataDaylightingData->DElightComplexFene(1).wndwName); + EXPECT_EQ(0., state->dataDaylightingData->DElightComplexFene(1).feneRota); } diff --git a/tst/EnergyPlus/unit/DaylightingManager.unit.cc b/tst/EnergyPlus/unit/DaylightingManager.unit.cc index 9c3c163dd9b..075cb1bf3b1 100644 --- a/tst/EnergyPlus/unit/DaylightingManager.unit.cc +++ b/tst/EnergyPlus/unit/DaylightingManager.unit.cc @@ -135,33 +135,33 @@ TEST_F(EnergyPlusFixture, DaylightingManager_GetInputDaylightingControls_Test) GetInputDayliteRefPt(*state, foundErrors); compare_err_stream(""); EXPECT_FALSE(foundErrors); - EXPECT_EQ(1, TotRefPoints); + EXPECT_EQ(1, state->dataDaylightingData->TotRefPoints); GetDaylightingControls(*state, numObjs, foundErrors); compare_err_stream(""); EXPECT_FALSE(foundErrors); EXPECT_EQ(1, numObjs); - EXPECT_EQ("WEST ZONE_DAYLCTRL", ZoneDaylight(1).Name); - EXPECT_EQ("WEST ZONE", ZoneDaylight(1).ZoneName); - EXPECT_EQ(SplitFluxDaylighting, ZoneDaylight(1).DaylightMethod); - EXPECT_EQ(Continuous, ZoneDaylight(1).LightControlType); + EXPECT_EQ("WEST ZONE_DAYLCTRL", state->dataDaylightingData->ZoneDaylight(1).Name); + EXPECT_EQ("WEST ZONE", state->dataDaylightingData->ZoneDaylight(1).ZoneName); + EXPECT_EQ(DataDaylighting::iDaylightingMethod::SplitFluxDaylighting, state->dataDaylightingData->ZoneDaylight(1).DaylightMethod); + EXPECT_EQ(DataDaylighting::iLtgCtrlType::Continuous, state->dataDaylightingData->ZoneDaylight(1).LightControlType); - EXPECT_EQ(0.3, ZoneDaylight(1).MinPowerFraction); - EXPECT_EQ(0.2, ZoneDaylight(1).MinLightFraction); - EXPECT_EQ(1, ZoneDaylight(1).LightControlSteps); - EXPECT_EQ(1.0, ZoneDaylight(1).LightControlProbability); + EXPECT_EQ(0.3, state->dataDaylightingData->ZoneDaylight(1).MinPowerFraction); + EXPECT_EQ(0.2, state->dataDaylightingData->ZoneDaylight(1).MinLightFraction); + EXPECT_EQ(1, state->dataDaylightingData->ZoneDaylight(1).LightControlSteps); + EXPECT_EQ(1.0, state->dataDaylightingData->ZoneDaylight(1).LightControlProbability); - EXPECT_EQ(1, ZoneDaylight(1).glareRefPtNumber); - EXPECT_EQ(180., ZoneDaylight(1).ViewAzimuthForGlare); - EXPECT_EQ(20., ZoneDaylight(1).MaxGlareallowed); - EXPECT_EQ(0, ZoneDaylight(1).DElightGriddingResolution); + EXPECT_EQ(1, state->dataDaylightingData->ZoneDaylight(1).glareRefPtNumber); + EXPECT_EQ(180., state->dataDaylightingData->ZoneDaylight(1).ViewAzimuthForGlare); + EXPECT_EQ(20., state->dataDaylightingData->ZoneDaylight(1).MaxGlareallowed); + EXPECT_EQ(0, state->dataDaylightingData->ZoneDaylight(1).DElightGriddingResolution); - EXPECT_EQ(1, ZoneDaylight(1).TotalDaylRefPoints); + EXPECT_EQ(1, state->dataDaylightingData->ZoneDaylight(1).TotalDaylRefPoints); - EXPECT_EQ(1, ZoneDaylight(1).DaylRefPtNum(1)); - EXPECT_EQ(1., ZoneDaylight(1).FracZoneDaylit(1)); - EXPECT_EQ(500., ZoneDaylight(1).IllumSetPoint(1)); + EXPECT_EQ(1, state->dataDaylightingData->ZoneDaylight(1).DaylRefPtNum(1)); + EXPECT_EQ(1., state->dataDaylightingData->ZoneDaylight(1).FracZoneDaylit(1)); + EXPECT_EQ(500., state->dataDaylightingData->ZoneDaylight(1).IllumSetPoint(1)); } TEST_F(EnergyPlusFixture, DaylightingManager_GetInputDaylightingControls_3RefPt_Test) @@ -237,41 +237,41 @@ TEST_F(EnergyPlusFixture, DaylightingManager_GetInputDaylightingControls_3RefPt_ GetInputDayliteRefPt(*state, foundErrors); compare_err_stream(""); EXPECT_FALSE(foundErrors); - EXPECT_EQ(3, TotRefPoints); + EXPECT_EQ(3, state->dataDaylightingData->TotRefPoints); GetDaylightingControls(*state, numObjs, foundErrors); compare_err_stream(""); EXPECT_FALSE(foundErrors); EXPECT_EQ(1, numObjs); - EXPECT_EQ("WEST ZONE_DAYLCTRL", ZoneDaylight(1).Name); - EXPECT_EQ("WEST ZONE", ZoneDaylight(1).ZoneName); - EXPECT_EQ(SplitFluxDaylighting, ZoneDaylight(1).DaylightMethod); - EXPECT_EQ(Continuous, ZoneDaylight(1).LightControlType); + EXPECT_EQ("WEST ZONE_DAYLCTRL", state->dataDaylightingData->ZoneDaylight(1).Name); + EXPECT_EQ("WEST ZONE", state->dataDaylightingData->ZoneDaylight(1).ZoneName); + EXPECT_EQ(DataDaylighting::iDaylightingMethod::SplitFluxDaylighting, state->dataDaylightingData->ZoneDaylight(1).DaylightMethod); + EXPECT_EQ(DataDaylighting::iLtgCtrlType::Continuous, state->dataDaylightingData->ZoneDaylight(1).LightControlType); - EXPECT_EQ(0.3, ZoneDaylight(1).MinPowerFraction); - EXPECT_EQ(0.2, ZoneDaylight(1).MinLightFraction); - EXPECT_EQ(1, ZoneDaylight(1).LightControlSteps); - EXPECT_EQ(1.0, ZoneDaylight(1).LightControlProbability); + EXPECT_EQ(0.3, state->dataDaylightingData->ZoneDaylight(1).MinPowerFraction); + EXPECT_EQ(0.2, state->dataDaylightingData->ZoneDaylight(1).MinLightFraction); + EXPECT_EQ(1, state->dataDaylightingData->ZoneDaylight(1).LightControlSteps); + EXPECT_EQ(1.0, state->dataDaylightingData->ZoneDaylight(1).LightControlProbability); - EXPECT_EQ(1, ZoneDaylight(1).glareRefPtNumber); - EXPECT_EQ(180., ZoneDaylight(1).ViewAzimuthForGlare); - EXPECT_EQ(20., ZoneDaylight(1).MaxGlareallowed); - EXPECT_EQ(0, ZoneDaylight(1).DElightGriddingResolution); + EXPECT_EQ(1, state->dataDaylightingData->ZoneDaylight(1).glareRefPtNumber); + EXPECT_EQ(180., state->dataDaylightingData->ZoneDaylight(1).ViewAzimuthForGlare); + EXPECT_EQ(20., state->dataDaylightingData->ZoneDaylight(1).MaxGlareallowed); + EXPECT_EQ(0, state->dataDaylightingData->ZoneDaylight(1).DElightGriddingResolution); - EXPECT_EQ(3, ZoneDaylight(1).TotalDaylRefPoints); + EXPECT_EQ(3, state->dataDaylightingData->ZoneDaylight(1).TotalDaylRefPoints); - EXPECT_EQ(1, ZoneDaylight(1).DaylRefPtNum(1)); - EXPECT_EQ(0.35, ZoneDaylight(1).FracZoneDaylit(1)); - EXPECT_EQ(400., ZoneDaylight(1).IllumSetPoint(1)); + EXPECT_EQ(1, state->dataDaylightingData->ZoneDaylight(1).DaylRefPtNum(1)); + EXPECT_EQ(0.35, state->dataDaylightingData->ZoneDaylight(1).FracZoneDaylit(1)); + EXPECT_EQ(400., state->dataDaylightingData->ZoneDaylight(1).IllumSetPoint(1)); - EXPECT_EQ(2, ZoneDaylight(1).DaylRefPtNum(2)); - EXPECT_EQ(0.4, ZoneDaylight(1).FracZoneDaylit(2)); - EXPECT_EQ(500., ZoneDaylight(1).IllumSetPoint(2)); + EXPECT_EQ(2, state->dataDaylightingData->ZoneDaylight(1).DaylRefPtNum(2)); + EXPECT_EQ(0.4, state->dataDaylightingData->ZoneDaylight(1).FracZoneDaylit(2)); + EXPECT_EQ(500., state->dataDaylightingData->ZoneDaylight(1).IllumSetPoint(2)); - EXPECT_EQ(3, ZoneDaylight(1).DaylRefPtNum(3)); - EXPECT_EQ(0.25, ZoneDaylight(1).FracZoneDaylit(3)); - EXPECT_EQ(450., ZoneDaylight(1).IllumSetPoint(3)); + EXPECT_EQ(3, state->dataDaylightingData->ZoneDaylight(1).DaylRefPtNum(3)); + EXPECT_EQ(0.25, state->dataDaylightingData->ZoneDaylight(1).FracZoneDaylit(3)); + EXPECT_EQ(450., state->dataDaylightingData->ZoneDaylight(1).IllumSetPoint(3)); } TEST_F(EnergyPlusFixture, DaylightingManager_GetInputDayliteRefPt_Test) @@ -322,25 +322,25 @@ TEST_F(EnergyPlusFixture, DaylightingManager_GetInputDayliteRefPt_Test) GetInputDayliteRefPt(*state, foundErrors); compare_err_stream(""); EXPECT_FALSE(foundErrors); - EXPECT_EQ(3, TotRefPoints); - - EXPECT_EQ("WEST ZONE_DAYLREFPT1", DaylRefPt(1).Name); - EXPECT_EQ(1, DaylRefPt(1).ZoneNum); - EXPECT_EQ(3.048, DaylRefPt(1).x); - EXPECT_EQ(2.048, DaylRefPt(1).y); - EXPECT_EQ(0.7, DaylRefPt(1).z); - - EXPECT_EQ("WEST ZONE_DAYLREFPT2", DaylRefPt(2).Name); - EXPECT_EQ(1, DaylRefPt(2).ZoneNum); - EXPECT_EQ(3.048, DaylRefPt(2).x); - EXPECT_EQ(3.048, DaylRefPt(2).y); - EXPECT_EQ(0.8, DaylRefPt(2).z); - - EXPECT_EQ("WEST ZONE_DAYLREFPT3", DaylRefPt(3).Name); - EXPECT_EQ(1, DaylRefPt(3).ZoneNum); - EXPECT_EQ(3.048, DaylRefPt(3).x); - EXPECT_EQ(4.048, DaylRefPt(3).y); - EXPECT_EQ(0.9, DaylRefPt(3).z); + EXPECT_EQ(3, state->dataDaylightingData->TotRefPoints); + + EXPECT_EQ("WEST ZONE_DAYLREFPT1", state->dataDaylightingData->DaylRefPt(1).Name); + EXPECT_EQ(1, state->dataDaylightingData->DaylRefPt(1).ZoneNum); + EXPECT_EQ(3.048, state->dataDaylightingData->DaylRefPt(1).x); + EXPECT_EQ(2.048, state->dataDaylightingData->DaylRefPt(1).y); + EXPECT_EQ(0.7, state->dataDaylightingData->DaylRefPt(1).z); + + EXPECT_EQ("WEST ZONE_DAYLREFPT2", state->dataDaylightingData->DaylRefPt(2).Name); + EXPECT_EQ(1, state->dataDaylightingData->DaylRefPt(2).ZoneNum); + EXPECT_EQ(3.048, state->dataDaylightingData->DaylRefPt(2).x); + EXPECT_EQ(3.048, state->dataDaylightingData->DaylRefPt(2).y); + EXPECT_EQ(0.8, state->dataDaylightingData->DaylRefPt(2).z); + + EXPECT_EQ("WEST ZONE_DAYLREFPT3", state->dataDaylightingData->DaylRefPt(3).Name); + EXPECT_EQ(1, state->dataDaylightingData->DaylRefPt(3).ZoneNum); + EXPECT_EQ(3.048, state->dataDaylightingData->DaylRefPt(3).x); + EXPECT_EQ(4.048, state->dataDaylightingData->DaylRefPt(3).y); + EXPECT_EQ(0.9, state->dataDaylightingData->DaylRefPt(3).z); } TEST_F(EnergyPlusFixture, DaylightingManager_GetInputOutputIlluminanceMap_Test) @@ -384,36 +384,36 @@ TEST_F(EnergyPlusFixture, DaylightingManager_GetInputOutputIlluminanceMap_Test) GetInputIlluminanceMap(*state, foundErrors); // compare_err_stream(""); // expecting errors because zone is not really defined - EXPECT_EQ(1, TotIllumMaps); + EXPECT_EQ(1, state->dataDaylightingData->TotIllumMaps); - EXPECT_EQ("MAP1", IllumMap(1).Name); - EXPECT_EQ(1, IllumMap(1).Zone); - EXPECT_EQ(0, IllumMap(1).Z); - EXPECT_EQ(0.1, IllumMap(1).Xmin); - EXPECT_EQ(6.0, IllumMap(1).Xmax); - EXPECT_EQ(10, IllumMap(1).Xnum); - EXPECT_EQ(0.2, IllumMap(1).Ymin); - EXPECT_EQ(5.0, IllumMap(1).Ymax); - EXPECT_EQ(11, IllumMap(1).Ynum); + EXPECT_EQ("MAP1", state->dataDaylightingData->IllumMap(1).Name); + EXPECT_EQ(1, state->dataDaylightingData->IllumMap(1).Zone); + EXPECT_EQ(0, state->dataDaylightingData->IllumMap(1).Z); + EXPECT_EQ(0.1, state->dataDaylightingData->IllumMap(1).Xmin); + EXPECT_EQ(6.0, state->dataDaylightingData->IllumMap(1).Xmax); + EXPECT_EQ(10, state->dataDaylightingData->IllumMap(1).Xnum); + EXPECT_EQ(0.2, state->dataDaylightingData->IllumMap(1).Ymin); + EXPECT_EQ(5.0, state->dataDaylightingData->IllumMap(1).Ymax); + EXPECT_EQ(11, state->dataDaylightingData->IllumMap(1).Ynum); // OutputControl:IlluminanceMap:Style - EXPECT_EQ(',', MapColSep); + EXPECT_EQ(',', state->dataDaylightingData->MapColSep); } TEST_F(EnergyPlusFixture, DaylightingManager_doesDayLightingUseDElight_Test) { - EXPECT_FALSE(doesDayLightingUseDElight()); + EXPECT_FALSE(doesDayLightingUseDElight(*state)); - ZoneDaylight.allocate(3); - ZoneDaylight(1).DaylightMethod = SplitFluxDaylighting; - ZoneDaylight(2).DaylightMethod = SplitFluxDaylighting; - ZoneDaylight(3).DaylightMethod = SplitFluxDaylighting; + state->dataDaylightingData->ZoneDaylight.allocate(3); + state->dataDaylightingData->ZoneDaylight(1).DaylightMethod = DataDaylighting::iDaylightingMethod::SplitFluxDaylighting; + state->dataDaylightingData->ZoneDaylight(2).DaylightMethod = DataDaylighting::iDaylightingMethod::SplitFluxDaylighting; + state->dataDaylightingData->ZoneDaylight(3).DaylightMethod = DataDaylighting::iDaylightingMethod::SplitFluxDaylighting; - EXPECT_FALSE(doesDayLightingUseDElight()); + EXPECT_FALSE(doesDayLightingUseDElight(*state)); - ZoneDaylight(2).DaylightMethod = DElightDaylighting; + state->dataDaylightingData->ZoneDaylight(2).DaylightMethod = DataDaylighting::iDaylightingMethod::DElightDaylighting; - EXPECT_TRUE(doesDayLightingUseDElight()); + EXPECT_TRUE(doesDayLightingUseDElight(*state)); } TEST_F(EnergyPlusFixture, DaylightingManager_GetDaylParamInGeoTrans_Test) @@ -858,27 +858,27 @@ TEST_F(EnergyPlusFixture, DaylightingManager_GetDaylParamInGeoTrans_Test) GetDaylightingParametersInput(*state); compare_err_stream(""); - EXPECT_EQ(3, TotRefPoints); + EXPECT_EQ(3, state->dataDaylightingData->TotRefPoints); - EXPECT_NEAR(2.048, ZoneDaylight(1).DaylRefPtAbsCoord(1, 1), 0.001); - EXPECT_NEAR(3.048, ZoneDaylight(1).DaylRefPtAbsCoord(2, 1), 0.001); - EXPECT_NEAR(0.9, ZoneDaylight(1).DaylRefPtAbsCoord(3, 1), 0.001); + EXPECT_NEAR(2.048, state->dataDaylightingData->ZoneDaylight(1).DaylRefPtAbsCoord(1, 1), 0.001); + EXPECT_NEAR(3.048, state->dataDaylightingData->ZoneDaylight(1).DaylRefPtAbsCoord(2, 1), 0.001); + EXPECT_NEAR(0.9, state->dataDaylightingData->ZoneDaylight(1).DaylRefPtAbsCoord(3, 1), 0.001); DataHeatBalance::Zone(1).RelNorth = 45.; GeometryTransformForDaylighting(*state); - EXPECT_NEAR(3.603, ZoneDaylight(1).DaylRefPtAbsCoord(1, 1), 0.001); - EXPECT_NEAR(0.707, ZoneDaylight(1).DaylRefPtAbsCoord(2, 1), 0.001); - EXPECT_NEAR(0.9, ZoneDaylight(1).DaylRefPtAbsCoord(3, 1), 0.001); + EXPECT_NEAR(3.603, state->dataDaylightingData->ZoneDaylight(1).DaylRefPtAbsCoord(1, 1), 0.001); + EXPECT_NEAR(0.707, state->dataDaylightingData->ZoneDaylight(1).DaylRefPtAbsCoord(2, 1), 0.001); + EXPECT_NEAR(0.9, state->dataDaylightingData->ZoneDaylight(1).DaylRefPtAbsCoord(3, 1), 0.001); DataHeatBalance::Zone(1).RelNorth = 90.; GeometryTransformForDaylighting(*state); - EXPECT_NEAR(3.048, ZoneDaylight(1).DaylRefPtAbsCoord(1, 1), 0.001); - EXPECT_NEAR(-2.048, ZoneDaylight(1).DaylRefPtAbsCoord(2, 1), 0.001); - EXPECT_NEAR(0.9, ZoneDaylight(1).DaylRefPtAbsCoord(3, 1), 0.001); + EXPECT_NEAR(3.048, state->dataDaylightingData->ZoneDaylight(1).DaylRefPtAbsCoord(1, 1), 0.001); + EXPECT_NEAR(-2.048, state->dataDaylightingData->ZoneDaylight(1).DaylRefPtAbsCoord(2, 1), 0.001); + EXPECT_NEAR(0.9, state->dataDaylightingData->ZoneDaylight(1).DaylRefPtAbsCoord(3, 1), 0.001); state->dataGlobal->BeginSimFlag = true; state->dataGlobal->WeightNow = 1.0; @@ -928,11 +928,11 @@ TEST_F(EnergyPlusFixture, DaylightingManager_ProfileAngle_Test) TEST_F(EnergyPlusFixture, AssociateWindowShadingControlWithDaylighting_Test) { state->dataGlobal->NumOfZones = 4; - ZoneDaylight.allocate(state->dataGlobal->NumOfZones); - ZoneDaylight(1).Name = "ZD1"; - ZoneDaylight(2).Name = "ZD2"; - ZoneDaylight(3).Name = "ZD3"; - ZoneDaylight(4).Name = "ZD4"; + state->dataDaylightingData->ZoneDaylight.allocate(state->dataGlobal->NumOfZones); + state->dataDaylightingData->ZoneDaylight(1).Name = "ZD1"; + state->dataDaylightingData->ZoneDaylight(2).Name = "ZD2"; + state->dataDaylightingData->ZoneDaylight(3).Name = "ZD3"; + state->dataDaylightingData->ZoneDaylight(4).Name = "ZD4"; TotWinShadingControl = 3; WindowShadingControl.allocate(TotWinShadingControl); @@ -990,38 +990,38 @@ TEST_F(EnergyPlusFixture, CreateShadeDeploymentOrder_test) WindowShadingControl(3).FenestrationIndex(2) = 9; state->dataGlobal->NumOfZones = zn; - ZoneDaylight.allocate(state->dataGlobal->NumOfZones); + state->dataDaylightingData->ZoneDaylight.allocate(state->dataGlobal->NumOfZones); - CreateShadeDeploymentOrder(zn); + CreateShadeDeploymentOrder(*state, zn); - EXPECT_EQ(ZoneDaylight(zn).ShadeDeployOrderExtWins.size(), 6ul); + EXPECT_EQ(state->dataDaylightingData->ZoneDaylight(zn).ShadeDeployOrderExtWins.size(), 6ul); std::vector compare1; compare1.push_back(8); compare1.push_back(9); - EXPECT_EQ(ZoneDaylight(zn).ShadeDeployOrderExtWins[0], compare1); + EXPECT_EQ(state->dataDaylightingData->ZoneDaylight(zn).ShadeDeployOrderExtWins[0], compare1); std::vector compare2; compare2.push_back(1); compare2.push_back(2); compare2.push_back(3); - EXPECT_EQ(ZoneDaylight(zn).ShadeDeployOrderExtWins[1], compare2); + EXPECT_EQ(state->dataDaylightingData->ZoneDaylight(zn).ShadeDeployOrderExtWins[1], compare2); std::vector compare3; compare3.push_back(4); - EXPECT_EQ(ZoneDaylight(zn).ShadeDeployOrderExtWins[2], compare3); + EXPECT_EQ(state->dataDaylightingData->ZoneDaylight(zn).ShadeDeployOrderExtWins[2], compare3); std::vector compare4; compare4.push_back(5); - EXPECT_EQ(ZoneDaylight(zn).ShadeDeployOrderExtWins[3], compare4); + EXPECT_EQ(state->dataDaylightingData->ZoneDaylight(zn).ShadeDeployOrderExtWins[3], compare4); std::vector compare5; compare5.push_back(6); - EXPECT_EQ(ZoneDaylight(zn).ShadeDeployOrderExtWins[4], compare5); + EXPECT_EQ(state->dataDaylightingData->ZoneDaylight(zn).ShadeDeployOrderExtWins[4], compare5); std::vector compare6; compare6.push_back(7); - EXPECT_EQ(ZoneDaylight(zn).ShadeDeployOrderExtWins[5], compare6); + EXPECT_EQ(state->dataDaylightingData->ZoneDaylight(zn).ShadeDeployOrderExtWins[5], compare6); } TEST_F(EnergyPlusFixture, MapShadeDeploymentOrderToLoopNumber_Test) @@ -1061,37 +1061,37 @@ TEST_F(EnergyPlusFixture, MapShadeDeploymentOrderToLoopNumber_Test) WindowShadingControl(3).FenestrationIndex(2) = 9; state->dataGlobal->NumOfZones = zn; - ZoneDaylight.allocate(state->dataGlobal->NumOfZones); - - CreateShadeDeploymentOrder(zn); - - EXPECT_EQ(ZoneDaylight(zn).ShadeDeployOrderExtWins.size(), 6ul); - - ZoneDaylight(zn).TotalDaylRefPoints = 1; - ZoneDaylight(zn).NumOfDayltgExtWins = 9; - ZoneDaylight(zn).MapShdOrdToLoopNum.allocate(ZoneDaylight(zn).NumOfDayltgExtWins); - ZoneDaylight(zn).DayltgExtWinSurfNums.allocate(ZoneDaylight(zn).NumOfDayltgExtWins); - ZoneDaylight(zn).DayltgExtWinSurfNums(1) = 1; - ZoneDaylight(zn).DayltgExtWinSurfNums(2) = 2; - ZoneDaylight(zn).DayltgExtWinSurfNums(3) = 3; - ZoneDaylight(zn).DayltgExtWinSurfNums(4) = 4; - ZoneDaylight(zn).DayltgExtWinSurfNums(5) = 5; - ZoneDaylight(zn).DayltgExtWinSurfNums(6) = 6; - ZoneDaylight(zn).DayltgExtWinSurfNums(7) = 7; - ZoneDaylight(zn).DayltgExtWinSurfNums(8) = 8; - ZoneDaylight(zn).DayltgExtWinSurfNums(9) = 9; + state->dataDaylightingData->ZoneDaylight.allocate(state->dataGlobal->NumOfZones); + + CreateShadeDeploymentOrder(*state, zn); + + EXPECT_EQ(state->dataDaylightingData->ZoneDaylight(zn).ShadeDeployOrderExtWins.size(), 6ul); + + state->dataDaylightingData->ZoneDaylight(zn).TotalDaylRefPoints = 1; + state->dataDaylightingData->ZoneDaylight(zn).NumOfDayltgExtWins = 9; + state->dataDaylightingData->ZoneDaylight(zn).MapShdOrdToLoopNum.allocate(state->dataDaylightingData->ZoneDaylight(zn).NumOfDayltgExtWins); + state->dataDaylightingData->ZoneDaylight(zn).DayltgExtWinSurfNums.allocate(state->dataDaylightingData->ZoneDaylight(zn).NumOfDayltgExtWins); + state->dataDaylightingData->ZoneDaylight(zn).DayltgExtWinSurfNums(1) = 1; + state->dataDaylightingData->ZoneDaylight(zn).DayltgExtWinSurfNums(2) = 2; + state->dataDaylightingData->ZoneDaylight(zn).DayltgExtWinSurfNums(3) = 3; + state->dataDaylightingData->ZoneDaylight(zn).DayltgExtWinSurfNums(4) = 4; + state->dataDaylightingData->ZoneDaylight(zn).DayltgExtWinSurfNums(5) = 5; + state->dataDaylightingData->ZoneDaylight(zn).DayltgExtWinSurfNums(6) = 6; + state->dataDaylightingData->ZoneDaylight(zn).DayltgExtWinSurfNums(7) = 7; + state->dataDaylightingData->ZoneDaylight(zn).DayltgExtWinSurfNums(8) = 8; + state->dataDaylightingData->ZoneDaylight(zn).DayltgExtWinSurfNums(9) = 9; MapShadeDeploymentOrderToLoopNumber(*state, zn); - EXPECT_EQ(ZoneDaylight(zn).MapShdOrdToLoopNum(1), 8); - EXPECT_EQ(ZoneDaylight(zn).MapShdOrdToLoopNum(2), 9); - EXPECT_EQ(ZoneDaylight(zn).MapShdOrdToLoopNum(3), 1); - EXPECT_EQ(ZoneDaylight(zn).MapShdOrdToLoopNum(4), 2); - EXPECT_EQ(ZoneDaylight(zn).MapShdOrdToLoopNum(5), 3); - EXPECT_EQ(ZoneDaylight(zn).MapShdOrdToLoopNum(6), 4); - EXPECT_EQ(ZoneDaylight(zn).MapShdOrdToLoopNum(7), 5); - EXPECT_EQ(ZoneDaylight(zn).MapShdOrdToLoopNum(8), 6); - EXPECT_EQ(ZoneDaylight(zn).MapShdOrdToLoopNum(9), 7); + EXPECT_EQ(state->dataDaylightingData->ZoneDaylight(zn).MapShdOrdToLoopNum(1), 8); + EXPECT_EQ(state->dataDaylightingData->ZoneDaylight(zn).MapShdOrdToLoopNum(2), 9); + EXPECT_EQ(state->dataDaylightingData->ZoneDaylight(zn).MapShdOrdToLoopNum(3), 1); + EXPECT_EQ(state->dataDaylightingData->ZoneDaylight(zn).MapShdOrdToLoopNum(4), 2); + EXPECT_EQ(state->dataDaylightingData->ZoneDaylight(zn).MapShdOrdToLoopNum(5), 3); + EXPECT_EQ(state->dataDaylightingData->ZoneDaylight(zn).MapShdOrdToLoopNum(6), 4); + EXPECT_EQ(state->dataDaylightingData->ZoneDaylight(zn).MapShdOrdToLoopNum(7), 5); + EXPECT_EQ(state->dataDaylightingData->ZoneDaylight(zn).MapShdOrdToLoopNum(8), 6); + EXPECT_EQ(state->dataDaylightingData->ZoneDaylight(zn).MapShdOrdToLoopNum(9), 7); } TEST_F(EnergyPlusFixture, DaylightingManager_DayltgInteriorIllum_Test) { @@ -1350,15 +1350,15 @@ TEST_F(EnergyPlusFixture, DaylightingManager_DayltgInteriorIllum_Test) DataEnvironment::SkyClearness = 6.0; // Set all daylighting factors to zero - ZoneDaylight(ZoneNum).DaylIllFacSky = 0.0; - ZoneDaylight(ZoneNum).DaylIllFacSun = 0.0; - ZoneDaylight(ZoneNum).DaylIllFacSunDisk = 0.0; - ZoneDaylight(ZoneNum).DaylBackFacSky = 0.0; - ZoneDaylight(ZoneNum).DaylBackFacSun = 0.0; - ZoneDaylight(ZoneNum).DaylBackFacSunDisk = 0.0; - ZoneDaylight(ZoneNum).DaylSourceFacSky = 0.0; - ZoneDaylight(ZoneNum).DaylSourceFacSun = 0.0; - ZoneDaylight(ZoneNum).DaylSourceFacSunDisk = 0.0; + state->dataDaylightingData->ZoneDaylight(ZoneNum).DaylIllFacSky = 0.0; + state->dataDaylightingData->ZoneDaylight(ZoneNum).DaylIllFacSun = 0.0; + state->dataDaylightingData->ZoneDaylight(ZoneNum).DaylIllFacSunDisk = 0.0; + state->dataDaylightingData->ZoneDaylight(ZoneNum).DaylBackFacSky = 0.0; + state->dataDaylightingData->ZoneDaylight(ZoneNum).DaylBackFacSun = 0.0; + state->dataDaylightingData->ZoneDaylight(ZoneNum).DaylBackFacSunDisk = 0.0; + state->dataDaylightingData->ZoneDaylight(ZoneNum).DaylSourceFacSky = 0.0; + state->dataDaylightingData->ZoneDaylight(ZoneNum).DaylSourceFacSun = 0.0; + state->dataDaylightingData->ZoneDaylight(ZoneNum).DaylSourceFacSunDisk = 0.0; DaylightingManager::DayltgInteriorIllum(*state, ZoneNum); EXPECT_NEAR(DaylightingManager::DaylIllum(1), 0.0, 0.001); @@ -1372,11 +1372,11 @@ TEST_F(EnergyPlusFixture, DaylightingManager_DayltgInteriorIllum_Test) // Set un-shaded surface illuminance factor to 1.0 for RefPt1, 0.1 for RefPt2 // Set shaded surface illuminance factor to 0.5 for RefPt1, 0.05 for RefPt2 int RefPt = 1; - ZoneDaylight(ZoneNum).DaylIllFacSky(state->dataGlobal->HourOfDay, Unshaded, ISky, RefPt, DayltgExtWin) = 1.0; - ZoneDaylight(ZoneNum).DaylIllFacSky(state->dataGlobal->HourOfDay, Shaded, ISky, RefPt, DayltgExtWin) = 0.5; + state->dataDaylightingData->ZoneDaylight(ZoneNum).DaylIllFacSky(state->dataGlobal->HourOfDay, Unshaded, ISky, RefPt, DayltgExtWin) = 1.0; + state->dataDaylightingData->ZoneDaylight(ZoneNum).DaylIllFacSky(state->dataGlobal->HourOfDay, Shaded, ISky, RefPt, DayltgExtWin) = 0.5; RefPt = 2; - ZoneDaylight(ZoneNum).DaylIllFacSky(state->dataGlobal->HourOfDay, Unshaded, ISky, RefPt, DayltgExtWin) = 0.1; - ZoneDaylight(ZoneNum).DaylIllFacSky(state->dataGlobal->HourOfDay, Shaded, ISky, RefPt, DayltgExtWin) = 0.05; + state->dataDaylightingData->ZoneDaylight(ZoneNum).DaylIllFacSky(state->dataGlobal->HourOfDay, Unshaded, ISky, RefPt, DayltgExtWin) = 0.1; + state->dataDaylightingData->ZoneDaylight(ZoneNum).DaylIllFacSky(state->dataGlobal->HourOfDay, Shaded, ISky, RefPt, DayltgExtWin) = 0.05; // Window5 model - expect 100 for unshaded and 50 for shaded (10 and 5 for RefPt2) SurfWinWindowModelType(IWin) = Window5DetailedModel; @@ -1551,7 +1551,7 @@ TEST_F(EnergyPlusFixture, DaylightingManager_GetInputDaylightingControls_Roundin DaylightingManager::GetInputDayliteRefPt(*state, foundErrors); compare_err_stream(""); EXPECT_FALSE(foundErrors); - EXPECT_EQ(10, DataDaylighting::TotRefPoints); + EXPECT_EQ(10, state->dataDaylightingData->TotRefPoints); DaylightingManager::GetDaylightingControls(*state, numObjs, foundErrors); // Used to throw @@ -1560,32 +1560,32 @@ TEST_F(EnergyPlusFixture, DaylightingManager_GetInputDaylightingControls_Roundin compare_err_stream(""); EXPECT_FALSE(foundErrors); - EXPECT_EQ("WEST ZONE_DAYLCTRL", DataDaylighting::ZoneDaylight(1).Name); - EXPECT_EQ("WEST ZONE", DataDaylighting::ZoneDaylight(1).ZoneName); - EXPECT_EQ(DataDaylighting::SplitFluxDaylighting, DataDaylighting::ZoneDaylight(1).DaylightMethod); - EXPECT_EQ(DataDaylighting::Continuous, DataDaylighting::ZoneDaylight(1).LightControlType); + EXPECT_EQ("WEST ZONE_DAYLCTRL", state->dataDaylightingData->ZoneDaylight(1).Name); + EXPECT_EQ("WEST ZONE", state->dataDaylightingData->ZoneDaylight(1).ZoneName); + EXPECT_EQ(DataDaylighting::iDaylightingMethod::SplitFluxDaylighting, state->dataDaylightingData->ZoneDaylight(1).DaylightMethod); + EXPECT_EQ(DataDaylighting::iLtgCtrlType::Continuous, state->dataDaylightingData->ZoneDaylight(1).LightControlType); - EXPECT_EQ(0.3, DataDaylighting::ZoneDaylight(1).MinPowerFraction); - EXPECT_EQ(0.2, DataDaylighting::ZoneDaylight(1).MinLightFraction); - EXPECT_EQ(1, DataDaylighting::ZoneDaylight(1).LightControlSteps); - EXPECT_EQ(1.0, DataDaylighting::ZoneDaylight(1).LightControlProbability); + EXPECT_EQ(0.3, state->dataDaylightingData->ZoneDaylight(1).MinPowerFraction); + EXPECT_EQ(0.2, state->dataDaylightingData->ZoneDaylight(1).MinLightFraction); + EXPECT_EQ(1, state->dataDaylightingData->ZoneDaylight(1).LightControlSteps); + EXPECT_EQ(1.0, state->dataDaylightingData->ZoneDaylight(1).LightControlProbability); - EXPECT_EQ(1, DataDaylighting::ZoneDaylight(1).glareRefPtNumber); - EXPECT_EQ(180., DataDaylighting::ZoneDaylight(1).ViewAzimuthForGlare); - EXPECT_EQ(20., DataDaylighting::ZoneDaylight(1).MaxGlareallowed); - EXPECT_EQ(0, DataDaylighting::ZoneDaylight(1).DElightGriddingResolution); + EXPECT_EQ(1, state->dataDaylightingData->ZoneDaylight(1).glareRefPtNumber); + EXPECT_EQ(180., state->dataDaylightingData->ZoneDaylight(1).ViewAzimuthForGlare); + EXPECT_EQ(20., state->dataDaylightingData->ZoneDaylight(1).MaxGlareallowed); + EXPECT_EQ(0, state->dataDaylightingData->ZoneDaylight(1).DElightGriddingResolution); - EXPECT_EQ(10, DataDaylighting::ZoneDaylight(1).TotalDaylRefPoints); + EXPECT_EQ(10, state->dataDaylightingData->ZoneDaylight(1).TotalDaylRefPoints); std::vector fractions({0.1053, 0.0936, 0.1213, 0.1018, 0.0893, 0.0842, 0.0882, 0.1026, 0.1134, 0.1003}); Real64 sum(0.0); int i = 1; for (auto frac: fractions) { sum += frac; - EXPECT_EQ(i, DataDaylighting::ZoneDaylight(1).DaylRefPtNum(i)); - EXPECT_EQ(format("WEST ZONE_DAYLREFPT{}", i), DataDaylighting::DaylRefPt(DataDaylighting::ZoneDaylight(1).DaylRefPtNum(i)).Name); - EXPECT_EQ(frac, DataDaylighting::ZoneDaylight(1).FracZoneDaylit(i)); - EXPECT_EQ(200., DataDaylighting::ZoneDaylight(1).IllumSetPoint(i)); + EXPECT_EQ(i, state->dataDaylightingData->ZoneDaylight(1).DaylRefPtNum(i)); + EXPECT_EQ(format("WEST ZONE_DAYLREFPT{}", i), state->dataDaylightingData->DaylRefPt(state->dataDaylightingData->ZoneDaylight(1).DaylRefPtNum(i)).Name); + EXPECT_EQ(frac, state->dataDaylightingData->ZoneDaylight(1).FracZoneDaylit(i)); + EXPECT_EQ(200., state->dataDaylightingData->ZoneDaylight(1).IllumSetPoint(i)); ++i; } @@ -1662,7 +1662,7 @@ TEST_F(EnergyPlusFixture, DaylightingManager_GetInputDaylightingControls_NotArou DaylightingManager::GetInputDayliteRefPt(*state, foundErrors); compare_err_stream(""); EXPECT_FALSE(foundErrors); - EXPECT_EQ(2, DataDaylighting::TotRefPoints); + EXPECT_EQ(2, state->dataDaylightingData->TotRefPoints); DaylightingManager::GetDaylightingControls(*state, numObjs, foundErrors); @@ -2132,27 +2132,27 @@ TEST_F(EnergyPlusFixture, DaylightingManager_OutputFormats) GetDaylightingParametersInput(*state); compare_err_stream(""); - EXPECT_EQ(4, TotRefPoints); + EXPECT_EQ(4, state->dataDaylightingData->TotRefPoints); - EXPECT_NEAR(2.048, ZoneDaylight(1).DaylRefPtAbsCoord(1, 1), 0.001); - EXPECT_NEAR(3.048, ZoneDaylight(1).DaylRefPtAbsCoord(2, 1), 0.001); - EXPECT_NEAR(0.9, ZoneDaylight(1).DaylRefPtAbsCoord(3, 1), 0.001); + EXPECT_NEAR(2.048, state->dataDaylightingData->ZoneDaylight(1).DaylRefPtAbsCoord(1, 1), 0.001); + EXPECT_NEAR(3.048, state->dataDaylightingData->ZoneDaylight(1).DaylRefPtAbsCoord(2, 1), 0.001); + EXPECT_NEAR(0.9, state->dataDaylightingData->ZoneDaylight(1).DaylRefPtAbsCoord(3, 1), 0.001); DataHeatBalance::Zone(1).RelNorth = 45.; GeometryTransformForDaylighting(*state); - EXPECT_NEAR(3.603, ZoneDaylight(1).DaylRefPtAbsCoord(1, 1), 0.001); - EXPECT_NEAR(0.707, ZoneDaylight(1).DaylRefPtAbsCoord(2, 1), 0.001); - EXPECT_NEAR(0.9, ZoneDaylight(1).DaylRefPtAbsCoord(3, 1), 0.001); + EXPECT_NEAR(3.603, state->dataDaylightingData->ZoneDaylight(1).DaylRefPtAbsCoord(1, 1), 0.001); + EXPECT_NEAR(0.707, state->dataDaylightingData->ZoneDaylight(1).DaylRefPtAbsCoord(2, 1), 0.001); + EXPECT_NEAR(0.9, state->dataDaylightingData->ZoneDaylight(1).DaylRefPtAbsCoord(3, 1), 0.001); DataHeatBalance::Zone(1).RelNorth = 90.; GeometryTransformForDaylighting(*state); - EXPECT_NEAR(3.048, ZoneDaylight(1).DaylRefPtAbsCoord(1, 1), 0.001); - EXPECT_NEAR(-2.048, ZoneDaylight(1).DaylRefPtAbsCoord(2, 1), 0.001); - EXPECT_NEAR(0.9, ZoneDaylight(1).DaylRefPtAbsCoord(3, 1), 0.001); + EXPECT_NEAR(3.048, state->dataDaylightingData->ZoneDaylight(1).DaylRefPtAbsCoord(1, 1), 0.001); + EXPECT_NEAR(-2.048, state->dataDaylightingData->ZoneDaylight(1).DaylRefPtAbsCoord(2, 1), 0.001); + EXPECT_NEAR(0.9, state->dataDaylightingData->ZoneDaylight(1).DaylRefPtAbsCoord(3, 1), 0.001); // reset eio stream EXPECT_TRUE(has_eio_output(true)); diff --git a/tst/EnergyPlus/unit/EMSManager.unit.cc b/tst/EnergyPlus/unit/EMSManager.unit.cc index 537a363cd8b..e135713722e 100644 --- a/tst/EnergyPlus/unit/EMSManager.unit.cc +++ b/tst/EnergyPlus/unit/EMSManager.unit.cc @@ -1589,7 +1589,7 @@ TEST_F(EnergyPlusFixture, EMSManager_TestWindowShadingControlExteriorScreenOptio EnergyPlus::SurfaceGeometry::AllocateSurfaceWindows(2); state->dataConstruction->Construct.allocate(1); DataSurfaces::WindowShadingControl.allocate(2); - DataDaylighting::ZoneDaylight.allocate(1); + state->dataDaylightingData->ZoneDaylight.allocate(1); DataSurfaces::Surface(1).Name = "Surface1"; DataSurfaces::Surface(2).Name = "Surface2"; DataSurfaces::Surface(1).Zone = 1; diff --git a/tst/EnergyPlus/unit/HeatBalanceManager.unit.cc b/tst/EnergyPlus/unit/HeatBalanceManager.unit.cc index 2586ee16879..169f546be25 100644 --- a/tst/EnergyPlus/unit/HeatBalanceManager.unit.cc +++ b/tst/EnergyPlus/unit/HeatBalanceManager.unit.cc @@ -1585,7 +1585,7 @@ TEST_F(EnergyPlusFixture, HeatBalanceManager_EMSConstructionTest) EXPECT_EQ(DataSurfaces::Surface(winSurfNum).Construction, win1ConstNum); Real64 transSol = DataSurfaces::SurfWinSysSolTransmittance(winSurfNum); EXPECT_GT(transSol, 0.8); - Real64 refPtIllum = DataDaylighting::ZoneDaylight(1).DaylIllumAtRefPt(1); + Real64 refPtIllum = state->dataDaylightingData->ZoneDaylight(1).DaylIllumAtRefPt(1); EXPECT_GT(refPtIllum, 3000.0); // Test 2 - Set time of day to afternoon - should use low transmittance window @@ -1600,7 +1600,7 @@ TEST_F(EnergyPlusFixture, HeatBalanceManager_EMSConstructionTest) EXPECT_EQ(DataSurfaces::Surface(winSurfNum).Construction, win2ConstNum); transSol = DataSurfaces::SurfWinSysSolTransmittance(winSurfNum); EXPECT_LT(transSol, 0.2); - refPtIllum = DataDaylighting::ZoneDaylight(1).DaylIllumAtRefPt(1); + refPtIllum = state->dataDaylightingData->ZoneDaylight(1).DaylIllumAtRefPt(1); EXPECT_LT(refPtIllum, 1000.0); } diff --git a/tst/EnergyPlus/unit/HeatBalanceSurfaceManager.unit.cc b/tst/EnergyPlus/unit/HeatBalanceSurfaceManager.unit.cc index 8300bd5ea15..ba382cae3f4 100644 --- a/tst/EnergyPlus/unit/HeatBalanceSurfaceManager.unit.cc +++ b/tst/EnergyPlus/unit/HeatBalanceSurfaceManager.unit.cc @@ -2762,13 +2762,13 @@ TEST_F(EnergyPlusFixture, HeatBalanceSurfaceManager_TestResilienceMetricReport) DataHeatBalFanSys::ZoneLightingLevelHourBins.allocate(state->dataGlobal->NumOfZones); DataHeatBalFanSys::ZoneLightingLevelOccuHourBins.allocate(state->dataGlobal->NumOfZones); - DataDaylighting::ZoneDaylight.allocate(state->dataGlobal->NumOfZones); - DataDaylighting::ZoneDaylight(1).DaylightMethod = DataDaylighting::SplitFluxDaylighting; - DataDaylighting::ZoneDaylight(1).DaylIllumAtRefPt.allocate(1); - DataDaylighting::ZoneDaylight(1).IllumSetPoint.allocate(1); - DataDaylighting::ZoneDaylight(1).ZonePowerReductionFactor = 0.5; - DataDaylighting::ZoneDaylight(1).DaylIllumAtRefPt(1) = 300; - DataDaylighting::ZoneDaylight(1).IllumSetPoint(1) = 400; + state->dataDaylightingData->ZoneDaylight.allocate(state->dataGlobal->NumOfZones); + state->dataDaylightingData->ZoneDaylight(1).DaylightMethod = DataDaylighting::iDaylightingMethod::SplitFluxDaylighting; + state->dataDaylightingData->ZoneDaylight(1).DaylIllumAtRefPt.allocate(1); + state->dataDaylightingData->ZoneDaylight(1).IllumSetPoint.allocate(1); + state->dataDaylightingData->ZoneDaylight(1).ZonePowerReductionFactor = 0.5; + state->dataDaylightingData->ZoneDaylight(1).DaylIllumAtRefPt(1) = 300; + state->dataDaylightingData->ZoneDaylight(1).IllumSetPoint(1) = 400; OutputReportTabular::displayVisualResilienceSummary = true; ReportVisualResilience(*state); From a795422e1a2225ef77e20025c02e83d9e770f82d Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Tue, 24 Nov 2020 15:14:43 -0700 Subject: [PATCH 04/10] moving DataDaylightingDevices to state --- src/EnergyPlus/CMakeLists.txt | 1 - src/EnergyPlus/Data/CommonIncludes.hh | 1 + src/EnergyPlus/Data/EnergyPlusData.cc | 2 + src/EnergyPlus/Data/EnergyPlusData.hh | 2 + src/EnergyPlus/DataDaylightingDevices.cc | 98 ------- src/EnergyPlus/DataDaylightingDevices.hh | 57 ++-- src/EnergyPlus/DaylightingDevices.cc | 305 ++++++++++---------- src/EnergyPlus/DaylightingDevices.hh | 13 +- src/EnergyPlus/DaylightingManager.cc | 59 ++-- src/EnergyPlus/HeatBalanceSurfaceManager.cc | 63 ++-- src/EnergyPlus/SolarShading.cc | 44 ++- 11 files changed, 262 insertions(+), 383 deletions(-) delete mode 100644 src/EnergyPlus/DataDaylightingDevices.cc diff --git a/src/EnergyPlus/CMakeLists.txt b/src/EnergyPlus/CMakeLists.txt index b5d3aa54888..ec288ebae19 100644 --- a/src/EnergyPlus/CMakeLists.txt +++ b/src/EnergyPlus/CMakeLists.txt @@ -150,7 +150,6 @@ SET( SRC DataDElight.cc DataDElight.hh DataDaylighting.hh - DataDaylightingDevices.cc DataDaylightingDevices.hh DataDefineEquip.cc DataDefineEquip.hh diff --git a/src/EnergyPlus/Data/CommonIncludes.hh b/src/EnergyPlus/Data/CommonIncludes.hh index b426dd1effb..d043bd7172e 100644 --- a/src/EnergyPlus/Data/CommonIncludes.hh +++ b/src/EnergyPlus/Data/CommonIncludes.hh @@ -84,6 +84,7 @@ #include #include #include +#include #include #include #include diff --git a/src/EnergyPlus/Data/EnergyPlusData.cc b/src/EnergyPlus/Data/EnergyPlusData.cc index 817580e47d5..575675949b3 100644 --- a/src/EnergyPlus/Data/EnergyPlusData.cc +++ b/src/EnergyPlus/Data/EnergyPlusData.cc @@ -86,6 +86,7 @@ namespace EnergyPlus { this->dataCTElectricGenerator = std::make_unique(); this->dataCurveManager = std::make_unique(); this->dataDaylightingData = std::make_unique(); + this->dataDaylightingDevicesData = std::make_unique(); this->dataEIRPlantLoopHeatPump = std::make_unique(); this->dataExteriorEnergyUse = std::make_unique(); this->dataFans = std::make_unique(); @@ -171,6 +172,7 @@ namespace EnergyPlus { this->dataCTElectricGenerator->clear_state(); this->dataCurveManager->clear_state(); this->dataDaylightingData->clear_state(); + this->dataDaylightingDevicesData->clear_state(); this->dataEIRPlantLoopHeatPump->clear_state(); this->dataExteriorEnergyUse->clear_state(); this->dataFans->clear_state(); diff --git a/src/EnergyPlus/Data/EnergyPlusData.hh b/src/EnergyPlus/Data/EnergyPlusData.hh index ea003309358..a7e29551b5d 100644 --- a/src/EnergyPlus/Data/EnergyPlusData.hh +++ b/src/EnergyPlus/Data/EnergyPlusData.hh @@ -98,6 +98,7 @@ struct DataGlobal; struct DataTimingsData; struct DataWaterData; struct DaylightingData; +struct DaylightingDevicesData; struct EIRPlantLoopHeatPumpsData; struct ExteriorEnergyUseData; struct FansData; @@ -185,6 +186,7 @@ struct EnergyPlusData : BaseGlobalStruct { std::unique_ptr dataGlobal; std::unique_ptr dataWaterData; std::unique_ptr dataDaylightingData; + std::unique_ptr dataDaylightingDevicesData; std::unique_ptr dataEIRPlantLoopHeatPump; std::unique_ptr dataExteriorEnergyUse; std::unique_ptr dataFans; diff --git a/src/EnergyPlus/DataDaylightingDevices.cc b/src/EnergyPlus/DataDaylightingDevices.cc deleted file mode 100644 index 4efb9ce3101..00000000000 --- a/src/EnergyPlus/DataDaylightingDevices.cc +++ /dev/null @@ -1,98 +0,0 @@ -// EnergyPlus, Copyright (c) 1996-2020, The Board of Trustees of the University of Illinois, -// The Regents of the University of California, through Lawrence Berkeley National Laboratory -// (subject to receipt of any required approvals from the U.S. Dept. of Energy), Oak Ridge -// National Laboratory, managed by UT-Battelle, Alliance for Sustainable Energy, LLC, and other -// contributors. All rights reserved. -// -// NOTICE: This Software was developed under funding from the U.S. Department of Energy and the -// U.S. Government consequently retains certain rights. As such, the U.S. Government has been -// granted for itself and others acting on its behalf a paid-up, nonexclusive, irrevocable, -// worldwide license in the Software to reproduce, distribute copies to the public, prepare -// derivative works, and perform publicly and display publicly, and to permit others to do so. -// -// Redistribution and use in source and binary forms, with or without modification, are permitted -// provided that the following conditions are met: -// -// (1) Redistributions of source code must retain the above copyright notice, this list of -// conditions and the following disclaimer. -// -// (2) Redistributions in binary form must reproduce the above copyright notice, this list of -// conditions and the following disclaimer in the documentation and/or other materials -// provided with the distribution. -// -// (3) Neither the name of the University of California, Lawrence Berkeley National Laboratory, -// the University of Illinois, U.S. Dept. of Energy nor the names of its contributors may be -// used to endorse or promote products derived from this software without specific prior -// written permission. -// -// (4) Use of EnergyPlus(TM) Name. If Licensee (i) distributes the software in stand-alone form -// without changes from the version obtained under this License, or (ii) Licensee makes a -// reference solely to the software portion of its product, Licensee must refer to the -// software as "EnergyPlus version X" software, where "X" is the version number Licensee -// obtained under this License and may not use a different name for the software. Except as -// specifically required in this Section (4), Licensee shall not use in a company name, a -// product name, in advertising, publicity, or other promotional activities any name, trade -// name, trademark, logo, or other designation of "EnergyPlus", "E+", "e+" or confusingly -// similar designation, without the U.S. Department of Energy's prior written consent. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY -// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR -// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. - -// EnergyPlus Headers -#include -namespace EnergyPlus { - -namespace DataDaylightingDevices { - - // MODULE INFORMATION: - // AUTHOR Peter Graham Ellis - // DATE WRITTEN May 2003 - // MODIFIED na - // RE-ENGINEERED na - - // PURPOSE OF THIS MODULE: - // This data-only module is a repository for variables used in daylighting devices which - // are shared by several modules. - - // METHODOLOGY EMPLOYED: na - // REFERENCES: na - // OTHER NOTES: na - - // Using/Aliasing - // Data - // -only module should be available to other modules and routines. - // Thus, all variables in this module must be PUBLIC. - - // MODULE PARAMETER DEFINITIONS: - int const MaxTZones(10); // Maximum number of transition zones - int const NumOfAngles(19); // Number of data points on transmittance vs. angle curve - - int const VisibleBeam(1); // Constant for radiation type - int const SolarBeam(2); // Constant for radiation type - int const SolarAniso(3); // Constant for radiation type - int const SolarIso(4); // Constant for radiation type - - // DERIVED TYPE DEFINITIONS: - - // MODULE VARIABLE TYPE DECLARATIONS: - - // INTERFACE BLOCK SPECIFICATIONS: na - - // MODULE VARIABLE DECLARATIONS: - int NumOfTDDPipes(0); // Number of TDD pipes in the input file - int NumOfShelf(0); // Number of daylighting shelves in the input file - - // Object Data - Array1D TDDPipe; - Array1D Shelf; - -} // namespace DataDaylightingDevices - -} // namespace EnergyPlus diff --git a/src/EnergyPlus/DataDaylightingDevices.hh b/src/EnergyPlus/DataDaylightingDevices.hh index acf544100c9..b29ea7e4974 100644 --- a/src/EnergyPlus/DataDaylightingDevices.hh +++ b/src/EnergyPlus/DataDaylightingDevices.hh @@ -59,32 +59,15 @@ namespace EnergyPlus { namespace DataDaylightingDevices { - // Using/Aliasing - - // Data - // -only module should be available to other modules and routines. - // Thus, all variables in this module must be PUBLIC. - - // MODULE PARAMETER DEFINITIONS: - extern int const MaxTZones; // Maximum number of transition zones - extern int const NumOfAngles; // Number of data points on transmittance vs. angle curve - - extern int const VisibleBeam; // Constant for radiation type - extern int const SolarBeam; // Constant for radiation type - extern int const SolarAniso; // Constant for radiation type - extern int const SolarIso; // Constant for radiation type - - // DERIVED TYPE DEFINITIONS: - - // MODULE VARIABLE TYPE DECLARATIONS: - - // INTERFACE BLOCK SPECIFICATIONS: na - - // MODULE VARIABLE DECLARATIONS: - extern int NumOfTDDPipes; // Number of TDD pipes in the input file - extern int NumOfShelf; // Number of daylighting shelves in the input file - - // Types + constexpr int MaxTZones(10); // Maximum number of transition zones + constexpr int NumOfAngles(19); // Number of data points on transmittance vs. angle curve + + enum class iRadType { + VisibleBeam, + SolarBeam, + SolarAniso, + SolarIso + }; struct TDDPipeData { @@ -123,7 +106,7 @@ namespace DataDaylightingDevices { // Default Constructor TDDPipeData() : Dome(0), Diffuser(0), Construction(0), Diameter(0.0), TotLength(0.0), Reff(0.0), NumOfTZones(0), AspectRatio(0.0), ReflectVis(0.0), - ReflectSol(0.0), PipeTransVisBeam(NumOfAngles, 0.0), PipeTransSolBeam(NumOfAngles, 0.0), TransSolIso(0.0), TransSolHorizon(0.0), + ReflectSol(0.0), PipeTransVisBeam(DataDaylightingDevices::NumOfAngles, 0.0), PipeTransSolBeam(DataDaylightingDevices::NumOfAngles, 0.0), TransSolIso(0.0), TransSolHorizon(0.0), ExtLength(0.0), TransmittedSolar(0.0), PipeAbsorbedSolar(0.0), HeatGain(0.0), HeatLoss(0.0), TransVisBeam(0.0), TransSolBeam(0.0), TransVisDiff(0.0), TransSolDiff(0.0) { @@ -151,12 +134,24 @@ namespace DataDaylightingDevices { } }; - // Object Data - extern Array1D TDDPipe; - extern Array1D Shelf; - } // namespace DataDaylightingDevices +struct DaylightingDevicesData : BaseGlobalStruct { + + int NumOfTDDPipes = 0; // Number of TDD pipes in the input file + int NumOfShelf = 0; // Number of daylighting shelves in the input file + Array1D TDDPipe; + Array1D Shelf; + + void clear_state() override + { + this->NumOfTDDPipes = 0; + this->NumOfShelf = 0; + this->TDDPipe.deallocate(); + this->Shelf.deallocate(); + } +}; + } // namespace EnergyPlus #endif diff --git a/src/EnergyPlus/DaylightingDevices.cc b/src/EnergyPlus/DaylightingDevices.cc index 483ab2004d8..452c8cf33be 100644 --- a/src/EnergyPlus/DaylightingDevices.cc +++ b/src/EnergyPlus/DaylightingDevices.cc @@ -57,7 +57,6 @@ #include #include #include -#include #include #include #include @@ -176,15 +175,13 @@ namespace DaylightingDevices { using DataSurfaces::Surface; using DataSurfaces::SurfaceClass; using DataSurfaces::TotSurfaces; - using namespace DataDaylightingDevices; - // Data // MODULE PARAMETER DEFINITIONS: na // DERIVED TYPE DEFINITIONS: na // MODULE VARIABLE TYPE DECLARATIONS: na // MODULE VARIABLE DECLARATIONS: - Array1D COSAngle(NumOfAngles); // List of cosines of incident angle + Array1D COSAngle(DataDaylightingDevices::NumOfAngles); // List of cosines of incident angle bool ShelfReported = false; // SUBROUTINE SPECIFICATIONS: @@ -193,7 +190,7 @@ namespace DaylightingDevices { void clear_state() { COSAngle.clear(); - COSAngle.allocate(NumOfAngles); + COSAngle.allocate(DataDaylightingDevices::NumOfAngles); ShelfReported = false; } @@ -251,7 +248,7 @@ namespace DaylightingDevices { Array1D TransBeam; // Table of beam transmittance vs. cosine angle // Default Constructor - TDDPipeStoredData() : AspectRatio(0.0), Reflectance(0.0), TransBeam(NumOfAngles, 0.0) + TDDPipeStoredData() : AspectRatio(0.0), Reflectance(0.0), TransBeam(DataDaylightingDevices::NumOfAngles, 0.0) { } }; @@ -263,35 +260,35 @@ namespace DaylightingDevices { // Initialize tubular daylighting devices (TDDs) GetTDDInput(state); - if (NumOfTDDPipes > 0) { + if (state.dataDaylightingDevicesData->NumOfTDDPipes > 0) { DisplayString(state, "Initializing Tubular Daylighting Devices"); // Setup COSAngle list for all TDDs COSAngle(1) = 0.0; - COSAngle(NumOfAngles) = 1.0; + COSAngle(DataDaylightingDevices::NumOfAngles) = 1.0; - dTheta = 90.0 * DataGlobalConstants::DegToRadians() / (NumOfAngles - 1.0); + dTheta = 90.0 * DataGlobalConstants::DegToRadians() / (DataDaylightingDevices::NumOfAngles - 1.0); Theta = 90.0 * DataGlobalConstants::DegToRadians(); - for (AngleNum = 2; AngleNum <= NumOfAngles - 1; ++AngleNum) { + for (AngleNum = 2; AngleNum <= DataDaylightingDevices::NumOfAngles - 1; ++AngleNum) { Theta -= dTheta; COSAngle(AngleNum) = std::cos(Theta); } // AngleNum - TDDPipeStored.allocate(NumOfTDDPipes * 2); + TDDPipeStored.allocate(state.dataDaylightingDevicesData->NumOfTDDPipes * 2); - for (PipeNum = 1; PipeNum <= NumOfTDDPipes; ++PipeNum) { + for (PipeNum = 1; PipeNum <= state.dataDaylightingDevicesData->NumOfTDDPipes; ++PipeNum) { // Initialize optical properties - TDDPipe(PipeNum).AspectRatio = TDDPipe(PipeNum).TotLength / TDDPipe(PipeNum).Diameter; - TDDPipe(PipeNum).ReflectVis = 1.0 - state.dataConstruction->Construct(TDDPipe(PipeNum).Construction).InsideAbsorpVis; - TDDPipe(PipeNum).ReflectSol = 1.0 - state.dataConstruction->Construct(TDDPipe(PipeNum).Construction).InsideAbsorpSolar; + state.dataDaylightingDevicesData->TDDPipe(PipeNum).AspectRatio = state.dataDaylightingDevicesData->TDDPipe(PipeNum).TotLength / state.dataDaylightingDevicesData->TDDPipe(PipeNum).Diameter; + state.dataDaylightingDevicesData->TDDPipe(PipeNum).ReflectVis = 1.0 - state.dataConstruction->Construct(state.dataDaylightingDevicesData->TDDPipe(PipeNum).Construction).InsideAbsorpVis; + state.dataDaylightingDevicesData->TDDPipe(PipeNum).ReflectSol = 1.0 - state.dataConstruction->Construct(state.dataDaylightingDevicesData->TDDPipe(PipeNum).Construction).InsideAbsorpSolar; // Calculate the beam transmittance table for visible and solar spectrum // First time thru use the visible reflectance - Reflectance = TDDPipe(PipeNum).ReflectVis; + Reflectance = state.dataDaylightingDevicesData->TDDPipe(PipeNum).ReflectVis; for (Loop = 1; Loop <= 2; ++Loop) { // For computational efficiency, search stored pipes to see if an identical pipe has already been calculated Found = false; for (StoredNum = 1; StoredNum <= NumStored; ++StoredNum) { - if (TDDPipeStored(StoredNum).AspectRatio != TDDPipe(PipeNum).AspectRatio) continue; + if (TDDPipeStored(StoredNum).AspectRatio != state.dataDaylightingDevicesData->TDDPipe(PipeNum).AspectRatio) continue; if (TDDPipeStored(StoredNum).Reflectance == Reflectance) { Found = true; // StoredNum points to the matching TDDPipeStored break; @@ -302,18 +299,18 @@ namespace DaylightingDevices { // Add a new pipe to TDDPipeStored ++NumStored; - TDDPipeStored(NumStored).AspectRatio = TDDPipe(PipeNum).AspectRatio; + TDDPipeStored(NumStored).AspectRatio = state.dataDaylightingDevicesData->TDDPipe(PipeNum).AspectRatio; TDDPipeStored(NumStored).Reflectance = Reflectance; // Set beam transmittances for 0 and 90 degrees TDDPipeStored(NumStored).TransBeam(1) = 0.0; - TDDPipeStored(NumStored).TransBeam(NumOfAngles) = 1.0; + TDDPipeStored(NumStored).TransBeam(DataDaylightingDevices::NumOfAngles) = 1.0; // Calculate intermediate beam transmittances between 0 and 90 degrees Theta = 90.0 * DataGlobalConstants::DegToRadians(); - for (AngleNum = 2; AngleNum <= NumOfAngles - 1; ++AngleNum) { + for (AngleNum = 2; AngleNum <= DataDaylightingDevices::NumOfAngles - 1; ++AngleNum) { Theta -= dTheta; - TDDPipeStored(NumStored).TransBeam(AngleNum) = CalcPipeTransBeam(Reflectance, TDDPipe(PipeNum).AspectRatio, Theta); + TDDPipeStored(NumStored).TransBeam(AngleNum) = CalcPipeTransBeam(Reflectance, state.dataDaylightingDevicesData->TDDPipe(PipeNum).AspectRatio, Theta); } // AngleNum StoredNum = NumStored; @@ -321,84 +318,84 @@ namespace DaylightingDevices { // Assign stored values to TDDPipe if (Loop == 1) { // Visible - TDDPipe(PipeNum).PipeTransVisBeam = TDDPipeStored(StoredNum).TransBeam; + state.dataDaylightingDevicesData->TDDPipe(PipeNum).PipeTransVisBeam = TDDPipeStored(StoredNum).TransBeam; } else { // Solar - TDDPipe(PipeNum).PipeTransSolBeam = TDDPipeStored(StoredNum).TransBeam; + state.dataDaylightingDevicesData->TDDPipe(PipeNum).PipeTransSolBeam = TDDPipeStored(StoredNum).TransBeam; } // Second time thru use the solar reflectance - Reflectance = TDDPipe(PipeNum).ReflectSol; + Reflectance = state.dataDaylightingDevicesData->TDDPipe(PipeNum).ReflectSol; } // Loop // Calculate the solar isotropic diffuse and horizon transmittances. These values are constant for a given TDD. - TDDPipe(PipeNum).TransSolIso = CalcTDDTransSolIso(state, PipeNum); - TDDPipe(PipeNum).TransSolHorizon = CalcTDDTransSolHorizon(state, PipeNum); + state.dataDaylightingDevicesData->TDDPipe(PipeNum).TransSolIso = CalcTDDTransSolIso(state, PipeNum); + state.dataDaylightingDevicesData->TDDPipe(PipeNum).TransSolHorizon = CalcTDDTransSolHorizon(state, PipeNum); // Initialize thermal properties SumTZoneLengths = 0.0; - for (TZoneNum = 1; TZoneNum <= TDDPipe(PipeNum).NumOfTZones; ++TZoneNum) { - SumTZoneLengths += TDDPipe(PipeNum).TZoneLength(TZoneNum); + for (TZoneNum = 1; TZoneNum <= state.dataDaylightingDevicesData->TDDPipe(PipeNum).NumOfTZones; ++TZoneNum) { + SumTZoneLengths += state.dataDaylightingDevicesData->TDDPipe(PipeNum).TZoneLength(TZoneNum); - SetupZoneInternalGain(state, TDDPipe(PipeNum).TZone(TZoneNum), + SetupZoneInternalGain(state, state.dataDaylightingDevicesData->TDDPipe(PipeNum).TZone(TZoneNum), "DaylightingDevice:Tubular", - TDDPipe(PipeNum).Name, + state.dataDaylightingDevicesData->TDDPipe(PipeNum).Name, IntGainTypeOf_DaylightingDeviceTubular, - &TDDPipe(PipeNum).TZoneHeatGain(TZoneNum)); + &state.dataDaylightingDevicesData->TDDPipe(PipeNum).TZoneHeatGain(TZoneNum)); } // TZoneNum - TDDPipe(PipeNum).ExtLength = TDDPipe(PipeNum).TotLength - SumTZoneLengths; + state.dataDaylightingDevicesData->TDDPipe(PipeNum).ExtLength = state.dataDaylightingDevicesData->TDDPipe(PipeNum).TotLength - SumTZoneLengths; // Setup report variables: CurrentModuleObject='DaylightingDevice:Tubular' SetupOutputVariable(state, "Tubular Daylighting Device Transmitted Solar Radiation Rate", OutputProcessor::Unit::W, - TDDPipe(PipeNum).TransmittedSolar, + state.dataDaylightingDevicesData->TDDPipe(PipeNum).TransmittedSolar, "Zone", "Average", - TDDPipe(PipeNum).Name); + state.dataDaylightingDevicesData->TDDPipe(PipeNum).Name); SetupOutputVariable(state, "Tubular Daylighting Device Pipe Absorbed Solar Radiation Rate", OutputProcessor::Unit::W, - TDDPipe(PipeNum).PipeAbsorbedSolar, + state.dataDaylightingDevicesData->TDDPipe(PipeNum).PipeAbsorbedSolar, "Zone", "Average", - TDDPipe(PipeNum).Name); + state.dataDaylightingDevicesData->TDDPipe(PipeNum).Name); SetupOutputVariable(state, "Tubular Daylighting Device Heat Gain Rate", OutputProcessor::Unit::W, - TDDPipe(PipeNum).HeatGain, + state.dataDaylightingDevicesData->TDDPipe(PipeNum).HeatGain, "Zone", "Average", - TDDPipe(PipeNum).Name); + state.dataDaylightingDevicesData->TDDPipe(PipeNum).Name); SetupOutputVariable(state, "Tubular Daylighting Device Heat Loss Rate", OutputProcessor::Unit::W, - TDDPipe(PipeNum).HeatLoss, + state.dataDaylightingDevicesData->TDDPipe(PipeNum).HeatLoss, "Zone", "Average", - TDDPipe(PipeNum).Name); + state.dataDaylightingDevicesData->TDDPipe(PipeNum).Name); SetupOutputVariable(state, "Tubular Daylighting Device Beam Solar Transmittance", OutputProcessor::Unit::None, - TDDPipe(PipeNum).TransSolBeam, + state.dataDaylightingDevicesData->TDDPipe(PipeNum).TransSolBeam, "Zone", "Average", - TDDPipe(PipeNum).Name); + state.dataDaylightingDevicesData->TDDPipe(PipeNum).Name); SetupOutputVariable(state, "Tubular Daylighting Device Beam Visible Transmittance", OutputProcessor::Unit::None, - TDDPipe(PipeNum).TransVisBeam, + state.dataDaylightingDevicesData->TDDPipe(PipeNum).TransVisBeam, "Zone", "Average", - TDDPipe(PipeNum).Name); + state.dataDaylightingDevicesData->TDDPipe(PipeNum).Name); SetupOutputVariable(state, "Tubular Daylighting Device Diffuse Solar Transmittance", OutputProcessor::Unit::None, - TDDPipe(PipeNum).TransSolDiff, + state.dataDaylightingDevicesData->TDDPipe(PipeNum).TransSolDiff, "Zone", "Average", - TDDPipe(PipeNum).Name); + state.dataDaylightingDevicesData->TDDPipe(PipeNum).Name); SetupOutputVariable(state, "Tubular Daylighting Device Diffuse Visible Transmittance", OutputProcessor::Unit::None, - TDDPipe(PipeNum).TransVisDiff, + state.dataDaylightingDevicesData->TDDPipe(PipeNum).TransVisDiff, "Zone", "Average", - TDDPipe(PipeNum).Name); + state.dataDaylightingDevicesData->TDDPipe(PipeNum).Name); } // PipeNum @@ -408,33 +405,33 @@ namespace DaylightingDevices { // Initialize daylighting shelves GetShelfInput(state); - if (NumOfShelf > 0) DisplayString(state, "Initializing Light Shelf Daylighting Devices"); + if (state.dataDaylightingDevicesData->NumOfShelf > 0) DisplayString(state, "Initializing Light Shelf Daylighting Devices"); - for (ShelfNum = 1; ShelfNum <= NumOfShelf; ++ShelfNum) { - WinSurf = Shelf(ShelfNum).Window; + for (ShelfNum = 1; ShelfNum <= state.dataDaylightingDevicesData->NumOfShelf; ++ShelfNum) { + WinSurf = state.dataDaylightingDevicesData->Shelf(ShelfNum).Window; - ShelfSurf = Shelf(ShelfNum).InSurf; + ShelfSurf = state.dataDaylightingDevicesData->Shelf(ShelfNum).InSurf; if (ShelfSurf > 0) { // Double surface area so that both sides of the shelf are treated as internal mass Surface(ShelfSurf).Area *= 2.0; } - ShelfSurf = Shelf(ShelfNum).OutSurf; + ShelfSurf = state.dataDaylightingDevicesData->Shelf(ShelfNum).OutSurf; if (ShelfSurf > 0) { - Shelf(ShelfNum).OutReflectVis = 1.0 - state.dataConstruction->Construct(Shelf(ShelfNum).Construction).OutsideAbsorpVis; - Shelf(ShelfNum).OutReflectSol = 1.0 - state.dataConstruction->Construct(Shelf(ShelfNum).Construction).OutsideAbsorpSolar; + state.dataDaylightingDevicesData->Shelf(ShelfNum).OutReflectVis = 1.0 - state.dataConstruction->Construct(state.dataDaylightingDevicesData->Shelf(ShelfNum).Construction).OutsideAbsorpVis; + state.dataDaylightingDevicesData->Shelf(ShelfNum).OutReflectSol = 1.0 - state.dataConstruction->Construct(state.dataDaylightingDevicesData->Shelf(ShelfNum).Construction).OutsideAbsorpSolar; - if (Shelf(ShelfNum).ViewFactor < 0) CalcViewFactorToShelf(state, ShelfNum); + if (state.dataDaylightingDevicesData->Shelf(ShelfNum).ViewFactor < 0) CalcViewFactorToShelf(state, ShelfNum); - if (Shelf(ShelfNum).ViewFactor + Surface(WinSurf).ViewFactorSky + Surface(WinSurf).ViewFactorGround > 1.0) { + if (state.dataDaylightingDevicesData->Shelf(ShelfNum).ViewFactor + Surface(WinSurf).ViewFactorSky + Surface(WinSurf).ViewFactorGround > 1.0) { ShowWarningError(state, format("DaylightingDevice:Shelf = {}: Window view factors to sky [{:.2R}],", - Shelf(ShelfNum).Name, + state.dataDaylightingDevicesData->Shelf(ShelfNum).Name, Surface(WinSurf).ViewFactorSky)); ShowContinueError(state, format("ground [{:.2R}], and outside shelf [{:.2R}] add up to > 1.0.", Surface(WinSurf).ViewFactorGround, - Shelf(ShelfNum).ViewFactor)); + state.dataDaylightingDevicesData->Shelf(ShelfNum).ViewFactor)); } // Report calculated view factor so that user knows what to make the view factor to ground @@ -445,8 +442,8 @@ namespace DaylightingDevices { } print(state.files.eio, "{},{:.2R},{},{:.2R},{:.2R}\n", - Shelf(ShelfNum).Name, - Shelf(ShelfNum).ViewFactor, + state.dataDaylightingDevicesData->Shelf(ShelfNum).Name, + state.dataDaylightingDevicesData->Shelf(ShelfNum).ViewFactor, Surface(WinSurf).Name, Surface(WinSurf).ViewFactorSky, Surface(WinSurf).ViewFactorGround); @@ -459,7 +456,7 @@ namespace DaylightingDevices { // solar reflection calculated from obstructions will not be used in daylighting shelf or tubular device // calculation - if (CalcSolRefl && (NumOfTDDPipes > 0 || NumOfShelf > 0)) { + if (CalcSolRefl && (state.dataDaylightingDevicesData->NumOfTDDPipes > 0 || state.dataDaylightingDevicesData->NumOfShelf > 0)) { ShowWarningError(state, "InitDaylightingDevices: Solar Distribution Model includes Solar Reflection calculations;"); ShowContinueError(state, "the resulting reflected solar values will not be used in the"); ShowContinueError(state, "DaylightingDevice:Shelf or DaylightingDevice:Tubular calculations."); @@ -499,12 +496,12 @@ namespace DaylightingDevices { // FLOW: cCurrentModuleObject = "DaylightingDevice:Tubular"; - NumOfTDDPipes = inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); + state.dataDaylightingDevicesData->NumOfTDDPipes = inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); - if (NumOfTDDPipes > 0) { - TDDPipe.allocate(NumOfTDDPipes); + if (state.dataDaylightingDevicesData->NumOfTDDPipes > 0) { + state.dataDaylightingDevicesData->TDDPipe.allocate(state.dataDaylightingDevicesData->NumOfTDDPipes); - for (PipeNum = 1; PipeNum <= NumOfTDDPipes; ++PipeNum) { + for (PipeNum = 1; PipeNum <= state.dataDaylightingDevicesData->NumOfTDDPipes; ++PipeNum) { inputProcessor->getObjectItem(state, cCurrentModuleObject, PipeNum, @@ -519,7 +516,7 @@ namespace DaylightingDevices { cNumericFieldNames); UtilityRoutines::IsNameEmpty(state, cAlphaArgs(1), cCurrentModuleObject, ErrorsFound); // Pipe name - TDDPipe(PipeNum).Name = cAlphaArgs(1); + state.dataDaylightingDevicesData->TDDPipe(PipeNum).Name = cAlphaArgs(1); // Get TDD:DOME object SurfNum = UtilityRoutines::FindItemInList(cAlphaArgs(2), Surface); @@ -570,7 +567,7 @@ namespace DaylightingDevices { " is not exposed to exterior radiation."); } - TDDPipe(PipeNum).Dome = SurfNum; + state.dataDaylightingDevicesData->TDDPipe(PipeNum).Dome = SurfNum; DataSurfaces::SurfWinTDDPipeNum(SurfNum) = PipeNum; } @@ -608,20 +605,20 @@ namespace DaylightingDevices { ErrorsFound = true; } - if (TDDPipe(PipeNum).Dome > 0 && std::abs(Surface(SurfNum).Area - Surface(TDDPipe(PipeNum).Dome).Area) > 0.1) { - if (SafeDivide(std::abs(Surface(SurfNum).Area - Surface(TDDPipe(PipeNum).Dome).Area), Surface(TDDPipe(PipeNum).Dome).Area) > + if (state.dataDaylightingDevicesData->TDDPipe(PipeNum).Dome > 0 && std::abs(Surface(SurfNum).Area - Surface(state.dataDaylightingDevicesData->TDDPipe(PipeNum).Dome).Area) > 0.1) { + if (SafeDivide(std::abs(Surface(SurfNum).Area - Surface(state.dataDaylightingDevicesData->TDDPipe(PipeNum).Dome).Area), Surface(state.dataDaylightingDevicesData->TDDPipe(PipeNum).Dome).Area) > 0.1) { // greater than 10% ShowSevereError(state, cCurrentModuleObject + " = " + cAlphaArgs(1) + ": Dome and diffuser areas are significantly different (>10%)."); ShowContinueError( state, - format("...Diffuser Area=[{:.4R}]; Dome Area=[{:.4R}].", Surface(SurfNum).Area, Surface(TDDPipe(PipeNum).Dome).Area)); + format("...Diffuser Area=[{:.4R}]; Dome Area=[{:.4R}].", Surface(SurfNum).Area, Surface(state.dataDaylightingDevicesData->TDDPipe(PipeNum).Dome).Area)); ErrorsFound = true; } else { ShowWarningError(state, cCurrentModuleObject + " = " + cAlphaArgs(1) + ": Dome and diffuser areas differ by > .1 m2."); ShowContinueError( state, - format("...Diffuser Area=[{:.4R}]; Dome Area=[{:.4R}].", Surface(SurfNum).Area, Surface(TDDPipe(PipeNum).Dome).Area)); + format("...Diffuser Area=[{:.4R}]; Dome Area=[{:.4R}].", Surface(SurfNum).Area, Surface(state.dataDaylightingDevicesData->TDDPipe(PipeNum).Dome).Area)); } } @@ -645,52 +642,52 @@ namespace DaylightingDevices { // Window multiplier is already handled in SurfaceGeometry.cc - TDDPipe(PipeNum).Diffuser = SurfNum; + state.dataDaylightingDevicesData->TDDPipe(PipeNum).Diffuser = SurfNum; DataSurfaces::SurfWinTDDPipeNum(SurfNum) = PipeNum; } // Construction - TDDPipe(PipeNum).Construction = UtilityRoutines::FindItemInList(cAlphaArgs(4), state.dataConstruction->Construct); + state.dataDaylightingDevicesData->TDDPipe(PipeNum).Construction = UtilityRoutines::FindItemInList(cAlphaArgs(4), state.dataConstruction->Construct); - if (TDDPipe(PipeNum).Construction == 0) { + if (state.dataDaylightingDevicesData->TDDPipe(PipeNum).Construction == 0) { ShowSevereError(state, cCurrentModuleObject + " = " + cAlphaArgs(1) + ": Pipe construction " + cAlphaArgs(4) + " not found."); ErrorsFound = true; } else { - state.dataConstruction->Construct(TDDPipe(PipeNum).Construction).IsUsed = true; + state.dataConstruction->Construct(state.dataDaylightingDevicesData->TDDPipe(PipeNum).Construction).IsUsed = true; } if (rNumericArgs(1) > 0) { - TDDPipe(PipeNum).Diameter = rNumericArgs(1); + state.dataDaylightingDevicesData->TDDPipe(PipeNum).Diameter = rNumericArgs(1); } else { ShowSevereError(state, cCurrentModuleObject + " = " + cAlphaArgs(1) + ": Pipe diameter must be greater than zero."); ErrorsFound = true; } - PipeArea = 0.25 * DataGlobalConstants::Pi() * pow_2(TDDPipe(PipeNum).Diameter); - if (TDDPipe(PipeNum).Dome > 0 && std::abs(PipeArea - Surface(TDDPipe(PipeNum).Dome).Area) > 0.1) { - if (SafeDivide(std::abs(PipeArea - Surface(TDDPipe(PipeNum).Dome).Area), Surface(TDDPipe(PipeNum).Dome).Area) > + PipeArea = 0.25 * DataGlobalConstants::Pi() * pow_2(state.dataDaylightingDevicesData->TDDPipe(PipeNum).Diameter); + if (state.dataDaylightingDevicesData->TDDPipe(PipeNum).Dome > 0 && std::abs(PipeArea - Surface(state.dataDaylightingDevicesData->TDDPipe(PipeNum).Dome).Area) > 0.1) { + if (SafeDivide(std::abs(PipeArea - Surface(state.dataDaylightingDevicesData->TDDPipe(PipeNum).Dome).Area), Surface(state.dataDaylightingDevicesData->TDDPipe(PipeNum).Dome).Area) > 0.1) { // greater than 10% ShowSevereError(state, cCurrentModuleObject + " = " + cAlphaArgs(1) + ": Pipe and dome/diffuser areas are significantly different (>10%)."); ShowContinueError( - state, format("...Pipe Area=[{:.4R}]; Dome/Diffuser Area=[{:.4R}].", PipeArea, Surface(TDDPipe(PipeNum).Dome).Area)); + state, format("...Pipe Area=[{:.4R}]; Dome/Diffuser Area=[{:.4R}].", PipeArea, Surface(state.dataDaylightingDevicesData->TDDPipe(PipeNum).Dome).Area)); ErrorsFound = true; } else { ShowWarningError(state, cCurrentModuleObject + " = " + cAlphaArgs(1) + ": Pipe and dome/diffuser areas differ by > .1 m2."); ShowContinueError( - state, format("...Pipe Area=[{:.4R}]; Dome/Diffuser Area=[{:.4R}].", PipeArea, Surface(TDDPipe(PipeNum).Dome).Area)); + state, format("...Pipe Area=[{:.4R}]; Dome/Diffuser Area=[{:.4R}].", PipeArea, Surface(state.dataDaylightingDevicesData->TDDPipe(PipeNum).Dome).Area)); } } if (rNumericArgs(2) > 0) { - TDDPipe(PipeNum).TotLength = rNumericArgs(2); + state.dataDaylightingDevicesData->TDDPipe(PipeNum).TotLength = rNumericArgs(2); } else { ShowSevereError(state, cCurrentModuleObject + " = " + cAlphaArgs(1) + ": Pipe length must be greater than zero."); ErrorsFound = true; } if (rNumericArgs(3) > 0) { - TDDPipe(PipeNum).Reff = rNumericArgs(3); + state.dataDaylightingDevicesData->TDDPipe(PipeNum).Reff = rNumericArgs(3); } else { ShowSevereError(state, cCurrentModuleObject + " = " + cAlphaArgs(1) + ": Effective thermal resistance (R value) must be greater than zero."); @@ -698,33 +695,33 @@ namespace DaylightingDevices { } // Transition zones - TDDPipe(PipeNum).NumOfTZones = NumAlphas - 4; + state.dataDaylightingDevicesData->TDDPipe(PipeNum).NumOfTZones = NumAlphas - 4; - if (TDDPipe(PipeNum).NumOfTZones < 1) { + if (state.dataDaylightingDevicesData->TDDPipe(PipeNum).NumOfTZones < 1) { ShowWarningError(state, cCurrentModuleObject + " = " + cAlphaArgs(1) + ": No transition zones specified. All pipe absorbed solar goes to exterior."); - } else if (TDDPipe(PipeNum).NumOfTZones > MaxTZones) { + } else if (state.dataDaylightingDevicesData->TDDPipe(PipeNum).NumOfTZones > DataDaylightingDevices::MaxTZones) { ShowSevereError(state, cCurrentModuleObject + " = " + cAlphaArgs(1) + ": Maximum number of transition zones exceeded."); ErrorsFound = true; } else { - TDDPipe(PipeNum).TZone.allocate(TDDPipe(PipeNum).NumOfTZones); - TDDPipe(PipeNum).TZoneLength.allocate(TDDPipe(PipeNum).NumOfTZones); - TDDPipe(PipeNum).TZoneHeatGain.allocate(TDDPipe(PipeNum).NumOfTZones); + state.dataDaylightingDevicesData->TDDPipe(PipeNum).TZone.allocate(state.dataDaylightingDevicesData->TDDPipe(PipeNum).NumOfTZones); + state.dataDaylightingDevicesData->TDDPipe(PipeNum).TZoneLength.allocate(state.dataDaylightingDevicesData->TDDPipe(PipeNum).NumOfTZones); + state.dataDaylightingDevicesData->TDDPipe(PipeNum).TZoneHeatGain.allocate(state.dataDaylightingDevicesData->TDDPipe(PipeNum).NumOfTZones); - TDDPipe(PipeNum).TZone = 0; - TDDPipe(PipeNum).TZoneLength = 0.0; - TDDPipe(PipeNum).TZoneHeatGain = 0.0; + state.dataDaylightingDevicesData->TDDPipe(PipeNum).TZone = 0; + state.dataDaylightingDevicesData->TDDPipe(PipeNum).TZoneLength = 0.0; + state.dataDaylightingDevicesData->TDDPipe(PipeNum).TZoneHeatGain = 0.0; - for (TZoneNum = 1; TZoneNum <= TDDPipe(PipeNum).NumOfTZones; ++TZoneNum) { + for (TZoneNum = 1; TZoneNum <= state.dataDaylightingDevicesData->TDDPipe(PipeNum).NumOfTZones; ++TZoneNum) { TZoneName = cAlphaArgs(TZoneNum + 4); - TDDPipe(PipeNum).TZone(TZoneNum) = UtilityRoutines::FindItemInList(TZoneName, Zone); - if (TDDPipe(PipeNum).TZone(TZoneNum) == 0) { + state.dataDaylightingDevicesData->TDDPipe(PipeNum).TZone(TZoneNum) = UtilityRoutines::FindItemInList(TZoneName, Zone); + if (state.dataDaylightingDevicesData->TDDPipe(PipeNum).TZone(TZoneNum) == 0) { ShowSevereError(state, cCurrentModuleObject + " = " + cAlphaArgs(1) + ": Transition zone " + TZoneName + " not found."); ErrorsFound = true; } - TDDPipe(PipeNum).TZoneLength(TZoneNum) = rNumericArgs(TZoneNum + 3); - if (TDDPipe(PipeNum).TZoneLength(TZoneNum) < 0) { + state.dataDaylightingDevicesData->TDDPipe(PipeNum).TZoneLength(TZoneNum) = rNumericArgs(TZoneNum + 3); + if (state.dataDaylightingDevicesData->TDDPipe(PipeNum).TZoneLength(TZoneNum) < 0) { ShowSevereError(state, cCurrentModuleObject + " = " + cAlphaArgs(1) + ": Transition zone length for " + TZoneName + " must be zero or greater."); ErrorsFound = true; @@ -767,12 +764,12 @@ namespace DaylightingDevices { // FLOW: cCurrentModuleObject = "DaylightingDevice:Shelf"; - NumOfShelf = inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); + state.dataDaylightingDevicesData->NumOfShelf = inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); - if (NumOfShelf > 0) { - Shelf.allocate(NumOfShelf); + if (state.dataDaylightingDevicesData->NumOfShelf > 0) { + state.dataDaylightingDevicesData->Shelf.allocate(state.dataDaylightingDevicesData->NumOfShelf); - for (ShelfNum = 1; ShelfNum <= NumOfShelf; ++ShelfNum) { + for (ShelfNum = 1; ShelfNum <= state.dataDaylightingDevicesData->NumOfShelf; ++ShelfNum) { inputProcessor->getObjectItem(state, cCurrentModuleObject, ShelfNum, @@ -787,7 +784,7 @@ namespace DaylightingDevices { cNumericFieldNames); UtilityRoutines::IsNameEmpty(state, cAlphaArgs(1), cCurrentModuleObject, ErrorsFound); // Shelf name - Shelf(ShelfNum).Name = cAlphaArgs(1); + state.dataDaylightingDevicesData->Shelf(ShelfNum).Name = cAlphaArgs(1); // Get window object SurfNum = UtilityRoutines::FindItemInList(cAlphaArgs(2), Surface); @@ -830,7 +827,7 @@ namespace DaylightingDevices { ErrorsFound = true; } - Shelf(ShelfNum).Window = SurfNum; + state.dataDaylightingDevicesData->Shelf(ShelfNum).Window = SurfNum; Surface(SurfNum).Shelf = ShelfNum; } @@ -856,7 +853,7 @@ namespace DaylightingDevices { ErrorsFound = true; } - Shelf(ShelfNum).InSurf = SurfNum; + state.dataDaylightingDevicesData->Shelf(ShelfNum).InSurf = SurfNum; } } @@ -901,7 +898,7 @@ namespace DaylightingDevices { " must not have WindowMaterial:Glazing."); ErrorsFound = true; } else { - Shelf(ShelfNum).Construction = ConstrNum; + state.dataDaylightingDevicesData->Shelf(ShelfNum).Construction = ConstrNum; state.dataConstruction->Construct(ConstrNum).IsUsed = true; } } else { @@ -912,17 +909,17 @@ namespace DaylightingDevices { // Get view factor to outside shelf (optional) if (NumNumbers > 0) { - Shelf(ShelfNum).ViewFactor = rNumericArgs(1); + state.dataDaylightingDevicesData->Shelf(ShelfNum).ViewFactor = rNumericArgs(1); if (rNumericArgs(1) == 0.0) { ShowWarningError(state, cCurrentModuleObject + " = " + cAlphaArgs(1) + ": View factor to outside shelf is zero. Shelf does not reflect on window."); } } else { - Shelf(ShelfNum).ViewFactor = -1.0; // Flag to have the view factor calculated during initialization + state.dataDaylightingDevicesData->Shelf(ShelfNum).ViewFactor = -1.0; // Flag to have the view factor calculated during initialization } - Shelf(ShelfNum).OutSurf = SurfNum; + state.dataDaylightingDevicesData->Shelf(ShelfNum).OutSurf = SurfNum; // Reset some properties of the SURFACE:SHADING:ATTACHED object in order to receive radiation and shading // Normally this would be done during initialization, but that's not early enough for some shading calculations @@ -933,7 +930,7 @@ namespace DaylightingDevices { } } - if (Shelf(ShelfNum).InSurf == 0 && Shelf(ShelfNum).OutSurf == 0) + if (state.dataDaylightingDevicesData->Shelf(ShelfNum).InSurf == 0 && state.dataDaylightingDevicesData->Shelf(ShelfNum).OutSurf == 0) ShowWarningError(state, cCurrentModuleObject + " = " + cAlphaArgs(1) + ": No inside shelf or outside shelf was specified."); } // ShelfNum @@ -1077,7 +1074,7 @@ namespace DaylightingDevices { Real64 P = COSI; // Angular distribution function: P = COS(Incident Angle) for diffuse isotropic // Calculate total TDD transmittance for given angle - trans = TransTDD(state, PipeNum, COSI, SolarBeam); + trans = TransTDD(state, PipeNum, COSI, DataDaylightingDevices::iRadType::SolarBeam); FluxInc += P * SINI * dPH; FluxTrans += trans * P * SINI * dPH; @@ -1130,8 +1127,8 @@ namespace DaylightingDevices { Real64 CosPhi; // Cosine of TDD:DOME altitude angle Real64 Theta; // TDD:DOME azimuth angle - CosPhi = std::cos(DataGlobalConstants::PiOvr2() - Surface(TDDPipe(PipeNum).Dome).Tilt * DataGlobalConstants::DegToRadians()); - Theta = Surface(TDDPipe(PipeNum).Dome).Azimuth * DataGlobalConstants::DegToRadians(); + CosPhi = std::cos(DataGlobalConstants::PiOvr2() - Surface(state.dataDaylightingDevicesData->TDDPipe(PipeNum).Dome).Tilt * DataGlobalConstants::DegToRadians()); + Theta = Surface(state.dataDaylightingDevicesData->TDDPipe(PipeNum).Dome).Azimuth * DataGlobalConstants::DegToRadians(); if (CosPhi > 0.01) { // Dome has a view of the horizon // Integrate over the semicircle @@ -1145,7 +1142,7 @@ namespace DaylightingDevices { Real64 COSI = CosPhi * std::cos(TH - Theta); // Cosine of the incident angle // Calculate total TDD transmittance for given angle - Real64 trans = TransTDD(state, PipeNum, COSI, SolarBeam); // Total beam solar transmittance of TDD + Real64 trans = TransTDD(state, PipeNum, COSI, DataDaylightingDevices::iRadType::SolarBeam); // Total beam solar transmittance of TDD FluxInc += COSI * dTH; FluxTrans += trans * COSI * dTH; @@ -1219,7 +1216,7 @@ namespace DaylightingDevices { Real64 AnisoSkyTDDMult; // Anisotropic sky multiplier for TDD // FLOW: - DomeSurf = TDDPipe(PipeNum).Dome; + DomeSurf = state.dataDaylightingDevicesData->TDDPipe(PipeNum).Dome; if (!DetailedSkyDiffuseAlgorithm || !ShadingTransmittanceVaries || SolarDistribution == MinimalShadowing) { IsoSkyRad = MultIsoSky(DomeSurf) * DifShdgRatioIsoSky(DomeSurf); @@ -1230,8 +1227,8 @@ namespace DaylightingDevices { } CircumSolarRad = MultCircumSolar(DomeSurf) * SunlitFrac(state.dataGlobal->TimeStep, state.dataGlobal->HourOfDay, DomeSurf); - AnisoSkyTDDMult = TDDPipe(PipeNum).TransSolIso * IsoSkyRad + TransTDD(state, PipeNum, COSI, SolarBeam) * CircumSolarRad + - TDDPipe(PipeNum).TransSolHorizon * HorizonRad; + AnisoSkyTDDMult = state.dataDaylightingDevicesData->TDDPipe(PipeNum).TransSolIso * IsoSkyRad + TransTDD(state, PipeNum, COSI, DataDaylightingDevices::iRadType::SolarBeam) * CircumSolarRad + + state.dataDaylightingDevicesData->TDDPipe(PipeNum).TransSolHorizon * HorizonRad; if (AnisoSkyMult(DomeSurf) > 0.0) { CalcTDDTransSolAniso = AnisoSkyTDDMult / AnisoSkyMult(DomeSurf); @@ -1245,7 +1242,7 @@ namespace DaylightingDevices { Real64 TransTDD(EnergyPlusData &state, int const PipeNum, // TDD pipe object number Real64 const COSI, // Cosine of the incident angle - int const RadiationType // Radiation type flag + DataDaylightingDevices::iRadType const RadiationType // Radiation type flag ) { @@ -1294,32 +1291,32 @@ namespace DaylightingDevices { TransTDD = 0.0; // Get constructions of each TDD component - constDome = Surface(TDDPipe(PipeNum).Dome).Construction; - constDiff = Surface(TDDPipe(PipeNum).Diffuser).Construction; + constDome = Surface(state.dataDaylightingDevicesData->TDDPipe(PipeNum).Dome).Construction; + constDiff = Surface(state.dataDaylightingDevicesData->TDDPipe(PipeNum).Diffuser).Construction; // Get the transmittance of each component and of total TDD { auto const SELECT_CASE_var(RadiationType); - if (SELECT_CASE_var == VisibleBeam) { + if (SELECT_CASE_var == DataDaylightingDevices::iRadType::VisibleBeam) { transDome = POLYF(COSI, state.dataConstruction->Construct(constDome).TransVisBeamCoef); - transPipe = InterpolatePipeTransBeam(COSI, TDDPipe(PipeNum).PipeTransVisBeam); + transPipe = InterpolatePipeTransBeam(COSI, state.dataDaylightingDevicesData->TDDPipe(PipeNum).PipeTransVisBeam); transDiff = state.dataConstruction->Construct(constDiff).TransDiffVis; // May want to change to POLYF also! TransTDD = transDome * transPipe * transDiff; - } else if (SELECT_CASE_var == SolarBeam) { + } else if (SELECT_CASE_var == DataDaylightingDevices::iRadType::SolarBeam) { transDome = POLYF(COSI, state.dataConstruction->Construct(constDome).TransSolBeamCoef); - transPipe = InterpolatePipeTransBeam(COSI, TDDPipe(PipeNum).PipeTransSolBeam); + transPipe = InterpolatePipeTransBeam(COSI, state.dataDaylightingDevicesData->TDDPipe(PipeNum).PipeTransSolBeam); transDiff = state.dataConstruction->Construct(constDiff).TransDiff; // May want to change to POLYF also! TransTDD = transDome * transPipe * transDiff; - } else if (SELECT_CASE_var == SolarAniso) { + } else if (SELECT_CASE_var == DataDaylightingDevices::iRadType::SolarAniso) { TransTDD = CalcTDDTransSolAniso(state, PipeNum, COSI); - } else if (SELECT_CASE_var == SolarIso) { - TransTDD = TDDPipe(PipeNum).TransSolIso; + } else if (SELECT_CASE_var == DataDaylightingDevices::iRadType::SolarIso) { + TransTDD = state.dataDaylightingDevicesData->TDDPipe(PipeNum).TransSolIso; } } @@ -1350,7 +1347,7 @@ namespace DaylightingDevices { Real64 InterpolatePipeTransBeam; // Argument array dimensioning - EP_SIZE_CHECK(transBeam, NumOfAngles); + EP_SIZE_CHECK(transBeam, DataDaylightingDevices::NumOfAngles); // Locals // FUNCTION ARGUMENT DEFINITIONS: @@ -1368,7 +1365,7 @@ namespace DaylightingDevices { Lo = FindArrayIndex(COSI, COSAngle); Hi = Lo + 1; - if (Lo > 0 && Hi <= NumOfAngles) { + if (Lo > 0 && Hi <= DataDaylightingDevices::NumOfAngles) { m = (transBeam(Hi) - transBeam(Lo)) / (COSAngle(Hi) - COSAngle(Lo)); b = transBeam(Lo) - m * COSAngle(Lo); @@ -1411,14 +1408,14 @@ namespace DaylightingDevices { // FLOW: FindTDDPipe = 0; - if (NumOfTDDPipes <= 0) { + if (state.dataDaylightingDevicesData->NumOfTDDPipes <= 0) { ShowFatalError(state, "FindTDDPipe: Surface=" + Surface(WinNum).Name + ", TDD:Dome object does not reference a valid Diffuser object....needs DaylightingDevice:Tubular of same name as Surface."); } - for (PipeNum = 1; PipeNum <= NumOfTDDPipes; ++PipeNum) { - if ((WinNum == TDDPipe(PipeNum).Dome) || (WinNum == TDDPipe(PipeNum).Diffuser)) { + for (PipeNum = 1; PipeNum <= state.dataDaylightingDevicesData->NumOfTDDPipes; ++PipeNum) { + if ((WinNum == state.dataDaylightingDevicesData->TDDPipe(PipeNum).Dome) || (WinNum == state.dataDaylightingDevicesData->TDDPipe(PipeNum).Diffuser)) { FindTDDPipe = PipeNum; break; } @@ -1470,8 +1467,8 @@ namespace DaylightingDevices { Real64 TotTDDPipeGain; // Total absorbed solar gain in the tubular daylighting device pipe // FLOW: - for (PipeNum = 1; PipeNum <= NumOfTDDPipes; ++PipeNum) { - DiffSurf = TDDPipe(PipeNum).Diffuser; + for (PipeNum = 1; PipeNum <= state.dataDaylightingDevicesData->NumOfTDDPipes; ++PipeNum) { + DiffSurf = state.dataDaylightingDevicesData->TDDPipe(PipeNum).Diffuser; transDiff = state.dataConstruction->Construct(Surface(DiffSurf).Construction).TransDiff; // Calculate diffuse solar reflected back up the pipe by the inside surface of the TDD:DIFFUSER @@ -1481,17 +1478,17 @@ namespace DaylightingDevices { // Add diffuse interior shortwave reflected from zone surfaces and from zone sources, lights, etc. QRefl += QS(Surface(DiffSurf).SolarEnclIndex) * Surface(DiffSurf).Area * transDiff; - TotTDDPipeGain = SurfWinTransSolar(TDDPipe(PipeNum).Dome) - SurfQRadSWOutIncident(DiffSurf) * Surface(DiffSurf).Area + - QRefl * (1.0 - TDDPipe(PipeNum).TransSolIso / transDiff) + - SurfWinQRadSWwinAbs(1, TDDPipe(PipeNum).Dome) * Surface(DiffSurf).Area / 2.0 + + TotTDDPipeGain = SurfWinTransSolar(state.dataDaylightingDevicesData->TDDPipe(PipeNum).Dome) - SurfQRadSWOutIncident(DiffSurf) * Surface(DiffSurf).Area + + QRefl * (1.0 - state.dataDaylightingDevicesData->TDDPipe(PipeNum).TransSolIso / transDiff) + + SurfWinQRadSWwinAbs(1, state.dataDaylightingDevicesData->TDDPipe(PipeNum).Dome) * Surface(DiffSurf).Area / 2.0 + SurfWinQRadSWwinAbs(1, DiffSurf) * Surface(DiffSurf).Area / 2.0; // Solar entering pipe | Solar exiting pipe | Absorbed due to // reflections on the way out | Inward absorbed solar from dome // glass | Inward absorbed solar from diffuser glass - TDDPipe(PipeNum).PipeAbsorbedSolar = max(0.0, TotTDDPipeGain); // Report variable [W] + state.dataDaylightingDevicesData->TDDPipe(PipeNum).PipeAbsorbedSolar = max(0.0, TotTDDPipeGain); // Report variable [W] - for (TZoneNum = 1; TZoneNum <= TDDPipe(PipeNum).NumOfTZones; ++TZoneNum) { + for (TZoneNum = 1; TZoneNum <= state.dataDaylightingDevicesData->TDDPipe(PipeNum).NumOfTZones; ++TZoneNum) { // Distribute absorbed solar gain in proportion to transition zone length - TDDPipe(PipeNum).TZoneHeatGain(TZoneNum) = TotTDDPipeGain * (TDDPipe(PipeNum).TZoneLength(TZoneNum) / TDDPipe(PipeNum).TotLength); + state.dataDaylightingDevicesData->TDDPipe(PipeNum).TZoneHeatGain(TZoneNum) = TotTDDPipeGain * (state.dataDaylightingDevicesData->TDDPipe(PipeNum).TZoneLength(TZoneNum) / state.dataDaylightingDevicesData->TDDPipe(PipeNum).TotLength); } // TZoneNum } } @@ -1537,31 +1534,31 @@ namespace DaylightingDevices { int NumMatch; // Number of vertices matched // FLOW: - W = Surface(Shelf(ShelfNum).Window).Width; - H = Surface(Shelf(ShelfNum).Window).Height; + W = Surface(state.dataDaylightingDevicesData->Shelf(ShelfNum).Window).Width; + H = Surface(state.dataDaylightingDevicesData->Shelf(ShelfNum).Window).Height; // Find length, i.e. projection, of outside shelf - if (Surface(Shelf(ShelfNum).OutSurf).Width == W) { - L = Surface(Shelf(ShelfNum).OutSurf).Height; - } else if (Surface(Shelf(ShelfNum).OutSurf).Height == W) { - L = Surface(Shelf(ShelfNum).OutSurf).Width; + if (Surface(state.dataDaylightingDevicesData->Shelf(ShelfNum).OutSurf).Width == W) { + L = Surface(state.dataDaylightingDevicesData->Shelf(ShelfNum).OutSurf).Height; + } else if (Surface(state.dataDaylightingDevicesData->Shelf(ShelfNum).OutSurf).Height == W) { + L = Surface(state.dataDaylightingDevicesData->Shelf(ShelfNum).OutSurf).Width; } else { - ShowFatalError(state, "DaylightingDevice:Shelf = " + Shelf(ShelfNum).Name + ": Width of window and outside shelf do not match."); + ShowFatalError(state, "DaylightingDevice:Shelf = " + state.dataDaylightingDevicesData->Shelf(ShelfNum).Name + ": Width of window and outside shelf do not match."); } // Error if more or less than two vertices match NumMatch = 0; for (VWin = 1; VWin <= 4; ++VWin) { for (VShelf = 1; VShelf <= 4; ++VShelf) { - if (distance(Surface(Shelf(ShelfNum).Window).Vertex(VWin), Surface(Shelf(ShelfNum).OutSurf).Vertex(VShelf)) == 0.0) ++NumMatch; + if (distance(Surface(state.dataDaylightingDevicesData->Shelf(ShelfNum).Window).Vertex(VWin), Surface(state.dataDaylightingDevicesData->Shelf(ShelfNum).OutSurf).Vertex(VShelf)) == 0.0) ++NumMatch; } } if (NumMatch < 2) { - ShowWarningError(state, "DaylightingDevice:Shelf = " + Shelf(ShelfNum).Name + + ShowWarningError(state, "DaylightingDevice:Shelf = " + state.dataDaylightingDevicesData->Shelf(ShelfNum).Name + ": Window and outside shelf must share two vertices. View factor calculation may be inaccurate."); } else if (NumMatch > 2) { - ShowFatalError(state, "DaylightingDevice:Shelf = " + Shelf(ShelfNum).Name + ": Window and outside shelf share too many vertices."); + ShowFatalError(state, "DaylightingDevice:Shelf = " + state.dataDaylightingDevicesData->Shelf(ShelfNum).Name + ": Window and outside shelf share too many vertices."); } // Calculate exact analytical view factor from window to outside shelf @@ -1573,7 +1570,7 @@ namespace DaylightingDevices { E3 = std::pow(pow_2(M) * (1.0 + pow_2(M) + pow_2(N)) / ((1.0 + pow_2(M)) * (pow_2(M) + pow_2(N))), pow_2(M)); E4 = std::pow(pow_2(N) * (1.0 + pow_2(M) + pow_2(N)) / ((1.0 + pow_2(N)) * (pow_2(M) + pow_2(N))), pow_2(N)); - Shelf(ShelfNum).ViewFactor = (1.0 / (DataGlobalConstants::Pi() * M)) * (E1 + 0.25 * std::log(E2 * E3 * E4)); + state.dataDaylightingDevicesData->Shelf(ShelfNum).ViewFactor = (1.0 / (DataGlobalConstants::Pi() * M)) * (E1 + 0.25 * std::log(E2 * E3 * E4)); } void FigureTDDZoneGains(EnergyPlusData &state) @@ -1612,11 +1609,11 @@ namespace DaylightingDevices { static bool MyEnvrnFlag(true); int Loop; - if (NumOfTDDPipes == 0) return; + if (state.dataDaylightingDevicesData->NumOfTDDPipes == 0) return; if (state.dataGlobal->BeginEnvrnFlag && MyEnvrnFlag) { - for (Loop = 1; Loop <= NumOfTDDPipes; ++Loop) { - TDDPipe(Loop).TZoneHeatGain = 0.0; + for (Loop = 1; Loop <= state.dataDaylightingDevicesData->NumOfTDDPipes; ++Loop) { + state.dataDaylightingDevicesData->TDDPipe(Loop).TZoneHeatGain = 0.0; } MyEnvrnFlag = false; } diff --git a/src/EnergyPlus/DaylightingDevices.hh b/src/EnergyPlus/DaylightingDevices.hh index 01381942587..35fb2bae191 100644 --- a/src/EnergyPlus/DaylightingDevices.hh +++ b/src/EnergyPlus/DaylightingDevices.hh @@ -49,6 +49,7 @@ #define DaylightingDevices_hh_INCLUDED // EnergyPlus Headers +#include #include namespace EnergyPlus { @@ -58,18 +59,8 @@ struct EnergyPlusData; namespace DaylightingDevices { - // Data - // MODULE PARAMETER DEFINITIONS: na - // DERIVED TYPE DEFINITIONS: na - // MODULE VARIABLE TYPE DECLARATIONS: na - - // MODULE VARIABLE DECLARATIONS: extern Array1D COSAngle; // List of cosines of incident angle - // SUBROUTINE SPECIFICATIONS: - - // Functions - void InitDaylightingDevices(EnergyPlusData &state); void GetTDDInput(EnergyPlusData &state); @@ -93,7 +84,7 @@ namespace DaylightingDevices { Real64 TransTDD(EnergyPlusData &state, int const PipeNum, // TDD pipe object number Real64 const COSI, // Cosine of the incident angle - int const RadiationType // Radiation type flag + DataDaylightingDevices::iRadType const RadiationType // Radiation type flag ); Real64 InterpolatePipeTransBeam(Real64 const COSI, // Cosine of the incident angle diff --git a/src/EnergyPlus/DaylightingManager.cc b/src/EnergyPlus/DaylightingManager.cc index 8fefde7dff1..1329a68f6e5 100644 --- a/src/EnergyPlus/DaylightingManager.cc +++ b/src/EnergyPlus/DaylightingManager.cc @@ -148,7 +148,6 @@ namespace DaylightingManager { using namespace DataHeatBalance; using namespace DataSurfaces; using namespace DataEnvironment; - using namespace DataDaylightingDevices; using DataBSDFWindow::BSDFDaylghtPosition; using namespace ScheduleManager; @@ -432,7 +431,7 @@ namespace DaylightingManager { // Daylighting shelf simplification: All light goes up to the ceiling regardless of orientation of shelf if (Surface(IWin).Shelf > 0) { - if (Shelf(Surface(IWin).Shelf).InSurf > 0) SurfWinFractionUpgoing(IWin) = 1.0; + if (state.dataDaylightingDevicesData->Shelf(Surface(IWin).Shelf).InSurf > 0) SurfWinFractionUpgoing(IWin) = 1.0; } } } @@ -585,9 +584,9 @@ namespace DaylightingManager { // Used in calculating daylighting through interior windows. CalcMinIntWinSolidAngs(state); - TDDTransVisBeam.allocate(24, NumOfTDDPipes); - TDDFluxInc.allocate(24, 4, NumOfTDDPipes); - TDDFluxTrans.allocate(24, 4, NumOfTDDPipes); + TDDTransVisBeam.allocate(24, state.dataDaylightingDevicesData->NumOfTDDPipes); + TDDFluxInc.allocate(24, 4, state.dataDaylightingDevicesData->NumOfTDDPipes); + TDDFluxTrans.allocate(24, 4, state.dataDaylightingDevicesData->NumOfTDDPipes); // Warning if detailed daylighting has been requested for a zone with no associated exterior windows. for (ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ++ZoneNum) { @@ -614,9 +613,9 @@ namespace DaylightingManager { TDDFluxInc = 0.0; TDDFluxTrans = 0.0; } else { - TDDTransVisBeam(state.dataGlobal->HourOfDay, {1, NumOfTDDPipes}) = 0.0; - TDDFluxInc(state.dataGlobal->HourOfDay, {1, 4}, {1, NumOfTDDPipes}) = 0.0; - TDDFluxTrans(state.dataGlobal->HourOfDay, {1, 4}, {1, NumOfTDDPipes}) = 0.0; + TDDTransVisBeam(state.dataGlobal->HourOfDay, {1, state.dataDaylightingDevicesData->NumOfTDDPipes}) = 0.0; + TDDFluxInc(state.dataGlobal->HourOfDay, {1, 4}, {1, state.dataDaylightingDevicesData->NumOfTDDPipes}) = 0.0; + TDDFluxTrans(state.dataGlobal->HourOfDay, {1, 4}, {1, state.dataDaylightingDevicesData->NumOfTDDPipes}) = 0.0; } if (!DetailedSolarTimestepIntegration) { @@ -1876,7 +1875,7 @@ namespace DaylightingManager { ShelfNum = Surface(IWin).Shelf; if (ShelfNum > 0) { - InShelfSurf = Shelf(Surface(IWin).Shelf).InSurf; // Inside daylighting shelf present if > 0 + InShelfSurf = state.dataDaylightingDevicesData->Shelf(Surface(IWin).Shelf).InSurf; // Inside daylighting shelf present if > 0 } else { InShelfSurf = 0; } @@ -2033,7 +2032,7 @@ namespace DaylightingManager { // Look up the TDD:DOME object PipeNum = SurfWinTDDPipeNum(IWin); - IWin2 = TDDPipe(PipeNum).Dome; + IWin2 = state.dataDaylightingDevicesData->TDDPipe(PipeNum).Dome; // Calculate reference point coords relative to the diffuser coordinate system // W21, W23, and WNORM are the unit vectors @@ -2354,7 +2353,7 @@ namespace DaylightingManager { // Look up the TDD:DOME object PipeNum = SurfWinTDDPipeNum(IWin); // Unshaded visible transmittance of TDD for a single ray from sky/ground element - TVISB = TransTDD(state, PipeNum, COSB, VisibleBeam) * SurfWinGlazedFrac(IWin); + TVISB = TransTDD(state, PipeNum, COSB, DataDaylightingDevices::iRadType::VisibleBeam) * SurfWinGlazedFrac(IWin); } else { // Regular window if (SurfWinWindowModelType(IWin) != WindowBSDFModel) { @@ -5544,8 +5543,6 @@ namespace DaylightingManager { // Using/Aliasing using DataHeatBalance::Zone; - using namespace DataDaylightingDevices; - // Locals // SUBROUTINE ARGUMENT DEFINITIONS: // na @@ -5566,8 +5563,8 @@ namespace DaylightingManager { ErrorsFound = false; - for (PipeNum = 1; PipeNum <= NumOfTDDPipes; ++PipeNum) { - SurfNum = TDDPipe(PipeNum).Diffuser; + for (PipeNum = 1; PipeNum <= state.dataDaylightingDevicesData->NumOfTDDPipes; ++PipeNum) { + SurfNum = state.dataDaylightingDevicesData->TDDPipe(PipeNum).Diffuser; if (SurfNum > 0) { bool daylightControlFound = false; int const pipeEnclNum = Zone(Surface(SurfNum).Zone).SolarEnclosureNum; @@ -5577,21 +5574,21 @@ namespace DaylightingManager { } } if (!daylightControlFound) { - ShowWarningError(state, "DaylightingDevice:Tubular = " + TDDPipe(PipeNum).Name + ": is not connected to a Zone that has Daylighting, no visible transmittance will be modeled through the daylighting device."); + ShowWarningError(state, "DaylightingDevice:Tubular = " + state.dataDaylightingDevicesData->TDDPipe(PipeNum).Name + ": is not connected to a Zone that has Daylighting, no visible transmittance will be modeled through the daylighting device."); } } else { // SurfNum == 0 // should not come here (would have already been caught in TDD get input), but is an error - ShowSevereError(state, "DaylightingDevice:Tubular = " + TDDPipe(PipeNum).Name + ": Diffuser surface not found "); + ShowSevereError(state, "DaylightingDevice:Tubular = " + state.dataDaylightingDevicesData->TDDPipe(PipeNum).Name + ": Diffuser surface not found "); ErrorsFound = true; } } // PipeNum - for (ShelfNum = 1; ShelfNum <= NumOfShelf; ++ShelfNum) { - SurfNum = Shelf(ShelfNum).Window; + for (ShelfNum = 1; ShelfNum <= state.dataDaylightingDevicesData->NumOfShelf; ++ShelfNum) { + SurfNum = state.dataDaylightingDevicesData->Shelf(ShelfNum).Window; if (SurfNum == 0) { // should not come here (would have already been caught in shelf get input), but is an error - ShowSevereError(state, "DaylightingDevice:Shelf = " + Shelf(ShelfNum).Name + ": window not found "); + ShowSevereError(state, "DaylightingDevice:Shelf = " + state.dataDaylightingDevicesData->Shelf(ShelfNum).Name + ": window not found "); ErrorsFound = true; } } // ShelfNum @@ -7296,9 +7293,9 @@ namespace DaylightingManager { } // Calculate and report TDD visible transmittances - for (PipeNum = 1; PipeNum <= NumOfTDDPipes; ++PipeNum) { + for (PipeNum = 1; PipeNum <= state.dataDaylightingDevicesData->NumOfTDDPipes; ++PipeNum) { - TDDPipe(PipeNum).TransVisBeam = + state.dataDaylightingDevicesData->TDDPipe(PipeNum).TransVisBeam = state.dataGlobal->WeightNow * TDDTransVisBeam(state.dataGlobal->HourOfDay, PipeNum) + state.dataGlobal->WeightPreviousHour * TDDTransVisBeam(state.dataGlobal->PreviousHour, PipeNum); for (ISky = 1; ISky <= 4; ++ISky) { @@ -7317,7 +7314,7 @@ namespace DaylightingManager { TDDTransVisDiff(ISky) = state.dataGlobal->WeightNow * TDDTransVisDiffNow + state.dataGlobal->WeightPreviousHour * TDDTransVisDiffPrev; } // ISky - TDDPipe(PipeNum).TransVisDiff = SkyWeight * TDDTransVisDiff(ISky1) + (1.0 - SkyWeight) * TDDTransVisDiff(ISky2); + state.dataDaylightingDevicesData->TDDPipe(PipeNum).TransVisDiff = SkyWeight * TDDTransVisDiff(ISky1) + (1.0 - SkyWeight) * TDDTransVisDiff(ISky2); } // PipeNum } @@ -7807,8 +7804,8 @@ namespace DaylightingManager { ShelfNum = Surface(IWin).Shelf; if (ShelfNum > 0) { - InShelfSurf = Shelf(ShelfNum).InSurf; // Inside daylighting shelf present if > 0 - OutShelfSurf = Shelf(ShelfNum).OutSurf; // Outside daylighting shelf present if > 0 + InShelfSurf = state.dataDaylightingDevicesData->Shelf(ShelfNum).InSurf; // Inside daylighting shelf present if > 0 + OutShelfSurf = state.dataDaylightingDevicesData->Shelf(ShelfNum).OutSurf; // Outside daylighting shelf present if > 0 } else { InShelfSurf = 0; OutShelfSurf = 0; @@ -8001,7 +7998,7 @@ namespace DaylightingManager { if (SurfWinOriginalClass(IWin) == SurfaceClass::TDD_Dome) { // Unshaded visible transmittance of TDD for a single ray from sky/ground element - TVISBR = TransTDD(state, PipeNum, COSB, VisibleBeam) * SurfWinGlazedFrac(IWin); + TVISBR = TransTDD(state, PipeNum, COSB, DataDaylightingDevices::iRadType::VisibleBeam) * SurfWinGlazedFrac(IWin); // Make all transmitted light diffuse for a TDD with a bare diffuser for (ISky = 1; ISky <= 4; ++ISky) { @@ -8122,7 +8119,7 @@ namespace DaylightingManager { if (ShadeOn) { // Shade if (SurfWinOriginalClass(IWin) == SurfaceClass::TDD_Dome) { // Shaded visible transmittance of TDD for a single ray from sky/ground element - TransMult(1) = TransTDD(state, PipeNum, COSB, VisibleBeam) * SurfWinGlazedFrac(IWin); + TransMult(1) = TransTDD(state, PipeNum, COSB, DataDaylightingDevices::iRadType::VisibleBeam) * SurfWinGlazedFrac(IWin); } else { // Shade only, no TDD // Calculate transmittance of the combined window and shading device for this sky/ground element TransMult(1) = POLYF(COSB, state.dataConstruction->Construct(IConstShaded).TransVisBeamCoef) * SurfWinGlazedFrac(IWin) * @@ -8246,13 +8243,13 @@ namespace DaylightingManager { for (ISky = 1; ISky <= 4; ++ISky) { // This is only an estimate because the anisotropic sky view of the shelf is not yet taken into account. // AnisoSkyMult would be great to use but it is not available until the heat balance starts up. - ZSK(ISky) = GILSK(IHR, ISky) * 1.0 * Shelf(ShelfNum).OutReflectVis * Shelf(ShelfNum).ViewFactor; + ZSK(ISky) = GILSK(IHR, ISky) * 1.0 * state.dataDaylightingDevicesData->Shelf(ShelfNum).OutReflectVis * state.dataDaylightingDevicesData->Shelf(ShelfNum).ViewFactor; // SurfaceWindow(IWin)%FractionUpgoing is already set to 1.0 earlier FLCWSK(1, ISky) += ZSK(ISky) * TVISBR * SurfWinFractionUpgoing(IWin); if (ISky == 1) { - ZSU = GILSU(IHR) * SunlitFracHR(IHR, OutShelfSurf) * Shelf(ShelfNum).OutReflectVis * Shelf(ShelfNum).ViewFactor; + ZSU = GILSU(IHR) * SunlitFracHR(IHR, OutShelfSurf) * state.dataDaylightingDevicesData->Shelf(ShelfNum).OutReflectVis * state.dataDaylightingDevicesData->Shelf(ShelfNum).ViewFactor; FLCWSU(1) += ZSU * TVISBR * SurfWinFractionUpgoing(IWin); } } // ISKY @@ -8296,7 +8293,7 @@ namespace DaylightingManager { if (SurfWinOriginalClass(IWin) == SurfaceClass::TDD_Dome) { // Unshaded visible transmittance of TDD for collimated beam from the sun - TVISBSun = TransTDD(state, PipeNum, COSBSun, VisibleBeam) * SurfWinGlazedFrac(IWin); + TVISBSun = TransTDD(state, PipeNum, COSBSun, DataDaylightingDevices::iRadType::VisibleBeam) * SurfWinGlazedFrac(IWin); TDDTransVisBeam(IHR, PipeNum) = TVISBSun; FLFWSUdisk(1) = 0.0; // Diffuse light only @@ -8335,7 +8332,7 @@ namespace DaylightingManager { if (ShadeOn || ScreenOn || SurfWinSolarDiffusing(IWin)) { // Shade or screen on or diffusing glass if (SurfWinOriginalClass(IWin) == SurfaceClass::TDD_Dome) { // Shaded visible transmittance of TDD for collimated beam from the sun - TransMult(1) = TransTDD(state, PipeNum, COSBSun, VisibleBeam) * SurfWinGlazedFrac(IWin); + TransMult(1) = TransTDD(state, PipeNum, COSBSun, DataDaylightingDevices::iRadType::VisibleBeam) * SurfWinGlazedFrac(IWin); } else { if (ScreenOn) { TransMult(1) = SurfaceScreens(SurfWinScreenNumber(IWin)).BmBmTransVis * SurfWinGlazedFrac(IWin) * diff --git a/src/EnergyPlus/HeatBalanceSurfaceManager.cc b/src/EnergyPlus/HeatBalanceSurfaceManager.cc index 3cb067bccf8..7e5e2190627 100644 --- a/src/EnergyPlus/HeatBalanceSurfaceManager.cc +++ b/src/EnergyPlus/HeatBalanceSurfaceManager.cc @@ -353,7 +353,6 @@ namespace HeatBalanceSurfaceManager { // na // Using/Aliasing - using DataDaylightingDevices::NumOfTDDPipes; using DataDElight::LUX2FC; using namespace SolarShading; using ConvectionCoefficients::InitInteriorConvectionCoeffs; @@ -555,7 +554,7 @@ namespace HeatBalanceSurfaceManager { if (!state.dataGlobal->DoingSizing) DayltgInteriorMapIllum(state, NZ); } - if (SunIsUp && NumOfTDDPipes > 0 && NZ == 1) { + if (SunIsUp && state.dataDaylightingDevicesData->NumOfTDDPipes > 0 && NZ == 1) { if (InitSurfaceHeatBalancefirstTime) DisplayString(state, "Computing Interior Daylighting Illumination for TDD pipes"); DayltgInteriorTDDIllum(state); } @@ -2330,7 +2329,6 @@ namespace HeatBalanceSurfaceManager { using General::InterpSlatAng; using General::InterpSw; using General::POLYF; - using namespace DataDaylightingDevices; using DaylightingDevices::TransTDD; using namespace DataWindowEquivalentLayer; using SolarShading::SurfaceScheduledSolarInc; @@ -2569,8 +2567,8 @@ namespace HeatBalanceSurfaceManager { } } - if (NumOfTDDPipes > 0) { - for (auto &e : TDDPipe) { + if (state.dataDaylightingDevicesData->NumOfTDDPipes > 0) { + for (auto &e : state.dataDaylightingDevicesData->TDDPipe) { e.TransSolBeam = 0.0; e.TransSolDiff = 0.0; e.TransVisBeam = 0.0; @@ -2785,9 +2783,9 @@ namespace HeatBalanceSurfaceManager { } } } - for (int PipeNum = 1; PipeNum <= NumOfTDDPipes; ++PipeNum) { - int SurfNum = TDDPipe(PipeNum).Diffuser; // TDD: Diffuser object number - int SurfNum2 = TDDPipe(PipeNum).Dome; // TDD: DOME object number + for (int PipeNum = 1; PipeNum <= state.dataDaylightingDevicesData->NumOfTDDPipes; ++PipeNum) { + int SurfNum = state.dataDaylightingDevicesData->TDDPipe(PipeNum).Diffuser; // TDD: Diffuser object number + int SurfNum2 = state.dataDaylightingDevicesData->TDDPipe(PipeNum).Dome; // TDD: DOME object number int ConstrNum = Surface(SurfNum).Construction; if (SurfWinStormWinFlag(SurfNum) == 1) ConstrNum = Surface(SurfNum).StormWinConstruction; @@ -2795,15 +2793,15 @@ namespace HeatBalanceSurfaceManager { // Reconstruct the beam, sky, and ground radiation transmittance of just the TDD:DOME and TDD pipe // by dividing out diffuse solar transmittance of TDD:DIFFUSER - currBeamSolar(SurfNum) = BeamSolarRad * TransTDD(state, PipeNum, currCosInc(SurfNum), SolarBeam) / + currBeamSolar(SurfNum) = BeamSolarRad * TransTDD(state, PipeNum, currCosInc(SurfNum), DataDaylightingDevices::iRadType::SolarBeam) / state.dataConstruction->Construct(ConstrNum).TransDiff; currSkySolarInc(SurfNum) = DifSolarRad * AnisoSkyMult(SurfNum2) * - TransTDD(state, PipeNum, currCosInc(SurfNum), SolarAniso) / + TransTDD(state, PipeNum, currCosInc(SurfNum), DataDaylightingDevices::iRadType::SolarAniso) / state.dataConstruction->Construct(ConstrNum).TransDiff; currGndSolarInc(SurfNum) = - GndSolarRad * Surface(SurfNum2).ViewFactorGround * TDDPipe(PipeNum).TransSolIso / + GndSolarRad * Surface(SurfNum2).ViewFactorGround * state.dataDaylightingDevicesData->TDDPipe(PipeNum).TransSolIso / state.dataConstruction->Construct(ConstrNum).TransDiff; // Incident direct (unreflected) beam SurfQRadSWOutIncidentBeam(SurfNum) = @@ -2816,9 +2814,9 @@ namespace HeatBalanceSurfaceManager { SurfQRadSWOutIncidentBeam(SurfNum) + SurfQRadSWOutIncidentSkyDiffuse(SurfNum) + SurfQRadSWOutIncBmToDiffReflGnd(SurfNum) + SurfQRadSWOutIncSkyDiffReflGnd(SurfNum); } - for (int ShelfNum = 1; ShelfNum <= NumOfShelf; ++ShelfNum) { - int SurfNum = Shelf(ShelfNum).Window; // Daylighting shelf object number - int OutShelfSurf = Shelf(ShelfNum).OutSurf; // Outside daylighting shelf present if > 0 + for (int ShelfNum = 1; ShelfNum <= state.dataDaylightingDevicesData->NumOfShelf; ++ShelfNum) { + int SurfNum = state.dataDaylightingDevicesData->Shelf(ShelfNum).Window; // Daylighting shelf object number + int OutShelfSurf = state.dataDaylightingDevicesData->Shelf(ShelfNum).OutSurf; // Outside daylighting shelf present if > 0 currCosInc(SurfNum) = CosIncAng(state.dataGlobal->TimeStep, state.dataGlobal->HourOfDay, SurfNum); currBeamSolar(SurfNum) = BeamSolarRad; currSkySolarInc(SurfNum) = DifSolarRad * AnisoSkyMult(SurfNum); @@ -2826,12 +2824,12 @@ namespace HeatBalanceSurfaceManager { Real64 ShelfSolarRad = (BeamSolarRad * SunlitFrac(state.dataGlobal->TimeStep, state.dataGlobal->HourOfDay, OutShelfSurf) * CosIncAng(state.dataGlobal->TimeStep, state.dataGlobal->HourOfDay, OutShelfSurf) + DifSolarRad * AnisoSkyMult(OutShelfSurf)) * - Shelf(ShelfNum).OutReflectSol; + state.dataDaylightingDevicesData->Shelf(ShelfNum).OutReflectSol; // Add all reflected solar from the outside shelf to the ground solar // NOTE: If the shelf blocks part of the view to the ground, the user must reduce the ground view factor!! currGndSolarInc(SurfNum) = GndSolarRad * Surface(SurfNum).ViewFactorGround + - ShelfSolarRad * Shelf(ShelfNum).ViewFactor; + ShelfSolarRad * state.dataDaylightingDevicesData->Shelf(ShelfNum).ViewFactor; } for (int zoneNum = 1; zoneNum <= state.dataGlobal->NumOfZones; ++zoneNum) { @@ -2869,7 +2867,7 @@ namespace HeatBalanceSurfaceManager { int ShelfNum = Surface(SurfNum).Shelf; // Daylighting shelf object number int InShelfSurf = 0; // Inside daylighting shelf surface number if (ShelfNum > 0) { - InShelfSurf = Shelf(ShelfNum).InSurf; // Inside daylighting shelf present if > 0 + InShelfSurf = state.dataDaylightingDevicesData->Shelf(ShelfNum).InSurf; // Inside daylighting shelf present if > 0 } SurfOpaqQRadSWInAbs(SurfNum) += SurfOpaqAI(SurfNum) * BeamSolarRad; if (InShelfSurf > 0) { // Inside daylighting shelf @@ -3104,7 +3102,7 @@ namespace HeatBalanceSurfaceManager { } else if (state.dataWindowManager->inExtWindowModel->isExternalLibraryModel()) { int SurfNum2 = SurfNum; if (SurfWinOriginalClass(SurfNum) == SurfaceClass::TDD_Diffuser) { - SurfNum2 = TDDPipe(SurfWinTDDPipeNum(SurfNum)).Dome; + SurfNum2 = state.dataDaylightingDevicesData->TDDPipe(SurfWinTDDPipeNum(SurfNum)).Dome; } std::pair incomingAngle = @@ -3407,8 +3405,8 @@ namespace HeatBalanceSurfaceManager { } // Surface(SurfNum)%ExtSolar } // end of surface window loop } // end of zone loop - for (int PipeNum = 1; PipeNum <= NumOfTDDPipes; ++PipeNum) { - int SurfNum = TDDPipe(PipeNum).Dome; // TDD: DOME object number + for (int PipeNum = 1; PipeNum <= state.dataDaylightingDevicesData->NumOfTDDPipes; ++PipeNum) { + int SurfNum = state.dataDaylightingDevicesData->TDDPipe(PipeNum).Dome; // TDD: DOME object number int ConstrNum = Surface(SurfNum).Construction; int TotGlassLay = state.dataConstruction->Construct(ConstrNum).TotGlassLayers; // Number of glass layers SurfWinQRadSWwinAbsTot(SurfNum) = 0.0; @@ -6782,9 +6780,9 @@ namespace HeatBalanceSurfaceManager { if (SurfWinOriginalClass(SurfNum) == SurfaceClass::TDD_Diffuser) { // Tubular daylighting device // Lookup up the TDD:DOME object int const pipeNum = SurfWinTDDPipeNum(SurfNum); - int const domeNum = DataDaylightingDevices::TDDPipe(pipeNum).Dome; + int const domeNum = state.dataDaylightingDevicesData->TDDPipe(pipeNum).Dome; // Ueff = 1 / effective R value between TDD:DOME and TDD:DIFFUSER - Real64 Ueff = 1.0 / DataDaylightingDevices::TDDPipe(pipeNum).Reff; + Real64 Ueff = 1.0 / state.dataDaylightingDevicesData->TDDPipe(pipeNum).Reff; // Similar to opaque surface but outside surface temp of TDD:DOME is used, and no embedded sources/sinks. // Absorbed shortwave radiation is treated similar to a regular window, but only 1 glass layer is allowed. @@ -6924,7 +6922,7 @@ namespace HeatBalanceSurfaceManager { // and the outside face of the TDD:DIFFUSER for reporting. // Set inside temp variables of TDD:DOME equal to inside temp of TDD:DIFFUSER - int domeNum = DataDaylightingDevices::TDDPipe(SurfWinTDDPipeNum(SurfNum)).Dome; + int domeNum = state.dataDaylightingDevicesData->TDDPipe(SurfWinTDDPipeNum(SurfNum)).Dome; TH(2, 1, domeNum) = TempSurfIn(domeNum) = TempSurfInTmp(domeNum) = TempSurfInRep(domeNum) = TempSurfIn(SurfNum); // Set outside temp reporting variable of TDD:DOME (since it gets skipped otherwise) @@ -7059,8 +7057,8 @@ namespace HeatBalanceSurfaceManager { DataSurfaces::SurfWinHeatTransferRepEnergy(surfNum) = DataSurfaces::SurfWinHeatGain(surfNum) * state.dataGlobal->TimeStepZoneSec; if (DataSurfaces::SurfWinOriginalClass(surfNum) == DataSurfaces::SurfaceClass::TDD_Diffuser) { // Tubular daylighting device int pipeNum = DataSurfaces::SurfWinTDDPipeNum(surfNum); - DataDaylightingDevices::TDDPipe(pipeNum).HeatGain = DataSurfaces::SurfWinHeatGainRep(surfNum); - DataDaylightingDevices::TDDPipe(pipeNum).HeatLoss = DataSurfaces::SurfWinHeatLossRep(surfNum); + state.dataDaylightingDevicesData->TDDPipe(pipeNum).HeatGain = DataSurfaces::SurfWinHeatGainRep(surfNum); + state.dataDaylightingDevicesData->TDDPipe(pipeNum).HeatLoss = DataSurfaces::SurfWinHeatLossRep(surfNum); } if (DataSurfaces::Surface(surfNum).ExtSolar) { // WindowManager's definition of ZoneWinHeatGain/Loss int zoneNum = DataSurfaces::Surface(surfNum).Zone; @@ -7491,9 +7489,9 @@ namespace HeatBalanceSurfaceManager { if (SurfWinOriginalClass(surfNum) == SurfaceClass::TDD_Diffuser) { // Tubular daylighting device // Lookup up the TDD:DOME object int const pipeNum = SurfWinTDDPipeNum(surfNum); - int const domeNum = DataDaylightingDevices::TDDPipe(pipeNum).Dome; + int const domeNum = state.dataDaylightingDevicesData->TDDPipe(pipeNum).Dome; // Ueff = 1 / effective R value between TDD:DOME and TDD:DIFFUSER - Real64 Ueff = 1.0 / DataDaylightingDevices::TDDPipe(pipeNum).Reff; + Real64 Ueff = 1.0 / state.dataDaylightingDevicesData->TDDPipe(pipeNum).Reff; // Similar to opaque surface but outside surface temp of TDD:DOME is used, and no embedded sources/sinks. // Absorbed shortwave radiation is treated similar to a regular window, but only 1 glass layer is allowed. @@ -7636,7 +7634,7 @@ namespace HeatBalanceSurfaceManager { // and the outside face of the TDD:DIFFUSER for reporting. // Set inside temp variables of TDD:DOME equal to inside temp of TDD:DIFFUSER - int domeNum = DataDaylightingDevices::TDDPipe(SurfWinTDDPipeNum(surfNum)).Dome; + int domeNum = state.dataDaylightingDevicesData->TDDPipe(SurfWinTDDPipeNum(surfNum)).Dome; TH(2, 1, domeNum) = TempSurfIn(domeNum) = TempSurfInTmp(domeNum) = TempSurfInRep(domeNum) = TempSurfIn(surfNum); // Set outside temp reporting variable of TDD:DOME (since it gets skipped otherwise) @@ -7755,8 +7753,8 @@ namespace HeatBalanceSurfaceManager { DataSurfaces::SurfWinHeatTransferRepEnergy(surfNum) = DataSurfaces::SurfWinHeatGain(surfNum) * state.dataGlobal->TimeStepZoneSec; if (DataSurfaces::SurfWinOriginalClass(surfNum) == DataSurfaces::SurfaceClass::TDD_Diffuser) { // Tubular daylighting device int pipeNum = DataSurfaces::SurfWinTDDPipeNum(surfNum); - DataDaylightingDevices::TDDPipe(pipeNum).HeatGain = DataSurfaces::SurfWinHeatGainRep(surfNum); - DataDaylightingDevices::TDDPipe(pipeNum).HeatLoss = DataSurfaces::SurfWinHeatLossRep(surfNum); + state.dataDaylightingDevicesData->TDDPipe(pipeNum).HeatGain = DataSurfaces::SurfWinHeatGainRep(surfNum); + state.dataDaylightingDevicesData->TDDPipe(pipeNum).HeatLoss = DataSurfaces::SurfWinHeatLossRep(surfNum); } if (DataSurfaces::Surface(surfNum).ExtSolar) { // WindowManager's definition of ZoneWinHeatGain/Loss int zoneNum = DataSurfaces::Surface(surfNum).Zone; @@ -7997,7 +7995,6 @@ namespace HeatBalanceSurfaceManager { using DataMoistureBalance::RhoVaporAirOut; using DataMoistureBalance::RhoVaporSurfIn; using DataMoistureBalance::TempOutsideAirFD; - using namespace DataDaylightingDevices; using namespace Psychrometrics; // Locals @@ -8053,9 +8050,9 @@ namespace HeatBalanceSurfaceManager { // Lookup up the TDD:DIFFUSER object int PipeNum = SurfWinTDDPipeNum(SurfNum); - int SurfNum2 = TDDPipe(PipeNum).Diffuser; + int SurfNum2 = state.dataDaylightingDevicesData->TDDPipe(PipeNum).Diffuser; int ZoneNum2 = Surface(SurfNum2).Zone; - Real64 Ueff = 1.0 / TDDPipe(PipeNum).Reff; // 1 / effective R value between TDD:DOME and TDD:DIFFUSER + Real64 Ueff = 1.0 / state.dataDaylightingDevicesData->TDDPipe(PipeNum).Reff; // 1 / effective R value between TDD:DOME and TDD:DIFFUSER F1 = Ueff / (Ueff + HConvIn(SurfNum2)); // Similar to opaque surface but inside conditions of TDD:DIFFUSER are used, and no embedded sources/sinks. diff --git a/src/EnergyPlus/SolarShading.cc b/src/EnergyPlus/SolarShading.cc index 260b2b24c3e..b7f1bb8c3f2 100644 --- a/src/EnergyPlus/SolarShading.cc +++ b/src/EnergyPlus/SolarShading.cc @@ -5961,7 +5961,6 @@ namespace SolarShading { using General::InterpSw; using General::POLYF; using ScheduleManager::GetCurrentScheduleValue; - using namespace DataDaylightingDevices; using DaylightingDevices::TransTDD; using namespace DataWindowEquivalentLayer; @@ -6048,8 +6047,8 @@ namespace SolarShading { SurfOpaqAO(SurfNum) = 0.0; } } - if (NumOfTDDPipes > 0) { - for (auto &e : TDDPipe) { + if (state.dataDaylightingDevicesData->NumOfTDDPipes > 0) { + for (auto &e : state.dataDaylightingDevicesData->TDDPipe) { int SurfDome = e.Dome; for (int lay = 1; lay <= CFSMAXNL + 1; ++lay) { SurfWinA(lay, SurfDome) = 0.0; @@ -6110,14 +6109,14 @@ namespace SolarShading { int SurfNum2 = SurfNum; int PipeNum = SurfWinTDDPipeNum(SurfNum); if (SurfWinOriginalClass(SurfNum) == SurfaceClass::TDD_Diffuser) { - SurfNum2 = TDDPipe(PipeNum).Dome; + SurfNum2 = state.dataDaylightingDevicesData->TDDPipe(PipeNum).Dome; } int InShelfSurf = 0; // Inside daylighting shelf surface number int OutShelfSurf = 0; // Outside daylighting shelf surface number int ShelfNum = Surface(SurfNum).Shelf; if (ShelfNum > 0) { // Daylighting shelf - InShelfSurf = Shelf(ShelfNum).InSurf; - OutShelfSurf = Shelf(ShelfNum).OutSurf; + InShelfSurf = state.dataDaylightingDevicesData->Shelf(ShelfNum).InSurf; + OutShelfSurf = state.dataDaylightingDevicesData->Shelf(ShelfNum).OutSurf; } Real64 CosInc = CosIncAng(state.dataGlobal->TimeStep, state.dataGlobal->HourOfDay, SurfNum2); Real64 SunLitFract = SunlitFrac(state.dataGlobal->TimeStep, state.dataGlobal->HourOfDay, SurfNum2); @@ -6520,7 +6519,7 @@ namespace SolarShading { // Construct( Surface( SurfNum ).Construction ).TransDiff = NomDiffTrans; } } else if (SurfWinOriginalClass(SurfNum) == SurfaceClass::TDD_Diffuser) { - DiffTrans = TransTDD(state, PipeNum, CosInc, SolarAniso); + DiffTrans = TransTDD(state, PipeNum, CosInc, DataDaylightingDevices::iRadType::SolarAniso); } else { DiffTrans = state.dataConstruction->Construct(ConstrNum).TransDiff; } @@ -6566,8 +6565,8 @@ namespace SolarShading { // Beam-beam transmittance for bare exterior window if (SunLitFract > 0.0) { if (SurfWinOriginalClass(SurfNum) == SurfaceClass::TDD_Diffuser) { - TBmDif = TransTDD(state, PipeNum, CosInc, SolarBeam); - TDDPipe(PipeNum).TransSolBeam = TBmDif; // Report variable + TBmDif = TransTDD(state, PipeNum, CosInc, DataDaylightingDevices::iRadType::SolarBeam); + state.dataDaylightingDevicesData->TDDPipe(PipeNum).TransSolBeam = TBmDif; // Report variable } else if (SurfWinWindowModelType(SurfNum) != WindowBSDFModel && SurfWinWindowModelType(SurfNum) != WindowEQLModel) { // Regular window if (!SurfWinSolarDiffusing(SurfNum)) { // Clear glazing @@ -6597,7 +6596,7 @@ namespace SolarShading { // Diffuse-diffuse transmittance for bare exterior window if (SurfWinOriginalClass(SurfNum) == SurfaceClass::TDD_Diffuser) { - TDifBare = TransTDD(state, PipeNum, CosInc, SolarAniso); + TDifBare = TransTDD(state, PipeNum, CosInc, DataDaylightingDevices::iRadType::SolarAniso); } else { if (SurfWinWindowModelType(SurfNum) == WindowBSDFModel) { // Complex Fenestration: use hemispherical ave of directional-hemispherical transmittance @@ -7738,20 +7737,20 @@ namespace SolarShading { int ShelfNum = Surface(SurfNum).Shelf; int OutShelfSurf = 0; if (ShelfNum > 0) { // Outside daylighting shelf - OutShelfSurf = Shelf(ShelfNum).OutSurf; + OutShelfSurf = state.dataDaylightingDevicesData->Shelf(ShelfNum).OutSurf; } // This lookup may be avoid if this 2nd surf loop can be combined with the 1st if (SurfWinOriginalClass(SurfNum) == SurfaceClass::TDD_Diffuser) { int PipeNum = SurfWinTDDPipeNum(SurfNum); - int SurfNum2 = TDDPipe(PipeNum).Dome; + int SurfNum2 = state.dataDaylightingDevicesData->TDDPipe(PipeNum).Dome; Real64 CosInc = CosIncAng(state.dataGlobal->TimeStep, state.dataGlobal->HourOfDay, SurfNum2); // Exterior diffuse solar incident on window (W/m2) Real64 DifSolarInc = DifSolarRad * AnisoSkyMult(SurfNum2) + GndSolarRad * Surface(SurfNum2).ViewFactorGround; // Exterior diffuse sky solar transmitted by TDD (W/m2) - Real64 SkySolarTrans = DifSolarRad * TransTDD(state, PipeNum, CosInc, SolarAniso) * AnisoSkyMult(SurfNum2); + Real64 SkySolarTrans = DifSolarRad * TransTDD(state, PipeNum, CosInc, DataDaylightingDevices::iRadType::SolarAniso) * AnisoSkyMult(SurfNum2); // Exterior diffuse ground solar transmitted by TDD (W/m2) - Real64 GndSolarTrans = GndSolarRad * TDDPipe(PipeNum).TransSolIso * Surface(SurfNum2).ViewFactorGround; + Real64 GndSolarTrans = GndSolarRad * state.dataDaylightingDevicesData->TDDPipe(PipeNum).TransSolIso * Surface(SurfNum2).ViewFactorGround; SurfWinBmSolar(SurfNum) = BeamSolarRad * WinTransBmSolar(SurfNum); SurfWinDifSolar(SurfNum) = SkySolarTrans * Surface(SurfNum).Area + GndSolarTrans * Surface(SurfNum).Area; @@ -7761,22 +7760,22 @@ namespace SolarShading { SurfWinTransSolar(SurfNum) = SurfWinBmSolar(SurfNum) + SurfWinDifSolar(SurfNum); //[W] SurfWinTransSolarEnergy(SurfNum) = SurfWinTransSolar(SurfNum) * state.dataGlobal->TimeStepZoneSec; - TDDPipe(PipeNum).TransmittedSolar = SurfWinTransSolar(SurfNum); + state.dataDaylightingDevicesData->TDDPipe(PipeNum).TransmittedSolar = SurfWinTransSolar(SurfNum); // TDDPipe(PipeNum)%TransSolBeam = TBmBm ! Reported above if (DifSolarInc > 0) { - TDDPipe(PipeNum).TransSolDiff = (SkySolarTrans + GndSolarTrans) / DifSolarInc; + state.dataDaylightingDevicesData->TDDPipe(PipeNum).TransSolDiff = (SkySolarTrans + GndSolarTrans) / DifSolarInc; } else { - TDDPipe(PipeNum).TransSolDiff = 0.0; + state.dataDaylightingDevicesData->TDDPipe(PipeNum).TransSolDiff = 0.0; } } else if (OutShelfSurf > 0) { // Outside daylighting shelf Real64 ShelfSolarRad = (BeamSolarRad * SunlitFrac(state.dataGlobal->TimeStep, state.dataGlobal->HourOfDay, OutShelfSurf) * CosIncAng(state.dataGlobal->TimeStep, state.dataGlobal->HourOfDay, OutShelfSurf) + DifSolarRad * AnisoSkyMult(OutShelfSurf)) * - Shelf(ShelfNum).OutReflectSol; + state.dataDaylightingDevicesData->Shelf(ShelfNum).OutReflectSol; Real64 DifSolarInc = DifSolarRad * AnisoSkyMult(SurfNum) + GndSolarRad * Surface(SurfNum).ViewFactorGround + - ShelfSolarRad * Shelf(ShelfNum).ViewFactor; + ShelfSolarRad * state.dataDaylightingDevicesData->Shelf(ShelfNum).ViewFactor; SurfWinBmSolar(SurfNum) = BeamSolarRad * WinTransBmSolar(SurfNum); SurfWinDifSolar(SurfNum) = DifSolarInc * WinTransDifSolar(SurfNum); @@ -7854,8 +7853,6 @@ namespace SolarShading { // PURPOSE OF THIS SUBROUTINE: // Calculates solar energy absorbed on exterior opaque surfaces - using namespace DataDaylightingDevices; - for (int ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ++ZoneNum) { for (int SurfNum = Zone(ZoneNum).SurfaceFirst; SurfNum <= Zone(ZoneNum).SurfaceLast; ++SurfNum) { if (((Surface(SurfNum).ExtBoundCond != ExternalEnvironment) && (Surface(SurfNum).ExtBoundCond != OtherSideCondModeledExt)) && @@ -7874,7 +7871,7 @@ namespace SolarShading { int SurfNum2 = 0; if (SurfWinOriginalClass(SurfNum) == SurfaceClass::TDD_Diffuser) { int PipeNum = SurfWinTDDPipeNum(SurfNum); - SurfNum2 = TDDPipe(PipeNum).Dome; + SurfNum2 = state.dataDaylightingDevicesData->TDDPipe(PipeNum).Dome; } else { SurfNum2 = SurfNum; } @@ -7928,7 +7925,6 @@ namespace SolarShading { // and interior beam from exterior window that is absorbed/transmitted by back surfaces using ScheduleManager::GetCurrentScheduleValue; - using namespace DataDaylightingDevices; using namespace MultiLayerOptics; if (state.dataSolarShading->MustAllocSolarShading) { @@ -7957,7 +7953,7 @@ namespace SolarShading { int SurfNum2 = 0; if (SurfWinOriginalClass(SurfNum) == SurfaceClass::TDD_Diffuser) { int PipeNum = SurfWinTDDPipeNum(SurfNum); - SurfNum2 = TDDPipe(PipeNum).Dome; + SurfNum2 = state.dataDaylightingDevicesData->TDDPipe(PipeNum).Dome; } else { SurfNum2 = SurfNum; } From 4bbc5273e1eb60171eb8884415f32e44ecb2fea1 Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Tue, 24 Nov 2020 15:38:11 -0700 Subject: [PATCH 05/10] moving DaylightingDevices to state --- src/EnergyPlus/Data/CommonIncludes.hh | 1 + src/EnergyPlus/Data/EnergyPlusData.cc | 4 +- src/EnergyPlus/Data/EnergyPlusData.hh | 4 +- src/EnergyPlus/DataDaylightingDevices.hh | 2 +- src/EnergyPlus/DaylightingDevices.cc | 51 ++++++------------------ src/EnergyPlus/DaylightingDevices.hh | 19 ++++++--- src/EnergyPlus/StateManagement.cc | 2 - 7 files changed, 34 insertions(+), 49 deletions(-) diff --git a/src/EnergyPlus/Data/CommonIncludes.hh b/src/EnergyPlus/Data/CommonIncludes.hh index d043bd7172e..fd20f167889 100644 --- a/src/EnergyPlus/Data/CommonIncludes.hh +++ b/src/EnergyPlus/Data/CommonIncludes.hh @@ -88,6 +88,7 @@ #include #include #include +#include #include #include #include diff --git a/src/EnergyPlus/Data/EnergyPlusData.cc b/src/EnergyPlus/Data/EnergyPlusData.cc index 575675949b3..1eb8e1704d8 100644 --- a/src/EnergyPlus/Data/EnergyPlusData.cc +++ b/src/EnergyPlus/Data/EnergyPlusData.cc @@ -86,7 +86,8 @@ namespace EnergyPlus { this->dataCTElectricGenerator = std::make_unique(); this->dataCurveManager = std::make_unique(); this->dataDaylightingData = std::make_unique(); - this->dataDaylightingDevicesData = std::make_unique(); + this->dataDaylightingDevicesData = std::make_unique(); + this->dataDaylightingDevices = std::make_unique(); this->dataEIRPlantLoopHeatPump = std::make_unique(); this->dataExteriorEnergyUse = std::make_unique(); this->dataFans = std::make_unique(); @@ -173,6 +174,7 @@ namespace EnergyPlus { this->dataCurveManager->clear_state(); this->dataDaylightingData->clear_state(); this->dataDaylightingDevicesData->clear_state(); + this->dataDaylightingDevices->clear_state(); this->dataEIRPlantLoopHeatPump->clear_state(); this->dataExteriorEnergyUse->clear_state(); this->dataFans->clear_state(); diff --git a/src/EnergyPlus/Data/EnergyPlusData.hh b/src/EnergyPlus/Data/EnergyPlusData.hh index a7e29551b5d..4cc51503a1a 100644 --- a/src/EnergyPlus/Data/EnergyPlusData.hh +++ b/src/EnergyPlus/Data/EnergyPlusData.hh @@ -98,6 +98,7 @@ struct DataGlobal; struct DataTimingsData; struct DataWaterData; struct DaylightingData; +struct DataDaylightingDevicesData; struct DaylightingDevicesData; struct EIRPlantLoopHeatPumpsData; struct ExteriorEnergyUseData; @@ -186,7 +187,8 @@ struct EnergyPlusData : BaseGlobalStruct { std::unique_ptr dataGlobal; std::unique_ptr dataWaterData; std::unique_ptr dataDaylightingData; - std::unique_ptr dataDaylightingDevicesData; + std::unique_ptr dataDaylightingDevicesData; + std::unique_ptr dataDaylightingDevices; std::unique_ptr dataEIRPlantLoopHeatPump; std::unique_ptr dataExteriorEnergyUse; std::unique_ptr dataFans; diff --git a/src/EnergyPlus/DataDaylightingDevices.hh b/src/EnergyPlus/DataDaylightingDevices.hh index b29ea7e4974..53803c669c2 100644 --- a/src/EnergyPlus/DataDaylightingDevices.hh +++ b/src/EnergyPlus/DataDaylightingDevices.hh @@ -136,7 +136,7 @@ namespace DataDaylightingDevices { } // namespace DataDaylightingDevices -struct DaylightingDevicesData : BaseGlobalStruct { +struct DataDaylightingDevicesData : BaseGlobalStruct { int NumOfTDDPipes = 0; // Number of TDD pipes in the input file int NumOfShelf = 0; // Number of daylighting shelves in the input file diff --git a/src/EnergyPlus/DaylightingDevices.cc b/src/EnergyPlus/DaylightingDevices.cc index 452c8cf33be..3a62dbf76cb 100644 --- a/src/EnergyPlus/DaylightingDevices.cc +++ b/src/EnergyPlus/DaylightingDevices.cc @@ -175,26 +175,6 @@ namespace DaylightingDevices { using DataSurfaces::Surface; using DataSurfaces::SurfaceClass; using DataSurfaces::TotSurfaces; - // Data - // MODULE PARAMETER DEFINITIONS: na - // DERIVED TYPE DEFINITIONS: na - // MODULE VARIABLE TYPE DECLARATIONS: na - - // MODULE VARIABLE DECLARATIONS: - Array1D COSAngle(DataDaylightingDevices::NumOfAngles); // List of cosines of incident angle - bool ShelfReported = false; - - // SUBROUTINE SPECIFICATIONS: - - // MODULE SUBROUTINES: - - void clear_state() { - COSAngle.clear(); - COSAngle.allocate(DataDaylightingDevices::NumOfAngles); - ShelfReported = false; - } - - // Functions void InitDaylightingDevices(EnergyPlusData &state) { @@ -212,17 +192,9 @@ namespace DaylightingDevices { // METHODOLOGY EMPLOYED: // Daylighting and thermal variables are calculated. BeamTrans/COSAngle table is calculated. - // REFERENCES: na - // Using/Aliasing using DataHeatBalance::IntGainTypeOf_DaylightingDeviceTubular; - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: na - - // DERIVED TYPE DEFINITIONS: - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int PipeNum; // TDD pipe object number int StoredNum; // Stored TDD pipe object number @@ -263,14 +235,14 @@ namespace DaylightingDevices { if (state.dataDaylightingDevicesData->NumOfTDDPipes > 0) { DisplayString(state, "Initializing Tubular Daylighting Devices"); // Setup COSAngle list for all TDDs - COSAngle(1) = 0.0; - COSAngle(DataDaylightingDevices::NumOfAngles) = 1.0; + state.dataDaylightingDevices->COSAngle(1) = 0.0; + state.dataDaylightingDevices->COSAngle(DataDaylightingDevices::NumOfAngles) = 1.0; dTheta = 90.0 * DataGlobalConstants::DegToRadians() / (DataDaylightingDevices::NumOfAngles - 1.0); Theta = 90.0 * DataGlobalConstants::DegToRadians(); for (AngleNum = 2; AngleNum <= DataDaylightingDevices::NumOfAngles - 1; ++AngleNum) { Theta -= dTheta; - COSAngle(AngleNum) = std::cos(Theta); + state.dataDaylightingDevices->COSAngle(AngleNum) = std::cos(Theta); } // AngleNum TDDPipeStored.allocate(state.dataDaylightingDevicesData->NumOfTDDPipes * 2); @@ -435,10 +407,10 @@ namespace DaylightingDevices { } // Report calculated view factor so that user knows what to make the view factor to ground - if (!ShelfReported) { + if (!state.dataDaylightingDevices->ShelfReported) { print(state.files.eio, "! ,Name,View Factor to Outside Shelf,Window Name,Window View Factor to Sky,Window View Factor to Ground\n"); - ShelfReported = true; + state.dataDaylightingDevices->ShelfReported = true; } print(state.files.eio, "{},{:.2R},{},{:.2R},{:.2R}\n", @@ -1300,14 +1272,14 @@ namespace DaylightingDevices { if (SELECT_CASE_var == DataDaylightingDevices::iRadType::VisibleBeam) { transDome = POLYF(COSI, state.dataConstruction->Construct(constDome).TransVisBeamCoef); - transPipe = InterpolatePipeTransBeam(COSI, state.dataDaylightingDevicesData->TDDPipe(PipeNum).PipeTransVisBeam); + transPipe = InterpolatePipeTransBeam(state, COSI, state.dataDaylightingDevicesData->TDDPipe(PipeNum).PipeTransVisBeam); transDiff = state.dataConstruction->Construct(constDiff).TransDiffVis; // May want to change to POLYF also! TransTDD = transDome * transPipe * transDiff; } else if (SELECT_CASE_var == DataDaylightingDevices::iRadType::SolarBeam) { transDome = POLYF(COSI, state.dataConstruction->Construct(constDome).TransSolBeamCoef); - transPipe = InterpolatePipeTransBeam(COSI, state.dataDaylightingDevicesData->TDDPipe(PipeNum).PipeTransSolBeam); + transPipe = InterpolatePipeTransBeam(state, COSI, state.dataDaylightingDevicesData->TDDPipe(PipeNum).PipeTransSolBeam); transDiff = state.dataConstruction->Construct(constDiff).TransDiff; // May want to change to POLYF also! TransTDD = transDome * transPipe * transDiff; @@ -1323,7 +1295,8 @@ namespace DaylightingDevices { return TransTDD; } - Real64 InterpolatePipeTransBeam(Real64 const COSI, // Cosine of the incident angle + Real64 InterpolatePipeTransBeam(EnergyPlusData &state, + Real64 const COSI, // Cosine of the incident angle const Array1D &transBeam // Table of beam transmittance vs. cosine angle ) { @@ -1362,12 +1335,12 @@ namespace DaylightingDevices { InterpolatePipeTransBeam = 0.0; // Linearly interpolate transBeam/COSAngle table to get value at current cosine of the angle - Lo = FindArrayIndex(COSI, COSAngle); + Lo = FindArrayIndex(COSI, state.dataDaylightingDevices->COSAngle); Hi = Lo + 1; if (Lo > 0 && Hi <= DataDaylightingDevices::NumOfAngles) { - m = (transBeam(Hi) - transBeam(Lo)) / (COSAngle(Hi) - COSAngle(Lo)); - b = transBeam(Lo) - m * COSAngle(Lo); + m = (transBeam(Hi) - transBeam(Lo)) / (state.dataDaylightingDevices->COSAngle(Hi) - state.dataDaylightingDevices->COSAngle(Lo)); + b = transBeam(Lo) - m * state.dataDaylightingDevices->COSAngle(Lo); InterpolatePipeTransBeam = m * COSI + b; } else { diff --git a/src/EnergyPlus/DaylightingDevices.hh b/src/EnergyPlus/DaylightingDevices.hh index 35fb2bae191..a21a0fb79e6 100644 --- a/src/EnergyPlus/DaylightingDevices.hh +++ b/src/EnergyPlus/DaylightingDevices.hh @@ -59,8 +59,6 @@ struct EnergyPlusData; namespace DaylightingDevices { - extern Array1D COSAngle; // List of cosines of incident angle - void InitDaylightingDevices(EnergyPlusData &state); void GetTDDInput(EnergyPlusData &state); @@ -87,7 +85,8 @@ namespace DaylightingDevices { DataDaylightingDevices::iRadType const RadiationType // Radiation type flag ); - Real64 InterpolatePipeTransBeam(Real64 const COSI, // Cosine of the incident angle + Real64 InterpolatePipeTransBeam(EnergyPlusData &state, + Real64 const COSI, // Cosine of the incident angle const Array1D &transBeam // Table of beam transmittance vs. cosine angle ); @@ -99,10 +98,20 @@ namespace DaylightingDevices { void FigureTDDZoneGains(EnergyPlusData &state); - void clear_state(); - } // namespace DaylightingDevices +struct DaylightingDevicesData : BaseGlobalStruct { + + Array1D COSAngle = Array1D(DataDaylightingDevices::NumOfAngles); // List of cosines of incident angle + bool ShelfReported = false; + + void clear_state() override + { + this->COSAngle = Array1D(DataDaylightingDevices::NumOfAngles); + this->ShelfReported = false; + } +}; + } // namespace EnergyPlus #endif diff --git a/src/EnergyPlus/StateManagement.cc b/src/EnergyPlus/StateManagement.cc index 46e0aa42720..2a87506ad1e 100644 --- a/src/EnergyPlus/StateManagement.cc +++ b/src/EnergyPlus/StateManagement.cc @@ -83,7 +83,6 @@ #include #include #include -#include #include #include #include @@ -229,7 +228,6 @@ void EnergyPlus::clearAllStates(EnergyPlusData &state) DataZoneControls::clear_state(); DataZoneEnergyDemands::clear_state(); DataZoneEquipment::clear_state(); - DaylightingDevices::clear_state(); DaylightingManager::clear_state(); DemandManager::clear_state(); DesiccantDehumidifiers::clear_state(); From dd2a9c34c4e3101eb731e0c2a98fe3381f1b20e6 Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Tue, 24 Nov 2020 20:49:04 -0700 Subject: [PATCH 06/10] moving DaylightingManager to state --- src/EnergyPlus/Data/CommonIncludes.hh | 1 + src/EnergyPlus/Data/EnergyPlusData.cc | 2 + src/EnergyPlus/Data/EnergyPlusData.hh | 2 + src/EnergyPlus/DaylightingManager.cc | 82 ++++++++++----------------- src/EnergyPlus/DaylightingManager.hh | 37 +++++++++++- src/EnergyPlus/StateManagement.cc | 2 - 6 files changed, 70 insertions(+), 56 deletions(-) diff --git a/src/EnergyPlus/Data/CommonIncludes.hh b/src/EnergyPlus/Data/CommonIncludes.hh index fd20f167889..66042a93716 100644 --- a/src/EnergyPlus/Data/CommonIncludes.hh +++ b/src/EnergyPlus/Data/CommonIncludes.hh @@ -85,6 +85,7 @@ #include #include #include +#include #include #include #include diff --git a/src/EnergyPlus/Data/EnergyPlusData.cc b/src/EnergyPlus/Data/EnergyPlusData.cc index 1eb8e1704d8..de5347a2f63 100644 --- a/src/EnergyPlus/Data/EnergyPlusData.cc +++ b/src/EnergyPlus/Data/EnergyPlusData.cc @@ -88,6 +88,7 @@ namespace EnergyPlus { this->dataDaylightingData = std::make_unique(); this->dataDaylightingDevicesData = std::make_unique(); this->dataDaylightingDevices = std::make_unique(); + this->dataDaylightingManager = std::make_unique(); this->dataEIRPlantLoopHeatPump = std::make_unique(); this->dataExteriorEnergyUse = std::make_unique(); this->dataFans = std::make_unique(); @@ -175,6 +176,7 @@ namespace EnergyPlus { this->dataDaylightingData->clear_state(); this->dataDaylightingDevicesData->clear_state(); this->dataDaylightingDevices->clear_state(); + this->dataDaylightingManager->clear_state(); this->dataEIRPlantLoopHeatPump->clear_state(); this->dataExteriorEnergyUse->clear_state(); this->dataFans->clear_state(); diff --git a/src/EnergyPlus/Data/EnergyPlusData.hh b/src/EnergyPlus/Data/EnergyPlusData.hh index 4cc51503a1a..f9beea2a8cf 100644 --- a/src/EnergyPlus/Data/EnergyPlusData.hh +++ b/src/EnergyPlus/Data/EnergyPlusData.hh @@ -100,6 +100,7 @@ struct DataWaterData; struct DaylightingData; struct DataDaylightingDevicesData; struct DaylightingDevicesData; +struct DaylightingManagerData; struct EIRPlantLoopHeatPumpsData; struct ExteriorEnergyUseData; struct FansData; @@ -189,6 +190,7 @@ struct EnergyPlusData : BaseGlobalStruct { std::unique_ptr dataDaylightingData; std::unique_ptr dataDaylightingDevicesData; std::unique_ptr dataDaylightingDevices; + std::unique_ptr dataDaylightingManager; std::unique_ptr dataEIRPlantLoopHeatPump; std::unique_ptr dataExteriorEnergyUse; std::unique_ptr dataFans; diff --git a/src/EnergyPlus/DaylightingManager.cc b/src/EnergyPlus/DaylightingManager.cc index 1329a68f6e5..fbed4e2b285 100644 --- a/src/EnergyPlus/DaylightingManager.cc +++ b/src/EnergyPlus/DaylightingManager.cc @@ -155,19 +155,7 @@ namespace DaylightingManager { // Data // MODULE PARAMETER DEFINITIONS: - bool CalcDayltghCoefficients_firstTime(true); - bool refFirstTime(true); - bool DayltgInteriorIllum_firstTime(true); // true first time routine is called - bool FirstTimeDaylFacCalc(true); - bool VeryFirstTime(true); - bool mapFirstTime(true); - bool CheckTDDs_firstTime(true); - bool DayltgExtHorizIllum_firstTime(true); // flag for first time thru to initialize - bool DayltgInteriorMapIllum_FirstTimeFlag(true); - bool ReportIllumMap_firstTime(true); - bool SQFirstTime(true); - bool doSkyReporting(true); - bool CreateDFSReportFile(true); + // Surface count crossover for using octree algorithm // The octree gives lower computational complexity for much higher performance @@ -237,21 +225,10 @@ namespace DaylightingManager { void clear_state() { // this will need a lot more, but it is a start - CalcDayltghCoefficients_firstTime = true; TDDTransVisBeam.deallocate(); TDDFluxInc.deallocate(); TDDFluxTrans.deallocate(); RefErrIndex.deallocate(); - refFirstTime = true; - DayltgInteriorIllum_firstTime = true; - FirstTimeDaylFacCalc = true; - VeryFirstTime = true; - mapFirstTime = true; - CheckTDDs_firstTime = true; - DayltgExtHorizIllum_firstTime = true; - DayltgInteriorMapIllum_FirstTimeFlag = true; - ReportIllumMap_firstTime = true; - SQFirstTime = true; TotWindowsWithDayl = 0; DaylIllum.deallocate(); maxNumRefPtInAnyZone = 0; @@ -266,8 +243,6 @@ namespace DaylightingManager { TDDFluxTrans.deallocate(); MapErrIndex.deallocate(); RefErrIndex.deallocate(); - doSkyReporting = true; - CreateDFSReportFile = true; } void DayltgAveInteriorReflectance(EnergyPlusData &state, int &ZoneNum) // Zone number @@ -542,11 +517,11 @@ namespace DaylightingManager { int ISlatAngle; // FLOW: - if (CalcDayltghCoefficients_firstTime) { + if (state.dataDaylightingManager->CalcDayltghCoefficients_firstTime) { GetDaylightingParametersInput(state); CheckTDDsAndLightShelvesInDaylitZones(state); AssociateWindowShadingControlWithDaylighting(state); - CalcDayltghCoefficients_firstTime = false; + state.dataDaylightingManager->CalcDayltghCoefficients_firstTime = false; } // End of check if firstTime // Find the total number of exterior windows associated with all Daylighting:Detailed zones. @@ -643,7 +618,7 @@ namespace DaylightingManager { THSUN = THSUNHR(IHR); SPHSUN = SPHSUNHR(IHR); CPHSUN = CPHSUNHR(IHR); - DayltgExtHorizIllum(GILSK(IHR, 1), GILSU(IHR)); + DayltgExtHorizIllum(state, GILSK(IHR, 1), GILSU(IHR)); } } } else { // timestep integrated calculations @@ -668,7 +643,7 @@ namespace DaylightingManager { THSUN = THSUNHR(state.dataGlobal->HourOfDay); SPHSUN = SPHSUNHR(state.dataGlobal->HourOfDay); CPHSUN = CPHSUNHR(state.dataGlobal->HourOfDay); - DayltgExtHorizIllum(GILSK(state.dataGlobal->HourOfDay, 1), GILSU(state.dataGlobal->HourOfDay)); + DayltgExtHorizIllum(state, GILSK(state.dataGlobal->HourOfDay, 1), GILSU(state.dataGlobal->HourOfDay)); } } @@ -689,9 +664,9 @@ namespace DaylightingManager { } // End of zone loop, ZoneNum - if (doSkyReporting) { + if (state.dataDaylightingManager->doSkyReporting) { if (!state.dataGlobal->KickOffSizing && !state.dataGlobal->KickOffSimulation) { - if (FirstTimeDaylFacCalc && TotWindowsWithDayl > 0) { + if (state.dataDaylightingManager->FirstTimeDaylFacCalc && TotWindowsWithDayl > 0) { // Write the bare-window four sky daylight factors at noon time to the eio file; this is done only // for first time that daylight factors are calculated and so is insensitive to possible variation // due to change in ground reflectance from month to month, or change in storm window status. @@ -736,8 +711,8 @@ namespace DaylightingManager { } } } - FirstTimeDaylFacCalc = false; - doSkyReporting = false; + state.dataDaylightingManager->FirstTimeDaylFacCalc = false; + state.dataDaylightingManager->doSkyReporting = false; } } } @@ -764,14 +739,14 @@ namespace DaylightingManager { } // open a new file eplusout.dfs for saving the daylight factors - if (CreateDFSReportFile) { + if (state.dataDaylightingManager->CreateDFSReportFile) { InputOutputFile &dfs = state.files.dfs.ensure_open(state, "CalcDayltgCoefficients", state.files.outputControl.dfs); print(dfs, "{}\n", "This file contains daylight factors for all exterior windows of daylight zones."); print(dfs, "{}\n", "MonthAndDay,Zone Name,Window Name,Window State"); print(dfs, "{}\n", "Hour,Reference Point,Daylight Factor for Clear Sky,Daylight Factor for Clear Turbid Sky," "Daylight Factor for Intermediate Sky,Daylight Factor for Overcast Sky"); - CreateDFSReportFile = false; + state.dataDaylightingManager->CreateDFSReportFile = false; } for (ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ++ZoneNum) { @@ -879,7 +854,7 @@ namespace DaylightingManager { bool ErrorsFound; int MapNum; - if (VeryFirstTime) { + if (state.dataDaylightingManager->VeryFirstTime) { // make sure all necessary surfaces match to pipes ErrorsFound = false; for (TZoneNum = 1; TZoneNum <= state.dataGlobal->NumOfZones; ++TZoneNum) { @@ -900,7 +875,7 @@ namespace DaylightingManager { if (ErrorsFound) { ShowFatalError(state, "Not all TubularDaylightDome objects have corresponding DaylightingDevice:Tubular objects. Program terminates."); } - VeryFirstTime = false; + state.dataDaylightingManager->VeryFirstTime = false; } // Calc for daylighting reference points @@ -1026,11 +1001,11 @@ namespace DaylightingManager { int WinEl; // Current window element - if (refFirstTime && + if (state.dataDaylightingManager->refFirstTime && std::any_of(state.dataDaylightingData->ZoneDaylight.begin(), state.dataDaylightingData->ZoneDaylight.end(), [](DataDaylighting::ZoneDaylightCalc const &e) { return e.TotalDaylRefPoints > 0; })) { RefErrIndex.allocate(maxval(state.dataDaylightingData->ZoneDaylight, &DataDaylighting::ZoneDaylightCalc::TotalDaylRefPoints), TotSurfaces); RefErrIndex = 0; - refFirstTime = false; + state.dataDaylightingManager->refFirstTime = false; } // Azimuth of view vector in absolute coord sys @@ -1428,13 +1403,13 @@ namespace DaylightingManager { static bool MySunIsUpFlag(false); int WinEl; // window elements counter - if (mapFirstTime && state.dataDaylightingData->TotIllumMaps > 0) { + if (state.dataDaylightingManager->mapFirstTime && state.dataDaylightingData->TotIllumMaps > 0) { IL = -999; for (MapNum = 1; MapNum <= state.dataDaylightingData->TotIllumMaps; ++MapNum) { IL = max(IL, state.dataDaylightingData->IllumMapCalc(MapNum).TotalMapRefPoints); } MapErrIndex.dimension(IL, TotSurfaces, 0); - mapFirstTime = false; + state.dataDaylightingManager->mapFirstTime = false; } // Azimuth of view vector in absolute coord sys @@ -5874,7 +5849,8 @@ namespace DaylightingManager { } } - void DayltgExtHorizIllum(Array1A HISK, // Horizontal illuminance from sky for different sky types + void DayltgExtHorizIllum(EnergyPlusData &state, + Array1A HISK, // Horizontal illuminance from sky for different sky types Real64 &HISU // Horizontal illuminance from sun for unit beam normal ) { @@ -5933,7 +5909,7 @@ namespace DaylightingManager { // is L(TH,PH)*SIN(PH)*COS(PH)*DTH*DPH, where L(TH,PH) is the luminance // of the patch in cd/m2. // Init - if (DayltgExtHorizIllum_firstTime) { + if (state.dataDaylightingManager->DayltgExtHorizIllum_firstTime) { for (IPH = 1; IPH <= NPH; ++IPH) { PH(IPH) = (IPH - 0.5) * DPH; SPHCPH(IPH) = std::sin(PH(IPH)) * std::cos(PH(IPH)); // DA = COS(PH)*DTH*DPH @@ -5941,7 +5917,7 @@ namespace DaylightingManager { for (ITH = 1; ITH <= NTH; ++ITH) { TH(ITH) = (ITH - 0.5) * DTH; } - DayltgExtHorizIllum_firstTime = false; + state.dataDaylightingManager->DayltgExtHorizIllum_firstTime = false; } HISK = 0.0; @@ -6367,7 +6343,7 @@ namespace DaylightingManager { // Three arrays to save original clear and dark (fully switched) states' // zone/window daylighting properties. - if (DayltgInteriorIllum_firstTime) { + if (state.dataDaylightingManager->DayltgInteriorIllum_firstTime) { int const d1(max(maxval(Zone, &ZoneData::NumSubSurfaces), maxval(state.dataDaylightingData->ZoneDaylight, &DataDaylighting::ZoneDaylightCalc::NumOfDayltgExtWins))); tmpIllumFromWinAtRefPt.allocate(d1, 2, maxNumRefPtInAnyZone); tmpBackLumFromWinAtRefPt.allocate(d1, 2, maxNumRefPtInAnyZone); @@ -6378,7 +6354,7 @@ namespace DaylightingManager { GLRNDX.allocate(maxNumRefPtInAnyZone); GLRNEW.allocate(maxNumRefPtInAnyZone); - DayltgInteriorIllum_firstTime = false; + state.dataDaylightingManager->DayltgInteriorIllum_firstTime = false; } tmpIllumFromWinAtRefPt = 0.0; tmpBackLumFromWinAtRefPt = 0.0; @@ -9567,11 +9543,11 @@ namespace DaylightingManager { int MapNum; int ILM; - if (DayltgInteriorMapIllum_FirstTimeFlag) { + if (state.dataDaylightingManager->DayltgInteriorMapIllum_FirstTimeFlag) { daylight_illum.allocate(DataDaylighting::MaxMapRefPoints); BACLUM.allocate(DataDaylighting::MaxMapRefPoints); GLRNDX.allocate(DataDaylighting::MaxMapRefPoints); - DayltgInteriorMapIllum_FirstTimeFlag = false; + state.dataDaylightingManager->DayltgInteriorMapIllum_FirstTimeFlag = false; } if (state.dataGlobal->WarmupFlag) return; @@ -10012,8 +9988,8 @@ namespace DaylightingManager { // BSLLC Finish // FLOW: - if (ReportIllumMap_firstTime) { - ReportIllumMap_firstTime = false; + if (state.dataDaylightingManager->ReportIllumMap_firstTime) { + state.dataDaylightingManager->ReportIllumMap_firstTime = false; FirstTimeMaps.dimension(state.dataDaylightingData->TotIllumMaps, true); EnvrnPrint.dimension(state.dataDaylightingData->TotIllumMaps, true); RefPts.allocate(state.dataGlobal->NumOfZones, DataDaylighting::MaxRefPoints); @@ -10123,13 +10099,13 @@ namespace DaylightingManager { } // X if (sqlite) { - if (SQFirstTime) { + if (state.dataDaylightingManager->SQFirstTime) { int const nX(maxval(state.dataDaylightingData->IllumMap, &DataDaylighting::IllumMapData::Xnum)); int const nY(maxval(state.dataDaylightingData->IllumMap, &DataDaylighting::IllumMapData::Ynum)); XValue.allocate(nX); YValue.allocate(nY); IllumValue.allocate(nX, nY); - SQFirstTime = false; + state.dataDaylightingManager->SQFirstTime = false; } // We need DataGlobals::CalendarYear, and not DataEnvironment::Year because diff --git a/src/EnergyPlus/DaylightingManager.hh b/src/EnergyPlus/DaylightingManager.hh index 09c38712d94..58a3fa3c035 100644 --- a/src/EnergyPlus/DaylightingManager.hh +++ b/src/EnergyPlus/DaylightingManager.hh @@ -374,7 +374,8 @@ namespace DaylightingManager { int const ZoneNum // Zone number ); - void DayltgExtHorizIllum(Array1A HISK, // Horizontal illuminance from sky for different sky types + void DayltgExtHorizIllum(EnergyPlusData &state, + Array1A HISK, // Horizontal illuminance from sky for different sky types Real64 &HISU // Horizontal illuminance from sun for unit beam normal ); @@ -512,6 +513,40 @@ namespace DaylightingManager { } // namespace DaylightingManager +struct DaylightingManagerData : BaseGlobalStruct { + + bool CalcDayltghCoefficients_firstTime = true; + bool refFirstTime = true; + bool DayltgInteriorIllum_firstTime = true; // true first time routine is called + bool FirstTimeDaylFacCalc = true; + bool VeryFirstTime = true; + bool mapFirstTime = true; + bool CheckTDDs_firstTime = true; + bool DayltgExtHorizIllum_firstTime = true; // flag for first time thru to initialize + bool DayltgInteriorMapIllum_FirstTimeFlag = true; + bool ReportIllumMap_firstTime = true; + bool SQFirstTime = true; + bool doSkyReporting = true; + bool CreateDFSReportFile = true; + + void clear_state() override + { + this->CalcDayltghCoefficients_firstTime = true; + this->refFirstTime = true; + this->DayltgInteriorIllum_firstTime = true; + this->FirstTimeDaylFacCalc = true; + this->VeryFirstTime = true; + this->mapFirstTime = true; + this->CheckTDDs_firstTime = true; + this->DayltgExtHorizIllum_firstTime = true; + this->DayltgInteriorMapIllum_FirstTimeFlag = true; + this->ReportIllumMap_firstTime = true; + this->SQFirstTime = true; + this->doSkyReporting = true; + this->CreateDFSReportFile = true; + } +}; + } // namespace EnergyPlus #endif diff --git a/src/EnergyPlus/StateManagement.cc b/src/EnergyPlus/StateManagement.cc index 2a87506ad1e..cf62a00c776 100644 --- a/src/EnergyPlus/StateManagement.cc +++ b/src/EnergyPlus/StateManagement.cc @@ -83,7 +83,6 @@ #include #include #include -#include #include #include #include @@ -228,7 +227,6 @@ void EnergyPlus::clearAllStates(EnergyPlusData &state) DataZoneControls::clear_state(); DataZoneEnergyDemands::clear_state(); DataZoneEquipment::clear_state(); - DaylightingManager::clear_state(); DemandManager::clear_state(); DesiccantDehumidifiers::clear_state(); DisplacementVentMgr::clear_state(); From a7edb5b52a48def43fcc47108506b74af18b8bc1 Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Tue, 24 Nov 2020 21:05:48 -0700 Subject: [PATCH 07/10] moving DaylightingManager to state --- src/EnergyPlus/DaylightingManager.cc | 254 ++++++++---------- src/EnergyPlus/DaylightingManager.hh | 57 ++-- src/EnergyPlus/SolarShading.cc | 3 +- .../unit/DaylightingManager.unit.cc | 18 +- 4 files changed, 156 insertions(+), 176 deletions(-) diff --git a/src/EnergyPlus/DaylightingManager.cc b/src/EnergyPlus/DaylightingManager.cc index fbed4e2b285..fb10f4fa8c0 100644 --- a/src/EnergyPlus/DaylightingManager.cc +++ b/src/EnergyPlus/DaylightingManager.cc @@ -151,38 +151,6 @@ namespace DaylightingManager { using DataBSDFWindow::BSDFDaylghtPosition; using namespace ScheduleManager; - // USE Vectors - - // Data - // MODULE PARAMETER DEFINITIONS: - - - // Surface count crossover for using octree algorithm - // The octree gives lower computational complexity for much higher performance - // as the surface count increases but has some overhead such that the direct - // algorithm can be more efficient at small surface counts. - // Testing to date shows that the octree performance is close to that of the - // direct algorithm even with small surface counts and that there is no single - // crossover that is ideal for all models: some cases with 10-30 surfaces were - // faster with the octree but another with 80 surfaces was faster with the - // direct algorithm. - // A reasonable, conservative crossover is selected but may be refined as more - // experience is gained. - int const octreeCrossover(100); // Octree surface count crossover - - // MODULE VARIABLE DECLARATIONS: - int TotWindowsWithDayl(0); // Total number of exterior windows in all daylit zones - Array1D DaylIllum; // Daylight illuminance at reference points (lux) - int maxNumRefPtInAnyZone(0); // The most number of reference points that any single zone has - int maxNumRefPtInAnyEncl(0); // The most number of reference points that any single enclosure has - Real64 PHSUN(0.0); // Solar altitude (radians) - Real64 SPHSUN(0.0); // Sine of solar altitude - Real64 CPHSUN(0.0); // Cosine of solar altitude - Real64 THSUN(0.0); // Solar azimuth (rad) in Absolute Coordinate System (azimuth=0 along east) - Array1D PHSUNHR(24, 0.0); // Hourly values of PHSUN - Array1D SPHSUNHR(24, 0.0); // Hourly values of the sine of PHSUN - Array1D CPHSUNHR(24, 0.0); // Hourly values of the cosine of PHSUN - Array1D THSUNHR(24, 0.0); // Hourly values of THSUN // In the following I,J,K arrays: // I = 1 for clear sky, 2 for clear turbid, 3 for intermediate, 4 for overcast; @@ -229,15 +197,6 @@ namespace DaylightingManager { TDDFluxInc.deallocate(); TDDFluxTrans.deallocate(); RefErrIndex.deallocate(); - TotWindowsWithDayl = 0; - DaylIllum.deallocate(); - maxNumRefPtInAnyZone = 0; - maxNumRefPtInAnyEncl = 0; - PHSUN = 0.0; - SPHSUN = 0.0; - CPHSUN = 0.0; - THSUN = 0.0; - //PHSUNHR.deallocate(); et al, do not deallocate ArrayND where array size is specified in the declaration TDDTransVisBeam.deallocate(); TDDFluxInc.deallocate(); TDDFluxTrans.deallocate(); @@ -534,13 +493,13 @@ namespace DaylightingManager { // Daylighting:Detailed zone to have zero exterior windows of its own, but it may have an interior // through which daylight passes from adjacent zones with exterior windows. if (state.dataGlobal->BeginSimFlag) { - TotWindowsWithDayl = 0; + state.dataDaylightingManager->TotWindowsWithDayl = 0; for (ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ++ZoneNum) { - TotWindowsWithDayl += state.dataDaylightingData->ZoneDaylight(ZoneNum).NumOfDayltgExtWins; + state.dataDaylightingManager->TotWindowsWithDayl += state.dataDaylightingData->ZoneDaylight(ZoneNum).NumOfDayltgExtWins; } } - if (TotWindowsWithDayl == 0) return; + if (state.dataDaylightingManager->TotWindowsWithDayl == 0) return; //-----------------------------------------! // Detailed daylighting factor calculation ! @@ -596,53 +555,53 @@ namespace DaylightingManager { if (!DetailedSolarTimestepIntegration) { if (state.dataGlobal->BeginDayFlag) { // Calculate hourly sun angles, clear sky zenith luminance, and exterior horizontal illuminance - PHSUN = 0.0; - SPHSUN = 0.0; - CPHSUN = 0.0; - THSUN = 0.0; - - PHSUNHR = 0.0; - SPHSUNHR = 0.0; - CPHSUNHR = 0.0; - THSUNHR = 0.0; + state.dataDaylightingManager->PHSUN = 0.0; + state.dataDaylightingManager->SPHSUN = 0.0; + state.dataDaylightingManager->CPHSUN = 0.0; + state.dataDaylightingManager->THSUN = 0.0; + + state.dataDaylightingManager->PHSUNHR = 0.0; + state.dataDaylightingManager->SPHSUNHR = 0.0; + state.dataDaylightingManager->CPHSUNHR = 0.0; + state.dataDaylightingManager->THSUNHR = 0.0; GILSK = 0.0; GILSU = 0.0; for (IHR = 1; IHR <= 24; ++IHR) { if (SUNCOSHR(IHR, 3) < SunIsUpValue) continue; // Skip if sun is below horizon //Autodesk SUNCOSHR was uninitialized here - PHSUN = DataGlobalConstants::PiOvr2() - std::acos(SUNCOSHR(IHR, 3)); - PHSUNHR(IHR) = PHSUN; - SPHSUNHR(IHR) = std::sin(PHSUN); - CPHSUNHR(IHR) = std::cos(PHSUN); - THSUNHR(IHR) = std::atan2(SUNCOSHR(IHR, 2), SUNCOSHR(IHR, 1)); + state.dataDaylightingManager->PHSUN = DataGlobalConstants::PiOvr2() - std::acos(SUNCOSHR(IHR, 3)); + state.dataDaylightingManager->PHSUNHR(IHR) = state.dataDaylightingManager->PHSUN; + state.dataDaylightingManager->SPHSUNHR(IHR) = std::sin(state.dataDaylightingManager->PHSUN); + state.dataDaylightingManager->CPHSUNHR(IHR) = std::cos(state.dataDaylightingManager->PHSUN); + state.dataDaylightingManager->THSUNHR(IHR) = std::atan2(SUNCOSHR(IHR, 2), SUNCOSHR(IHR, 1)); // Get exterior horizontal illuminance from sky and sun - THSUN = THSUNHR(IHR); - SPHSUN = SPHSUNHR(IHR); - CPHSUN = CPHSUNHR(IHR); + state.dataDaylightingManager->THSUN = state.dataDaylightingManager->THSUNHR(IHR); + state.dataDaylightingManager->SPHSUN = state.dataDaylightingManager->SPHSUNHR(IHR); + state.dataDaylightingManager->CPHSUN = state.dataDaylightingManager->CPHSUNHR(IHR); DayltgExtHorizIllum(state, GILSK(IHR, 1), GILSU(IHR)); } } } else { // timestep integrated calculations - PHSUN = 0.0; - SPHSUN = 0.0; - CPHSUN = 0.0; - THSUN = 0.0; - - PHSUNHR(state.dataGlobal->HourOfDay) = 0.0; - SPHSUNHR(state.dataGlobal->HourOfDay) = 0.0; - CPHSUNHR(state.dataGlobal->HourOfDay) = 0.0; - THSUNHR(state.dataGlobal->HourOfDay) = 0.0; + state.dataDaylightingManager->PHSUN = 0.0; + state.dataDaylightingManager->SPHSUN = 0.0; + state.dataDaylightingManager->CPHSUN = 0.0; + state.dataDaylightingManager->THSUN = 0.0; + + state.dataDaylightingManager->PHSUNHR(state.dataGlobal->HourOfDay) = 0.0; + state.dataDaylightingManager->SPHSUNHR(state.dataGlobal->HourOfDay) = 0.0; + state.dataDaylightingManager->CPHSUNHR(state.dataGlobal->HourOfDay) = 0.0; + state.dataDaylightingManager->THSUNHR(state.dataGlobal->HourOfDay) = 0.0; GILSK(state.dataGlobal->HourOfDay, {1, 4}) = 0.0; GILSU(state.dataGlobal->HourOfDay) = 0.0; if (!(SUNCOSHR(state.dataGlobal->HourOfDay, 3) < SunIsUpValue)) { // Skip if sun is below horizon - PHSUN = DataGlobalConstants::PiOvr2() - std::acos(SUNCOSHR(state.dataGlobal->HourOfDay, 3)); - PHSUNHR(state.dataGlobal->HourOfDay) = PHSUN; - SPHSUNHR(state.dataGlobal->HourOfDay) = std::sin(PHSUN); - CPHSUNHR(state.dataGlobal->HourOfDay) = std::cos(PHSUN); - THSUNHR(state.dataGlobal->HourOfDay) = std::atan2(SUNCOSHR(state.dataGlobal->HourOfDay, 2), SUNCOSHR(state.dataGlobal->HourOfDay, 1)); + state.dataDaylightingManager->PHSUN = DataGlobalConstants::PiOvr2() - std::acos(SUNCOSHR(state.dataGlobal->HourOfDay, 3)); + state.dataDaylightingManager->PHSUNHR(state.dataGlobal->HourOfDay) = state.dataDaylightingManager->PHSUN; + state.dataDaylightingManager->SPHSUNHR(state.dataGlobal->HourOfDay) = std::sin(state.dataDaylightingManager->PHSUN); + state.dataDaylightingManager->CPHSUNHR(state.dataGlobal->HourOfDay) = std::cos(state.dataDaylightingManager->PHSUN); + state.dataDaylightingManager->THSUNHR(state.dataGlobal->HourOfDay) = std::atan2(SUNCOSHR(state.dataGlobal->HourOfDay, 2), SUNCOSHR(state.dataGlobal->HourOfDay, 1)); // Get exterior horizontal illuminance from sky and sun - THSUN = THSUNHR(state.dataGlobal->HourOfDay); - SPHSUN = SPHSUNHR(state.dataGlobal->HourOfDay); - CPHSUN = CPHSUNHR(state.dataGlobal->HourOfDay); + state.dataDaylightingManager->THSUN = state.dataDaylightingManager->THSUNHR(state.dataGlobal->HourOfDay); + state.dataDaylightingManager->SPHSUN = state.dataDaylightingManager->SPHSUNHR(state.dataGlobal->HourOfDay); + state.dataDaylightingManager->CPHSUN = state.dataDaylightingManager->CPHSUNHR(state.dataGlobal->HourOfDay); DayltgExtHorizIllum(state, GILSK(state.dataGlobal->HourOfDay, 1), GILSU(state.dataGlobal->HourOfDay)); } } @@ -666,7 +625,7 @@ namespace DaylightingManager { if (state.dataDaylightingManager->doSkyReporting) { if (!state.dataGlobal->KickOffSizing && !state.dataGlobal->KickOffSimulation) { - if (state.dataDaylightingManager->FirstTimeDaylFacCalc && TotWindowsWithDayl > 0) { + if (state.dataDaylightingManager->FirstTimeDaylFacCalc && state.dataDaylightingManager->TotWindowsWithDayl > 0) { // Write the bare-window four sky daylight factors at noon time to the eio file; this is done only // for first time that daylight factors are calculated and so is insensitive to possible variation // due to change in ground reflectance from month to month, or change in storm window status. @@ -718,7 +677,7 @@ namespace DaylightingManager { } // Skip if no daylight windows - if (TotWindowsWithDayl == 0) return; + if (state.dataDaylightingManager->TotWindowsWithDayl == 0) return; // Skip if no request of reporting if ((!state.dataDaylightingData->DFSReportSizingDays) && (!state.dataDaylightingData->DFSReportAllShadowCalculationDays)) return; @@ -3464,12 +3423,12 @@ namespace DaylightingManager { ++ISunPos; // Altitude of sun (degrees) - PHSUN = PHSUNHR(iHour); - SPHSUN = SPHSUNHR(iHour); - CPHSUN = CPHSUNHR(iHour); + state.dataDaylightingManager->PHSUN = state.dataDaylightingManager->PHSUNHR(iHour); + state.dataDaylightingManager->SPHSUN = state.dataDaylightingManager->SPHSUNHR(iHour); + state.dataDaylightingManager->CPHSUN = state.dataDaylightingManager->CPHSUNHR(iHour); // Azimuth of sun in absolute coord sys - THSUN = THSUNHR(iHour); + state.dataDaylightingManager->THSUN = state.dataDaylightingManager->THSUNHR(iHour); // First time through, call routine to calculate inter-reflected illuminance // at reference point and luminance of window with shade, screen or blind. @@ -3633,7 +3592,7 @@ namespace DaylightingManager { auto l(EDIRSK.index(iHour, 1, 1)); for (ISky = 1; ISky <= 4; ++ISky, ++l) { // [ l ] == ( iHour, 1, ISky ) if (PHRAY > 0.0) { // Ray heads upward to sky - ELUM = DayltgSkyLuminance(ISky, THRAY, PHRAY); + ELUM = DayltgSkyLuminance(state, ISky, THRAY, PHRAY); XEDIRSK(ISky) = ELUM * DOMEGA_Ray_3; DEDIR = XEDIRSK(ISky) * TVISB; EDIRSK[l] += DEDIR * ObTrans; @@ -3674,9 +3633,9 @@ namespace DaylightingManager { // Beam solar reaching reference point directly without exterior reflection // Unit vector from ref. pt. to sun - RAYCOS(1) = CPHSUN * std::cos(THSUN); - RAYCOS(2) = CPHSUN * std::sin(THSUN); - RAYCOS(3) = SPHSUN; + RAYCOS(1) = state.dataDaylightingManager->CPHSUN * std::cos(state.dataDaylightingManager->THSUN); + RAYCOS(2) = state.dataDaylightingManager->CPHSUN * std::sin(state.dataDaylightingManager->THSUN); + RAYCOS(3) = state.dataDaylightingManager->SPHSUN; // Is sun on front side of exterior window? COSI = dot(WNORM2, RAYCOS); @@ -3797,7 +3756,7 @@ namespace DaylightingManager { // pass angle from sun to window normal here using PHSUN and THSUN from above and surface angles // SunAltitudeToWindowNormalAngle = PHSUN - SurfaceWindow(IWin)%Phi // SunAzimuthToWindowNormalAngle = THSUN - SurfaceWindow(IWin)%Theta - CalcScreenTransmittance(state, IWin, (PHSUN - SurfWinPhi(IWin)), (THSUN - SurfWinTheta(IWin))); + CalcScreenTransmittance(state, IWin, (state.dataDaylightingManager->PHSUN - SurfWinPhi(IWin)), (state.dataDaylightingManager->THSUN - SurfWinTheta(IWin))); TransBmBmMult(1) = SurfaceScreens(SurfWinScreenNumber(IWin)).BmBmTrans; EDIRSUdisk(iHour, 2) = RAYCOS(3) * TVISS * TransBmBmMult(1) * ObTransDisk; } @@ -3806,8 +3765,8 @@ namespace DaylightingManager { // Position factor for sun (note that AZVIEW is wrt y-axis and THSUN is wrt // x-axis of absolute coordinate system. - XR = std::tan(std::abs(DataGlobalConstants::PiOvr2() - AZVIEW - THSUN) + 0.001); - YR = std::tan(PHSUN + 0.001); + XR = std::tan(std::abs(DataGlobalConstants::PiOvr2() - AZVIEW - state.dataDaylightingManager->THSUN) + 0.001); + YR = std::tan(state.dataDaylightingManager->PHSUN + 0.001); POSFAC = DayltgGlarePositionFactor(XR, YR); { @@ -3964,7 +3923,7 @@ namespace DaylightingManager { // pass angle from sun to window normal here using PHSUN and THSUN from above and // surface angles SunAltitudeToWindowNormalAngle = PHSUN - SurfaceWindow(IWin)%Phi // SunAzimuthToWindowNormalAngle = THSUN - SurfaceWindow(IWin)%Theta - CalcScreenTransmittance(state, IWin, (PHSUN - SurfWinPhi(IWin)), (THSUN - SurfWinTheta(IWin))); + CalcScreenTransmittance(state, IWin, (state.dataDaylightingManager->PHSUN - SurfWinPhi(IWin)), (state.dataDaylightingManager->THSUN - SurfWinTheta(IWin))); TransBmBmMultRefl(1) = SurfaceScreens(SurfWinScreenNumber(IWin)).BmBmTrans; EDIRSUdisk(iHour, 2) += SunVecMir(3) * SpecReflectance * TVisRefl * TransBmBmMultRefl(1); } // End of check if window has a blind or screen @@ -4087,12 +4046,12 @@ namespace DaylightingManager { ++ISunPos; // Altitude of sun (degrees) - PHSUN = PHSUNHR(iHour); - SPHSUN = SPHSUNHR(iHour); - CPHSUN = CPHSUNHR(iHour); + state.dataDaylightingManager->PHSUN = state.dataDaylightingManager->PHSUNHR(iHour); + state.dataDaylightingManager->SPHSUN = state.dataDaylightingManager->SPHSUNHR(iHour); + state.dataDaylightingManager->CPHSUN = state.dataDaylightingManager->CPHSUNHR(iHour); // Azimuth of sun in absolute coord sys - THSUN = THSUNHR(iHour); + state.dataDaylightingManager->THSUN = state.dataDaylightingManager->THSUNHR(iHour); for (ISky = 1; ISky <= 4; ++ISky) { // Loop over sky types @@ -4233,12 +4192,12 @@ namespace DaylightingManager { if (SUNCOSHR(iHour, 3) < SunIsUpValue) return; // Altitude of sun (degrees) - PHSUN = PHSUNHR(iHour); - SPHSUN = SPHSUNHR(iHour); - CPHSUN = CPHSUNHR(iHour); + state.dataDaylightingManager->PHSUN = state.dataDaylightingManager->PHSUNHR(iHour); + state.dataDaylightingManager->SPHSUN = state.dataDaylightingManager->SPHSUNHR(iHour); + state.dataDaylightingManager->CPHSUN = state.dataDaylightingManager->CPHSUNHR(iHour); // Azimuth of sun in absolute coord sys - THSUN = THSUNHR(iHour); + state.dataDaylightingManager->THSUN = state.dataDaylightingManager->THSUNHR(iHour); for (ISky = 1; ISky <= 4; ++ISky) { // Loop over sky types @@ -4366,8 +4325,8 @@ namespace DaylightingManager { DayltgSetupAdjZoneListsAndPointers(state); } - maxNumRefPtInAnyZone = 0; - maxNumRefPtInAnyEncl = 0; + state.dataDaylightingManager->maxNumRefPtInAnyZone = 0; + state.dataDaylightingManager->maxNumRefPtInAnyEncl = 0; for (int SurfNum = 1; SurfNum <= TotSurfaces; ++SurfNum) { if (Surface(SurfNum).Class != SurfaceClass::Window) continue; // Loop through all zones in the same enclosure to find total reference points @@ -4376,9 +4335,9 @@ namespace DaylightingManager { for (int const zoneNum : DataViewFactorInformation::ZoneSolarInfo(surfEnclNum).ZoneNums) { int numRefPoints = state.dataDaylightingData->ZoneDaylight(zoneNum).TotalDaylRefPoints; numEnclRefPoints += numRefPoints; - maxNumRefPtInAnyZone = max(numRefPoints, maxNumRefPtInAnyZone); + state.dataDaylightingManager->maxNumRefPtInAnyZone = max(numRefPoints, state.dataDaylightingManager->maxNumRefPtInAnyZone); } - maxNumRefPtInAnyEncl = max(numEnclRefPoints, maxNumRefPtInAnyEncl); + state.dataDaylightingManager->maxNumRefPtInAnyEncl = max(numEnclRefPoints, state.dataDaylightingManager->maxNumRefPtInAnyEncl); DataViewFactorInformation::ZoneSolarInfo(surfEnclNum).TotalEnclosureDaylRefPoints = numEnclRefPoints; if (numEnclRefPoints > 0) { if (!SurfWinSurfDayLightInit(SurfNum)) { @@ -5929,7 +5888,7 @@ namespace DaylightingManager { for (ITH = 1; ITH <= NTH; ++ITH) { Real64 const TH_ITH(TH(ITH)); for (ISky = 1; ISky <= 4; ++ISky) { - HISK(ISky) += DayltgSkyLuminance(ISky, TH_ITH, PH_IPH) * SPHCPH_IPH; + HISK(ISky) += DayltgSkyLuminance(state, ISky, TH_ITH, PH_IPH) * SPHCPH_IPH; } } } @@ -5939,7 +5898,7 @@ namespace DaylightingManager { } // Direct solar horizontal illum (for unit direct normal illuminance) - HISU = SPHSUN * 1.0; + HISU = state.dataDaylightingManager->SPHSUN * 1.0; } void DayltgHitObstruction(EnergyPlusData &state, @@ -6345,14 +6304,14 @@ namespace DaylightingManager { // zone/window daylighting properties. if (state.dataDaylightingManager->DayltgInteriorIllum_firstTime) { int const d1(max(maxval(Zone, &ZoneData::NumSubSurfaces), maxval(state.dataDaylightingData->ZoneDaylight, &DataDaylighting::ZoneDaylightCalc::NumOfDayltgExtWins))); - tmpIllumFromWinAtRefPt.allocate(d1, 2, maxNumRefPtInAnyZone); - tmpBackLumFromWinAtRefPt.allocate(d1, 2, maxNumRefPtInAnyZone); - tmpSourceLumFromWinAtRefPt.allocate(d1, 2, maxNumRefPtInAnyZone); + tmpIllumFromWinAtRefPt.allocate(d1, 2, state.dataDaylightingManager->maxNumRefPtInAnyZone); + tmpBackLumFromWinAtRefPt.allocate(d1, 2, state.dataDaylightingManager->maxNumRefPtInAnyZone); + tmpSourceLumFromWinAtRefPt.allocate(d1, 2, state.dataDaylightingManager->maxNumRefPtInAnyZone); - SetPnt.allocate(maxNumRefPtInAnyZone); - DaylIllum.allocate(maxNumRefPtInAnyZone); - GLRNDX.allocate(maxNumRefPtInAnyZone); - GLRNEW.allocate(maxNumRefPtInAnyZone); + SetPnt.allocate(state.dataDaylightingManager->maxNumRefPtInAnyZone); + state.dataDaylightingManager->DaylIllum.allocate(state.dataDaylightingManager->maxNumRefPtInAnyZone); + GLRNDX.allocate(state.dataDaylightingManager->maxNumRefPtInAnyZone); + GLRNEW.allocate(state.dataDaylightingManager->maxNumRefPtInAnyZone); state.dataDaylightingManager->DayltgInteriorIllum_firstTime = false; } @@ -6365,7 +6324,7 @@ namespace DaylightingManager { // Initialize reference point illuminance and window background luminance for (IL = 1; IL <= NREFPT; ++IL) { SetPnt(IL) = state.dataDaylightingData->ZoneDaylight(ZoneNum).IllumSetPoint(IL); - DaylIllum(IL) = 0.0; + state.dataDaylightingManager->DaylIllum(IL) = 0.0; state.dataDaylightingData->ZoneDaylight(ZoneNum).BacLum(IL) = 0.0; } @@ -6668,7 +6627,7 @@ namespace DaylightingManager { IS = 2; for (IL = 1; IL <= NREFPT; ++IL) { - DaylIllum(IL) += state.dataDaylightingData->ZoneDaylight(ZoneNum).IllumFromWinAtRefPt(loop, IS, IL); + state.dataDaylightingManager->DaylIllum(IL) += state.dataDaylightingData->ZoneDaylight(ZoneNum).IllumFromWinAtRefPt(loop, IS, IL); state.dataDaylightingData->ZoneDaylight(ZoneNum).BacLum(IL) += state.dataDaylightingData->ZoneDaylight(ZoneNum).BackLumFromWinAtRefPt(loop, IS, IL); } } // End of second window loop over exterior windows associated with this zone @@ -6688,7 +6647,7 @@ namespace DaylightingManager { previously_shaded.allocate(state.dataDaylightingData->ZoneDaylight(ZoneNum).NumOfDayltgExtWins); // If daylight illuminance is above setpoint, allow switching - if (ISWFLG != 0 && DaylIllum(1) > SetPnt(1)) { + if (ISWFLG != 0 && state.dataDaylightingManager->DaylIllum(1) > SetPnt(1)) { // Third loop over windows. Get illuminance at ref pt 1 from // windows that can be switched (DILLSW) with a group and those that can't (DILLUN). @@ -6798,7 +6757,7 @@ namespace DaylightingManager { // and need to adjusted for intermediate switched state at VisTransSelected: IS = 2 IS = 1; VTRAT = SurfWinVisTransSelected(IWin) / (TVIS1(igroup) + 0.000001); - DaylIllum(IL) += (VTRAT - 1.0) * state.dataDaylightingData->ZoneDaylight(ZoneNum).IllumFromWinAtRefPt(loop, IS, IL); + state.dataDaylightingManager->DaylIllum(IL) += (VTRAT - 1.0) * state.dataDaylightingData->ZoneDaylight(ZoneNum).IllumFromWinAtRefPt(loop, IS, IL); state.dataDaylightingData->ZoneDaylight(ZoneNum).BacLum(IL) += (VTRAT - 1.0) * state.dataDaylightingData->ZoneDaylight(ZoneNum).BackLumFromWinAtRefPt(loop, IS, IL); // Adjust illum, background illum and source luminance for this window in intermediate switched state @@ -6811,7 +6770,7 @@ namespace DaylightingManager { } // IL } // ASETIL < 1 // If new daylight does not exceed the illuminance setpoint, done, no more checking other groups of switchable glazings - if (DaylIllum(1) <= SetPnt(1)) { + if (state.dataDaylightingManager->DaylIllum(1) <= SetPnt(1)) { breakOuterLoop = true; break; } @@ -6902,11 +6861,11 @@ namespace DaylightingManager { if (SurfWinShadingFlag(IWin) != SwitchableGlazing) { // for non switchable glazings or switchable glazings not switched yet (still in clear state) // SurfaceWindow(IWin)%ShadingFlag = GlassConditionallyLightened - RDAYIL(IL, igroup) = DaylIllum(IL) - WDAYIL(1, IL, igroup) + WDAYIL(2, IL, igroup); + RDAYIL(IL, igroup) = state.dataDaylightingManager->DaylIllum(IL) - WDAYIL(1, IL, igroup) + WDAYIL(2, IL, igroup); RBACLU(IL, igroup) = state.dataDaylightingData->ZoneDaylight(ZoneNum).BacLum(IL) - WBACLU(1, IL, igroup) + WBACLU(2, IL, igroup); } else { // switchable glazings already in partially switched state when calc the RDAYIL(IL) & RBACLU(IL) - RDAYIL(IL, igroup) = DaylIllum(IL) - WDAYIL(2, IL, igroup) + tmpIllumFromWinAtRefPt(loop, 2, IL); + RDAYIL(IL, igroup) = state.dataDaylightingManager->DaylIllum(IL) - WDAYIL(2, IL, igroup) + tmpIllumFromWinAtRefPt(loop, 2, IL); RBACLU(IL, igroup) = state.dataDaylightingData->ZoneDaylight(ZoneNum).BacLum(IL) - WBACLU(2, IL, igroup) + tmpBackLumFromWinAtRefPt(loop, 2, IL); } } @@ -7017,7 +6976,7 @@ namespace DaylightingManager { for (IL = 1; IL <= NREFPT; ++IL) { state.dataDaylightingData->ZoneDaylight(ZoneNum).BacLum(IL) = RBACLU(IL, igroup); GLRNDX(IL) = GLRNEW(IL); - DaylIllum(IL) = RDAYIL(IL, igroup); + state.dataDaylightingManager->DaylIllum(IL) = RDAYIL(IL, igroup); } // TH comments (5/22/2009): seems for EC windows, if the calculated glare exceeds the max setpoint, @@ -7072,7 +7031,7 @@ namespace DaylightingManager { while (tmpSWFactor > 0) { // calc new glare at new switching state for (IL = 1; IL <= NREFPT; ++IL) { - RDAYIL(IL, igroup) = DaylIllum(IL) + (WDAYIL(1, IL, igroup) - WDAYIL(2, IL, igroup)) * (1.0 - tmpSWFactor); + RDAYIL(IL, igroup) = state.dataDaylightingManager->DaylIllum(IL) + (WDAYIL(1, IL, igroup) - WDAYIL(2, IL, igroup)) * (1.0 - tmpSWFactor); RBACLU(IL, igroup) = state.dataDaylightingData->ZoneDaylight(ZoneNum).BacLum(IL) + (WBACLU(1, IL, igroup) - WBACLU(2, IL, igroup)) * (1.0 - tmpSWFactor); BACL = max(SetPnt(IL) * state.dataDaylightingData->ZoneDaylight(ZoneNum).AveVisDiffReflect / DataGlobalConstants::Pi(), RBACLU(IL, igroup)); @@ -7118,7 +7077,7 @@ namespace DaylightingManager { if (!GlareOK) { // Glare too high, use previous state and re-calc for (IL = 1; IL <= NREFPT; ++IL) { - RDAYIL(IL, igroup) = DaylIllum(IL) + (WDAYIL(1, IL, igroup) - WDAYIL(2, IL, igroup)) * (1.0 - tmpSWFactor); + RDAYIL(IL, igroup) = state.dataDaylightingManager->DaylIllum(IL) + (WDAYIL(1, IL, igroup) - WDAYIL(2, IL, igroup)) * (1.0 - tmpSWFactor); RBACLU(IL, igroup) = state.dataDaylightingData->ZoneDaylight(ZoneNum).BacLum(IL) + (WBACLU(1, IL, igroup) - WBACLU(2, IL, igroup)) * (1.0 - tmpSWFactor); BACL = max(SetPnt(IL) * state.dataDaylightingData->ZoneDaylight(ZoneNum).AveVisDiffReflect / DataGlobalConstants::Pi(), RBACLU(IL, igroup)); @@ -7138,7 +7097,7 @@ namespace DaylightingManager { for (IL = 1; IL <= NREFPT; ++IL) { state.dataDaylightingData->ZoneDaylight(ZoneNum).BacLum(IL) = RBACLU(IL, igroup); GLRNDX(IL) = GLRNEW(IL); - DaylIllum(IL) = RDAYIL(IL, igroup); + state.dataDaylightingManager->DaylIllum(IL) = RDAYIL(IL, igroup); tmpMult = (TVIS1(igroup) - (TVIS1(igroup) - TVIS2(igroup)) * tmpSWFactor) / TVIS2(igroup); // update report variables @@ -7172,7 +7131,7 @@ namespace DaylightingManager { // Variables for reporting for (IL = 1; IL <= NREFPT; ++IL) { - state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylIllumAtRefPt(IL) = DaylIllum(IL); + state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylIllumAtRefPt(IL) = state.dataDaylightingManager->DaylIllum(IL); state.dataDaylightingData->ZoneDaylight(ZoneNum).GlareIndexAtRefPt(IL) = GLRNDX(IL); // added TH 12/2/2008 @@ -7183,7 +7142,7 @@ namespace DaylightingManager { } // added TH 7/6/2009 - if (DaylIllum(IL) > state.dataDaylightingData->ZoneDaylight(ZoneNum).IllumSetPoint(IL)) { + if (state.dataDaylightingManager->DaylIllum(IL) > state.dataDaylightingData->ZoneDaylight(ZoneNum).IllumSetPoint(IL)) { state.dataDaylightingData->ZoneDaylight(ZoneNum).TimeExceedingDaylightIlluminanceSPAtRefPt(IL) = state.dataGlobal->TimeStepZone; // fraction of hours } else { state.dataDaylightingData->ZoneDaylight(ZoneNum).TimeExceedingDaylightIlluminanceSPAtRefPt(IL) = 0.0; @@ -7373,11 +7332,11 @@ namespace DaylightingManager { // Total fraction of zone that is daylit ZFTOT += state.dataDaylightingData->ZoneDaylight(ZoneNum).FracZoneDaylit(IL); - DaylIllum(IL) = state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylIllumAtRefPt(IL); - if (DaylIllum(IL) >= state.dataDaylightingData->ZoneDaylight(ZoneNum).IllumSetPoint(IL)) { + state.dataDaylightingManager->DaylIllum(IL) = state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylIllumAtRefPt(IL); + if (state.dataDaylightingManager->DaylIllum(IL) >= state.dataDaylightingData->ZoneDaylight(ZoneNum).IllumSetPoint(IL)) { FL = 0.0; } else { - FL = (state.dataDaylightingData->ZoneDaylight(ZoneNum).IllumSetPoint(IL) - DaylIllum(IL)) / state.dataDaylightingData->ZoneDaylight(ZoneNum).IllumSetPoint(IL); + FL = (state.dataDaylightingData->ZoneDaylight(ZoneNum).IllumSetPoint(IL) - state.dataDaylightingManager->DaylIllum(IL)) / state.dataDaylightingData->ZoneDaylight(ZoneNum).IllumSetPoint(IL); } // BRANCH ON LIGHTING SYSTEM TYPE @@ -7397,10 +7356,10 @@ namespace DaylightingManager { } else { // LSYSTP = 2 // Stepped system FP = 0.0; - if (DaylIllum(IL) > 0.0 && DaylIllum(IL) < state.dataDaylightingData->ZoneDaylight(ZoneNum).IllumSetPoint(IL)) + if (state.dataDaylightingManager->DaylIllum(IL) > 0.0 && state.dataDaylightingManager->DaylIllum(IL) < state.dataDaylightingData->ZoneDaylight(ZoneNum).IllumSetPoint(IL)) FP = double(int(state.dataDaylightingData->ZoneDaylight(ZoneNum).LightControlSteps * FL) + 1) / double(state.dataDaylightingData->ZoneDaylight(ZoneNum).LightControlSteps); - if (DaylIllum(IL) == 0.0) FP = 1.0; + if (state.dataDaylightingManager->DaylIllum(IL) == 0.0) FP = 1.0; if (state.dataDaylightingData->ZoneDaylight(ZoneNum).LightControlProbability < 1.0) { // Manual operation. Occupant sets lights one level too high a fraction of the time equal to @@ -7867,7 +7826,7 @@ namespace DaylightingManager { if (ISunPos == 1) SkyObstructionMult(IPH, ITH) = 1.0; if (PH > 0.0) { // Contribution is from sky for (ISky = 1; ISky <= 4; ++ISky) { - ZSK(ISky) = DayltgSkyLuminance(ISky, TH, PH) * COSB * DA * ObTransM(IPH, ITH); + ZSK(ISky) = DayltgSkyLuminance(state, ISky, TH, PH) * COSB * DA * ObTransM(IPH, ITH); } } else { // PH <= 0.0; contribution is from ground if (CalcSolRefl && ObTransM(IPH, ITH) > 1.e-6 && ISunPos == 1) { @@ -8253,7 +8212,7 @@ namespace DaylightingManager { if (SunlitFracHR(IHR, IWin) > 0.0) { // Cos of angle of incidence COSBSun = - SPHSUN * std::sin(SurfWinPhi(IWin)) + CPHSUN * std::cos(SurfWinPhi(IWin)) * std::cos(THSUN - SurfWinTheta(IWin)); + state.dataDaylightingManager->SPHSUN * std::sin(SurfWinPhi(IWin)) + state.dataDaylightingManager->CPHSUN * std::cos(SurfWinPhi(IWin)) * std::cos(state.dataDaylightingManager->THSUN - SurfWinTheta(IWin)); if (COSBSun > 0.0) { // Multiply direct normal illuminance (normalized to 1.0 lux) @@ -8554,7 +8513,7 @@ namespace DaylightingManager { if (Altitude > 0.0) { // Ray from sky element for (iSky = 1; iSky <= 4; ++iSky) { - ElementLuminanceSky(iSky, iIncElem) = DayltgSkyLuminance(iSky, Azimuth, Altitude) * LambdaInc; + ElementLuminanceSky(iSky, iIncElem) = DayltgSkyLuminance(state, iSky, Azimuth, Altitude) * LambdaInc; } } else if (Altitude < 0.0) { // Ray from ground element @@ -8567,7 +8526,7 @@ namespace DaylightingManager { // Ray from the element which is half sky and half ground for (iSky = 1; iSky <= 4; ++iSky) { // in this case half of the pach is coming from the sky and half from the ground - ElementLuminanceSky(iSky, iIncElem) = 0.5 * DayltgSkyLuminance(iSky, Azimuth, Altitude) * LambdaInc; + ElementLuminanceSky(iSky, iIncElem) = 0.5 * DayltgSkyLuminance(state, iSky, Azimuth, Altitude) * LambdaInc; ElementLuminanceSky(iSky, iIncElem) += 0.5 * GILSK(IHR, iSky) * GndReflectanceForDayltg / DataGlobalConstants::Pi() * LambdaInc; } ElementLuminanceSun(iIncElem) = 0.5 * GILSU(IHR) * GndReflectanceForDayltg / DataGlobalConstants::Pi() * LambdaInc; @@ -9024,10 +8983,10 @@ namespace DaylightingManager { // Need to recalculate position factor for dominant direction in case of specular bsdf. Otherwise this will produce // very inaccurate results because of position factor of the sun and bsdf pach can vary by lot if (iTrnElem == SolBmIndex) { - XR = std::tan(std::abs(DataGlobalConstants::PiOvr2() - AZVIEW - THSUN) + 0.001); - YR = std::tan(PHSUN + 0.001); + XR = std::tan(std::abs(DataGlobalConstants::PiOvr2() - AZVIEW - state.dataDaylightingManager->THSUN) + 0.001); + YR = std::tan(state.dataDaylightingManager->PHSUN + 0.001); PosFac = DayltgGlarePositionFactor(XR, YR); - RayZ = SPHSUN; + RayZ = state.dataDaylightingManager->SPHSUN; } if (PosFac != 0.0) { @@ -9061,7 +9020,8 @@ namespace DaylightingManager { EDIRSUdisk(iHour, 1) = ELumSunDisk; } - Real64 DayltgSkyLuminance(int const ISky, // Sky type: 1=clear, 2=clear turbid, 3=intermediate, 4=overcast + Real64 DayltgSkyLuminance(EnergyPlusData &state, + int const ISky, // Sky type: 1=clear, 2=clear turbid, 3=intermediate, 4=overcast Real64 const THSKY, // Azimuth and altitude of sky element (radians) Real64 const PHSKY) { @@ -9126,9 +9086,9 @@ namespace DaylightingManager { // FLOW: SPHSKY = max(std::sin(PHSKY), 0.01); // Prevent floating point underflows - Z = DataGlobalConstants::PiOvr2() - PHSUN; + Z = DataGlobalConstants::PiOvr2() - state.dataDaylightingManager->PHSUN; if (ISky >= 1 && ISky <= 3) { // Following not needed for overcast sky - COSG = SPHSKY * SPHSUN + std::cos(PHSKY) * CPHSUN * std::cos(THSKY - THSUN); + COSG = SPHSKY * state.dataDaylightingManager->SPHSUN + std::cos(PHSKY) * state.dataDaylightingManager->CPHSUN * std::cos(THSKY - state.dataDaylightingManager->THSUN); COSG = max(DataPrecisionGlobals::constant_minusone, min(COSG, 1.0)); // Prevent out of range due to roundoff G = std::acos(COSG); } @@ -9136,20 +9096,20 @@ namespace DaylightingManager { if (ISky == 1) { // Clear Sky Z1 = 0.910 + 10.0 * std::exp(-3.0 * G) + 0.45 * COSG * COSG; Z2 = 1.0 - std::exp(-0.32 / SPHSKY); - Z3 = 0.27385 * (0.91 + 10.0 * std::exp(-3.0 * Z) + 0.45 * SPHSUN * SPHSUN); + Z3 = 0.27385 * (0.91 + 10.0 * std::exp(-3.0 * Z) + 0.45 * state.dataDaylightingManager->SPHSUN * state.dataDaylightingManager->SPHSUN); DayltgSkyLuminance = Z1 * Z2 / Z3; } else if (ISky == 2) { // Clear turbid sky Z1 = 0.856 + 16.0 * std::exp(-3.0 * G) + 0.3 * COSG * COSG; Z2 = 1.0 - std::exp(-0.32 / SPHSKY); - Z3 = 0.27385 * (0.856 + 16.0 * std::exp(-3.0 * Z) + 0.3 * SPHSUN * SPHSUN); + Z3 = 0.27385 * (0.856 + 16.0 * std::exp(-3.0 * Z) + 0.3 * state.dataDaylightingManager->SPHSUN * state.dataDaylightingManager->SPHSUN); DayltgSkyLuminance = Z1 * Z2 / Z3; } else if (ISky == 3) { // Intermediate sky - Z1 = (1.35 * (std::sin(3.59 * PHSKY - 0.009) + 2.31) * std::sin(2.6 * PHSUN + 0.316) + PHSKY + 4.799) / 2.326; - Z2 = std::exp(-G * 0.563 * ((PHSUN - 0.008) * (PHSKY + 1.059) + 0.812)); - Z3 = 0.99224 * std::sin(2.6 * PHSUN + 0.316) + 2.73852; - Z4 = std::exp(-Z * 0.563 * ((PHSUN - 0.008) * 2.6298 + 0.812)); + Z1 = (1.35 * (std::sin(3.59 * PHSKY - 0.009) + 2.31) * std::sin(2.6 * state.dataDaylightingManager->PHSUN + 0.316) + PHSKY + 4.799) / 2.326; + Z2 = std::exp(-G * 0.563 * ((state.dataDaylightingManager->PHSUN - 0.008) * (PHSKY + 1.059) + 0.812)); + Z3 = 0.99224 * std::sin(2.6 * state.dataDaylightingManager->PHSUN + 0.316) + 2.73852; + Z4 = std::exp(-Z * 0.563 * ((state.dataDaylightingManager->PHSUN - 0.008) * 2.6298 + 0.812)); DayltgSkyLuminance = Z1 * Z2 / (Z3 * Z4); } else if (ISky == 4) { // Overcast sky diff --git a/src/EnergyPlus/DaylightingManager.hh b/src/EnergyPlus/DaylightingManager.hh index 58a3fa3c035..12bd13aab02 100644 --- a/src/EnergyPlus/DaylightingManager.hh +++ b/src/EnergyPlus/DaylightingManager.hh @@ -72,23 +72,18 @@ namespace DaylightingManager { using DataBSDFWindow::BSDFRefPoints; using DataBSDFWindow::BSDFRefPointsGeomDescr; - // Data - // MODULE PARAMETER DEFINITIONS: - extern int const octreeCrossover; // Surface count crossover for switching to octree algorithm - - // MODULE VARIABLE DECLARATIONS: - extern int TotWindowsWithDayl; // Total number of exterior windows in all daylit zones - extern Array1D DaylIllum; // Daylight illuminance at reference points (lux) - extern int maxNumRefPtInAnyZone; // The most number of reference points that any single zone has - extern int maxNumRefPtInAnyEncl; // The most number of reference points that any single enclosure has - extern Real64 PHSUN; // Solar altitude (radians) - extern Real64 SPHSUN; // Sine of solar altitude - extern Real64 CPHSUN; // Cosine of solar altitude - extern Real64 THSUN; // Solar azimuth (rad) in Absolute Coordinate System (azimuth=0 along east) - extern Array1D PHSUNHR; // Hourly values of PHSUN - extern Array1D SPHSUNHR; // Hourly values of the sine of PHSUN - extern Array1D CPHSUNHR; // Hourly values of the cosine of PHSUN - extern Array1D THSUNHR; // Hourly values of THSUN + // Surface count crossover for using octree algorithm + // The octree gives lower computational complexity for much higher performance + // as the surface count increases but has some overhead such that the direct + // algorithm can be more efficient at small surface counts. + // Testing to date shows that the octree performance is close to that of the + // direct algorithm even with small surface counts and that there is no single + // crossover that is ideal for all models: some cases with 10-30 surfaces were + // faster with the octree but another with 80 surfaces was faster with the + // direct algorithm. + // A reasonable, conservative crossover is selected but may be refined as more + // experience is gained. + constexpr int octreeCrossover(100); // Octree surface count crossover // In the following I,J,K arrays: // I = 1 for clear sky, 2 for clear turbid, 3 for intermediate, 4 for overcast; @@ -457,7 +452,8 @@ namespace DaylightingManager { Optional_int_const MapNum = _, Optional MapWindowSolidAngAtRefPtWtd = _); - Real64 DayltgSkyLuminance(int const ISky, // Sky type: 1=clear, 2=clear turbid, 3=intermediate, 4=overcast + Real64 DayltgSkyLuminance(EnergyPlusData &state, + int const ISky, // Sky type: 1=clear, 2=clear turbid, 3=intermediate, 4=overcast Real64 const THSKY, // Azimuth and altitude of sky element (radians) Real64 const PHSKY); @@ -529,6 +525,19 @@ struct DaylightingManagerData : BaseGlobalStruct { bool doSkyReporting = true; bool CreateDFSReportFile = true; + int TotWindowsWithDayl = 0; // Total number of exterior windows in all daylit zones + Array1D DaylIllum; // Daylight illuminance at reference points (lux) + int maxNumRefPtInAnyZone = 0; // The most number of reference points that any single zone has + int maxNumRefPtInAnyEncl = 0; // The most number of reference points that any single enclosure has + Real64 PHSUN = 0.0; // Solar altitude (radians) + Real64 SPHSUN = 0.0; // Sine of solar altitude + Real64 CPHSUN = 0.0; // Cosine of solar altitude + Real64 THSUN = 0.0; // Solar azimuth (rad) in Absolute Coordinate System (azimuth=0 along east) + Array1D PHSUNHR = Array1D(24, 0.0); // Hourly values of PHSUN + Array1D SPHSUNHR = Array1D(24, 0.0); // Hourly values of the sine of PHSUN + Array1D CPHSUNHR = Array1D(24, 0.0); // Hourly values of the cosine of PHSUN + Array1D THSUNHR = Array1D(24, 0.0); // Hourly values of THSUN + void clear_state() override { this->CalcDayltghCoefficients_firstTime = true; @@ -544,6 +553,18 @@ struct DaylightingManagerData : BaseGlobalStruct { this->SQFirstTime = true; this->doSkyReporting = true; this->CreateDFSReportFile = true; + this->TotWindowsWithDayl = 0; + this->DaylIllum.deallocate(); + this->maxNumRefPtInAnyZone = 0; + this->maxNumRefPtInAnyEncl = 0; + this->PHSUN = 0.0; + this->SPHSUN = 0.0; + this->CPHSUN = 0.0; + this->THSUN = 0.0; + this->PHSUNHR = Array1D(24, 0.0); + this->SPHSUNHR = Array1D(24, 0.0); + this->CPHSUNHR = Array1D(24, 0.0); + this->THSUNHR = Array1D(24, 0.0); } }; diff --git a/src/EnergyPlus/SolarShading.cc b/src/EnergyPlus/SolarShading.cc index b7f1bb8c3f2..4f2cbdc847a 100644 --- a/src/EnergyPlus/SolarShading.cc +++ b/src/EnergyPlus/SolarShading.cc @@ -8209,7 +8209,6 @@ namespace SolarShading { // Using/Aliasing using DataSystemVariables::DetailedSolarTimestepIntegration; using DaylightingManager::CalcDayltgCoefficients; - using DaylightingManager::TotWindowsWithDayl; // Locals // SUBROUTINE ARGUMENT DEFINITIONS: @@ -8310,7 +8309,7 @@ namespace SolarShading { // Recalculate daylighting coefficients if storm window has been added // or removed from one or more windows at beginning of day - if (TotWindowsWithDayl > 0 && !state.dataGlobal->BeginSimFlag && !state.dataGlobal->BeginEnvrnFlag && !state.dataGlobal->WarmupFlag && TotStormWin > 0 && StormWinChangeThisDay) { + if (state.dataDaylightingManager->TotWindowsWithDayl > 0 && !state.dataGlobal->BeginSimFlag && !state.dataGlobal->BeginEnvrnFlag && !state.dataGlobal->WarmupFlag && TotStormWin > 0 && StormWinChangeThisDay) { CalcDayltgCoefficients(state); } } diff --git a/tst/EnergyPlus/unit/DaylightingManager.unit.cc b/tst/EnergyPlus/unit/DaylightingManager.unit.cc index 075cb1bf3b1..f7a92584395 100644 --- a/tst/EnergyPlus/unit/DaylightingManager.unit.cc +++ b/tst/EnergyPlus/unit/DaylightingManager.unit.cc @@ -1360,7 +1360,7 @@ TEST_F(EnergyPlusFixture, DaylightingManager_DayltgInteriorIllum_Test) state->dataDaylightingData->ZoneDaylight(ZoneNum).DaylSourceFacSun = 0.0; state->dataDaylightingData->ZoneDaylight(ZoneNum).DaylSourceFacSunDisk = 0.0; DaylightingManager::DayltgInteriorIllum(*state, ZoneNum); - EXPECT_NEAR(DaylightingManager::DaylIllum(1), 0.0, 0.001); + EXPECT_NEAR(state->dataDaylightingManager->DaylIllum(1), 0.0, 0.001); int ISky = 1; int DayltgExtWin = 1; @@ -1382,26 +1382,26 @@ TEST_F(EnergyPlusFixture, DaylightingManager_DayltgInteriorIllum_Test) SurfWinWindowModelType(IWin) = Window5DetailedModel; SurfWinShadingFlag(IWin) = DataSurfaces::NoShade; DaylightingManager::DayltgInteriorIllum(*state, ZoneNum); - EXPECT_NEAR(DaylightingManager::DaylIllum(1), 100.0, 0.001); - EXPECT_NEAR(DaylightingManager::DaylIllum(2), 10.0, 0.001); + EXPECT_NEAR(state->dataDaylightingManager->DaylIllum(1), 100.0, 0.001); + EXPECT_NEAR(state->dataDaylightingManager->DaylIllum(2), 10.0, 0.001); SurfWinShadingFlag(IWin) = DataSurfaces::ExtBlindOn; DaylightingManager::DayltgInteriorIllum(*state, ZoneNum); - EXPECT_NEAR(DaylightingManager::DaylIllum(1), 50.0, 0.001); - EXPECT_NEAR(DaylightingManager::DaylIllum(2), 5.0, 0.001); + EXPECT_NEAR(state->dataDaylightingManager->DaylIllum(1), 50.0, 0.001); + EXPECT_NEAR(state->dataDaylightingManager->DaylIllum(2), 5.0, 0.001); // BSDF model - expect 100 for unshaded and 100 for shaded (10 for RefPt2 // BSDF does shading differently, it's integrated in the base state SurfWinWindowModelType(IWin) = WindowBSDFModel; SurfWinShadingFlag(IWin) = DataSurfaces::NoShade; DaylightingManager::DayltgInteriorIllum(*state, ZoneNum); - EXPECT_NEAR(DaylightingManager::DaylIllum(1), 100.0, 0.001); - EXPECT_NEAR(DaylightingManager::DaylIllum(2), 10.0, 0.001); + EXPECT_NEAR(state->dataDaylightingManager->DaylIllum(1), 100.0, 0.001); + EXPECT_NEAR(state->dataDaylightingManager->DaylIllum(2), 10.0, 0.001); SurfWinShadingFlag(IWin) = DataSurfaces::ExtBlindOn; DaylightingManager::DayltgInteriorIllum(*state, ZoneNum); - EXPECT_NEAR(DaylightingManager::DaylIllum(1), 100.0, 0.001); - EXPECT_NEAR(DaylightingManager::DaylIllum(2), 10.0, 0.001); + EXPECT_NEAR(state->dataDaylightingManager->DaylIllum(1), 100.0, 0.001); + EXPECT_NEAR(state->dataDaylightingManager->DaylIllum(2), 10.0, 0.001); } From 4c190204ad814d8da491eee9a1f8c6daf53f364c Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Tue, 24 Nov 2020 21:24:42 -0700 Subject: [PATCH 08/10] moving DaylightingManager to state --- src/EnergyPlus/DaylightingManager.cc | 338 ++++++++---------- src/EnergyPlus/DaylightingManager.hh | 89 +++-- .../unit/DaylightingManager.unit.cc | 2 +- 3 files changed, 196 insertions(+), 233 deletions(-) diff --git a/src/EnergyPlus/DaylightingManager.cc b/src/EnergyPlus/DaylightingManager.cc index fb10f4fa8c0..69bd69cdf26 100644 --- a/src/EnergyPlus/DaylightingManager.cc +++ b/src/EnergyPlus/DaylightingManager.cc @@ -152,58 +152,6 @@ namespace DaylightingManager { using namespace ScheduleManager; - // In the following I,J,K arrays: - // I = 1 for clear sky, 2 for clear turbid, 3 for intermediate, 4 for overcast; - // J = 1 for bare window, 2 - 12 for shaded; - // K = sun position index. - Array3D EINTSK(24, MaxSlatAngs + 1, 4, 0.0); // Sky-related portion of internally reflected illuminance - Array2D EINTSU(24, MaxSlatAngs + 1, 0.0); // Sun-related portion of internally reflected illuminance, - // excluding entering beam - Array2D EINTSUdisk(24, MaxSlatAngs + 1, 0.0); // Sun-related portion of internally reflected illuminance - // due to entering beam - Array3D WLUMSK(24, MaxSlatAngs + 1, 4, 0.0); // Sky-related window luminance - Array2D WLUMSU(24, MaxSlatAngs + 1, 0.0); // Sun-related window luminance, excluding view of solar disk - Array2D WLUMSUdisk(24, MaxSlatAngs + 1, 0.0); // Sun-related window luminance, due to view of solar disk - - Array2D GILSK(24, 4, 0.0); // Horizontal illuminance from sky, by sky type, for each hour of the day - Array1D GILSU(24, 0.0); // Horizontal illuminance from sun for each hour of the day - - Array3D EDIRSK(24, MaxSlatAngs + 1, 4); // Sky-related component of direct illuminance - Array2D EDIRSU(24, MaxSlatAngs + 1); // Sun-related component of direct illuminance (excluding beam solar at ref pt) - Array2D EDIRSUdisk(24, MaxSlatAngs + 1); // Sun-related component of direct illuminance due to beam solar at ref pt - Array3D AVWLSK(24, MaxSlatAngs + 1, 4); // Sky-related average window luminance - Array2D AVWLSU(24, MaxSlatAngs + 1); // Sun-related average window luminance, excluding view of solar disk - Array2D AVWLSUdisk(24, MaxSlatAngs + 1); // Sun-related average window luminance due to view of solar disk - - // Allocatable daylight factor arrays -- are in the ZoneDaylight Structure - - Array2D TDDTransVisBeam; - Array3D TDDFluxInc; - Array3D TDDFluxTrans; - - Array2D_int MapErrIndex; - Array2D_int RefErrIndex; - - // SUBROUTINE SPECIFICATIONS FOR MODULE DaylightingModule - - // MODULE SUBROUTINES: - - // Functions - - void clear_state() - { - // this will need a lot more, but it is a start - TDDTransVisBeam.deallocate(); - TDDFluxInc.deallocate(); - TDDFluxTrans.deallocate(); - RefErrIndex.deallocate(); - TDDTransVisBeam.deallocate(); - TDDFluxInc.deallocate(); - TDDFluxTrans.deallocate(); - MapErrIndex.deallocate(); - RefErrIndex.deallocate(); - } - void DayltgAveInteriorReflectance(EnergyPlusData &state, int &ZoneNum) // Zone number { @@ -518,9 +466,9 @@ namespace DaylightingManager { // Used in calculating daylighting through interior windows. CalcMinIntWinSolidAngs(state); - TDDTransVisBeam.allocate(24, state.dataDaylightingDevicesData->NumOfTDDPipes); - TDDFluxInc.allocate(24, 4, state.dataDaylightingDevicesData->NumOfTDDPipes); - TDDFluxTrans.allocate(24, 4, state.dataDaylightingDevicesData->NumOfTDDPipes); + state.dataDaylightingManager->TDDTransVisBeam.allocate(24, state.dataDaylightingDevicesData->NumOfTDDPipes); + state.dataDaylightingManager->TDDFluxInc.allocate(24, 4, state.dataDaylightingDevicesData->NumOfTDDPipes); + state.dataDaylightingManager->TDDFluxTrans.allocate(24, 4, state.dataDaylightingDevicesData->NumOfTDDPipes); // Warning if detailed daylighting has been requested for a zone with no associated exterior windows. for (ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ++ZoneNum) { @@ -543,13 +491,13 @@ namespace DaylightingManager { // Zero daylighting factor arrays if (!DetailedSolarTimestepIntegration) { - TDDTransVisBeam = 0.0; - TDDFluxInc = 0.0; - TDDFluxTrans = 0.0; + state.dataDaylightingManager->TDDTransVisBeam = 0.0; + state.dataDaylightingManager->TDDFluxInc = 0.0; + state.dataDaylightingManager->TDDFluxTrans = 0.0; } else { - TDDTransVisBeam(state.dataGlobal->HourOfDay, {1, state.dataDaylightingDevicesData->NumOfTDDPipes}) = 0.0; - TDDFluxInc(state.dataGlobal->HourOfDay, {1, 4}, {1, state.dataDaylightingDevicesData->NumOfTDDPipes}) = 0.0; - TDDFluxTrans(state.dataGlobal->HourOfDay, {1, 4}, {1, state.dataDaylightingDevicesData->NumOfTDDPipes}) = 0.0; + state.dataDaylightingManager->TDDTransVisBeam(state.dataGlobal->HourOfDay, {1, state.dataDaylightingDevicesData->NumOfTDDPipes}) = 0.0; + state.dataDaylightingManager->TDDFluxInc(state.dataGlobal->HourOfDay, {1, 4}, {1, state.dataDaylightingDevicesData->NumOfTDDPipes}) = 0.0; + state.dataDaylightingManager->TDDFluxTrans(state.dataGlobal->HourOfDay, {1, 4}, {1, state.dataDaylightingDevicesData->NumOfTDDPipes}) = 0.0; } if (!DetailedSolarTimestepIntegration) { @@ -564,8 +512,8 @@ namespace DaylightingManager { state.dataDaylightingManager->SPHSUNHR = 0.0; state.dataDaylightingManager->CPHSUNHR = 0.0; state.dataDaylightingManager->THSUNHR = 0.0; - GILSK = 0.0; - GILSU = 0.0; + state.dataDaylightingManager->GILSK = 0.0; + state.dataDaylightingManager->GILSU = 0.0; for (IHR = 1; IHR <= 24; ++IHR) { if (SUNCOSHR(IHR, 3) < SunIsUpValue) continue; // Skip if sun is below horizon //Autodesk SUNCOSHR was uninitialized here state.dataDaylightingManager->PHSUN = DataGlobalConstants::PiOvr2() - std::acos(SUNCOSHR(IHR, 3)); @@ -577,7 +525,7 @@ namespace DaylightingManager { state.dataDaylightingManager->THSUN = state.dataDaylightingManager->THSUNHR(IHR); state.dataDaylightingManager->SPHSUN = state.dataDaylightingManager->SPHSUNHR(IHR); state.dataDaylightingManager->CPHSUN = state.dataDaylightingManager->CPHSUNHR(IHR); - DayltgExtHorizIllum(state, GILSK(IHR, 1), GILSU(IHR)); + DayltgExtHorizIllum(state, state.dataDaylightingManager->GILSK(IHR, 1), state.dataDaylightingManager->GILSU(IHR)); } } } else { // timestep integrated calculations @@ -590,8 +538,8 @@ namespace DaylightingManager { state.dataDaylightingManager->SPHSUNHR(state.dataGlobal->HourOfDay) = 0.0; state.dataDaylightingManager->CPHSUNHR(state.dataGlobal->HourOfDay) = 0.0; state.dataDaylightingManager->THSUNHR(state.dataGlobal->HourOfDay) = 0.0; - GILSK(state.dataGlobal->HourOfDay, {1, 4}) = 0.0; - GILSU(state.dataGlobal->HourOfDay) = 0.0; + state.dataDaylightingManager->GILSK(state.dataGlobal->HourOfDay, {1, 4}) = 0.0; + state.dataDaylightingManager->GILSU(state.dataGlobal->HourOfDay) = 0.0; if (!(SUNCOSHR(state.dataGlobal->HourOfDay, 3) < SunIsUpValue)) { // Skip if sun is below horizon state.dataDaylightingManager->PHSUN = DataGlobalConstants::PiOvr2() - std::acos(SUNCOSHR(state.dataGlobal->HourOfDay, 3)); state.dataDaylightingManager->PHSUNHR(state.dataGlobal->HourOfDay) = state.dataDaylightingManager->PHSUN; @@ -602,7 +550,7 @@ namespace DaylightingManager { state.dataDaylightingManager->THSUN = state.dataDaylightingManager->THSUNHR(state.dataGlobal->HourOfDay); state.dataDaylightingManager->SPHSUN = state.dataDaylightingManager->SPHSUNHR(state.dataGlobal->HourOfDay); state.dataDaylightingManager->CPHSUN = state.dataDaylightingManager->CPHSUNHR(state.dataGlobal->HourOfDay); - DayltgExtHorizIllum(state, GILSK(state.dataGlobal->HourOfDay, 1), GILSU(state.dataGlobal->HourOfDay)); + DayltgExtHorizIllum(state, state.dataDaylightingManager->GILSK(state.dataGlobal->HourOfDay, 1), state.dataDaylightingManager->GILSU(state.dataGlobal->HourOfDay)); } } @@ -962,8 +910,8 @@ namespace DaylightingManager { if (state.dataDaylightingManager->refFirstTime && std::any_of(state.dataDaylightingData->ZoneDaylight.begin(), state.dataDaylightingData->ZoneDaylight.end(), [](DataDaylighting::ZoneDaylightCalc const &e) { return e.TotalDaylRefPoints > 0; })) { - RefErrIndex.allocate(maxval(state.dataDaylightingData->ZoneDaylight, &DataDaylighting::ZoneDaylightCalc::TotalDaylRefPoints), TotSurfaces); - RefErrIndex = 0; + state.dataDaylightingManager->RefErrIndex.allocate(maxval(state.dataDaylightingData->ZoneDaylight, &DataDaylighting::ZoneDaylightCalc::TotalDaylRefPoints), TotSurfaces); + state.dataDaylightingManager->RefErrIndex = 0; state.dataDaylightingManager->refFirstTime = false; } @@ -1367,7 +1315,7 @@ namespace DaylightingManager { for (MapNum = 1; MapNum <= state.dataDaylightingData->TotIllumMaps; ++MapNum) { IL = max(IL, state.dataDaylightingData->IllumMapCalc(MapNum).TotalMapRefPoints); } - MapErrIndex.dimension(IL, TotSurfaces, 0); + state.dataDaylightingManager->MapErrIndex.dimension(IL, TotSurfaces, 0); state.dataDaylightingManager->mapFirstTime = false; } @@ -1896,7 +1844,7 @@ namespace DaylightingManager { ShowFatalError(state, "Program terminates due to preceding condition."); } } else if (ALF < 0.1524 && ExtWinType == DataDaylighting::iExtWinType::AdjZoneExtWin) { - if (RefErrIndex(iRefPoint, IWin) == 0) { // only show error message once + if (state.dataDaylightingManager->RefErrIndex(iRefPoint, IWin) == 0) { // only show error message once ShowWarningError(state, "CalcDaylightCoeffRefPoints: For Zone=\"" + Zone(ZoneNum).Name + "\" External Window=\"" + Surface(IWin).Name + "\"in Zone=\"" + Zone(Surface(IWin).Zone).Name + "\" reference point is less than 0.15m (6\") from window plane "); @@ -1906,12 +1854,12 @@ namespace DaylightingManager { RREF(1), RREF(2), RREF(3))); - RefErrIndex(iRefPoint, IWin) = 1; + state.dataDaylightingManager->RefErrIndex(iRefPoint, IWin) = 1; } } } else if (CalledFrom == DataDaylighting::iCalledFor::MapPoint) { if (ALF < 0.1524 && ExtWinType == DataDaylighting::iExtWinType::AdjZoneExtWin) { - if (MapErrIndex(iRefPoint, IWin) == 0) { // only show error message once + if (state.dataDaylightingManager->MapErrIndex(iRefPoint, IWin) == 0) { // only show error message once ShowWarningError(state, "CalcDaylightCoeffMapPoints: For Zone=\"" + Zone(ZoneNum).Name + "\" External Window=\"" + Surface(IWin).Name + "\"in Zone=\"" + Zone(Surface(IWin).Zone).Name + "\" map point is less than 0.15m (6\") from window plane "); ShowContinueError(state, @@ -1920,7 +1868,7 @@ namespace DaylightingManager { RREF(1), RREF(2), RREF(3))); - MapErrIndex(iRefPoint, IWin) = 1; + state.dataDaylightingManager->MapErrIndex(iRefPoint, IWin) = 1; } } } @@ -2072,19 +2020,19 @@ namespace DaylightingManager { if (!DetailedSolarTimestepIntegration) { // Initialize sky and sun components of direct illuminance (arrays EDIRSK, EDIRSU, EDIRSUdisk) // and average window luminance (arrays AVWLSK, AVWLSU, AVWLSUdisk), at ref pt. - EDIRSK = 0.0; - EDIRSU = 0.0; - EDIRSUdisk = 0.0; - AVWLSK = 0.0; - AVWLSU = 0.0; - AVWLSUdisk = 0.0; + state.dataDaylightingManager->EDIRSK = 0.0; + state.dataDaylightingManager->EDIRSU = 0.0; + state.dataDaylightingManager->EDIRSUdisk = 0.0; + state.dataDaylightingManager->AVWLSK = 0.0; + state.dataDaylightingManager->AVWLSU = 0.0; + state.dataDaylightingManager->AVWLSUdisk = 0.0; } else { - EDIRSK(state.dataGlobal->HourOfDay, {1, MaxSlatAngs + 1}, {1, 4}) = 0.0; - EDIRSU(state.dataGlobal->HourOfDay, {1, MaxSlatAngs + 1}) = 0.0; - EDIRSUdisk(state.dataGlobal->HourOfDay, {1, MaxSlatAngs + 1}) = 0.0; - AVWLSK(state.dataGlobal->HourOfDay, {1, MaxSlatAngs + 1}, {1, 4}) = 0.0; - AVWLSU(state.dataGlobal->HourOfDay, {1, MaxSlatAngs + 1}) = 0.0; - AVWLSUdisk(state.dataGlobal->HourOfDay, {1, MaxSlatAngs + 1}) = 0.0; + state.dataDaylightingManager->EDIRSK(state.dataGlobal->HourOfDay, {1, MaxSlatAngs + 1}, {1, 4}) = 0.0; + state.dataDaylightingManager->EDIRSU(state.dataGlobal->HourOfDay, {1, MaxSlatAngs + 1}) = 0.0; + state.dataDaylightingManager->EDIRSUdisk(state.dataGlobal->HourOfDay, {1, MaxSlatAngs + 1}) = 0.0; + state.dataDaylightingManager->AVWLSK(state.dataGlobal->HourOfDay, {1, MaxSlatAngs + 1}, {1, 4}) = 0.0; + state.dataDaylightingManager->AVWLSU(state.dataGlobal->HourOfDay, {1, MaxSlatAngs + 1}) = 0.0; + state.dataDaylightingManager->AVWLSUdisk(state.dataGlobal->HourOfDay, {1, MaxSlatAngs + 1}) = 0.0; } if (CalledFrom == DataDaylighting::iCalledFor::RefPoint) { // Initialize solid angle subtended by window wrt ref pt @@ -3488,8 +3436,8 @@ namespace DaylightingManager { // Beam solar reflected from nearest obstruction DayltgSurfaceLumFromSun(state, iHour, Ray, NearestHitSurfNum, NearestHitPt, LumAtHitPtFrSun); - AVWLSU(iHour, 1) += LumAtHitPtFrSun * TVISB; - if (PHRAY >= 0.0) EDIRSU(iHour, 1) += LumAtHitPtFrSun * DOMEGA_Ray_3 * TVISB; + state.dataDaylightingManager->AVWLSU(iHour, 1) += LumAtHitPtFrSun * TVISB; + if (PHRAY >= 0.0) state.dataDaylightingManager->EDIRSU(iHour, 1) += LumAtHitPtFrSun * DOMEGA_Ray_3 * TVISB; // Sky solar reflected from nearest obstruction @@ -3528,15 +3476,15 @@ namespace DaylightingManager { SkyReflVisLum = ObsVisRefl * Surface(NearestHitSurfNumX).ViewFactorSky * DifShdgRatioIsoSkyHRTS(1, iHour, NearestHitSurfNumX) / DataGlobalConstants::Pi(); } - assert(equal_dimensions(AVWLSK, EDIRSK)); - auto l2(GILSK.index(iHour, 1)); - auto l3(AVWLSK.index(iHour, 1, 1)); + assert(equal_dimensions(state.dataDaylightingManager->AVWLSK, state.dataDaylightingManager->EDIRSK)); + auto l2(state.dataDaylightingManager->GILSK.index(iHour, 1)); + auto l3(state.dataDaylightingManager->AVWLSK.index(iHour, 1, 1)); for (ISky = 1; ISky <= 4; ++ISky, ++l2, ++l3) { // [ l2 ] == ( ISky, iHour ) // [ l3 ] == ( ISky, 1, iHour ) - XAVWLSK(ISky) = GILSK[l2] * SkyReflVisLum; - AVWLSK[l3] += XAVWLSK(ISky) * TVISB; + XAVWLSK(ISky) = state.dataDaylightingManager->GILSK[l2] * SkyReflVisLum; + state.dataDaylightingManager->AVWLSK[l3] += XAVWLSK(ISky) * TVISB; if (PHRAY >= 0.0) { - XEDIRSK(ISky) = GILSK[l2] * SkyReflVisLum * DOMEGA_Ray_3; - EDIRSK[l3] += XEDIRSK(ISky) * TVISB; + XEDIRSK(ISky) = state.dataDaylightingManager->GILSK[l2] * SkyReflVisLum * DOMEGA_Ray_3; + state.dataDaylightingManager->EDIRSK[l3] += XEDIRSK(ISky) * TVISB; } } } @@ -3547,18 +3495,18 @@ namespace DaylightingManager { // Contribution of sky or ground luminance in cd/m2 if (SurfWinOriginalClass(IWin) == SurfaceClass::TDD_Diffuser) { // Make all transmitted light diffuse for a TDD with a bare diffuser - assert(equal_dimensions(AVWLSK, WLUMSK)); - assert(equal_dimensions(AVWLSK, EDIRSK)); - auto l3(AVWLSK.index(iHour, 1, 1)); + assert(equal_dimensions(state.dataDaylightingManager->AVWLSK, state.dataDaylightingManager->WLUMSK)); + assert(equal_dimensions(state.dataDaylightingManager->AVWLSK, state.dataDaylightingManager->EDIRSK)); + auto l3(state.dataDaylightingManager->AVWLSK.index(iHour, 1, 1)); for (ISky = 1; ISky <= 4; ++ISky, ++l3) { // [ l3 ] == ( ISky, 1, iHour ) - AVWLSK[l3] += WLUMSK[l3]; + state.dataDaylightingManager->AVWLSK[l3] += state.dataDaylightingManager->WLUMSK[l3]; if (ISky == 1) { - AVWLSU(iHour, 1) += WLUMSU(iHour, 1); - AVWLSUdisk(iHour, 1) += WLUMSUdisk(iHour, 1); + state.dataDaylightingManager->AVWLSU(iHour, 1) += state.dataDaylightingManager->WLUMSU(iHour, 1); + state.dataDaylightingManager->AVWLSUdisk(iHour, 1) += state.dataDaylightingManager->WLUMSUdisk(iHour, 1); } if (PHRAY > 0.0) { - EDIRSK[l3] += WLUMSK[l3] * DOMEGA_Ray_3; - if (ISky == 1) EDIRSU(iHour, 1) += WLUMSU(iHour, 1) * DOMEGA_Ray_3; + state.dataDaylightingManager->EDIRSK[l3] += state.dataDaylightingManager->WLUMSK[l3] * DOMEGA_Ray_3; + if (ISky == 1) state.dataDaylightingManager->EDIRSU(iHour, 1) += state.dataDaylightingManager->WLUMSU(iHour, 1) * DOMEGA_Ray_3; } } @@ -3586,23 +3534,23 @@ namespace DaylightingManager { } Real64 const GILSK_mult((GndReflectanceForDayltg / DataGlobalConstants::Pi()) * ObTrans * SkyObstructionMult); Real64 const TVISB_ObTrans(TVISB * ObTrans); - Real64 const AVWLSU_add(TVISB_ObTrans * GILSU(iHour) * (GndReflectanceForDayltg / DataGlobalConstants::Pi())); + Real64 const AVWLSU_add(TVISB_ObTrans * state.dataDaylightingManager->GILSU(iHour) * (GndReflectanceForDayltg / DataGlobalConstants::Pi())); Vector3 const SUNCOS_iHour(SUNCOSHR(iHour, {1, 3})); - assert(equal_dimensions(EDIRSK, AVWLSK)); - auto l(EDIRSK.index(iHour, 1, 1)); + assert(equal_dimensions(state.dataDaylightingManager->EDIRSK, state.dataDaylightingManager->AVWLSK)); + auto l(state.dataDaylightingManager->EDIRSK.index(iHour, 1, 1)); for (ISky = 1; ISky <= 4; ++ISky, ++l) { // [ l ] == ( iHour, 1, ISky ) if (PHRAY > 0.0) { // Ray heads upward to sky ELUM = DayltgSkyLuminance(state, ISky, THRAY, PHRAY); XEDIRSK(ISky) = ELUM * DOMEGA_Ray_3; DEDIR = XEDIRSK(ISky) * TVISB; - EDIRSK[l] += DEDIR * ObTrans; - AVWLSK[l] += ELUM * TVISB_ObTrans; + state.dataDaylightingManager->EDIRSK[l] += DEDIR * ObTrans; + state.dataDaylightingManager->AVWLSK[l] += ELUM * TVISB_ObTrans; XAVWLSK(ISky) = ELUM * ObTrans; } else { // PHRAY <= 0. // Ray heads downward to ground. // Contribution from sky diffuse reflected from ground - XAVWLSK(ISky) = GILSK(iHour, ISky) * GILSK_mult; - AVWLSK[l] += TVISB * XAVWLSK(ISky); + XAVWLSK(ISky) = state.dataDaylightingManager->GILSK(iHour, ISky) * GILSK_mult; + state.dataDaylightingManager->AVWLSK[l] += TVISB * XAVWLSK(ISky); // Contribution from beam solar reflected from ground (beam reaching ground point // can be obstructed [SunObstructionMult < 1.0] if CalcSolRefl = .TRUE.) if (ISky == 1) { @@ -3616,9 +3564,9 @@ namespace DaylightingManager { if (hitObs) break; } // if ( hitObs ) SunObstructionMult = 0.0; - if (!hitObs) AVWLSU(iHour, 1) += AVWLSU_add; + if (!hitObs) state.dataDaylightingManager->AVWLSU(iHour, 1) += AVWLSU_add; } else { - AVWLSU(iHour, 1) += AVWLSU_add; + state.dataDaylightingManager->AVWLSU(iHour, 1) += AVWLSU_add; } } // End of check if ISky = 1 } // End of check if ray is going up or down @@ -3732,7 +3680,7 @@ namespace DaylightingManager { if (ExtWinType == DataDaylighting::iExtWinType::AdjZoneExtWin && hitIntWinDisk) TVISS *= TVISIntWinDisk; } - EDIRSUdisk(iHour, 1) = RAYCOS(3) * TVISS * ObTransDisk; // Bare window + state.dataDaylightingManager->EDIRSUdisk(iHour, 1) = RAYCOS(3) * TVISS * ObTransDisk; // Bare window TransBmBmMult = 0.0; if (ShType == WSC_ST_ExteriorBlind || ShType == WSC_ST_InteriorBlind || ShType == WSC_ST_BetweenGlassBlind) { @@ -3747,7 +3695,7 @@ namespace DaylightingManager { } TransBmBmMult(JB) = BlindBeamBeamTrans( ProfAng, SlatAng, Blind(BlNum).SlatWidth, Blind(BlNum).SlatSeparation, Blind(BlNum).SlatThickness); - EDIRSUdisk(iHour, JB + 1) = RAYCOS(3) * TVISS * TransBmBmMult(JB) * ObTransDisk; + state.dataDaylightingManager->EDIRSUdisk(iHour, JB + 1) = RAYCOS(3) * TVISS * TransBmBmMult(JB) * ObTransDisk; // do this only once for fixed slat blinds if (!SurfWinMovableSlats(IWin)) break; @@ -3758,7 +3706,7 @@ namespace DaylightingManager { // SunAzimuthToWindowNormalAngle = THSUN - SurfaceWindow(IWin)%Theta CalcScreenTransmittance(state, IWin, (state.dataDaylightingManager->PHSUN - SurfWinPhi(IWin)), (state.dataDaylightingManager->THSUN - SurfWinTheta(IWin))); TransBmBmMult(1) = SurfaceScreens(SurfWinScreenNumber(IWin)).BmBmTrans; - EDIRSUdisk(iHour, 2) = RAYCOS(3) * TVISS * TransBmBmMult(1) * ObTransDisk; + state.dataDaylightingManager->EDIRSUdisk(iHour, 2) = RAYCOS(3) * TVISS * TransBmBmMult(1) * ObTransDisk; } // Glare from solar disk @@ -3787,16 +3735,16 @@ namespace DaylightingManager { // Solid angle subtended by sun is 0.000068 steradians XAVWL = 14700.0 * std::sqrt(0.000068 * POSFAC) * double(NWX * NWY) / std::pow(WindowSolidAngleDaylightPoint, 0.8); - AVWLSUdisk(iHour, 1) = XAVWL * TVISS * ObTransDisk; // Bare window + state.dataDaylightingManager->AVWLSUdisk(iHour, 1) = XAVWL * TVISS * ObTransDisk; // Bare window if (ShType == WSC_ST_ExteriorBlind || ShType == WSC_ST_InteriorBlind || ShType == WSC_ST_BetweenGlassBlind) { for (JB = 1; JB <= MaxSlatAngs; ++JB) { // IF (.NOT. SurfaceWindow(IWin)%MovableSlats .AND. JB > 1) EXIT - AVWLSUdisk(iHour, JB + 1) = XAVWL * TVISS * TransBmBmMult(JB) * ObTransDisk; + state.dataDaylightingManager->AVWLSUdisk(iHour, JB + 1) = XAVWL * TVISS * TransBmBmMult(JB) * ObTransDisk; if (!SurfWinMovableSlats(IWin)) break; } } else if (ShType == WSC_ST_ExteriorScreen) { - AVWLSUdisk(iHour, 2) = XAVWL * TVISS * TransBmBmMult(1) * ObTransDisk; + state.dataDaylightingManager->AVWLSUdisk(iHour, 2) = XAVWL * TVISS * TransBmBmMult(1) * ObTransDisk; } } // Position Factor } // Beam avoids all obstructions @@ -3899,7 +3847,7 @@ namespace DaylightingManager { state.dataConstruction->Construct(Surface(ReflSurfNum).ShadowSurfGlazingConstruct).ReflSolBeamFrontCoef); TVisRefl = POLYF(CosIncAngRec, state.dataConstruction->Construct(IConst).TransVisBeamCoef) * SurfWinGlazedFrac(IWin) * SurfWinLightWellEff(IWin); - EDIRSUdisk(iHour, 1) += SunVecMir(3) * SpecReflectance * TVisRefl; // Bare window + state.dataDaylightingManager->EDIRSUdisk(iHour, 1) += SunVecMir(3) * SpecReflectance * TVisRefl; // Bare window TransBmBmMultRefl = 0.0; if (ShType == WSC_ST_ExteriorBlind || ShType == WSC_ST_InteriorBlind || ShType == WSC_ST_BetweenGlassBlind) { @@ -3915,7 +3863,7 @@ namespace DaylightingManager { } TransBmBmMultRefl(JB) = BlindBeamBeamTrans( ProfAng, SlatAng, Blind(BlNum).SlatWidth, Blind(BlNum).SlatSeparation, Blind(BlNum).SlatThickness); - EDIRSUdisk(iHour, JB + 1) += SunVecMir(3) * SpecReflectance * TVisRefl * TransBmBmMultRefl(JB); + state.dataDaylightingManager->EDIRSUdisk(iHour, JB + 1) += SunVecMir(3) * SpecReflectance * TVisRefl * TransBmBmMultRefl(JB); if (!SurfWinMovableSlats(IWin)) break; } @@ -3925,7 +3873,7 @@ namespace DaylightingManager { // SunAzimuthToWindowNormalAngle = THSUN - SurfaceWindow(IWin)%Theta CalcScreenTransmittance(state, IWin, (state.dataDaylightingManager->PHSUN - SurfWinPhi(IWin)), (state.dataDaylightingManager->THSUN - SurfWinTheta(IWin))); TransBmBmMultRefl(1) = SurfaceScreens(SurfWinScreenNumber(IWin)).BmBmTrans; - EDIRSUdisk(iHour, 2) += SunVecMir(3) * SpecReflectance * TVisRefl * TransBmBmMultRefl(1); + state.dataDaylightingManager->EDIRSUdisk(iHour, 2) += SunVecMir(3) * SpecReflectance * TVisRefl * TransBmBmMultRefl(1); } // End of check if window has a blind or screen // Glare from reflected solar disk @@ -3938,15 +3886,15 @@ namespace DaylightingManager { if (POSFAC != 0.0 && SurfaceWindow(IWin).SolidAngAtRefPtWtd(iRefPoint) > 0.000001) { XAVWL = 14700.0 * std::sqrt(0.000068 * POSFAC) * double(NWX * NWY) / std::pow(SurfaceWindow(IWin).SolidAngAtRefPtWtd(iRefPoint), 0.8); - AVWLSUdisk(iHour, 1) += XAVWL * TVisRefl * SpecReflectance; // Bare window + state.dataDaylightingManager->AVWLSUdisk(iHour, 1) += XAVWL * TVisRefl * SpecReflectance; // Bare window if (ShType == WSC_ST_ExteriorBlind || ShType == WSC_ST_InteriorBlind || ShType == WSC_ST_BetweenGlassBlind) { for (JB = 1; JB <= MaxSlatAngs; ++JB) { // IF(.NOT. SurfaceWindow(IWin)%MovableSlats .AND. JB > 1) EXIT - AVWLSUdisk(iHour, JB + 1) += XAVWL * TVisRefl * SpecReflectance * TransBmBmMultRefl(JB); + state.dataDaylightingManager->AVWLSUdisk(iHour, JB + 1) += XAVWL * TVisRefl * SpecReflectance * TransBmBmMultRefl(JB); if (!SurfWinMovableSlats(IWin)) break; } } else if (ShType == WSC_ST_ExteriorScreen) { - AVWLSUdisk(iHour, 2) += XAVWL * TVisRefl * SpecReflectance * TransBmBmMultRefl(1); + state.dataDaylightingManager->AVWLSUdisk(iHour, 2) += XAVWL * TVisRefl * SpecReflectance * TransBmBmMultRefl(1); } } } // End of check that obstruction can specularly reflect @@ -3977,14 +3925,14 @@ namespace DaylightingManager { for (ISky = 1; ISky <= 4; ++ISky) { for (JB = 1; JB <= MaxSlatAngs; ++JB) { // IF (.NOT.SurfaceWindow(IWin)%MovableSlats .AND. JB > 1) EXIT - AVWLSK(iHour, JB + 1, ISky) += WLUMSK(iHour, JB + 1, ISky) * TVisIntWinMult; + state.dataDaylightingManager->AVWLSK(iHour, JB + 1, ISky) += state.dataDaylightingManager->WLUMSK(iHour, JB + 1, ISky) * TVisIntWinMult; if (ISky == 1) { - AVWLSU(iHour, JB + 1) += WLUMSU(iHour, JB + 1) * TVisIntWinMult; - AVWLSUdisk(iHour, JB + 1) += WLUMSUdisk(iHour, JB + 1) * TVisIntWinDiskMult; + state.dataDaylightingManager->AVWLSU(iHour, JB + 1) += state.dataDaylightingManager->WLUMSU(iHour, JB + 1) * TVisIntWinMult; + state.dataDaylightingManager->AVWLSUdisk(iHour, JB + 1) += state.dataDaylightingManager->WLUMSUdisk(iHour, JB + 1) * TVisIntWinDiskMult; } if (PHRAY > 0.0) { - EDIRSK(iHour, JB + 1, ISky) += WLUMSK(iHour, JB + 1, ISky) * DOMEGA_Ray_3_TVisIntWinMult; - if (ISky == 1) EDIRSU(iHour, JB + 1) += WLUMSU(iHour, JB + 1) * DOMEGA_Ray_3_TVisIntWinMult; + state.dataDaylightingManager->EDIRSK(iHour, JB + 1, ISky) += state.dataDaylightingManager->WLUMSK(iHour, JB + 1, ISky) * DOMEGA_Ray_3_TVisIntWinMult; + if (ISky == 1) state.dataDaylightingManager->EDIRSU(iHour, JB + 1) += state.dataDaylightingManager->WLUMSU(iHour, JB + 1) * DOMEGA_Ray_3_TVisIntWinMult; } if (!SurfWinMovableSlats(IWin)) break; } @@ -4067,13 +4015,13 @@ namespace DaylightingManager { for (JSH = 1; JSH <= MaxSlatAngs + 1; ++JSH) { if (!SurfWinMovableSlats(IWin) && JSH > 2) break; - if (GILSK(iHour, ISky) > tmpDFCalc) { + if (state.dataDaylightingManager->GILSK(iHour, ISky) > tmpDFCalc) { state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylIllFacSky(iHour, JSH, ISky, iRefPoint, loopwin) = - (EDIRSK(iHour, JSH, ISky) + EINTSK(iHour, JSH, ISky)) / GILSK(iHour, ISky); + (state.dataDaylightingManager->EDIRSK(iHour, JSH, ISky) + state.dataDaylightingManager->EINTSK(iHour, JSH, ISky)) / state.dataDaylightingManager->GILSK(iHour, ISky); state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylSourceFacSky(iHour, JSH, ISky, iRefPoint, loopwin) = - AVWLSK(iHour, JSH, ISky) / (NWX * NWY * GILSK(iHour, ISky)); + state.dataDaylightingManager->AVWLSK(iHour, JSH, ISky) / (NWX * NWY * state.dataDaylightingManager->GILSK(iHour, ISky)); state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylBackFacSky(iHour, JSH, ISky, iRefPoint, loopwin) = - EINTSK(iHour, JSH, ISky) * state.dataDaylightingData->ZoneDaylight(ZoneNum).AveVisDiffReflect / (DataGlobalConstants::Pi() * GILSK(iHour, ISky)); + state.dataDaylightingManager->EINTSK(iHour, JSH, ISky) * state.dataDaylightingData->ZoneDaylight(ZoneNum).AveVisDiffReflect / (DataGlobalConstants::Pi() * state.dataDaylightingManager->GILSK(iHour, ISky)); } else { state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylIllFacSky(iHour, JSH, ISky, iRefPoint, loopwin) = 0.0; state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylSourceFacSky(iHour, JSH, ISky, iRefPoint, loopwin) = 0.0; @@ -4081,21 +4029,21 @@ namespace DaylightingManager { } if (ISky == 1) { - if (GILSU(iHour) > tmpDFCalc) { + if (state.dataDaylightingManager->GILSU(iHour) > tmpDFCalc) { state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylIllFacSun(iHour, JSH, iRefPoint, loopwin) = - (EDIRSU(iHour, JSH) + EINTSU(iHour, JSH)) / (GILSU(iHour) + 0.0001); + (state.dataDaylightingManager->EDIRSU(iHour, JSH) + state.dataDaylightingManager->EINTSU(iHour, JSH)) / (state.dataDaylightingManager->GILSU(iHour) + 0.0001); state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylIllFacSunDisk(iHour, JSH, iRefPoint, loopwin) = - (EDIRSUdisk(iHour, JSH) + EINTSUdisk(iHour, JSH)) / (GILSU(iHour) + 0.0001); + (state.dataDaylightingManager->EDIRSUdisk(iHour, JSH) + state.dataDaylightingManager->EINTSUdisk(iHour, JSH)) / (state.dataDaylightingManager->GILSU(iHour) + 0.0001); state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylSourceFacSun(iHour, JSH, iRefPoint, loopwin) = - AVWLSU(iHour, JSH) / (NWX * NWY * (GILSU(iHour) + 0.0001)); + state.dataDaylightingManager->AVWLSU(iHour, JSH) / (NWX * NWY * (state.dataDaylightingManager->GILSU(iHour) + 0.0001)); state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylSourceFacSunDisk(iHour, JSH, iRefPoint, loopwin) = - AVWLSUdisk(iHour, JSH) / (NWX * NWY * (GILSU(iHour) + 0.0001)); + state.dataDaylightingManager->AVWLSUdisk(iHour, JSH) / (NWX * NWY * (state.dataDaylightingManager->GILSU(iHour) + 0.0001)); state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylBackFacSun(iHour, JSH, iRefPoint, loopwin) = - EINTSU(iHour, JSH) * state.dataDaylightingData->ZoneDaylight(ZoneNum).AveVisDiffReflect / (DataGlobalConstants::Pi() * (GILSU(iHour) + 0.0001)); + state.dataDaylightingManager->EINTSU(iHour, JSH) * state.dataDaylightingData->ZoneDaylight(ZoneNum).AveVisDiffReflect / (DataGlobalConstants::Pi() * (state.dataDaylightingManager->GILSU(iHour) + 0.0001)); state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylBackFacSunDisk(iHour, JSH, iRefPoint, loopwin) = - EINTSUdisk(iHour, JSH) * state.dataDaylightingData->ZoneDaylight(ZoneNum).AveVisDiffReflect / (DataGlobalConstants::Pi() * (GILSU(iHour) + 0.0001)); + state.dataDaylightingManager->EINTSUdisk(iHour, JSH) * state.dataDaylightingData->ZoneDaylight(ZoneNum).AveVisDiffReflect / (DataGlobalConstants::Pi() * (state.dataDaylightingManager->GILSU(iHour) + 0.0001)); } else { state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylIllFacSun(iHour, JSH, iRefPoint, loopwin) = 0.0; state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylIllFacSunDisk(iHour, JSH, iRefPoint, loopwin) = 0.0; @@ -4213,13 +4161,13 @@ namespace DaylightingManager { for (JSH = 1; JSH <= MaxSlatAngs + 1; ++JSH) { if (!SurfWinMovableSlats(IWin) && JSH > 2) break; - if (GILSK(iHour, ISky) > tmpDFCalc) { + if (state.dataDaylightingManager->GILSK(iHour, ISky) > tmpDFCalc) { state.dataDaylightingData->IllumMapCalc(MapNum).DaylIllFacSky(iHour, JSH, ISky, iMapPoint, loopwin) = - (EDIRSK(iHour, JSH, ISky) + EINTSK(iHour, JSH, ISky)) / GILSK(iHour, ISky); + (state.dataDaylightingManager->EDIRSK(iHour, JSH, ISky) + state.dataDaylightingManager->EINTSK(iHour, JSH, ISky)) / state.dataDaylightingManager->GILSK(iHour, ISky); state.dataDaylightingData->IllumMapCalc(MapNum).DaylSourceFacSky(iHour, JSH, ISky, iMapPoint, loopwin) = - AVWLSK(iHour, JSH, ISky) / (NWX * NWY * GILSK(iHour, ISky)); + state.dataDaylightingManager->AVWLSK(iHour, JSH, ISky) / (NWX * NWY * state.dataDaylightingManager->GILSK(iHour, ISky)); state.dataDaylightingData->IllumMapCalc(MapNum).DaylBackFacSky(iHour, JSH, ISky, iMapPoint, loopwin) = - EINTSK(iHour, JSH, ISky) * state.dataDaylightingData->ZoneDaylight(ZoneNum).AveVisDiffReflect / (DataGlobalConstants::Pi() * GILSK(iHour, ISky)); + state.dataDaylightingManager->EINTSK(iHour, JSH, ISky) * state.dataDaylightingData->ZoneDaylight(ZoneNum).AveVisDiffReflect / (DataGlobalConstants::Pi() * state.dataDaylightingManager->GILSK(iHour, ISky)); } else { state.dataDaylightingData->IllumMapCalc(MapNum).DaylIllFacSky(iHour, JSH, ISky, iMapPoint, loopwin) = 0.0; state.dataDaylightingData->IllumMapCalc(MapNum).DaylSourceFacSky(iHour, JSH, ISky, iMapPoint, loopwin) = 0.0; @@ -4227,21 +4175,21 @@ namespace DaylightingManager { } if (ISky == 1) { - if (GILSU(iHour) > tmpDFCalc) { + if (state.dataDaylightingManager->GILSU(iHour) > tmpDFCalc) { state.dataDaylightingData->IllumMapCalc(MapNum).DaylIllFacSun(iHour, JSH, iMapPoint, loopwin) = - (EDIRSU(iHour, JSH) + EINTSU(iHour, JSH)) / (GILSU(iHour) + 0.0001); + (state.dataDaylightingManager->EDIRSU(iHour, JSH) + state.dataDaylightingManager->EINTSU(iHour, JSH)) / (state.dataDaylightingManager->GILSU(iHour) + 0.0001); state.dataDaylightingData->IllumMapCalc(MapNum).DaylIllFacSunDisk(iHour, JSH, iMapPoint, loopwin) = - (EDIRSUdisk(iHour, JSH) + EINTSUdisk(iHour, JSH)) / (GILSU(iHour) + 0.0001); + (state.dataDaylightingManager->EDIRSUdisk(iHour, JSH) + state.dataDaylightingManager->EINTSUdisk(iHour, JSH)) / (state.dataDaylightingManager->GILSU(iHour) + 0.0001); state.dataDaylightingData->IllumMapCalc(MapNum).DaylSourceFacSun(iHour, JSH, iMapPoint, loopwin) = - AVWLSU(iHour, JSH) / (NWX * NWY * (GILSU(iHour) + 0.0001)); + state.dataDaylightingManager->AVWLSU(iHour, JSH) / (NWX * NWY * (state.dataDaylightingManager->GILSU(iHour) + 0.0001)); state.dataDaylightingData->IllumMapCalc(MapNum).DaylSourceFacSunDisk(iHour, JSH, iMapPoint, loopwin) = - AVWLSUdisk(iHour, JSH) / (NWX * NWY * (GILSU(iHour) + 0.0001)); + state.dataDaylightingManager->AVWLSUdisk(iHour, JSH) / (NWX * NWY * (state.dataDaylightingManager->GILSU(iHour) + 0.0001)); state.dataDaylightingData->IllumMapCalc(MapNum).DaylBackFacSun(iHour, JSH, iMapPoint, loopwin) = - EINTSU(iHour, JSH) * state.dataDaylightingData->ZoneDaylight(ZoneNum).AveVisDiffReflect / (DataGlobalConstants::Pi() * (GILSU(iHour) + 0.0001)); + state.dataDaylightingManager->EINTSU(iHour, JSH) * state.dataDaylightingData->ZoneDaylight(ZoneNum).AveVisDiffReflect / (DataGlobalConstants::Pi() * (state.dataDaylightingManager->GILSU(iHour) + 0.0001)); state.dataDaylightingData->IllumMapCalc(MapNum).DaylBackFacSunDisk(iHour, JSH, iMapPoint, loopwin) = - EINTSUdisk(iHour, JSH) * state.dataDaylightingData->ZoneDaylight(ZoneNum).AveVisDiffReflect / (DataGlobalConstants::Pi() * (GILSU(iHour) + 0.0001)); + state.dataDaylightingManager->EINTSUdisk(iHour, JSH) * state.dataDaylightingData->ZoneDaylight(ZoneNum).AveVisDiffReflect / (DataGlobalConstants::Pi() * (state.dataDaylightingManager->GILSU(iHour) + 0.0001)); } else { state.dataDaylightingData->IllumMapCalc(MapNum).DaylIllFacSun(iHour, JSH, iMapPoint, loopwin) = 0.0; state.dataDaylightingData->IllumMapCalc(MapNum).DaylIllFacSunDisk(iHour, JSH, iMapPoint, loopwin) = 0.0; @@ -6560,7 +6508,7 @@ namespace DaylightingManager { // is up in the present time step but GILSK(ISky,HourOfDay) and GILSK(ISky,NextHour) are both zero. for (ISky = 1; ISky <= 4; ++ISky) { // HorIllSky(ISky) = WeightNow * GILSK(ISky,HourOfDay) + WeightNextHour * GILSK(ISky,NextHour) + 0.001 - HorIllSky(ISky) = state.dataGlobal->WeightNow * GILSK(state.dataGlobal->HourOfDay, ISky) + state.dataGlobal->WeightPreviousHour * GILSK(state.dataGlobal->PreviousHour, ISky) + 0.001; + HorIllSky(ISky) = state.dataGlobal->WeightNow * state.dataDaylightingManager->GILSK(state.dataGlobal->HourOfDay, ISky) + state.dataGlobal->WeightPreviousHour * state.dataDaylightingManager->GILSK(state.dataGlobal->PreviousHour, ISky) + 0.001; } // HISKF is current time step horizontal illuminance from sky, calculated in DayltgLuminousEfficacy, @@ -7231,17 +7179,17 @@ namespace DaylightingManager { for (PipeNum = 1; PipeNum <= state.dataDaylightingDevicesData->NumOfTDDPipes; ++PipeNum) { state.dataDaylightingDevicesData->TDDPipe(PipeNum).TransVisBeam = - state.dataGlobal->WeightNow * TDDTransVisBeam(state.dataGlobal->HourOfDay, PipeNum) + state.dataGlobal->WeightPreviousHour * TDDTransVisBeam(state.dataGlobal->PreviousHour, PipeNum); + state.dataGlobal->WeightNow * state.dataDaylightingManager->TDDTransVisBeam(state.dataGlobal->HourOfDay, PipeNum) + state.dataGlobal->WeightPreviousHour * state.dataDaylightingManager->TDDTransVisBeam(state.dataGlobal->PreviousHour, PipeNum); for (ISky = 1; ISky <= 4; ++ISky) { - if (TDDFluxInc(state.dataGlobal->HourOfDay, ISky, PipeNum) > 0.0) { - TDDTransVisDiffNow = TDDFluxTrans(state.dataGlobal->HourOfDay, ISky, PipeNum) / TDDFluxInc(state.dataGlobal->HourOfDay, ISky, PipeNum); + if (state.dataDaylightingManager->TDDFluxInc(state.dataGlobal->HourOfDay, ISky, PipeNum) > 0.0) { + TDDTransVisDiffNow = state.dataDaylightingManager->TDDFluxTrans(state.dataGlobal->HourOfDay, ISky, PipeNum) / state.dataDaylightingManager->TDDFluxInc(state.dataGlobal->HourOfDay, ISky, PipeNum); } else { TDDTransVisDiffNow = 0.0; } - if (TDDFluxInc(state.dataGlobal->PreviousHour, ISky, PipeNum) > 0.0) { - TDDTransVisDiffPrev = TDDFluxTrans(state.dataGlobal->PreviousHour, ISky, PipeNum) / TDDFluxInc(state.dataGlobal->PreviousHour, ISky, PipeNum); + if (state.dataDaylightingManager->TDDFluxInc(state.dataGlobal->PreviousHour, ISky, PipeNum) > 0.0) { + TDDTransVisDiffPrev = state.dataDaylightingManager->TDDFluxTrans(state.dataGlobal->PreviousHour, ISky, PipeNum) / state.dataDaylightingManager->TDDFluxInc(state.dataGlobal->PreviousHour, ISky, PipeNum); } else { TDDTransVisDiffPrev = 0.0; } @@ -7718,9 +7666,9 @@ namespace DaylightingManager { // FLOW: // Initialize window luminance and fluxes for split-flux calculation - WLUMSK(IHR, _, _) = 0.0; - WLUMSU(IHR, _) = 0.0; - WLUMSUdisk(IHR, _) = 0.0; + state.dataDaylightingManager->WLUMSK(IHR, _, _) = 0.0; + state.dataDaylightingManager->WLUMSU(IHR, _) = 0.0; + state.dataDaylightingManager->WLUMSUdisk(IHR, _) = 0.0; FLFWSK = 0.0; FLFWSU = 0.0; FLFWSUdisk = 0.0; @@ -7847,7 +7795,7 @@ namespace DaylightingManager { for (ISky = 1; ISky <= 4; ++ISky) { // Below, luminance of ground in cd/m2 is illuminance on ground in lumens/m2 // times ground reflectance, divided by pi, times obstruction multiplier. - ZSK(ISky) = (GILSK(IHR, ISky) * GndReflectanceForDayltg / DataGlobalConstants::Pi()) * COSB * DA * ObTransM(IPH, ITH) * SkyObstructionMult(IPH, ITH); + ZSK(ISky) = (state.dataDaylightingManager->GILSK(IHR, ISky) * GndReflectanceForDayltg / DataGlobalConstants::Pi()) * COSB * DA * ObTransM(IPH, ITH) * SkyObstructionMult(IPH, ITH); } // Determine if sun illuminates the point that ray hits the ground. If the solar reflection // calculation has been requested (CalcSolRefl = .TRUE.) shading by obstructions, including @@ -7864,7 +7812,7 @@ namespace DaylightingManager { } if (hitObs) SunObstructionMult = 0.0; } - ZSU = (GILSU(IHR) * GndReflectanceForDayltg / DataGlobalConstants::Pi()) * COSB * DA * ObTransM(IPH, ITH) * SunObstructionMult; + ZSU = (state.dataDaylightingManager->GILSU(IHR) * GndReflectanceForDayltg / DataGlobalConstants::Pi()) * COSB * DA * ObTransM(IPH, ITH) * SunObstructionMult; } // BEAM SOLAR AND SKY SOLAR REFLECTED FROM NEAREST OBSTRUCTION @@ -7920,7 +7868,7 @@ namespace DaylightingManager { } dReflObsSky = SkyReflVisLum * COSB * DA; for (ISky = 1; ISky <= 4; ++ISky) { - ZSK(ISky) += GILSK(IHR, ISky) * dReflObsSky; + ZSK(ISky) += state.dataDaylightingManager->GILSK(IHR, ISky) * dReflObsSky; } } } // End of check if exterior solar reflection calculation is active @@ -7937,22 +7885,22 @@ namespace DaylightingManager { // Make all transmitted light diffuse for a TDD with a bare diffuser for (ISky = 1; ISky <= 4; ++ISky) { - WLUMSK(IHR, 1, ISky) += ZSK(ISky) * TVISBR / DataGlobalConstants::Pi(); + state.dataDaylightingManager->WLUMSK(IHR, 1, ISky) += ZSK(ISky) * TVISBR / DataGlobalConstants::Pi(); FLFWSK(1, ISky) += ZSK(ISky) * TVISBR * (1.0 - SurfWinFractionUpgoing(IWin)); FLCWSK(1, ISky) += ZSK(ISky) * TVISBR * SurfWinFractionUpgoing(IWin); // For later calculation of diffuse visible transmittance - TDDFluxInc(IHR, ISky, PipeNum) += ZSK(ISky); - TDDFluxTrans(IHR, ISky, PipeNum) += ZSK(ISky) * TVISBR; + state.dataDaylightingManager->TDDFluxInc(IHR, ISky, PipeNum) += ZSK(ISky); + state.dataDaylightingManager->TDDFluxTrans(IHR, ISky, PipeNum) += ZSK(ISky) * TVISBR; if (ISky == 1) { - WLUMSU(IHR, 1) += ZSU * TVISBR / DataGlobalConstants::Pi(); + state.dataDaylightingManager->WLUMSU(IHR, 1) += ZSU * TVISBR / DataGlobalConstants::Pi(); FLFWSU(1) += ZSU * TVISBR * (1.0 - SurfWinFractionUpgoing(IWin)); FLCWSU(1) += ZSU * TVISBR * SurfWinFractionUpgoing(IWin); // For later calculation of diffuse visible transmittance - TDDFluxInc(IHR, ISky, PipeNum) += ZSU; - TDDFluxTrans(IHR, ISky, PipeNum) += ZSU * TVISBR; + state.dataDaylightingManager->TDDFluxInc(IHR, ISky, PipeNum) += ZSU; + state.dataDaylightingManager->TDDFluxTrans(IHR, ISky, PipeNum) += ZSU * TVISBR; } } @@ -8150,13 +8098,13 @@ namespace DaylightingManager { // EXIT after first pass if not movable slats or exterior window screen if (!SurfWinMovableSlats(IWin) && JB > 1) break; - WLUMSK(IHR, JB + 1, ISky) += ZSK(ISky) * TransMult(JB) / DataGlobalConstants::Pi(); + state.dataDaylightingManager->WLUMSK(IHR, JB + 1, ISky) += ZSK(ISky) * TransMult(JB) / DataGlobalConstants::Pi(); FLFWSK(JB + 1, ISky) += ZSK(ISky) * TransMult(JB) * (1.0 - SurfWinFractionUpgoing(IWin)); if (PH > 0.0 && (BlindOn || ScreenOn)) FLFWSK(JB + 1, ISky) += ZSK(ISky) * TransBmBmMult(JB); FLCWSK(JB + 1, ISky) += ZSK(ISky) * TransMult(JB) * SurfWinFractionUpgoing(IWin); if (PH <= 0.0 && (BlindOn || ScreenOn)) FLCWSK(JB + 1, ISky) += ZSK(ISky) * TransBmBmMult(JB); if (ISky == 1) { - WLUMSU(IHR, JB + 1) += ZSU * TransMult(JB) / DataGlobalConstants::Pi(); + state.dataDaylightingManager->WLUMSU(IHR, JB + 1) += ZSU * TransMult(JB) / DataGlobalConstants::Pi(); FLFWSU(JB + 1) += ZSU * TransMult(JB) * (1.0 - SurfWinFractionUpgoing(IWin)); if (PH > 0.0 && (BlindOn || ScreenOn)) FLFWSU(JB + 1) += ZSU * TransBmBmMult(JB); FLCWSU(JB + 1) += ZSU * TransMult(JB) * SurfWinFractionUpgoing(IWin); @@ -8178,13 +8126,13 @@ namespace DaylightingManager { for (ISky = 1; ISky <= 4; ++ISky) { // This is only an estimate because the anisotropic sky view of the shelf is not yet taken into account. // AnisoSkyMult would be great to use but it is not available until the heat balance starts up. - ZSK(ISky) = GILSK(IHR, ISky) * 1.0 * state.dataDaylightingDevicesData->Shelf(ShelfNum).OutReflectVis * state.dataDaylightingDevicesData->Shelf(ShelfNum).ViewFactor; + ZSK(ISky) = state.dataDaylightingManager->GILSK(IHR, ISky) * 1.0 * state.dataDaylightingDevicesData->Shelf(ShelfNum).OutReflectVis * state.dataDaylightingDevicesData->Shelf(ShelfNum).ViewFactor; // SurfaceWindow(IWin)%FractionUpgoing is already set to 1.0 earlier FLCWSK(1, ISky) += ZSK(ISky) * TVISBR * SurfWinFractionUpgoing(IWin); if (ISky == 1) { - ZSU = GILSU(IHR) * SunlitFracHR(IHR, OutShelfSurf) * state.dataDaylightingDevicesData->Shelf(ShelfNum).OutReflectVis * state.dataDaylightingDevicesData->Shelf(ShelfNum).ViewFactor; + ZSU = state.dataDaylightingManager->GILSU(IHR) * SunlitFracHR(IHR, OutShelfSurf) * state.dataDaylightingDevicesData->Shelf(ShelfNum).OutReflectVis * state.dataDaylightingDevicesData->Shelf(ShelfNum).ViewFactor; FLCWSU(1) += ZSU * TVISBR * SurfWinFractionUpgoing(IWin); } } // ISKY @@ -8199,7 +8147,7 @@ namespace DaylightingManager { if (!SurfWinMovableSlats(IWin) && JSH > 2) break; // Full area of window is used in following since effect of dividers on reducing // effective window transmittance has already been accounted for in calc of FLFWSK and FLCWSK. - EINTSK(IHR, JSH, ISky) = + state.dataDaylightingManager->EINTSK(IHR, JSH, ISky) = (FLFWSK(JSH, ISky) * SurfWinRhoFloorWall(IWin) + FLCWSK(JSH, ISky) * SurfWinRhoCeilingWall(IWin)) * (Surface(IWin).Area / SurfWinGlazedFrac(IWin)) / (ZoneInsideSurfArea * (1.0 - state.dataDaylightingData->ZoneDaylight(ZoneNum).AveVisDiffReflect)); } // JSH @@ -8229,11 +8177,11 @@ namespace DaylightingManager { if (SurfWinOriginalClass(IWin) == SurfaceClass::TDD_Dome) { // Unshaded visible transmittance of TDD for collimated beam from the sun TVISBSun = TransTDD(state, PipeNum, COSBSun, DataDaylightingDevices::iRadType::VisibleBeam) * SurfWinGlazedFrac(IWin); - TDDTransVisBeam(IHR, PipeNum) = TVISBSun; + state.dataDaylightingManager->TDDTransVisBeam(IHR, PipeNum) = TVISBSun; FLFWSUdisk(1) = 0.0; // Diffuse light only - WLUMSU(IHR, 1) += ZSU1 * TVISBSun / DataGlobalConstants::Pi(); + state.dataDaylightingManager->WLUMSU(IHR, 1) += ZSU1 * TVISBSun / DataGlobalConstants::Pi(); FLFWSU(1) += ZSU1 * TVISBSun * (1.0 - SurfWinFractionUpgoing(IWin)); FLCWSU(1) += ZSU1 * TVISBSun * SurfWinFractionUpgoing(IWin); @@ -8339,8 +8287,8 @@ namespace DaylightingManager { // SurfaceWindow(IWin)%FractionUpgoing is already set to 1.0 earlier } - WLUMSU(IHR, JB + 1) += ZSU1 * TransMult(JB) / DataGlobalConstants::Pi(); - WLUMSUdisk(IHR, JB + 1) = ZSU1 * TransBmBmMult(JB) / DataGlobalConstants::Pi(); + state.dataDaylightingManager->WLUMSU(IHR, JB + 1) += ZSU1 * TransMult(JB) / DataGlobalConstants::Pi(); + state.dataDaylightingManager->WLUMSUdisk(IHR, JB + 1) = ZSU1 * TransBmBmMult(JB) / DataGlobalConstants::Pi(); FLFWSU(JB + 1) += ZSU1 * TransMult(JB) * (1.0 - SurfWinFractionUpgoing(IWin)); FLFWSUdisk(JB + 1) = ZSU1 * TransBmBmMult(JB); FLCWSU(JB + 1) += ZSU1 * TransMult(JB) * SurfWinFractionUpgoing(IWin); @@ -8417,7 +8365,7 @@ namespace DaylightingManager { } // End of check of interior/exterior/between-glass blind } // ShadeOn/BlindOn - WLUMSU(IHR, JB + 1) += ZSU1refl * TransMult(JB) / DataGlobalConstants::Pi(); + state.dataDaylightingManager->WLUMSU(IHR, JB + 1) += ZSU1refl * TransMult(JB) / DataGlobalConstants::Pi(); FLFWSU(JB + 1) += ZSU1refl * TransMult(JB) * (1.0 - SurfWinFractionUpgoing(IWin)); FLCWSU(JB + 1) += ZSU1refl * TransMult(JB) * SurfWinFractionUpgoing(IWin); } // End of loop over slat angles @@ -8434,11 +8382,11 @@ namespace DaylightingManager { // effective window transmittance already accounted for in calc of FLFWSU and FLCWSU // CR 7869 added effect of intervening interior windows on transmittance and // added inside surface area of adjacent zone - EINTSU(IHR, JSH) = (FLFWSU(JSH) * SurfWinRhoFloorWall(IWin) + FLCWSU(JSH) * SurfWinRhoCeilingWall(IWin)) * + state.dataDaylightingManager->EINTSU(IHR, JSH) = (FLFWSU(JSH) * SurfWinRhoFloorWall(IWin) + FLCWSU(JSH) * SurfWinRhoCeilingWall(IWin)) * (Surface(IWin).Area / SurfWinGlazedFrac(IWin)) / (ZoneInsideSurfArea * (1.0 - state.dataDaylightingData->ZoneDaylight(ZoneNum).AveVisDiffReflect)); - EINTSUdisk(IHR, JSH) = FLFWSUdisk(JSH) * SurfWinRhoFloorWall(IWin) * (Surface(IWin).Area / SurfWinGlazedFrac(IWin)) / + state.dataDaylightingManager->EINTSUdisk(IHR, JSH) = FLFWSUdisk(JSH) * SurfWinRhoFloorWall(IWin) * (Surface(IWin).Area / SurfWinGlazedFrac(IWin)) / (ZoneInsideSurfArea * (1.0 - state.dataDaylightingData->ZoneDaylight(ZoneNum).AveVisDiffReflect)); } } @@ -8519,17 +8467,17 @@ namespace DaylightingManager { // Ray from ground element // BeamObstrMultiplier = ComplexWind(IWin)%DaylghtGeom(CurCplxFenState)%GndObstrMultiplier(WinEl, iIncElem) for (iSky = 1; iSky <= 4; ++iSky) { - ElementLuminanceSky(iSky, iIncElem) = GILSK(IHR, iSky) * GndReflectanceForDayltg / DataGlobalConstants::Pi() * LambdaInc; + ElementLuminanceSky(iSky, iIncElem) = state.dataDaylightingManager->GILSK(IHR, iSky) * GndReflectanceForDayltg / DataGlobalConstants::Pi() * LambdaInc; } - ElementLuminanceSun(iIncElem) = GILSU(IHR) * GndReflectanceForDayltg / DataGlobalConstants::Pi() * LambdaInc; + ElementLuminanceSun(iIncElem) = state.dataDaylightingManager->GILSU(IHR) * GndReflectanceForDayltg / DataGlobalConstants::Pi() * LambdaInc; } else { // Ray from the element which is half sky and half ground for (iSky = 1; iSky <= 4; ++iSky) { // in this case half of the pach is coming from the sky and half from the ground ElementLuminanceSky(iSky, iIncElem) = 0.5 * DayltgSkyLuminance(state, iSky, Azimuth, Altitude) * LambdaInc; - ElementLuminanceSky(iSky, iIncElem) += 0.5 * GILSK(IHR, iSky) * GndReflectanceForDayltg / DataGlobalConstants::Pi() * LambdaInc; + ElementLuminanceSky(iSky, iIncElem) += 0.5 * state.dataDaylightingManager->GILSK(IHR, iSky) * GndReflectanceForDayltg / DataGlobalConstants::Pi() * LambdaInc; } - ElementLuminanceSun(iIncElem) = 0.5 * GILSU(IHR) * GndReflectanceForDayltg / DataGlobalConstants::Pi() * LambdaInc; + ElementLuminanceSun(iIncElem) = 0.5 * state.dataDaylightingManager->GILSU(IHR) * GndReflectanceForDayltg / DataGlobalConstants::Pi() * LambdaInc; } // Sun beam calculations if ((SolBmIndex == iIncElem) && (SunlitFracHR(IHR, IWin) > 0.0)) { @@ -8751,12 +8699,12 @@ namespace DaylightingManager { ZoneInsideSurfArea = state.dataDaylightingData->ZoneDaylight(ZoneNum).TotInsSurfArea; for (iSky = 1; iSky <= 4; ++iSky) { - EINTSK(IHR, 1, iSky) = FFSKTot(iSky) * (Surface(IWin).Area / SurfWinGlazedFrac(IWin)) / + state.dataDaylightingManager->EINTSK(IHR, 1, iSky) = FFSKTot(iSky) * (Surface(IWin).Area / SurfWinGlazedFrac(IWin)) / (ZoneInsideSurfArea * (1.0 - state.dataDaylightingData->ZoneDaylight(ZoneNum).AveVisDiffReflect)); } - EINTSU(IHR, 1) = + state.dataDaylightingManager->EINTSU(IHR, 1) = FFSUTot * (Surface(IWin).Area / SurfWinGlazedFrac(IWin)) / (ZoneInsideSurfArea * (1.0 - state.dataDaylightingData->ZoneDaylight(ZoneNum).AveVisDiffReflect)); - EINTSUdisk(IHR, 1) = FFSUdiskTot * (Surface(IWin).Area / SurfWinGlazedFrac(IWin)) / + state.dataDaylightingManager->EINTSUdisk(IHR, 1) = FFSUdiskTot * (Surface(IWin).Area / SurfWinGlazedFrac(IWin)) / (ZoneInsideSurfArea * (1.0 - state.dataDaylightingData->ZoneDaylight(ZoneNum).AveVisDiffReflect)); if (allocated(FLSK)) FLSK.deallocate(); @@ -8883,12 +8831,12 @@ namespace DaylightingManager { // Store solution in global variables for (iSky = 1; iSky <= 4; ++iSky) { - AVWLSK(IHR, 1, iSky) += WinLumSK(iSky); - EDIRSK(IHR, 1, iSky) += EDirSky(iSky); + state.dataDaylightingManager->AVWLSK(IHR, 1, iSky) += WinLumSK(iSky); + state.dataDaylightingManager->EDIRSK(IHR, 1, iSky) += EDirSky(iSky); } - AVWLSU(IHR, 1) += WinLumSU; - EDIRSU(IHR, 1) += EDirSun; + state.dataDaylightingManager->AVWLSU(IHR, 1) += WinLumSU; + state.dataDaylightingManager->EDIRSU(IHR, 1) += EDirSun; // AVWLSUdisk(1,IHR) = AVWLSUdisk(1,IHR) + WinLumSUdisk } @@ -9016,8 +8964,8 @@ namespace DaylightingManager { } } - AVWLSUdisk(iHour, 1) = WinLumSunDisk; - EDIRSUdisk(iHour, 1) = ELumSunDisk; + state.dataDaylightingManager->AVWLSUdisk(iHour, 1) = WinLumSunDisk; + state.dataDaylightingManager->EDIRSUdisk(iHour, 1) = ELumSunDisk; } Real64 DayltgSkyLuminance(EnergyPlusData &state, @@ -9768,7 +9716,7 @@ namespace DaylightingManager { // Adding 0.001 in the following prevents zero HorIllSky in early morning or late evening when sun // is up in the present time step but GILSK(ISky,HourOfDay) and GILSK(ISky,NextHour) are both zero. for (ISky = 1; ISky <= 4; ++ISky) { - HorIllSky(ISky) = state.dataGlobal->WeightNow * GILSK(state.dataGlobal->HourOfDay, ISky) + state.dataGlobal->WeightPreviousHour * GILSK(state.dataGlobal->PreviousHour, ISky) + 0.001; + HorIllSky(ISky) = state.dataGlobal->WeightNow * state.dataDaylightingManager->GILSK(state.dataGlobal->HourOfDay, ISky) + state.dataGlobal->WeightPreviousHour * state.dataDaylightingManager->GILSK(state.dataGlobal->PreviousHour, ISky) + 0.001; } // HISKF is current time step horizontal illuminance from sky, calculated in DayltgLuminousEfficacy, diff --git a/src/EnergyPlus/DaylightingManager.hh b/src/EnergyPlus/DaylightingManager.hh index 12bd13aab02..1454f6c1398 100644 --- a/src/EnergyPlus/DaylightingManager.hh +++ b/src/EnergyPlus/DaylightingManager.hh @@ -59,6 +59,7 @@ // EnergyPlus Headers #include #include +#include #include namespace EnergyPlus { @@ -85,43 +86,6 @@ namespace DaylightingManager { // experience is gained. constexpr int octreeCrossover(100); // Octree surface count crossover - // In the following I,J,K arrays: - // I = 1 for clear sky, 2 for clear turbid, 3 for intermediate, 4 for overcast; - // J = 1 for bare window, 2 - 12 for shaded; - // K = sun position index. - extern Array3D EINTSK; // Sky-related portion of internally reflected illuminance - extern Array2D EINTSU; // Sun-related portion of internally reflected illuminance, - // excluding entering beam - extern Array2D EINTSUdisk; // Sun-related portion of internally reflected illuminance - // due to entering beam - extern Array3D WLUMSK; // Sky-related window luminance - extern Array2D WLUMSU; // Sun-related window luminance, excluding view of solar disk - extern Array2D WLUMSUdisk; // Sun-related window luminance, due to view of solar disk - - extern Array2D GILSK; // Horizontal illuminance from sky, by sky type, for each hour of the day - extern Array1D GILSU; // Horizontal illuminance from sun for each hour of the day - - extern Array3D EDIRSK; // Sky-related component of direct illuminance - extern Array2D EDIRSU; // Sun-related component of direct illuminance (excluding beam solar at ref pt) - extern Array2D EDIRSUdisk; // Sun-related component of direct illuminance due to beam solar at ref pt - extern Array3D AVWLSK; // Sky-related average window luminance - extern Array2D AVWLSU; // Sun-related average window luminance, excluding view of solar disk - extern Array2D AVWLSUdisk; // Sun-related average window luminance due to view of solar disk - - // Allocatable daylight factor arrays -- are in the ZoneDaylight Structure - - extern Array2D TDDTransVisBeam; - extern Array3D TDDFluxInc; - extern Array3D TDDFluxTrans; - - extern Array2D_int MapErrIndex; - extern Array2D_int RefErrIndex; - - extern Array1D_bool CheckTDDZone; - - // Functions - void clear_state(); - void DayltgAveInteriorReflectance(EnergyPlusData &state, int &ZoneNum); // Zone number void CalcDayltgCoefficients(EnergyPlusData &state); @@ -538,6 +502,38 @@ struct DaylightingManagerData : BaseGlobalStruct { Array1D CPHSUNHR = Array1D(24, 0.0); // Hourly values of the cosine of PHSUN Array1D THSUNHR = Array1D(24, 0.0); // Hourly values of THSUN + // In the following I,J,K arrays: + // I = 1 for clear sky, 2 for clear turbid, 3 for intermediate, 4 for overcast; + // J = 1 for bare window, 2 - 12 for shaded; + // K = sun position index. + Array3D EINTSK = Array3D(24, DataSurfaces::MaxSlatAngs + 1, 4, 0.0); // Sky-related portion of internally reflected illuminance + Array2D EINTSU = Array2D(24, DataSurfaces::MaxSlatAngs + 1, 0.0); // Sun-related portion of internally reflected illuminance, + // excluding entering beam + Array2D EINTSUdisk = Array2D(24, DataSurfaces::MaxSlatAngs + 1, 0.0); // Sun-related portion of internally reflected illuminance + // due to entering beam + Array3D WLUMSK = Array3D(24, DataSurfaces::MaxSlatAngs + 1, 4, 0.0); // Sky-related window luminance + Array2D WLUMSU = Array2D(24, DataSurfaces::MaxSlatAngs + 1, 0.0); // Sun-related window luminance, excluding view of solar disk + Array2D WLUMSUdisk = Array2D(24, DataSurfaces::MaxSlatAngs + 1, 0.0); // Sun-related window luminance, due to view of solar disk + + Array2D GILSK = Array2D(24, 4, 0.0); // Horizontal illuminance from sky, by sky type, for each hour of the day + Array1D GILSU = Array1D(24, 0.0); // Horizontal illuminance from sun for each hour of the day + + Array3D EDIRSK = Array3D(24, DataSurfaces::MaxSlatAngs + 1, 4); // Sky-related component of direct illuminance + Array2D EDIRSU = Array2D(24, DataSurfaces::MaxSlatAngs + 1); // Sun-related component of direct illuminance (excluding beam solar at ref pt) + Array2D EDIRSUdisk = Array2D(24, DataSurfaces::MaxSlatAngs + 1); // Sun-related component of direct illuminance due to beam solar at ref pt + Array3D AVWLSK = Array3D(24, DataSurfaces::MaxSlatAngs + 1, 4); // Sky-related average window luminance + Array2D AVWLSU = Array2D(24, DataSurfaces::MaxSlatAngs + 1); // Sun-related average window luminance, excluding view of solar disk + Array2D AVWLSUdisk = Array2D(24, DataSurfaces::MaxSlatAngs + 1); // Sun-related average window luminance due to view of solar disk + + // Allocatable daylight factor arrays -- are in the ZoneDaylight Structure + + Array2D TDDTransVisBeam; + Array3D TDDFluxInc; + Array3D TDDFluxTrans; + + Array2D_int MapErrIndex; + Array2D_int RefErrIndex; + void clear_state() override { this->CalcDayltghCoefficients_firstTime = true; @@ -565,6 +561,25 @@ struct DaylightingManagerData : BaseGlobalStruct { this->SPHSUNHR = Array1D(24, 0.0); this->CPHSUNHR = Array1D(24, 0.0); this->THSUNHR = Array1D(24, 0.0); + this->EINTSK = Array3D(24, DataSurfaces::MaxSlatAngs + 1, 4, 0.0); + this->EINTSU = Array2D(24, DataSurfaces::MaxSlatAngs + 1, 0.0); + this->EINTSUdisk = Array2D(24, DataSurfaces::MaxSlatAngs + 1, 0.0); + this->WLUMSK = Array3D(24, DataSurfaces::MaxSlatAngs + 1, 4, 0.0); + this->WLUMSU = Array2D(24, DataSurfaces::MaxSlatAngs + 1, 0.0); + this->WLUMSUdisk = Array2D(24, DataSurfaces::MaxSlatAngs + 1, 0.0); + this->GILSK = Array2D(24, 4, 0.0); + this->GILSU = Array1D(24, 0.0); + this->EDIRSK = Array3D(24, DataSurfaces::MaxSlatAngs + 1, 4); + this->EDIRSU = Array2D(24, DataSurfaces::MaxSlatAngs + 1); + this->EDIRSUdisk = Array2D(24, DataSurfaces::MaxSlatAngs + 1); + this->AVWLSK = Array3D(24, DataSurfaces::MaxSlatAngs + 1, 4); + this->AVWLSU = Array2D(24, DataSurfaces::MaxSlatAngs + 1); + this->AVWLSUdisk = Array2D(24, DataSurfaces::MaxSlatAngs + 1); + this->TDDTransVisBeam.deallocate(); + this->TDDFluxInc.deallocate(); + this->TDDFluxTrans.deallocate(); + this->MapErrIndex.deallocate(); + this->RefErrIndex.deallocate(); } }; diff --git a/tst/EnergyPlus/unit/DaylightingManager.unit.cc b/tst/EnergyPlus/unit/DaylightingManager.unit.cc index f7a92584395..4371d2dd68d 100644 --- a/tst/EnergyPlus/unit/DaylightingManager.unit.cc +++ b/tst/EnergyPlus/unit/DaylightingManager.unit.cc @@ -1343,7 +1343,7 @@ TEST_F(EnergyPlusFixture, DaylightingManager_DayltgInteriorIllum_Test) InternalHeatGains::GetInternalHeatGainsInputFlag = false; DaylightingManager::GetInputDayliteRefPt(*state, foundErrors); DaylightingManager::GetDaylightingParametersInput(*state); - DaylightingManager::GILSK = 100.0; + state->dataDaylightingManager->GILSK = 100.0; state->dataGlobal->WeightNow = 1.0; DataEnvironment::HISUNF = 100.0; DataEnvironment::HISKF = 100.0; From 4e14332c90d6b1e1f5d7f2ca46288b0f90b69fe3 Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Tue, 24 Nov 2020 21:36:06 -0700 Subject: [PATCH 09/10] minor cleanups --- src/EnergyPlus/DaylightingManager.cc | 132 +++++++++++++-------------- src/EnergyPlus/DaylightingManager.hh | 18 ++-- 2 files changed, 69 insertions(+), 81 deletions(-) diff --git a/src/EnergyPlus/DaylightingManager.cc b/src/EnergyPlus/DaylightingManager.cc index 69bd69cdf26..c4c077f0f45 100644 --- a/src/EnergyPlus/DaylightingManager.cc +++ b/src/EnergyPlus/DaylightingManager.cc @@ -94,9 +94,7 @@ #include #include -namespace EnergyPlus { - -namespace DaylightingManager { +namespace EnergyPlus::DaylightingManager { // MODULE INFORMATION // AUTHOR Fred Winkelmann @@ -147,10 +145,6 @@ namespace DaylightingManager { // Using/Aliasing using namespace DataHeatBalance; using namespace DataSurfaces; - using namespace DataEnvironment; - using DataBSDFWindow::BSDFDaylghtPosition; - - using namespace ScheduleManager; void DayltgAveInteriorReflectance(EnergyPlusData &state, int &ZoneNum) // Zone number { @@ -454,9 +448,9 @@ namespace DaylightingManager { //-----------------------------------------! if (!DetailedSolarTimestepIntegration && !state.dataGlobal->KickOffSizing && !state.dataGlobal->KickOffSimulation) { if (state.dataGlobal->WarmupFlag) { - DisplayString(state, "Calculating Detailed Daylighting Factors, Start Date=" + CurMnDy); + DisplayString(state, "Calculating Detailed Daylighting Factors, Start Date=" + DataEnvironment::CurMnDy); } else { - DisplayString(state, "Updating Detailed Daylighting Factors, Start Date=" + CurMnDy); + DisplayString(state, "Updating Detailed Daylighting Factors, Start Date=" + DataEnvironment::CurMnDy); } } @@ -515,7 +509,7 @@ namespace DaylightingManager { state.dataDaylightingManager->GILSK = 0.0; state.dataDaylightingManager->GILSU = 0.0; for (IHR = 1; IHR <= 24; ++IHR) { - if (SUNCOSHR(IHR, 3) < SunIsUpValue) continue; // Skip if sun is below horizon //Autodesk SUNCOSHR was uninitialized here + if (SUNCOSHR(IHR, 3) < DataEnvironment::SunIsUpValue) continue; // Skip if sun is below horizon //Autodesk SUNCOSHR was uninitialized here state.dataDaylightingManager->PHSUN = DataGlobalConstants::PiOvr2() - std::acos(SUNCOSHR(IHR, 3)); state.dataDaylightingManager->PHSUNHR(IHR) = state.dataDaylightingManager->PHSUN; state.dataDaylightingManager->SPHSUNHR(IHR) = std::sin(state.dataDaylightingManager->PHSUN); @@ -540,7 +534,7 @@ namespace DaylightingManager { state.dataDaylightingManager->THSUNHR(state.dataGlobal->HourOfDay) = 0.0; state.dataDaylightingManager->GILSK(state.dataGlobal->HourOfDay, {1, 4}) = 0.0; state.dataDaylightingManager->GILSU(state.dataGlobal->HourOfDay) = 0.0; - if (!(SUNCOSHR(state.dataGlobal->HourOfDay, 3) < SunIsUpValue)) { // Skip if sun is below horizon + if (!(SUNCOSHR(state.dataGlobal->HourOfDay, 3) < DataEnvironment::SunIsUpValue)) { // Skip if sun is below horizon state.dataDaylightingManager->PHSUN = DataGlobalConstants::PiOvr2() - std::acos(SUNCOSHR(state.dataGlobal->HourOfDay, 3)); state.dataDaylightingManager->PHSUNHR(state.dataGlobal->HourOfDay) = state.dataDaylightingManager->PHSUN; state.dataDaylightingManager->SPHSUNHR(state.dataGlobal->HourOfDay) = std::sin(state.dataDaylightingManager->PHSUN); @@ -608,7 +602,7 @@ namespace DaylightingManager { print(state.files.eio, " Sky Daylight Factors,{},{},{},{},{},{:.4R}\n", skyTypeString, - CurMnDy, + DataEnvironment::CurMnDy, Zone(ZoneNum).Name, Surface(IWin).Name, state.dataDaylightingData->DaylRefPt(state.dataDaylightingData->ZoneDaylight(ZoneNum).DaylRefPtNum(refPtNum)).Name, @@ -681,14 +675,14 @@ namespace DaylightingManager { for (ISlatAngle = 1; ISlatAngle <= ISA; ++ISlatAngle) { if (ISlatAngle == 1) { // base window without shades, screens, or blinds - print(state.files.dfs, "{},{},{},Base Window\n", CurMnDy, Zone(ZoneNum).Name, Surface(IWin).Name); + print(state.files.dfs, "{},{},{},Base Window\n", DataEnvironment::CurMnDy, Zone(ZoneNum).Name, Surface(IWin).Name); } else if (ISlatAngle == 2 && ISA == 2) { // window shade or blind with fixed slat angle - print(state.files.dfs, "{},{},{},Blind or Slat Applied\n", CurMnDy, Zone(ZoneNum).Name, Surface(IWin).Name); + print(state.files.dfs, "{},{},{},Blind or Slat Applied\n", DataEnvironment::CurMnDy, Zone(ZoneNum).Name, Surface(IWin).Name); } else { // blind with variable slat angle SlatAngle = 180.0 / double(MaxSlatAngs - 1) * double(ISlatAngle - 2); - print(state.files.dfs, "{},{},{},{:.1R}\n", CurMnDy, Zone(ZoneNum).Name, Surface(IWin).Name, SlatAngle); + print(state.files.dfs, "{},{},{},{:.1R}\n", DataEnvironment::CurMnDy, Zone(ZoneNum).Name, Surface(IWin).Name, SlatAngle); } for (IHR = 1; IHR <= 24; ++IHR) { @@ -2452,7 +2446,7 @@ namespace DaylightingManager { Real64 AZVIEW; // Azimuth of view vector // Object Data - BSDFDaylghtPosition elPos; // altitude and azimuth of intersection element + DataBSDFWindow::BSDFDaylghtPosition elPos; // altitude and azimuth of intersection element Vector Vec; // temporary vector variable NumOfWinEl = NWX * NWY; @@ -2585,8 +2579,8 @@ namespace DaylightingManager { } void InitializeCFSStateData(EnergyPlusData &state, - BSDFRefPoints &StateRefPoint, - BSDFRefPointsGeomDescr &DaylghtGeomDescr, + DataBSDFWindow::BSDFRefPoints &StateRefPoint, + DataBSDFWindow::BSDFRefPointsGeomDescr &DaylghtGeomDescr, [[maybe_unused]] int const ZoneNum, // Current zone number int const iWin, Vector3 const &RefPoint, // reference point @@ -2829,7 +2823,7 @@ namespace DaylightingManager { } // do IX = 1, NWX } - void AllocateForCFSRefPointsState(BSDFRefPoints &StateRefPoint, int const NumOfWinEl, int const NBasis, int const NTrnBasis) + void AllocateForCFSRefPointsState(DataBSDFWindow::BSDFRefPoints &StateRefPoint, int const NumOfWinEl, int const NBasis, int const NTrnBasis) { // SUBROUTINE INFORMATION: // AUTHOR Simon Vidanovic @@ -2934,7 +2928,7 @@ namespace DaylightingManager { } } - void AllocateForCFSRefPointsGeometry(BSDFRefPointsGeomDescr &RefPointsGeomDescr, int const NumOfWinEl) + void AllocateForCFSRefPointsGeometry(DataBSDFWindow::BSDFRefPointsGeomDescr &RefPointsGeomDescr, int const NumOfWinEl) { // SUBROUTINE INFORMATION: // AUTHOR Simon Vidanovic @@ -2974,8 +2968,8 @@ namespace DaylightingManager { Vector3 const &RefPoint, Vector3 const &RWin, Vector3 const &WNorm, - BSDFRefPoints &RefPointMap, - BSDFRefPointsGeomDescr &RefPointGeomMap, + DataBSDFWindow::BSDFRefPoints &RefPointMap, + DataBSDFWindow::BSDFRefPointsGeomDescr &RefPointGeomMap, int const iWin, int const CurFenState, int const NTrnBasis, @@ -3036,7 +3030,7 @@ namespace DaylightingManager { } void CFSRefPointPosFactor(EnergyPlusData &state, - Vector3 const &RefPoint, BSDFRefPoints &RefPointMap, int const iWin, int const CurFenState, int const NTrnBasis, Real64 const AZVIEW) + Vector3 const &RefPoint, DataBSDFWindow::BSDFRefPoints &RefPointMap, int const iWin, int const CurFenState, int const NTrnBasis, Real64 const AZVIEW) { // SUBROUTINE INFORMATION: // AUTHOR Simon Vidanovic @@ -3069,7 +3063,7 @@ namespace DaylightingManager { static Vector3 InterPoint; // Object Data - BSDFDaylghtPosition elPos; // altitude and azimuth of intersection element + DataBSDFWindow::BSDFDaylghtPosition elPos; // altitude and azimuth of intersection element auto const &sTrn(state.dataBSDFWindow->ComplexWind(iWin).Geom(CurFenState).sTrn); for (iTrnRay = 1; iTrnRay <= NTrnBasis; ++iTrnRay) { @@ -3287,7 +3281,7 @@ namespace DaylightingManager { using General::BlindBeamBeamTrans; using General::POLYF; - if (SUNCOSHR(iHour, 3) < SunIsUpValue) return; + if (SUNCOSHR(iHour, 3) < DataEnvironment::SunIsUpValue) return; // SUBROUTINE LOCAL VARIABLE DECLARATIONS: static Vector3 const RREF(0.0); // Location of a reference point in absolute coordinate system //Autodesk Was used uninitialized: @@ -3532,9 +3526,9 @@ namespace DaylightingManager { GroundHitPt(2) = RWIN2(2); } } - Real64 const GILSK_mult((GndReflectanceForDayltg / DataGlobalConstants::Pi()) * ObTrans * SkyObstructionMult); + Real64 const GILSK_mult((DataEnvironment::GndReflectanceForDayltg / DataGlobalConstants::Pi()) * ObTrans * SkyObstructionMult); Real64 const TVISB_ObTrans(TVISB * ObTrans); - Real64 const AVWLSU_add(TVISB_ObTrans * state.dataDaylightingManager->GILSU(iHour) * (GndReflectanceForDayltg / DataGlobalConstants::Pi())); + Real64 const AVWLSU_add(TVISB_ObTrans * state.dataDaylightingManager->GILSU(iHour) * (DataEnvironment::GndReflectanceForDayltg / DataGlobalConstants::Pi())); Vector3 const SUNCOS_iHour(SUNCOSHR(iHour, {1, 3})); assert(equal_dimensions(state.dataDaylightingManager->EDIRSK, state.dataDaylightingManager->AVWLSK)); auto l(state.dataDaylightingManager->EDIRSK.index(iHour, 1, 1)); @@ -3989,7 +3983,7 @@ namespace DaylightingManager { Real64 VTR; // For switchable glazing, ratio of visible transmittance of // fully-switched state to that of the unswitched state - if (SUNCOSHR(iHour, 3) < SunIsUpValue) return; + if (SUNCOSHR(iHour, 3) < DataEnvironment::SunIsUpValue) return; ++ISunPos; @@ -4137,7 +4131,7 @@ namespace DaylightingManager { Real64 VTR; // For switchable glazing, ratio of visible transmittance of // fully-switched state to that of the unswitched state - if (SUNCOSHR(iHour, 3) < SunIsUpValue) return; + if (SUNCOSHR(iHour, 3) < DataEnvironment::SunIsUpValue) return; // Altitude of sun (degrees) state.dataDaylightingManager->PHSUN = state.dataDaylightingManager->PHSUNHR(iHour); @@ -4458,7 +4452,7 @@ namespace DaylightingManager { // RJH DElight Modification Begin - Calls to DElight preprocessing subroutines if (doesDayLightingUseDElight(state)) { - dLatitude = Latitude; + dLatitude = DataEnvironment::Latitude; DisplayString(state, "Calculating DElight Daylighting Factors"); DElightInputGenerator(state); // Init Error Flag to 0 (no Warnings or Errors) @@ -5010,7 +5004,7 @@ namespace DaylightingManager { } if (!lAlphaFieldBlanks(4)) { // Field: Availability Schedule Name - zone_daylight.AvailSchedNum = GetScheduleIndex(state, cAlphaArgs(4)); + zone_daylight.AvailSchedNum = ScheduleManager::GetScheduleIndex(state, cAlphaArgs(4)); if (zone_daylight.AvailSchedNum == 0) { ShowWarningError(state, "Invalid " + cAlphaFieldNames(4) + " = " + cAlphaArgs(4) + ", occurs in " + cCurrentModuleObject + "object for " + cCurrentModuleObject + "=\"" + cAlphaArgs(1)); @@ -6276,16 +6270,16 @@ namespace DaylightingManager { state.dataDaylightingData->ZoneDaylight(ZoneNum).BacLum(IL) = 0.0; } - if (SkyClearness > 3.0) { // Sky is average of clear and clear turbid - SkyWeight = min(1.0, (SkyClearness - 3.0) / 3.0); + if (DataEnvironment::SkyClearness > 3.0) { // Sky is average of clear and clear turbid + SkyWeight = min(1.0, (DataEnvironment::SkyClearness - 3.0) / 3.0); ISky1 = 1; ISky2 = 2; - } else if (SkyClearness > 1.2) { // Sky is average of clear turbid and intermediate - SkyWeight = (SkyClearness - 1.2) / 1.8; + } else if (DataEnvironment::SkyClearness > 1.2) { // Sky is average of clear turbid and intermediate + SkyWeight = (DataEnvironment::SkyClearness - 1.2) / 1.8; ISky1 = 2; ISky2 = 3; } else { // Sky is average of intermediate and overcast - SkyWeight = min(1.0, max(0.0, (SkyClearness - 1.0) / 0.2, (SkyBrightness - 0.05) / 0.4)); + SkyWeight = min(1.0, max(0.0, (DataEnvironment::SkyClearness - 1.0) / 0.2, (DataEnvironment::SkyBrightness - 0.05) / 0.4)); ISky1 = 3; ISky2 = 4; } @@ -6515,21 +6509,21 @@ namespace DaylightingManager { // which is called in WeatherManager. HISUNF is current time step horizontal illuminance from sun, // also calculated in DayltgLuminousEfficacy. - HorIllSkyFac = HISKF / ((1 - SkyWeight) * HorIllSky(ISky2) + SkyWeight * HorIllSky(ISky1)); + HorIllSkyFac = DataEnvironment::HISKF / ((1 - SkyWeight) * HorIllSky(ISky2) + SkyWeight * HorIllSky(ISky1)); for (IS = 1; IS <= 2; ++IS) { if (IS == 2 && (SurfWinWindowModelType(IWin) == WindowBSDFModel)) break; if (IS == 2 && SurfWinShadingFlag(IWin) <= 0 && !SurfWinSolarDiffusing(IWin)) break; state.dataDaylightingData->ZoneDaylight(ZoneNum).IllumFromWinAtRefPt(loop, IS, IL) = - DFSUHR(IS) * HISUNF + + DFSUHR(IS) * DataEnvironment::HISUNF + HorIllSkyFac * (DFSKHR(IS, ISky1) * SkyWeight * HorIllSky(ISky1) + DFSKHR(IS, ISky2) * (1.0 - SkyWeight) * HorIllSky(ISky2)); state.dataDaylightingData->ZoneDaylight(ZoneNum).BackLumFromWinAtRefPt(loop, IS, IL) = - BFSUHR(IS) * HISUNF + + BFSUHR(IS) * DataEnvironment::HISUNF + HorIllSkyFac * (BFSKHR(IS, ISky1) * SkyWeight * HorIllSky(ISky1) + BFSKHR(IS, ISky2) * (1.0 - SkyWeight) * HorIllSky(ISky2)); state.dataDaylightingData->ZoneDaylight(ZoneNum).SourceLumFromWinAtRefPt(loop, IS, IL) = - SFSUHR(IS) * HISUNF + + SFSUHR(IS) * DataEnvironment::HISUNF + HorIllSkyFac * (SFSKHR(IS, ISky1) * SkyWeight * HorIllSky(ISky1) + SFSKHR(IS, ISky2) * (1.0 - SkyWeight) * HorIllSky(ISky2)); state.dataDaylightingData->ZoneDaylight(ZoneNum).SourceLumFromWinAtRefPt(loop, IS, IL) = @@ -7161,16 +7155,16 @@ namespace DaylightingManager { int ISky2; Real64 SkyWeight; // Weighting factor used to average two different sky types - if (SkyClearness > 3.0) { // Sky is average of clear and clear turbid - SkyWeight = min(1.0, (SkyClearness - 3.0) / 3.0); + if (DataEnvironment::SkyClearness > 3.0) { // Sky is average of clear and clear turbid + SkyWeight = min(1.0, (DataEnvironment::SkyClearness - 3.0) / 3.0); ISky1 = 1; ISky2 = 2; - } else if (SkyClearness > 1.2) { // Sky is average of clear turbid and intermediate - SkyWeight = (SkyClearness - 1.2) / 1.8; + } else if (DataEnvironment::SkyClearness > 1.2) { // Sky is average of clear turbid and intermediate + SkyWeight = (DataEnvironment::SkyClearness - 1.2) / 1.8; ISky1 = 2; ISky2 = 3; } else { // Sky is average of intermediate and overcast - SkyWeight = min(1.0, max(0.0, (SkyClearness - 1.0) / 0.2, (SkyBrightness - 0.05) / 0.4)); + SkyWeight = min(1.0, max(0.0, (DataEnvironment::SkyClearness - 1.0) / 0.2, (DataEnvironment::SkyBrightness - 0.05) / 0.4)); ISky1 = 3; ISky2 = 4; } @@ -7795,7 +7789,7 @@ namespace DaylightingManager { for (ISky = 1; ISky <= 4; ++ISky) { // Below, luminance of ground in cd/m2 is illuminance on ground in lumens/m2 // times ground reflectance, divided by pi, times obstruction multiplier. - ZSK(ISky) = (state.dataDaylightingManager->GILSK(IHR, ISky) * GndReflectanceForDayltg / DataGlobalConstants::Pi()) * COSB * DA * ObTransM(IPH, ITH) * SkyObstructionMult(IPH, ITH); + ZSK(ISky) = (state.dataDaylightingManager->GILSK(IHR, ISky) * DataEnvironment::GndReflectanceForDayltg / DataGlobalConstants::Pi()) * COSB * DA * ObTransM(IPH, ITH) * SkyObstructionMult(IPH, ITH); } // Determine if sun illuminates the point that ray hits the ground. If the solar reflection // calculation has been requested (CalcSolRefl = .TRUE.) shading by obstructions, including @@ -7812,7 +7806,7 @@ namespace DaylightingManager { } if (hitObs) SunObstructionMult = 0.0; } - ZSU = (state.dataDaylightingManager->GILSU(IHR) * GndReflectanceForDayltg / DataGlobalConstants::Pi()) * COSB * DA * ObTransM(IPH, ITH) * SunObstructionMult; + ZSU = (state.dataDaylightingManager->GILSU(IHR) * DataEnvironment::GndReflectanceForDayltg / DataGlobalConstants::Pi()) * COSB * DA * ObTransM(IPH, ITH) * SunObstructionMult; } // BEAM SOLAR AND SKY SOLAR REFLECTED FROM NEAREST OBSTRUCTION @@ -8467,17 +8461,17 @@ namespace DaylightingManager { // Ray from ground element // BeamObstrMultiplier = ComplexWind(IWin)%DaylghtGeom(CurCplxFenState)%GndObstrMultiplier(WinEl, iIncElem) for (iSky = 1; iSky <= 4; ++iSky) { - ElementLuminanceSky(iSky, iIncElem) = state.dataDaylightingManager->GILSK(IHR, iSky) * GndReflectanceForDayltg / DataGlobalConstants::Pi() * LambdaInc; + ElementLuminanceSky(iSky, iIncElem) = state.dataDaylightingManager->GILSK(IHR, iSky) * DataEnvironment::GndReflectanceForDayltg / DataGlobalConstants::Pi() * LambdaInc; } - ElementLuminanceSun(iIncElem) = state.dataDaylightingManager->GILSU(IHR) * GndReflectanceForDayltg / DataGlobalConstants::Pi() * LambdaInc; + ElementLuminanceSun(iIncElem) = state.dataDaylightingManager->GILSU(IHR) * DataEnvironment::GndReflectanceForDayltg / DataGlobalConstants::Pi() * LambdaInc; } else { // Ray from the element which is half sky and half ground for (iSky = 1; iSky <= 4; ++iSky) { // in this case half of the pach is coming from the sky and half from the ground ElementLuminanceSky(iSky, iIncElem) = 0.5 * DayltgSkyLuminance(state, iSky, Azimuth, Altitude) * LambdaInc; - ElementLuminanceSky(iSky, iIncElem) += 0.5 * state.dataDaylightingManager->GILSK(IHR, iSky) * GndReflectanceForDayltg / DataGlobalConstants::Pi() * LambdaInc; + ElementLuminanceSky(iSky, iIncElem) += 0.5 * state.dataDaylightingManager->GILSK(IHR, iSky) * DataEnvironment::GndReflectanceForDayltg / DataGlobalConstants::Pi() * LambdaInc; } - ElementLuminanceSun(iIncElem) = 0.5 * state.dataDaylightingManager->GILSU(IHR) * GndReflectanceForDayltg / DataGlobalConstants::Pi() * LambdaInc; + ElementLuminanceSun(iIncElem) = 0.5 * state.dataDaylightingManager->GILSU(IHR) * DataEnvironment::GndReflectanceForDayltg / DataGlobalConstants::Pi() * LambdaInc; } // Sun beam calculations if ((SolBmIndex == iIncElem) && (SunlitFracHR(IHR, IWin) > 0.0)) { @@ -9470,16 +9464,16 @@ namespace DaylightingManager { BACLUM = 0.0; GLRNDX = 0.0; - if (SkyClearness > 3.0) { // Sky is average of clear and clear turbid - SkyWeight = min(1.0, (SkyClearness - 3.0) / 3.0); + if (DataEnvironment::SkyClearness > 3.0) { // Sky is average of clear and clear turbid + SkyWeight = min(1.0, (DataEnvironment::SkyClearness - 3.0) / 3.0); ISky1 = 1; ISky2 = 2; - } else if (SkyClearness > 1.2) { // Sky is average of clear turbid and intermediate - SkyWeight = (SkyClearness - 1.2) / 1.8; + } else if (DataEnvironment::SkyClearness > 1.2) { // Sky is average of clear turbid and intermediate + SkyWeight = (DataEnvironment::SkyClearness - 1.2) / 1.8; ISky1 = 2; ISky2 = 3; } else { // Sky is average of intermediate and overcast - SkyWeight = min(1.0, max(0.0, (SkyClearness - 1.0) / 0.2, (SkyBrightness - 0.05) / 0.4)); + SkyWeight = min(1.0, max(0.0, (DataEnvironment::SkyClearness - 1.0) / 0.2, (DataEnvironment::SkyBrightness - 0.05) / 0.4)); ISky1 = 3; ISky2 = 4; } @@ -9722,21 +9716,21 @@ namespace DaylightingManager { // HISKF is current time step horizontal illuminance from sky, calculated in DayltgLuminousEfficacy, // which is called in WeatherManager. HISUNF is current time step horizontal illuminance from sun, // also calculated in DayltgLuminousEfficacy. - HorIllSkyFac = HISKF / ((1.0 - SkyWeight) * HorIllSky(ISky2) + SkyWeight * HorIllSky(ISky1)); + HorIllSkyFac = DataEnvironment::HISKF / ((1.0 - SkyWeight) * HorIllSky(ISky2) + SkyWeight * HorIllSky(ISky1)); for (IS = 1; IS <= 2; ++IS) { if (IS == 2 && SurfWinShadingFlag(IWin) <= 0 && !SurfWinSolarDiffusing(IWin)) break; state.dataDaylightingData->IllumMapCalc(MapNum).IllumFromWinAtMapPt(loop, IS, ILB) = - DFSUHR(IS) * HISUNF + HorIllSkyFac * (DFSKHR(IS, ISky1) * SkyWeight * HorIllSky(ISky1) + + DFSUHR(IS) * DataEnvironment::HISUNF + HorIllSkyFac * (DFSKHR(IS, ISky1) * SkyWeight * HorIllSky(ISky1) + DFSKHR(IS, ISky2) * (1.0 - SkyWeight) * HorIllSky(ISky2)); state.dataDaylightingData->IllumMapCalc(MapNum).BackLumFromWinAtMapPt(loop, IS, ILB) = - BFSUHR(IS) * HISUNF + HorIllSkyFac * (BFSKHR(IS, ISky1) * SkyWeight * HorIllSky(ISky1) + + BFSUHR(IS) * DataEnvironment::HISUNF + HorIllSkyFac * (BFSKHR(IS, ISky1) * SkyWeight * HorIllSky(ISky1) + BFSKHR(IS, ISky2) * (1.0 - SkyWeight) * HorIllSky(ISky2)); state.dataDaylightingData->IllumMapCalc(MapNum).SourceLumFromWinAtMapPt(loop, IS, ILB) = - SFSUHR(IS) * HISUNF + HorIllSkyFac * (SFSKHR(IS, ISky1) * SkyWeight * HorIllSky(ISky1) + + SFSUHR(IS) * DataEnvironment::HISUNF + HorIllSkyFac * (SFSKHR(IS, ISky1) * SkyWeight * HorIllSky(ISky1) + SFSKHR(IS, ISky2) * (1.0 - SkyWeight) * HorIllSky(ISky2)); state.dataDaylightingData->IllumMapCalc(MapNum).SourceLumFromWinAtMapPt(loop, IS, ILB) = max(state.dataDaylightingData->IllumMapCalc(MapNum).SourceLumFromWinAtMapPt(loop, IS, ILB), 0.0); @@ -9925,7 +9919,7 @@ namespace DaylightingManager { // CommaDelimited = false; //Unused Set but never used } - SavedMnDy(MapNum) = CurMnDyHr.substr(0, 5); + SavedMnDy(MapNum) = DataEnvironment::CurMnDyHr.substr(0, 5); state.dataDaylightingData->IllumMap(MapNum).Name = format("{} at {:.2R}m", state.dataDaylightingData->IllumMap(MapNum).Name, state.dataDaylightingData->IllumMap(MapNum).Z); @@ -9936,16 +9930,16 @@ namespace DaylightingManager { state.dataDaylightingData->ZoneDaylight(state.dataDaylightingData->IllumMap(MapNum).Zone).DaylRefPtAbsCoord(3, R) ); } } - if (SavedMnDy(MapNum) != CurMnDyHr.substr(0, 5)) { + if (SavedMnDy(MapNum) != DataEnvironment::CurMnDyHr.substr(0, 5)) { EnvrnPrint(MapNum) = true; - SavedMnDy(MapNum) = CurMnDyHr.substr(0, 5); + SavedMnDy(MapNum) = DataEnvironment::CurMnDyHr.substr(0, 5); } if (EnvrnPrint(MapNum)) { WriteDaylightMapTitle(state, MapNum, *state.dataDaylightingData->IllumMap(MapNum).mapFile, state.dataDaylightingData->IllumMap(MapNum).Name, - EnvironmentName, + DataEnvironment::EnvironmentName, state.dataDaylightingData->IllumMap(MapNum).Zone, RefPts(state.dataDaylightingData->IllumMap(MapNum).Zone, 1), RefPts(state.dataDaylightingData->IllumMap(MapNum).Zone, 2), @@ -10019,8 +10013,8 @@ namespace DaylightingManager { // We need DataGlobals::CalendarYear, and not DataEnvironment::Year because // otherwise if you run a TMY file, you'll get for eg 1977, 1981, etc SQYear = state.dataGlobal->CalendarYear; - SQMonth = Month; - SQDayOfMonth = DayOfMonth; + SQMonth = DataEnvironment::Month; + SQDayOfMonth = DataEnvironment::DayOfMonth; for (Y = 1; Y <= state.dataDaylightingData->IllumMap(MapNum).Ynum; ++Y) { YValue(Y) = state.dataDaylightingData->IllumMap(MapNum).Ymin + (Y - 1) * state.dataDaylightingData->IllumMap(MapNum).Yinc; @@ -10594,7 +10588,7 @@ namespace DaylightingManager { // This is an interior window in ZoneNum int const ConstrNum = Surface(IWin).Construction; int const adjEnclNum = Surface(Surface(IWin).ExtBoundCond).SolarEnclIndex; - QDifTrans = QSDifSol(adjEnclNum) * state.dataConstruction->Construct(ConstrNum).TransDiffVis * Surface(IWin).Area * PDIFLW; + QDifTrans = QSDifSol(adjEnclNum) * state.dataConstruction->Construct(ConstrNum).TransDiffVis * Surface(IWin).Area * DataEnvironment::PDIFLW; QDifTransUp = QDifTrans * SurfWinFractionUpgoing(IWin); QDifTransDn = QDifTrans * (1.0 - SurfWinFractionUpgoing(IWin)); if (state.dataDaylightingData->ZoneDaylight(ZoneNum).TotInsSurfArea * (1.0 - state.dataDaylightingData->ZoneDaylight(ZoneNum).AveVisDiffReflect) != 0.0) { @@ -10611,7 +10605,7 @@ namespace DaylightingManager { // TH, CR 7873, 9/17/2009 BmInterReflIll = 0.0; if (state.dataDaylightingData->ZoneDaylight(ZoneNum).TotInsSurfArea > 0) { - BmInterReflIll = (EnclSolDBIntWin(ZoneNum) * BeamSolarRad * PDIRLW * state.dataDaylightingData->ZoneDaylight(ZoneNum).FloorVisRefl) / + BmInterReflIll = (EnclSolDBIntWin(ZoneNum) * DataEnvironment::BeamSolarRad * DataEnvironment::PDIRLW * state.dataDaylightingData->ZoneDaylight(ZoneNum).FloorVisRefl) / (state.dataDaylightingData->ZoneDaylight(ZoneNum).TotInsSurfArea * (1.0 - state.dataDaylightingData->ZoneDaylight(ZoneNum).AveVisDiffReflect)); } @@ -10850,6 +10844,4 @@ namespace DaylightingManager { } } -} // namespace DaylightingManager - } // namespace EnergyPlus diff --git a/src/EnergyPlus/DaylightingManager.hh b/src/EnergyPlus/DaylightingManager.hh index 1454f6c1398..74bebac30c2 100644 --- a/src/EnergyPlus/DaylightingManager.hh +++ b/src/EnergyPlus/DaylightingManager.hh @@ -69,10 +69,6 @@ struct EnergyPlusData; namespace DaylightingManager { - // Using/Aliasing - using DataBSDFWindow::BSDFRefPoints; - using DataBSDFWindow::BSDFRefPointsGeomDescr; - // Surface count crossover for using octree algorithm // The octree gives lower computational complexity for much higher performance // as the surface count increases but has some overhead such that the direct @@ -192,8 +188,8 @@ namespace DaylightingManager { Optional_int_const MapNum = _); void InitializeCFSStateData(EnergyPlusData &state, - BSDFRefPoints &StateRefPoint, - BSDFRefPointsGeomDescr &DaylghtGeomDescr, + DataBSDFWindow::BSDFRefPoints &StateRefPoint, + DataBSDFWindow::BSDFRefPointsGeomDescr &DaylghtGeomDescr, int const ZoneNum, // Current zone number int const iWin, Vector3 const &RefPoint, // reference point @@ -213,16 +209,16 @@ namespace DaylightingManager { DataDaylighting::iCalledFor const CalledFrom, Optional_int_const MapNum = _); - void AllocateForCFSRefPointsState(BSDFRefPoints &StateRefPoint, int const NumOfWinEl, int const NBasis, int const NTrnBasis); + void AllocateForCFSRefPointsState(DataBSDFWindow::BSDFRefPoints &StateRefPoint, int const NumOfWinEl, int const NBasis, int const NTrnBasis); - void AllocateForCFSRefPointsGeometry(BSDFRefPointsGeomDescr &RefPointsGeomDescr, int const NumOfWinEl); + void AllocateForCFSRefPointsGeometry(DataBSDFWindow::BSDFRefPointsGeomDescr &RefPointsGeomDescr, int const NumOfWinEl); void CFSRefPointSolidAngle(EnergyPlusData &state, Vector3 const &RefPoint, Vector3 const &RWin, Vector3 const &WNorm, - BSDFRefPoints &RefPointMap, - BSDFRefPointsGeomDescr &RefPointGeomMap, + DataBSDFWindow::BSDFRefPoints &RefPointMap, + DataBSDFWindow::BSDFRefPointsGeomDescr &RefPointGeomMap, int const iWin, int const CurFenState, int const NTrnBasis, @@ -230,7 +226,7 @@ namespace DaylightingManager { Real64 const WinElArea); void CFSRefPointPosFactor(EnergyPlusData &state, - Vector3 const &RefPoint, BSDFRefPoints &RefPointMap, int const iWin, int const CurFenState, int const NTrnBasis, Real64 const AZVIEW); + Vector3 const &RefPoint, DataBSDFWindow::BSDFRefPoints &RefPointMap, int const iWin, int const CurFenState, int const NTrnBasis, Real64 const AZVIEW); Real64 CalcObstrMultiplier(Vector3 const &GroundHitPt, // Coordinates of point that ray hits ground (m) int const AltSteps, // Number of steps in altitude angle for solar reflection calc From b8c08c7a4a464f495a03c62213716114de6485a2 Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Wed, 25 Nov 2020 09:42:18 -0700 Subject: [PATCH 10/10] add back original int values to new LtgCtrlType enum --- src/EnergyPlus/DataDaylighting.hh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/EnergyPlus/DataDaylighting.hh b/src/EnergyPlus/DataDaylighting.hh index 2789b181666..4e3fb26f771 100644 --- a/src/EnergyPlus/DataDaylighting.hh +++ b/src/EnergyPlus/DataDaylighting.hh @@ -94,9 +94,9 @@ namespace DataDaylighting { // Parameters for "Lighting Control Type" enum class iLtgCtrlType { - Continuous, - Stepped, - ContinuousOff + Continuous = 1, + Stepped = 2, + ContinuousOff = 3 }; struct IntWinAdjZoneExtWinStruct // nested structure for ZoneDaylight