From 1e1f16dc505dce933126393fa362c3f64fa0f255 Mon Sep 17 00:00:00 2001 From: Michael Wetter Date: Mon, 9 Dec 2024 05:32:04 -0800 Subject: [PATCH] Issue4069 occupants (#4073) * Refactored Buildings.Occupants For #4069 --- .../Validation/BinaryVariableGeneration.mo | 24 +++++-- .../ExponentialVariableGeneration.mo | 22 ++++-- .../BaseClasses/Validation/Linear1D.mo | 25 +++++-- .../BaseClasses/Validation/Logit1D.mo | 24 +++++-- .../Validation/Logit1DQuadratic.mo | 24 +++++-- .../BaseClasses/Validation/Logit2D.mo | 25 +++++-- .../BaseClasses/Validation/Weibull1DOFF.mo | 25 +++++-- .../BaseClasses/Validation/Weibull1DON.mo | 24 +++++-- .../Validation/WeibullVariableGeneration.mo | 22 ++++-- .../BaseClasses/binaryVariableGeneration.mo | 16 +++-- .../exponentialVariableGeneration.mo | 18 +++-- Buildings/Occupants/BaseClasses/linear1D.mo | 15 +++- Buildings/Occupants/BaseClasses/logit1D.mo | 15 +++- .../Occupants/BaseClasses/logit1DQuadratic.mo | 15 +++- Buildings/Occupants/BaseClasses/logit2D.mo | 15 +++- Buildings/Occupants/BaseClasses/package.mo | 6 +- .../Occupants/BaseClasses/weibull1DOFF.mo | 29 +++++--- .../Occupants/BaseClasses/weibull1DON.mo | 33 ++++++--- .../BaseClasses/weibullVariableGeneration.mo | 18 +++-- .../Office/Blinds/Haldi2008BlindsTIn.mo | 25 +++++-- .../Office/Blinds/Haldi2008BlindsTOut.mo | 25 +++++-- .../Inkarojrit2008BlindsSolarIntensity.mo | 25 +++++-- .../Blinds/Newsham1994BlindsSolarIntensity.mo | 6 ++ .../Blinds/Zhang2012BlindsSolarAltitude.mo | 32 ++++++--- .../Blinds/Zhang2012BlindsSolarIntensity.mo | 33 ++++++--- .../Office/Lighting/Gunay2016Light.mo | 27 +++++-- .../Office/Lighting/Hunt1979Light.mo | 19 +++-- .../Office/Lighting/Love1998Light1.mo | 25 +++++-- .../Office/Lighting/Love1998Light2.mo | 27 +++++-- .../Office/Lighting/Reinhart2003Light.mo | 27 +++++-- .../Office/Occupancy/Wang2005Occupancy.mo | 50 +++++++------ .../Office/Windows/Haldi2008WindowsTIn.mo | 39 +++++++---- .../Office/Windows/Haldi2008WindowsTOut.mo | 39 +++++++---- .../Office/Windows/Haldi2009WindowsTInTout.mo | 44 ++++++++---- .../Herkel2008WindowsCompletelyOpen.mo | 45 ++++++++---- .../Office/Windows/Herkel2008WindowsSmall.mo | 43 ++++++++---- .../Windows/Herkel2008WindowsTiltedOpen.mo | 45 ++++++++---- .../Windows/Rijal2007WindowsTInTOutTComf.mo | 55 +++++++++------ .../Office/Windows/Yun2008WindowsTIn.mo | 39 +++++++---- .../Office/Windows/Yun2008WindowsTOut.mo | 40 +++++++---- .../Office/Windows/Zhang2012WindowsAll.mo | 39 +++++++---- .../Office/Windows/Zhang2012WindowsEast.mo | 39 +++++++---- .../Office/Windows/Zhang2012WindowsNorth.mo | 41 +++++++---- .../Office/Windows/Zhang2012WindowsSouth.mo | 39 +++++++---- .../Office/Windows/Zhang2012WindowsWest.mo | 41 +++++++---- .../AirConditioning/Ren2014ACBedroom.mo | 63 +++++++++++------ .../AirConditioning/Ren2014ACLivingroom.mo | 63 +++++++++++------ .../Validation/Ren2014ACBedroom.mo | 4 +- .../Residential/Heating/Nicol2001HeatingEU.mo | 28 ++++++-- .../Heating/Nicol2001HeatingPakistan.mo | 27 +++++-- .../Residential/Heating/Nicol2001HeatingUK.mo | 27 +++++-- .../Residential/Windows/Nicol2001WindowsEU.mo | 29 ++++++-- .../Windows/Nicol2001WindowsPakistan.mo | 29 ++++++-- .../Residential/Windows/Nicol2001WindowsUK.mo | 29 ++++++-- ...es_Validation_BinaryVariableGeneration.txt | 4 +- ...lidation_ExponentialVariableGeneration.txt | 4 +- ...upants_BaseClasses_Validation_Linear1D.txt | 4 +- ...cupants_BaseClasses_Validation_Logit1D.txt | 4 +- ...aseClasses_Validation_Logit1DQuadratic.txt | 4 +- ...cupants_BaseClasses_Validation_Logit2D.txt | 4 +- ...ts_BaseClasses_Validation_Weibull1DOFF.txt | 4 +- ...nts_BaseClasses_Validation_Weibull1DON.txt | 4 +- ...s_Validation_WeibullVariableGeneration.txt | 4 +- ...e_Blinds_Validation_Haldi2008BlindsTIn.txt | 8 +-- ..._Blinds_Validation_Haldi2008BlindsTOut.txt | 8 +-- ...ion_Inkarojrit2008BlindsSolarIntensity.txt | 8 +-- ...alidation_Zhang2012BlindsSolarAltitude.txt | 8 +-- ...lidation_Zhang2012BlindsSolarIntensity.txt | 10 +-- ...ice_Lighting_Validation_Gunay2016Light.txt | 8 +-- ...fice_Lighting_Validation_Hunt1979Light.txt | 8 +-- ..._Lighting_Validation_Reinhart2003Light.txt | 8 +-- ...Occupancy_Validation_Wang2005Occupancy.txt | 4 +- ...Windows_Validation_Haldi2008WindowsTIn.txt | 8 +-- ...indows_Validation_Haldi2008WindowsTOut.txt | 6 +- ...ows_Validation_Haldi2009WindowsTInTout.txt | 6 +- ...dation_Herkel2008WindowsCompletelyOpen.txt | 6 +- ...dows_Validation_Herkel2008WindowsSmall.txt | 6 +- ...Validation_Herkel2008WindowsTiltedOpen.txt | 6 +- ...alidation_Rijal2007WindowsTInTOutTComf.txt | 8 +-- ...e_Windows_Validation_Yun2008WindowsTIn.txt | 8 +-- ..._Windows_Validation_Yun2008WindowsTOut.txt | 6 +- ...Windows_Validation_Zhang2012WindowsAll.txt | 6 +- ...indows_Validation_Zhang2012WindowsEast.txt | 6 +- ...ndows_Validation_Zhang2012WindowsNorth.txt | 6 +- ...ndows_Validation_Zhang2012WindowsSouth.txt | 6 +- ...indows_Validation_Zhang2012WindowsWest.txt | 6 +- ..._Heating_Validation_Nicol2001HeatingEU.txt | 6 +- ..._Heating_Validation_Nicol2001HeatingUK.txt | 6 +- ..._Windows_Validation_Nicol2001WindowsEU.txt | 6 +- ...ws_Validation_Nicol2001WindowsPakistan.txt | 6 +- ..._Windows_Validation_Nicol2001WindowsUK.txt | 6 +- .../ConvertBuildings_from_11_to_12.0.0.mos | 70 +++++++++++++++++++ .../UsersGuide/ReleaseNotes/Version_12_0_0.mo | 26 +++++++ 93 files changed, 1368 insertions(+), 557 deletions(-) diff --git a/Buildings/Occupants/BaseClasses/Validation/BinaryVariableGeneration.mo b/Buildings/Occupants/BaseClasses/Validation/BinaryVariableGeneration.mo index 4243c54cd0b..d80c900c2d1 100644 --- a/Buildings/Occupants/BaseClasses/Validation/BinaryVariableGeneration.mo +++ b/Buildings/Occupants/BaseClasses/Validation/BinaryVariableGeneration.mo @@ -2,24 +2,32 @@ within Buildings.Occupants.BaseClasses.Validation; model BinaryVariableGeneration "Test model for binary variable generation function" extends Modelica.Icons.Example; - parameter Integer seed = 5 "Seed for the random number generator"; + parameter Integer localSeed = 10 + "Local seed to be used to generate the initial state of the random number generator"; + parameter Integer globalSeed = 30129 + "Global seed to be combined with the local seed"; Real p "Time-varying real number as input"; output Real y "Output"; protected parameter Modelica.Units.SI.Time t0(final fixed=false) "First sample time instant"; - Real curSeed "Current value for seed as a real-valued variable"; + Integer state[Modelica.Math.Random.Generators.Xorshift1024star.nState] + "State of the random number generator"; + Boolean r "Return value of random number generator"; initial equation y = 0; t0 = time; - curSeed = t0*seed; + state = Modelica.Math.Random.Generators.Xorshift1024star.initialState( + localSeed = localSeed, + globalSeed = globalSeed); + r = false; equation p = time; when sample(0, 0.1) then - curSeed = seed*1E6*time; - if Buildings.Occupants.BaseClasses.binaryVariableGeneration(p, globalSeed=integer(curSeed)) then + (r, state) = Buildings.Occupants.BaseClasses.binaryVariableGeneration(p, pre(state)); + if r then y = 1; else y = 0; @@ -37,6 +45,12 @@ Buildings.Occupants.BaseClasses.binaryVariableGeneration. ", revisions="