Index: palm/trunk/SOURCE/indoor_model_mod.f90
===================================================================
--- palm/trunk/SOURCE/indoor_model_mod.f90	(revision 4246)
+++ palm/trunk/SOURCE/indoor_model_mod.f90	(revision 4267)
@@ -26,4 +26,8 @@
 ! -----------------
 ! $Id$
+! Bugfix in initialization, some indices to access building_pars where wrong.
+! Introduction of seasonal parameters.
+! 
+! 4246 2019-09-30 09:27:52Z pavelkrc
 ! 
 ! 
@@ -121,4 +125,8 @@
     USE netcdf_data_input_mod,                                                 &
         ONLY:  building_id_f, building_type_f
+
+    USE palm_date_time_mod,                                                    &
+        ONLY:  get_date_time, northward_equinox, seconds_per_hour,             &
+               southward_equinox
 
     USE surface_mod,                                                           &
@@ -273,6 +281,40 @@
     REAL(wp), PARAMETER ::  params_solar_protection  = 300.0_wp    !< [W/m2] chap. G.5.3.1 sun protection closed, if the radiation 
                                                                    !< on facade exceeds this value
-
-    
+!
+!-- Definition of seasonal parameters, summer and winter, for different building types
+    REAL(wp), DIMENSION(0:1,1:7) ::  summer_pars = RESHAPE( (/               & ! building_type 1
+                                          0.5_wp,                              & ! basical airflow without occupancy of the room
+                                          2.0_wp,                              & ! additional airflow depend of occupancy of the room
+                                          0.5_wp,                              & ! building_type 2: basical airflow without occupancy of the room
+                                          2.0_wp,                              & ! additional airflow depend of occupancy of the room
+                                          0.8_wp,                              & ! building_type 3: basical airflow without occupancy of the room
+                                          2.0_wp,                              & ! additional airflow depend of occupancy of the room
+                                          0.1_wp,                              & ! building_type 4: basical airflow without occupancy of the room
+                                          1.5_wp,                              & ! additional airflow depend of occupancy of the room
+                                          0.1_wp,                              & ! building_type 5: basical airflow without occupancy of the room
+                                          1.5_wp,                              & ! additional airflow depend of occupancy of the room
+                                          0.1_wp,                              & ! building_type 6: basical airflow without occupancy of the room
+                                          1.5_wp,                              & ! additional airflow depend of occupancy of the room
+                                          0.1_wp,                              & ! building_type 7: basical airflow without occupancy of the room
+                                          1.5_wp                               & ! additional airflow depend of occupancy of the room
+                                                           /), (/ 2, 7 /) )
+
+    REAL(wp), DIMENSION(0:1,1:7) ::  winter_pars = RESHAPE( (/               & ! building_type 1
+                                          0.1_wp,                              & ! basical airflow without occupancy of the room
+                                          0.5_wp,                              & ! additional airflow depend of occupancy of the room
+                                          0.1_wp,                              & ! building_type 2: basical airflow without occupancy of the room
+                                          0.5_wp,                              & ! additional airflow depend of occupancy of the room
+                                          0.1_wp,                              & ! building_type 3: basical airflow without occupancy of the room
+                                          0.5_wp,                              & ! additional airflow depend of occupancy of the room
+                                          0.1_wp,                              & ! building_type 4: basical airflow without occupancy of the room
+                                          1.5_wp,                              & ! additional airflow depend of occupancy of the room
+                                          0.1_wp,                              & ! building_type 5: basical airflow without occupancy of the room
+                                          1.5_wp,                              & ! additional airflow depend of occupancy of the room
+                                          0.1_wp,                              & ! building_type 6: basical airflow without occupancy of the room
+                                          1.5_wp,                              & ! additional airflow depend of occupancy of the room
+                                          0.1_wp,                              & ! building_type 7: basical airflow without occupancy of the room
+                                          1.5_wp                               & ! additional airflow depend of occupancy of the room
+                                                           /), (/ 2, 7 /) )
+
     SAVE
 
@@ -424,5 +466,5 @@
 
     USE control_parameters,                                                    &
-        ONLY:  message_string
+        ONLY:  message_string, time_since_reference_point
 
     USE indices,                                                               &
@@ -442,12 +484,13 @@
     IMPLICIT NONE
 
-    INTEGER(iwp) ::  bt   !< local building type
-    INTEGER(iwp) ::  i    !< running index along x-direction
-    INTEGER(iwp) ::  j    !< running index along y-direction
-    INTEGER(iwp) ::  k    !< running index along z-direction
-    INTEGER(iwp) ::  l    !< running index for surface-element orientation
-    INTEGER(iwp) ::  m    !< running index surface elements
-    INTEGER(iwp) ::  n    !< building index
-    INTEGER(iwp) ::  nb   !< building index
+    INTEGER(iwp) ::  bt          !< local building type
+    INTEGER(iwp) ::  day_of_year !< day of the year
+    INTEGER(iwp) ::  i           !< running index along x-direction
+    INTEGER(iwp) ::  j           !< running index along y-direction
+    INTEGER(iwp) ::  k           !< running index along z-direction
+    INTEGER(iwp) ::  l           !< running index for surface-element orientation
+    INTEGER(iwp) ::  m           !< running index surface elements
+    INTEGER(iwp) ::  n           !< building index
+    INTEGER(iwp) ::  nb          !< building index
 
     INTEGER(iwp), DIMENSION(:), ALLOCATABLE ::  build_ids           !< building IDs on entire model domain
@@ -927,17 +970,15 @@
 !-- In a second step initialize with building tpyes from static input file, 
 !-- where building types can be individual for each building.
-    buildings(:)%lambda_layer3       = building_pars(63,building_type)
-    buildings(:)%s_layer3            = building_pars(57,building_type)
+    buildings(:)%lambda_layer3       = building_pars(31,building_type)
+    buildings(:)%s_layer3            = building_pars(44,building_type)
     buildings(:)%f_c_win             = building_pars(119,building_type)
     buildings(:)%g_value_win         = building_pars(120,building_type)    
-    buildings(:)%u_value_win         = building_pars(121,building_type)    
-    buildings(:)%air_change_low      = building_pars(122,building_type)    
-    buildings(:)%air_change_high     = building_pars(123,building_type)    
+    buildings(:)%u_value_win         = building_pars(121,building_type)       
     buildings(:)%eta_ve              = building_pars(124,building_type)    
     buildings(:)%factor_a            = building_pars(125,building_type)    
     buildings(:)%factor_c            = building_pars(126,building_type)
     buildings(:)%lambda_at           = building_pars(127,building_type)    
-    buildings(:)%theta_int_h_set     = building_pars(118,building_type)    
-    buildings(:)%theta_int_c_set     = building_pars(117,building_type)
+    buildings(:)%theta_int_h_set     = building_pars(13,building_type)    
+    buildings(:)%theta_int_c_set     = building_pars(12,building_type)
     buildings(:)%q_h_max             = building_pars(128,building_type)    
     buildings(:)%q_c_max             = building_pars(129,building_type)          
@@ -948,4 +989,18 @@
     buildings(:)%params_waste_heat_h = building_pars(134,building_type)
     buildings(:)%params_waste_heat_c = building_pars(135,building_type)
+!
+!-- Initialize seasonal dependent parameters, depending on day of the year.
+!-- First, calculated day of the year. 
+    CALL get_date_time( time_since_reference_point, day_of_year = day_of_year )
+!
+!-- Summer is defined in between northward- and southward equinox. 
+    IF ( day_of_year >= northward_equinox  .AND.                               &
+         day_of_year <= southward_equinox )  THEN
+       buildings(:)%air_change_low      = summer_pars(0,building_type)    
+       buildings(:)%air_change_high     = summer_pars(1,building_type)
+    ELSE
+       buildings(:)%air_change_low      = winter_pars(0,building_type)    
+       buildings(:)%air_change_high     = winter_pars(1,building_type)
+    ENDIF
 !
 !-- Initialize ventilaation load. Please note, building types > 7 are actually
@@ -979,17 +1034,15 @@
                  bt = building_type_f%var(j,i)
                  
-                 buildings(nb)%lambda_layer3       = building_pars(63,bt)
-                 buildings(nb)%s_layer3            = building_pars(57,bt)
+                 buildings(nb)%lambda_layer3       = building_pars(31,bt)
+                 buildings(nb)%s_layer3            = building_pars(44,bt)
                  buildings(nb)%f_c_win             = building_pars(119,bt)
                  buildings(nb)%g_value_win         = building_pars(120,bt)    
                  buildings(nb)%u_value_win         = building_pars(121,bt)    
-                 buildings(nb)%air_change_low      = building_pars(122,bt)    
-                 buildings(nb)%air_change_high     = building_pars(123,bt)    
                  buildings(nb)%eta_ve              = building_pars(124,bt)    
                  buildings(nb)%factor_a            = building_pars(125,bt)    
                  buildings(nb)%factor_c            = building_pars(126,bt)
                  buildings(nb)%lambda_at           = building_pars(127,bt)    
-                 buildings(nb)%theta_int_h_set     = building_pars(118,bt)    
-                 buildings(nb)%theta_int_c_set     = building_pars(117,bt)
+                 buildings(nb)%theta_int_h_set     = building_pars(13,bt)    
+                 buildings(nb)%theta_int_c_set     = building_pars(12,bt)
                  buildings(nb)%q_h_max             = building_pars(128,bt)    
                  buildings(nb)%q_c_max             = building_pars(129,bt)          
@@ -1000,4 +1053,14 @@
                  buildings(nb)%params_waste_heat_h = building_pars(134,bt)
                  buildings(nb)%params_waste_heat_c = building_pars(135,bt)
+
+              IF ( day_of_year >= northward_equinox  .AND.                     &
+                   day_of_year <= southward_equinox )  THEN
+                 buildings(nb)%air_change_low      = summer_pars(0,bt)    
+                 buildings(nb)%air_change_high     = summer_pars(1,bt)
+              ELSE
+                 buildings(nb)%air_change_low      = winter_pars(0,bt)    
+                 buildings(nb)%air_change_high     = winter_pars(1,bt)
+              ENDIF
+
 !
 !--              Initialize ventilaation load. Please note, building types > 7 
@@ -1039,6 +1102,6 @@
           du_tmp = 1.0_wp / u_tmp
           
-          buildings(nb)%h_es = ( du_tmp / ( du_tmp - ( 1.0_wp / h_is ) ) ) *   &
-                                 u_tmp   
+          buildings(nb)%h_es = 1.0_wp / ( du_tmp - ( 1.0_wp / h_is ) )
+
        ENDIF
     ENDDO
@@ -1078,7 +1141,4 @@
     USE grid_variables,                                                        &
         ONLY:  dx, dy
-
-    USE palm_date_time_mod,                                                    &
-        ONLY:  get_date_time, seconds_per_hour
 
     USE pegrid
@@ -1124,10 +1184,8 @@
 !--       Residental Building, panel WBS 70    
           IF ( buildings(nb)%ventilation_int_loads == 1 )  THEN
-             IF ( time_utc_hour >= 6.0_wp  .AND.  time_utc_hour <= 8.0_wp )  THEN
+             IF ( time_utc_hour >= 8.0_wp  .AND.  time_utc_hour <= 18.0_wp )  THEN
+                schedule_d = 0
+             ELSE
                 schedule_d = 1
-             ELSEIF ( time_utc_hour >= 18.0_wp  .AND.  time_utc_hour <= 23.0_wp )  THEN
-                schedule_d = 1
-             ELSE
-                schedule_d = 0
              ENDIF
           ENDIF
