!- =================== Occupant models in EMS application of EnergyPlus ========================================= !- This program presents an implementation of occupant models in EMS application of EnergyPlus. !- These models are Reinhart (2004), Boyce et al. (2006), Hunt (1979) light switch models, Reinhart (2004), !- Newsham (1994), Haldi and Robinson (2010) blinds use models, Rijal et al. (2008), Haldi and Robinson !- (2009), Yun and Steemers (2008), Haldi and Robinson(2008) window use models, Reinhart (2004), !- Wang et al.(2005), Page et al. (2008) occupancy models, Schiavon and Lee (2013) dynamic clothing model. !- This work is completed through a research contract funded by the Natural Resources Canada in 2013. !- The EMS script presented here is for information only. Researchers assume no liability for any inaccurate, !- delayed or incomplete information, nor for any actions taken in reliance thereon. !- Authors would like to thank Mr. Farhang Tahmasabi for his valuable input. !- =============================================================================================================== !- Simulation time step must be 5 minutes. !- Variables used outside the subroutine or set to be exported outside the EMS application must be defined as !- global variables. !- Refer to the EnergyPlus EMS application user's guide for further information about programming in the EnergyPlus !- Runtime Language (ERL). !- ============================ ALL OBJECTS IN CLASS: ENERGYMANAGEMENTSYSTEM:SENSOR ============================ !- EMS Sensors are output values of the EnergyPlus model !- They are the inputs for the occupant models representing the way occupants sense the indoor climate EnergyManagementSystem:Sensor, Top, !- Name NRCan2014, !- Output:Variable or Output:Meter Index Key Name Zone Operative Temperature; !- Output:Variable or Output:Meter Name EnergyManagementSystem:Sensor, Tin, !- Name NRCan2014, !- Output:Variable or Output:Meter Index Key Name Zone Mean Air Temperature; !- Output:Variable or Output:Meter Name EnergyManagementSystem:Sensor, Tout, !- Name NRCan2014, !- Output:Variable or Output:Meter Index Key Name Zone Outdoor Air Drybulb Temperature ; !- Output:Variable or Output:Meter Name EnergyManagementSystem:Sensor, Rain, !- Name NRCan2014, !- Output:Variable or Output:Meter Index Key Name Site Rain Status ; !- Output:Variable or Output:Meter Name EnergyManagementSystem:Sensor, Wind, !- Name NRCan2014, !- Output:Variable or Output:Meter Index Key Name Site Wind Speed ; !- Output:Variable or Output:Meter Name EnergyManagementSystem:Sensor, SolRadOut, !- Name SW, !- Output:Variable or Output:Meter Index Key Name Surface Outside Face Incident Solar Radiation Rate per Area ; !- Output:Variable or Output:Meter Name EnergyManagementSystem:Sensor, SolRadIn, !- Name MidBottomWindow, !- Output:Variable or Output:Meter Index Key Name Surface Window Transmitted Solar Radiation Rate ; !- Output:Variable or Output:Meter Name EnergyManagementSystem:Sensor, Daylight, !- Name NRCan2014, !- Output:Variable or Output:Meter Index Key Name Daylighting Reference Point 1 Illuminance; !- Output:Variable or Output:Meter Name EnergyManagementSystem:Sensor, E_glob, !- Name NRCan2014, !- Output:Variable or Output:Meter Index Key Name Site Exterior Horizontal Beam Illuminance ; !- Output:Variable or Output:Meter Name EnergyManagementSystem:Sensor, Lum_Eff, !- Name NRCan2014, !- Output:Variable or Output:Meter Index Key Name Site Beam Solar Radiation Luminous Efficacy; !- Output:Variable or Output:Meter Name EnergyManagementSystem:Sensor, Beam_SolRad, !- Name MidBottomWindow, !- Output:Variable or Output:Meter Index Key Name Surface Window Transmitted Beam Solar Radiation Rate ; !- Output:Variable or Output:Meter Name EnergyManagementSystem:Sensor, Num_People, !- Name NRCan2014, !- Output:Variable or Output:Meter Index Key Name Zone People Occupant Count ; !- Output:Variable or Output:Meter Name EnergyManagementSystem:Sensor, PMV, !- Name Occupant, !- Output:Variable or Output:Meter Index Key Name Zone Thermal Comfort Fanger Model PMV; !- Output:Variable or Output:Meter Name !- =========== ALL OBJECTS IN CLASS: ENERGYMANAGEMENTSYSTEM:ACTUATOR =========== !- Here the EMS actuators are schedules in EnergyPlus model !- Number of people schedule EnergyManagementSystem:Actuator, Occupant, !- Name Occupant, !- Actuated Component Unique Name Schedule:Constant, !- Actuated Component Type Schedule Value; !- Actuated Component Control Type !- Lighting object schedule name EnergyManagementSystem:Actuator, Light, !- Name Light, !- Actuated Component Unique Name Schedule:Constant, !- Actuated Component Type Schedule Value; !- Actuated Component Control Type !- Zone ventilation opening area fraction schedule name EnergyManagementSystem:Actuator, Window, !- Name Window, !- Actuated Component Unique Name Schedule:Constant, !- Actuated Component Type Schedule Value; !- Actuated Component Control Type !- Shading control schedule names !- Window was divided in four components to permit partial blind opening/closing actions EnergyManagementSystem:Actuator, BottomShade, !- Name BottomShade, !- Actuated Component Unique Name Schedule:Constant, !- Actuated Component Type Schedule Value; !- Actuated Component Control Type EnergyManagementSystem:Actuator, MidBottomShade, !- Name MidBottomShade, !- Actuated Component Unique Name Schedule:Constant, !- Actuated Component Type Schedule Value; !- Actuated Component Control Type EnergyManagementSystem:Actuator, MidTopShade, !- Name MidTopShade, !- Actuated Component Unique Name Schedule:Constant, !- Actuated Component Type Schedule Value; !- Actuated Component Control Type EnergyManagementSystem:Actuator, TopShade, !- Name TopShade, !- Actuated Component Unique Name Schedule:Constant, !- Actuated Component Type Schedule Value; !- Actuated Component Control Type !- Clothing insulation schedule name in People object EnergyManagementSystem:Actuator, Cloth, !- Name Cloth, !- Actuated Component Unique Name Schedule:Constant, !- Actuated Component Type Schedule Value; !- Actuated Component Control Type !- =========== ALL OBJECTS IN CLASS: ENERGYMANAGEMENTSYSTEM:PROGRAMCALLINGMANAGER =========== !- Specify the occupant models used in the simulation EnergyManagementSystem:ProgramCallingManager, Model, !- Name BeginTimestepBeforePredictor, !- EnergyPlus Model Calling Point CreateNewOccupant, !- Program Name 1 Clothing_Schiavon, !- Program Name 2 Occupancy_Page, !- Program Name 3 LightSwitchOnReinhart, !- Program Name 4 LightSwitchOffReinhart, !- Program Name 5 Haldi_Blinds, !- Program Name 6 Window_Haldi_2009; !- Program Name 7 !- =========== ALL OBJECTS IN CLASS: ENERGYMANAGEMENTSYSTEM:PROGRAM =========== !- This subroutine generates the model input parameters. !- In the beginning of each annual simulation a new set of occupant parameters are generated. !- Because these parameters will be used in other subroutines, they need to be defined as global variables. EnergyManagementSystem:Program, CreateNewOccupant, !- Name if currenttime < 2 && dayofyear == 1, !- Program Line 1 set Seeder=@SeedRandom ActualTime, !- Program Line 2 set A1=@RandomNormal 2 0.2 1.5 2.5, !- A4 set A2=@RandomNormal 1.6 0.1 1 2, !- A5 set A3=@RandomNormal 0-3.9 0.1 0-5 0, !- A6 set A4=@RandomNormal 0-1.3 0.01 0-5 0, !- A7 set A5=@RandomNormal 0-4 0.8 0-10 0, !- A8 set A6=@RandomNormal 0-610 120 0-1000 0, !- A9 set A7=@RandomNormal 0-1450 250 0-2000 0, !- A10 set A8=@RandomNormal 0-5.2 0.2 0-10 0, !- A11 set A9=@RandomNormal 0-6.7 0.1 0-10 0, !- A12 set A10=@RandomNormal 610 120 300 900, !- A13 set A11=@RandomNormal 1450 250 750 2000, !- A14 set A12=@RandomNormal 0-1.5 0.05 0-2 0, !- A15 set A13=@RandomNormal 0-3.6 0.03 0-5 0, !- A16 set A14=@RandomNormal 0-6.4 1.3 0-10 0, !- A17 set A15=@RandomNormal 0-12 0.4 0-15 0, !- A18 set A16=@RandomNormal 0-12.2 0.3 0-15 0, !- A19 set A17=@RandomNormal 6.4 1.3 0 10, !- A20 set A18=@RandomNormal 4 0.4 0 10, !- A21 set A19=@RandomNormal 0-1.6 0.2 0-5 0, !- A22 set A20=@RandomNormal 0.2134 0.1 0 2, !- A23 set A21=@RandomNormal 8 0.25 7 9, !- A24 set A22=@RandomNormal 10 0.25 9 11, !- A25 set A23=@RandomNormal 12 0.25 11 13, !- A26 set A24=@RandomNormal 15 0.25 14 16, !- A27 set A25=@RandomNormal 18 0.25 17 19, !- A28 set A26=@RandomNormal 0-7.4 0.16 0-100 0, !- A29 set A27=@RandomNormal 0-8 0.1 0-100 0, !- A30 set A28=@RandomNormal 0-0.27 0.14 0-100 0, !- A31 set A29=@RandomNormal 0-1.5 0.1 0-100 0, !- A32 set A30=@RandomNormal 0-3.6 0.03 0-100 0, !- A33 set A31=@RandomNormal 0.43 0.062 0 100, !- A34 set A32=@RandomNormal 0-4.842 1.079 0-100 0, !- A35 set A33=@RandomNormal 0.57 8.4 0 100, !- A36 set A34=@RandomNormal 0.209 0.049 0 1, !- A37 set A35=@RandomNormal 0.05 0.006 0 1, !- A38 set A36=@RandomNormal 0.25 0.25 0 1, !- A39 set A37=@RandomNormal 0-1.520 0.051 0-5 0, set B1=@RandomNormal 0-0.018 0.004 0-1 0, !- A40 set B2=@RandomNormal 0-0.009 0.002 0-1 0, !- A41 set B3=@RandomNormal 0-0.002 0.0005 0-1 0, !- A42 set B4=@RandomNormal 0.006 0.0001 0 1, !- A43 set B5=@RandomNormal 0.003 0.001 0 1, !- A44 set B6=@RandomNormal 14.4 2.9 0 25, !- A45 set B7=@RandomNormal 6.5 1.3 0 10, !- A46 set B8=@RandomNormal 0.001 0.002 0 1, !- A47 set B9=@RandomNormal 0.0008 0.0001 0 1, !- A48 set B10=@RandomNormal 0-14.4 2.9 0-30 0, !- A49 set B11=@RandomNormal 0-6.5 1.3 0-10 0, !- A50 set B12=@RandomNormal 0-0.0007 0.00005 0-1 0, !- A51 set B13=@RandomNormal 0-0.0003 0.00002 0-1 0, !- A52 set B14=@RandomNormal 0.17 0.03 0 1, !- A53 set B15=@RandomNormal 0.31 0.02 0 1, !- A54 set B16=@RandomNormal 0.28 0.01 0 1, !- A55 set B17=@RandomNormal 0.17 0.03 0 1, !- A56 set B18=@RandomNormal 0.043 0.003 0 1, !- A57 set B19=@RandomNormal 0.027 0.002 0 1, !- A58 set B21=@RandomNormal 0-0.45 0.11 0-2 0, !- A59 set B22=@RandomNormal 0-0.34 0.08 0-2 0, !- A60 set B23=@RandomNormal 0-0.17 0.03 0-1 0, !- A61 set B24=@RandomNormal 0-0.29 0.02 0-1 0, !- A62 set B25=@RandomNormal 0-0.05 0.01 0-1 0, !- A63 set B26=@RandomNormal 0-0.17 0.03 0-1 0, !- A64 set B27=@RandomNormal 0-0.05 0.005 0-1 0, !- A65 set B28=@RandomNormal 0-0.078 0.002 0-1 0, !- A66 set B29=@RandomNormal 0-0.0165 0.01 0-1 0, !- A67 set B30=@RandomNormal 0-0.0063 0.003 0-1 0, !- A68 set B31=@RandomNormal 0.001 0.00001 0 100, !- A69 set B32=@RandomNormal 2.17 0.16 0 100, !- A70 set B33=@RandomNormal 0.0008 0.00001 0 100, !- A71 set B34=@RandomNormal 1.27 0.086 0 100, !- A72 set B35=@RandomNormal 0.00000091 0.00000133 0 1, !- A73 set B36=@RandomNormal 0-2.23 0.16 0-100 100 , !- A74 set B37=@RandomNormal 0-0.0007 0.00005 0-1 0, !- A75 set B38=@RandomNormal 0-3.14 0.07 0-100 0, !- A76 set B39=@RandomNormal 0-0.0003 0.00002 0-1 0, !- A77 set B40=@RandomNormal 0-2.7 0.04 0-100 0, !- A78 set B41=@RandomNormal 0-0.000023 0.0000011 0-1 0, !- A79 set B42=@RandomNormal 1.95 0.11 0 5, !- A80 set B43=@RandomNormal 0.22 0.053 0 1, !- A81 set B44=@RandomNormal 0-0.003 0.038 0-100 0, !- A82 set B45=@RandomNormal 0-0.26 2.46 0 10, !- A83 set B46=@RandomNormal 0-0.007 0.002 0-1 0, !- A84 set B47=@RandomNormal 0-1.12 0.15 0-10 10, !- A85 set B48=@RandomNormal 0.213 0.022 0-10 10, set B49=@RandomNormal 0-0.091 0.061 0-10 10, set C1=@RandomNormal 0.25 0.10 0 1, !- A86 set C2=@RandomNormal 1 0.25 0 1.5, !- A87 endif; !- A95 !- Schiavon and Lee's Dynamic clothing model !- It inputs the outdoor temperature at 6 AM and operative temperature in the office EnergyManagementSystem:Program, Clothing_Schiavon, !- Name if CurrentTime==6, !- Program Line 1 set clo=Tout, !- Program Line 2 endif, !- A4 set clo=A20+B29*Top+B30*clo, !- A5 set clo=10^clo, !- A6 set cloth = clo; !- A7 !- Reinhart's office occupancy model EnergyManagementSystem:Program, Occupancy_Reinhart, !- Name if CurrentTime==1, !- Program Line 1 set Arrival=@RandomNormal A21 0.25 7 9, !- Program Line 2 set Coffee1=@RandomNormal A22 0.25 9 11, !- A4 set Lunch=@RandomNormal A23 0.25 11 13, !- A5 set Coffee2=@RandomNormal A24 0.25 14 16, !- A6 set Departure=@RandomNormal A25 0.25 17 19, !- A7 set Vac1=C1, !- A8 set Vac2=C2, !- A9 endif, !- A10 set arr_event = 0, !- A11 set dpt_event = 0, !- A12 if DayOfWeek==7 || DayOfWeek==1 , !- A13 set Presence=0, !- A14 else, !- A15 if CurrentTime<=Arrival, !- A16 set Presence=0, !- A17 elseif CurrentTime>Arrival && CurrentTime<=Coffee1, !- A18 set Presence=1, !- A19 set arr_event = 1, !- A20 elseif CurrentTime>Coffee1 && CurrentTime<=Coffee1+Vac1, !- A21 set Presence=0, !- A22 set dpt_event = 1, !- A23 elseif CurrentTime>Coffee1+Vac1 && CurrentTime<=Lunch, !- A24 set Presence=1, !- A25 set arr_event = 1, !- A26 elseif CurrentTime>Lunch && CurrentTime<=Lunch+Vac2, !- A27 set Presence=0, !- A28 set dpt_event = 1, !- A29 elseif CurrentTime>Lunch+Vac2 && CurrentTime<=Coffee2, !- A30 set Presence=1, !- A31 set arr_event = 1, !- A32 elseif CurrentTime>Coffee2 && CurrentTime<=Coffee2+Vac1, !- A33 set Presence=0, !- A34 set dpt_event = 1, !- A35 elseif CurrentTime>Coffee2+Vac1 && CurrentTime<=Departure, !- A36 set Presence=1, !- A37 set arr_event = 1, !- A38 elseif CurrentTime>Departure, !- A39 set Presence=0, !- A40 set dpt_event = 1, !- A41 endif, !- A42 endif, !- A43 set occupant=presence; !- A44 !- Wang et al.'s office occupancy model EnergyManagementSystem:Program, Occupancy_Wang, !- Name if CurrentTime==1, !- Program Line 1 set Arrival=@RandomNormal A21 0.25 7 9, !- Program Line 2 set Coffee1=@RandomNormal A22 0.25 9 11, !- A4 set Lunch=@RandomNormal A23 0.25 11 13, !- A5 set Coffee2=@RandomNormal A24 0.25 14 16, !- A6 set Departure=@RandomNormal A25 0.25 17 19, !- A7 set handle=@RandomUniform 0 1, !- A8 set handle=@Ln handle, !- A9 set Vac1=C1*handle*(0-1),!- A10 set Vac2=C2*handle*(0-1),!- A11 endif, !- A12 set arr_event = 0, !- A13 set dpt_event = 0, !- A14 if DayOfWeek==7 || DayOfWeek==1 , !- A15 set Presence=0, !- A16 else, !- A17 if CurrentTime<=Arrival, !- A18 set Presence=0, !- A19 elseif CurrentTime>Arrival && CurrentTime<=Coffee1, !- A20 set Presence=1, !- A21 set arr_event = 1, !- A22 elseif CurrentTime>Coffee1 && CurrentTime<=Coffee1+Vac1, !- A23 set Presence=0, !- A24 set dpt_event = 1, !- A25 elseif CurrentTime>Coffee1+Vac1 && CurrentTime<=Lunch, !- A26 set Presence=1, !- A27 set arr_event = 1, !- A28 elseif CurrentTime>Lunch && CurrentTime<=Lunch+Vac2, !- A29 set Presence=0, !- A30 set dpt_event = 1, !- A31 elseif CurrentTime>Lunch+Vac2 && CurrentTime<=Coffee2, !- A32 set Presence=1, !- A33 set arr_event = 1, !- A34 elseif CurrentTime>Coffee2 && CurrentTime<=Coffee2+Vac1, !- A35 set Presence=0, !- A36 set dpt_event = 1, !- A37 elseif CurrentTime>Coffee2+Vac1 && CurrentTime<=Departure, !- A38 set Presence=1, !- A39 set arr_event = 1, !- A40 elseif CurrentTime>Departure, !- A41 set Presence=0, !- A42 set dpt_event = 1, !- A43 endif, !- A44 endif, !- A45 set occupant = presence; !- A46 !- Page et al.'s office occupancy model !- DOE's office occupancy profile was used as model input EnergyManagementSystem:Program, Occupancy_Page, !- Name if DayOfWeek<>7 && DayOfWeek<>1 , !- Program Line 1 if CurrentTime < 6, !- Program Line 2 set presence = 0, !- A4 elseif CurrentTime < 7, !- A5 set presence = 0.1, !- A6 elseif CurrentTime < 8, !- A7 set presence = 0.2, !- A8 elseif CurrentTime < 12, !- A9 set presence = 0.9, !- A10 elseif CurrentTime < 13, !- A11 set presence = 0.5, !- A12 elseif CurrentTime < 17, !- A13 set presence = 0.95, !- A14 elseif CurrentTime < 18, !- A15 set presence = 0.7, !- A16 elseif CurrentTime < 20, !- A17 set presence = 0.4, !- A18 elseif CurrentTime < 22, !- A19 set presence = 0.1, !- A20 elseif CurrentTime < 24, !- A21 set presence = 0.05, !- A22 endif, !- A23 endif, !- A24 if DayOfWeek<>7 && DayOfWeek<>1 , !- Program Line 1 if CurrentTime + ZoneTimeStep < 6, !- Program Line 2 set pre_next_ts = 0, !- A4 elseif CurrentTime + ZoneTimeStep < 7, !- A5 set pre_next_ts = 0.1, !- A6 elseif CurrentTime + ZoneTimeStep < 8, !- A7 set pre_next_ts = 0.2, !- A8 elseif CurrentTime + ZoneTimeStep < 12, !- A9 set pre_next_ts = 0.9, !- A10 elseif CurrentTime + ZoneTimeStep < 13, !- A11 set pre_next_ts = 0.5, !- A12 elseif CurrentTime + ZoneTimeStep < 17, !- A13 set pre_next_ts = 0.95, !- A14 elseif CurrentTime + ZoneTimeStep < 18, !- A15 set pre_next_ts = 0.7, !- A16 elseif CurrentTime + ZoneTimeStep < 20, !- A17 set pre_next_ts = 0.4, !- A18 elseif CurrentTime + ZoneTimeStep < 22, !- A19 set pre_next_ts = 0.1, !- A20 elseif CurrentTime + ZoneTimeStep < 24, !- A21 set pre_next_ts = 0.05, !- A22 endif, !- A23 endif, !- A24 set arr_event = 0, !- A25 set dpt_event = 0, !- A26 set T01 = (A36-1)/(A36+1)*presence+pre_next_ts, !- A27 set T11 = (presence-1)/presence*T01+pre_next_ts/presence, !- A28 if Num_People == 0, !- A29 set R=@RandomUniform 0 1,!- A30 if T01 > R, !- A31 set Occupant = 1, !- A32 set arr_event = 1, !- A33 set arrival = currenttime, endif, !- A34 endif, !- A35 if Num_People == 1, !- A36 set R=@RandomUniform 0 1,!- A37 if (1-T11) > R, !- A38 set Occupant = 0, !- A39 set dpt_event = 1, !- A40 endif, !- A41 endif; !- A42 !- Hunt's light switch on model !- Note that an assumption was made that actions are permitted at arrival !- -- including intermediate arrivals -- timesteps. EnergyManagementSystem:Program, LightSwitchOnHunt, !- Name set handle=A1+B1*daylight, !- Program Line 1 set handle=@Exp handle, !- Program Line 2 set handle=handle/(handle+1), !- A4 if arr_event==1, !- A5 if handle>R, !- A6 set Light=1, !- A7 endif, !- A8 endif; !- A9 !- Reinhart's light switch on model EnergyManagementSystem:Program, LightSwitchOnReinhart, !- Name if arr_event == 1, !- Program Line 1 set handle=A2+B2*daylight, !- Program Line 2 set handle=@Exp handle, !- A4 set handle=handle/(handle+1), !- A5 set R=@RandomUniform 0 1,!- A6 if handle>R, !- A7 set Light=1, !- A8 endif, !- A9 endif, !- A10 if Num_People>0 && daylight<240, !- A11 set handle=A3+B3*daylight, !- A12 set handle=@Exp handle, !- A13 set handle=handle/(handle+1), !- A14 set R=@RandomUniform 0 1,!- A15 if handle>R, !- A16 set Light=1, !- A17 endif, !- A18 endif; !- A19 !- Boyce et al.'s light switch off model. An assumption was made that the simulated !- occupants can only turn off at departure (including intermediate departures) time-steps EnergyManagementSystem:Program, Light_Off_Boyce, !- Name set handle=A5+B5*daylight, !- Program Line 1 set handle=@Exp handle, !- Program Line 2 set handle=handle/(handle+1), !- A4 set R=@RandomUniform 0 1,!- A5 if dpt_event==1, !- A6 if handle>R, !- A7 set Light=0, !- A8 endif, !- A9 endif; !- A10 !- Reinhart's light switch off model EnergyManagementSystem:Program, LightSwitchOffReinhart, !- Name if CurrentTime<17, !- Program Line 1 set handle=A4+B4*C2, !- Program Line 2 else, !- A4 set handle=A4+B4*12*60, !- A5 endif, !- A6 set handle=@Exp handle, !- A7 set handle=handle/(handle+1), !- A8 set R=@RandomUniform 0 1,!- A9 if dpt_event==1, !- A10 if handle>R, !- A11 set Light=0, !- A12 endif, !- A13 endif; !- A14 !- Newsham's blinds use model EnergyManagementSystem:Program, Blind_Newsham, !- Name if Num_People>0, !- Program Line 1 set handle=A7+B7*Beam_SolRad, !- Program Line 2 set handle=@Exp handle, !- A4 set handle=handle/(handle+1), !- A5 set R=@RandomUniform 0 1,!- A6 if handle>R, !- A7 set Blinds=1, !- A8 endif, !- A9 endif, !- A10 if current_time>arrival && current_time0, !- Program Line 2 set handle=A6+B6*(handle+0.0001), !- A4 set handle=@Exp handle, !- A5 set handle=handle/(handle+1), !- A6 set R=@RandomUniform 0 1,!- A7 if handle>R, !- A8 set Blinds=1, !- A9 endif, !- A10 endif, !- A11 if current_time>arrival && current_timearrival && current_timeR, !- A8 set handle=A28+B35*E_glob+B36*unshadedfrac, !- A9 set handle=@Exp handle, !- A10 set handle=handle/(handle+1), !- A11 set R=@RandomUniform 0 1,!- A12 if handle>R, !- A13 set Blinds=1, !- A14 else, !- A15 set lambda=1.522*blinds-2.294, !- A16 set lambda=@Exp lambda, !- A17 set db = @RandomUniform 0 1, !- A18 set db = @ln (1-db), !- A19 set lambda = (lambda^alpha)*(0-1), !- A20 set db=db*lambda, !- A21 set db=db^(1/alpha), !- A22 set db=db*100, !- A23 set remainder=@Mod db 25,!- A24 set db=(db-remainder)/100, !- A25 set db=@max 0.25 db, !- A58 set blinds=@min blinds+db 1, !- A29 endif, !- A30 endif, !- A31 endif, !- A32 if Num_People == 1, !- A33 set handle=A27+B33*daylight+B34*unshadedfrac, !- A34 set handle=@Exp handle, !- A35 set handle=handle/(handle+1), !- A36 set R=@RandomUniform 0 1,!- A37 if handle>R, !- A38 set handle=A28+B35*E_glob+B36*unshadedfrac, !- A39 set handle=@Exp handle, !- A40 set handle=handle/(handle+1), !- A41 set R=@RandomUniform 0 1,!- A42 if handle>R, !- A43 set Blinds=1, !- A44 else, !- A45 set lambda=1.522*blinds-2.294, !- A46 set lambda=@Exp lambda, !- A47 set db = @RandomUniform 0 1, !- A48 set db = @ln (1-db), !- A49 set lambda = (lambda^alpha)*(0-1), !- A50 set db=db*lambda, !- A51 set db=db^(1/alpha), !- A52 set db=db*100, !- A53 set remainder=@Mod db 25,!- A54 set db=(db-remainder)/100, !- A55 set db=@max 0.25 db, !- A58 set blinds=@min blinds+db 1, !- A59 endif, !- A60 endif, !- A61 endif, !- A62 if current_time>arrival && current_timeR, !- A68 set handle=A31+B41*E_glob+B42*unshadedfrac, !- A69 set handle=@Exp handle, !- A70 set handle=handle/(handle+1), !- A71 set R=@RandomUniform 0 1,!- A72 if handle>R, !- A73 set Blinds=0, !- A74 else, !- A75 set db = @RandomUniform 0 1, !- A76 set db=db*100, !- A53 set remainder=@Mod db 25,!- A54 set db=(db-remainder)/100, !- A55 set blinds=@max blinds-db 0, !- A77 endif, !- A78 endif, !- A79 endif, !- A80 if Num_People == 1, !- A81 set handle=A30+B39*daylight+B40*unshadedfrac, !- A82 set handle=@Exp handle, !- A83 set handle=handle/(handle+1), !- A84 set R=@RandomUniform 0 1,!- A85 if handle>R, !- A86 set handle=A31+B41*E_glob+B42*unshadedfrac, !- A87 set handle=@Exp handle, !- A88 set handle=handle/(handle+1), !- A89 set R=@RandomUniform 0 1,!- A90 if handle>R, !- A91 set Blinds=0, !- A92 else, !- A93 set db = @RandomUniform 0 1, !- A94 set db=db*100, !- A53 set remainder=@Mod db 25,!- A54 set db=(db-remainder)/100, !- A55 set blinds=@max blinds-db 0, !- A95 endif, !- A96 endif, !- A97 endif, !- A98 if Blinds==0, !- A99 set BottomShade=0, !- A100 set MidBottomShade=0, !- A101 set MidTopShade=0, !- A102 set TopShade=0, !- A103 elseif Blinds==0.25, !- A104 set BottomShade=0, !- A105 set MidBottomShade=0, !- A106 set MidTopShade=0, !- A107 set TopShade=1, !- A108 elseif Blinds==0.5, !- A109 set BottomShade=0, !- A110 set MidBottomShade=0, !- A111 set MidTopShade=1, !- A112 set TopShade=1, !- A113 elseif Blinds==0.75, !- A114 set BottomShade=0, !- A115 set MidBottomShade=1, !- A116 set MidTopShade=1, !- A117 set TopShade=1, !- A118 elseif Blinds==1, !- A119 set BottomShade=1, !- A120 set MidBottomShade=1, !- A121 set MidTopShade=1, !- A122 set TopShade=1, !- A123 endif; !- A124 !- Yun et al.'s window use model EnergyManagementSystem:Program, Window_Yun, !- Name if Num_People>0, !- Program Line 1 if arr_event==1, !- Program Line 2 set handle=A32+B43*Tin+B44*Tout, !- A4 set handle=@Exp handle, !- A5 set handle=handle/(handle+1), !- A6 set R=@RandomUniform 0 1,!- A7 if handle>R && Tout>15, !- A8 set Window=1, !- A9 endif, !- A10 else, !- A11 set handle=A33+B45*Tin, !- A12 set handle=@Exp handle, !- A13 set handle=handle/(handle+1), !- A14 set R=@RandomUniform 0 1,!- A15 if handle>R && Tout>15, !- A16 set Window=1, !- A17 endif, !- A18 endif, !- A19 endif, !- A20 if Num_People>0, !- A21 set handle=A34+B46*Tin, !- A22 set R=@RandomUniform 0 1,!- A23 if handle>R && Tin<30, !- A24 set Window=0, !- A25 endif, !- A26 endif; !- A27 !- Rijal et al.'s window use model EnergyManagementSystem:Program, Window_Rijal, !- Name if Num_People>0 && Tout>15, !- Program Line 1 if PMV>0.5, !- Program Line 2 set handle=A14+B14*Tin+B17*Tout, !- A4 set handle=@Exp handle, !- A5 set handle=handle/(handle+1), !- A6 set R=@RandomUniform 0 1,!- A7 if handle>R, !- A8 set Window=1, !- A9 endif, !- A10 endif, !- A11 endif, !- A12 if Num_People>0, !- A13 if PMV<0-0.5, !- A14 set handle=A17+B23*Tin+B26*Tout, !- A15 set handle=@Exp handle, !- A16 set handle=handle/(handle+1), !- A17 set R=@RandomUniform 0 1,!- A18 if handle>R, !- A19 set Window=0, !- A20 endif, !- A21 endif, !- A22 endif; !- A23 !- Haldi and Robinson's Bernoulli window use model EnergyManagementSystem:Program, Window_Haldi_2008, !- Name if Num_People> 0, !- Program Line 1 set handle=A35*Tout+B47, !- Program Line 2 set handle=@Exp handle, !- A4 set handle=handle/(handle+1), !- A5 set R=@RandomUniform 0 1,!- A6 if handle>R && Tout > 15,!- A7 set Window=1, !- A8 else, !- A9 set Window = 0, !- A10 endif, !- A11 endif; !- A12 !- Haldi and Robinson's Markov window use model EnergyManagementSystem:Program, Window_Haldi_2009, !- Name Wind_Cur_State = Window, if Wind_Cur_State == 0, if arr_event==1 && Tout>15, !- Program Line 1 set handle=A15+B15*Tin+B18*Tout+B21*Rain, !- Program Line 2 set handle=@Exp handle, !- A4 set handle=handle/(handle+1), !- A5 set R=@RandomUniform 0 1,!- A6 if handle>R, !- A7 set Window=1, !- A8 endif, !- A9 endif, !- A10 if Num_People>0, !- A11 set handle=A16+B16*Tin+B19*Tout+B22*Rain, !- A12 set handle=@Exp handle, !- A13 set handle=handle/(handle+1), !- A14 set R=@RandomUniform 0 1,!- A15 if handle>R, !- A16 set Window=1, !- A17 endif, !- A18 endif, !- A19 else, if arr_event==1, !- A20 set handle=A18+B24*Tin+B27*Tout, !- A21 set handle=@Exp handle, !- A22 set handle=handle/(handle+1), !- A23 set R=@RandomUniform 0 1,!- A24 if handle>R, !- A25 set Window=0, !- A26 endif, !- A27 endif, !- A28 if dpt_event==1, !- A20 set handle=A37+B48*Tin+B49*Tout, !- A21 set handle=@Exp handle, !- A22 set handle=handle/(handle+1), !- A23 set R=@RandomUniform 0 1,!- A24 if handle>R, !- A25 set Window=0, !- A26 endif, !- A27 endif, !- A28 if Num_People>0, !- A29 set handle=A19+B25*Tin+B28*Tout, !- A30 set handle=@Exp handle, !- A31 set handle=handle/(handle+1), !- A32 set R=@RandomUniform 0 1,!- A33 if handle>R, !- A34 set Window=0, !- A35 endif, !- A36 endif, !- A37 endif;