!> @file indoor_model_mod.f90 !--------------------------------------------------------------------------------! ! This file is part of the PALM model system. ! ! PALM is free software: you can redistribute it and/or modify it under the ! terms of the GNU General Public License as published by the Free Software ! Foundation, either version 3 of the License, or (at your option) any later ! version. ! ! PALM is distributed in the hope that it will be useful, but WITHOUT ANY ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR ! A PARTICULAR PURPOSE. See the GNU General Public License for more details. ! ! You should have received a copy of the GNU General Public License along with ! PALM. If not, see . ! ! Copyright 2018-2018 Leibniz Universitaet Hannover ! Copyright 2018-2018 Hochschule Offenburg !--------------------------------------------------------------------------------! ! ! Current revisions: ! ----------------- ! ! ! Former revisions: ! ----------------- ! $Id: indoor_model_mod.f90 3597 2018-12-04 08:40:18Z schwenkel $ ! Renamed t_surf_10cm to pt_10cm ! ! 3593 2018-12-03 13:51:13Z kanani ! Replace degree symbol by degree_C ! ! 3524 2018-11-14 13:36:44Z raasch ! working precision added to make code Fortran 2008 conform ! ! 3469 2018-10-30 20:05:07Z kanani ! Initial revision (tlang, suehring, kanani, srissman) ! ! ! ! Authors: ! -------- ! @author Tobias Lang ! @author Jens Pfafferott ! @author Farah Kanani-Suehring ! @author Matthias Suehring ! @author Sascha Rißmann ! ! ! Description: ! ------------ !> !> Module for Indoor Climate Model (ICM) !> The module is based on the DIN EN ISO 13790 with simplified hour-based procedure. !> This model is a equivalent circuit diagram of a three-point RC-model (5R1C). !> This module differ between indoor-air temperature an average temperature of indoor surfaces which make it prossible to determine thermal comfort !> the heat transfer between indoor and outdoor is simplified !> @todo Replace window_area_per_facade by %frac(1,m) for window !> @todo emissivity change for window blinds if solar_protection_on=1 !> @todo write datas in netcdf file as output data !> @todo reduce the building volume with netto ground surface to take respect costruction areas like walls and ceilings. Have effect on factor_a, factor_c, airchange and lambda_at !> !> @note Do we allow use of integer flags, or only logical flags? (concerns e.g. cooling_on, heating_on) !> @note How to write indoor temperature output to pt array? !> !> @bug !------------------------------------------------------------------------------! MODULE indoor_model_mod USE control_parameters, & ONLY: initializing_actions USE kinds USE surface_mod, & ONLY: surf_usm_h, surf_usm_v IMPLICIT NONE ! !-- Define data structure for buidlings. TYPE build INTEGER(iwp) :: id !< building ID INTEGER(iwp) :: kb_min !< lowest vertical index of a building INTEGER(iwp) :: kb_max !< highest vertical index of a building INTEGER(iwp) :: num_facades_per_building_h !< total number of horizontal facades elements INTEGER(iwp) :: num_facades_per_building_h_l !< number of horizontal facade elements on local subdomain INTEGER(iwp) :: num_facades_per_building_v !< total number of vertical facades elements INTEGER(iwp) :: num_facades_per_building_v_l !< number of vertical facade elements on local subdomain INTEGER(iwp), DIMENSION(:), ALLOCATABLE :: l_v !< index array linking surface-element orientation index !< for vertical surfaces with building INTEGER(iwp), DIMENSION(:), ALLOCATABLE :: m_h !< index array linking surface-element index for !< horizontal surfaces with building INTEGER(iwp), DIMENSION(:), ALLOCATABLE :: m_v !< index array linking surface-element index for !< vertical surfaces with building INTEGER(iwp), DIMENSION(:), ALLOCATABLE :: num_facade_h !< number of horizontal facade elements per buidling !< and height level INTEGER(iwp), DIMENSION(:), ALLOCATABLE :: num_facade_v !< number of vertical facades elements per buidling !< and height level LOGICAL :: on_pe = .FALSE. !< flag indicating whether a building with certain ID is on local subdomain REAL(wp), DIMENSION(:), ALLOCATABLE :: t_in !< mean building indoor temperature, height dependent REAL(wp), DIMENSION(:), ALLOCATABLE :: t_in_l !< mean building indoor temperature on local subdomain, height dependent REAL(wp), DIMENSION(:), ALLOCATABLE :: volume !< total building volume, height dependent REAL(wp), DIMENSION(:), ALLOCATABLE :: vol_frac !< fraction of local on total building volume, height dependent REAL(wp), DIMENSION(:), ALLOCATABLE :: vpf !< building volume volume per facade element, height dependent END TYPE build TYPE(build), DIMENSION(:), ALLOCATABLE :: buildings !< building array INTEGER(iwp) :: num_build !< total number of buildings in domain REAL(wp) :: volume_fraction REAL(wp), DIMENSION(:), ALLOCATABLE :: t_in !< dummy array for indoor temperature for the !< total building volume at each discrete height level REAL(wp), DIMENSION(:), ALLOCATABLE :: t_in_l !< dummy array for indoor temperature for the !< local building volume fraction at each discrete height level ! !-- Declare all global variables within the module INTEGER(iwp) :: building_type = 1 !< namelist parameter with !< X1=construction year (cy) 1950, X2=cy 2000, X3=cy 2050 !< R=Residental building, O=Office, RW=Enlarged Windows, P=Panel type (Plattenbau) WBS 70, H=Hospital (in progress), I=Industrial halls (in progress), S=Special Building (in progress) !< (0=R1, 1=R2, 2=R3, 3=O1, 4=O2, 5=O3,...) INTEGER(iwp) :: cooling_on !< Indoor cooling flag (0=off, 1=on) INTEGER(iwp) :: heating_on !< Indoor heating flag (0=off, 1=on) INTEGER(iwp) :: solar_protection_off !< Solar protection off INTEGER(iwp) :: solar_protection_on !< Solar protection on REAL(wp) :: air_change_high !< [1/h] air changes per time_utc_hour REAL(wp) :: air_change_low !< [1/h] air changes per time_utc_hour REAL(wp) :: eff_mass_area !< [m²] the effective mass-related area REAL(wp) :: floor_area_per_facade !< [m²] net floor area (Sum of all floors) REAL(wp) :: total_area ! CORRECT?) REAL(wp) :: qint_high !< [W/m2] internal heat gains, option Database qint_0-23 REAL(wp) :: qint_low !< [W/m2] internal heat gains, option Database qint_0-23 REAL(wp) :: phi_c_max !< [W] Max. Cooling capacity (negative) REAL(wp) :: phi_h_max !< [W] Max. Heating capacity (negative) REAL(wp) :: phi_hc_nd ! Initialization of the indoor model. !> Static information are calculated here, e.g. building parameters and !> geometrical information, everything that doesn't change in time. ! !-- Input values !-- Input datas from Palm, M4 ! i_global --> net_sw_in !global radiation [W/m2] ! theta_e --> pt(k,j,i) !undisturbed outside temperature, 1. PALM volume, for windows ! theta_sup = theta_f --> surf_usm_h%pt_10cm(m) ! surf_usm_v(l)%pt_10cm(m) !Air temperature, facade near (10cm) air temperature from 1. Palm volume ! theta_node --> t_wall_h(nzt_wall,m) ! t_wall_v(l)%t(nzt_wall,m) !Temperature of innermost wall layer, for opaque wall !------------------------------------------------------------------------------! SUBROUTINE im_init USE arrays_3d, & ONLY: dzw USE control_parameters, & ONLY: message_string USE indices, & ONLY: nxl, nxr, nyn, nys, nzb, nzt, wall_flags_0 USE grid_variables, & ONLY: dx, dy USE netcdf_data_input_mod, & ONLY: building_id_f USE pegrid USE surface_mod, & ONLY: surf_usm_h, surf_usm_v USE urban_surface_mod, & ONLY: building_pars, building_type IMPLICIT NONE INTEGER(iwp) :: fa !< running index for facade elements of each building 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 INTEGER(iwp), DIMENSION(:), ALLOCATABLE :: build_ids_final !< building IDs on entire model domain, !< multiple occurences are sorted out INTEGER(iwp), DIMENSION(:), ALLOCATABLE :: build_ids_final_tmp !< temporary array used for resizing INTEGER(iwp), DIMENSION(:), ALLOCATABLE :: build_ids_l !< building IDs on local subdomain INTEGER(iwp), DIMENSION(:), ALLOCATABLE :: build_ids_l_tmp !< temporary array used to resize array of building IDs INTEGER(iwp), DIMENSION(:), ALLOCATABLE :: displace_dum !< displacements of start addresses, used for MPI_ALLGATHERV INTEGER(iwp), DIMENSION(:), ALLOCATABLE :: k_max_l !< highest vertical index of a building on subdomain INTEGER(iwp), DIMENSION(:), ALLOCATABLE :: k_min_l !< lowest vertical index of a building on subdomain INTEGER(iwp), DIMENSION(:), ALLOCATABLE :: n_fa !< counting array INTEGER(iwp), DIMENSION(:), ALLOCATABLE :: num_facades_h !< dummy array used for summing-up total number of !< horizontal facade elements INTEGER(iwp), DIMENSION(:), ALLOCATABLE :: num_facades_v !< dummy array used for summing-up total number of !< vertical facade elements INTEGER(iwp), DIMENSION(:), ALLOCATABLE :: receive_dum_h !< dummy array used for MPI_ALLREDUCE INTEGER(iwp), DIMENSION(:), ALLOCATABLE :: receive_dum_v !< dummy array used for MPI_ALLREDUCE INTEGER(iwp), DIMENSION(0:numprocs-1) :: num_buildings !< number of buildings with different ID on entire model domain INTEGER(iwp), DIMENSION(0:numprocs-1) :: num_buildings_l !< number of buildings with different ID on local subdomain REAL(wp), DIMENSION(:), ALLOCATABLE :: local_weight !< dummy representing fraction of local on total building volume, !< height dependent REAL(wp), DIMENSION(:), ALLOCATABLE :: volume !< total building volume at each discrete height level REAL(wp), DIMENSION(:), ALLOCATABLE :: volume_l !< total building volume at each discrete height level, !< on local subdomain ! !-- Initializing of indoor model is only possible if buildings can be !-- distinguished by their IDs. IF ( .NOT. building_id_f%from_file ) THEN message_string = 'Indoor model requires information about building_id' CALL message( 'im_init', 'PA0999', 1, 2, 0, 6, 0 ) ENDIF ! !-- Determine number of different building IDs on local subdomain. num_buildings_l = 0 num_buildings = 0 ALLOCATE( build_ids_l(1) ) DO i = nxl, nxr DO j = nys, nyn IF ( building_id_f%var(j,i) /= building_id_f%fill ) THEN IF ( num_buildings_l(myid) > 0 ) THEN IF ( ANY( building_id_f%var(j,i) .EQ. build_ids_l ) ) THEN CYCLE ELSE num_buildings_l(myid) = num_buildings_l(myid) + 1 ! !-- Resize array with different local building ids ALLOCATE( build_ids_l_tmp(1:SIZE(build_ids_l)) ) build_ids_l_tmp = build_ids_l DEALLOCATE( build_ids_l ) ALLOCATE( build_ids_l(1:num_buildings_l(myid)) ) build_ids_l(1:num_buildings_l(myid)-1) = & build_ids_l_tmp(1:num_buildings_l(myid)-1) build_ids_l(num_buildings_l(myid)) = building_id_f%var(j,i) DEALLOCATE( build_ids_l_tmp ) ENDIF ! !-- First occuring building id on PE ELSE num_buildings_l(myid) = num_buildings_l(myid) + 1 build_ids_l(1) = building_id_f%var(j,i) ENDIF ENDIF ENDDO ENDDO ! !-- Determine number of building IDs for the entire domain. (Note, building IDs !-- can appear multiple times as buildings might be distributed over several !-- PEs.) #if defined( __parallel ) CALL MPI_ALLREDUCE( num_buildings_l, num_buildings, numprocs, & MPI_INTEGER, MPI_SUM, comm2d, ierr ) #else num_buildings = num_buildings_l #endif ALLOCATE( build_ids(1:SUM(num_buildings)) ) ! !-- Gather building IDs. Therefore, first, determine displacements used !-- required for MPI_GATHERV call. ALLOCATE( displace_dum(0:numprocs-1) ) displace_dum(0) = 0 DO i = 1, numprocs-1 displace_dum(i) = displace_dum(i-1) + num_buildings(i-1) ENDDO #if defined( __parallel ) CALL MPI_ALLGATHERV( build_ids_l(1:num_buildings_l(myid)), & num_buildings(myid), & MPI_INTEGER, & build_ids, & num_buildings, & displace_dum, & MPI_INTEGER, & comm2d, ierr ) DEALLOCATE( displace_dum ) #else build_ids = build_ids_l #endif ! !-- Note: in parallel mode, building IDs can occur mutliple times, as !-- each PE has send its own ids. Therefore, sort out building IDs which !-- appear multiple times. num_build = 0 DO n = 1, SIZE(build_ids) IF ( ALLOCATED(build_ids_final) ) THEN IF ( ANY( build_ids(n) .EQ. build_ids_final ) ) THEN !FK: Warum ANY?, Warum .EQ.? --> s.o CYCLE ELSE num_build = num_build + 1 ! !-- Resize ALLOCATE( build_ids_final_tmp(1:num_build) ) build_ids_final_tmp(1:num_build-1) = build_ids_final(1:num_build-1) DEALLOCATE( build_ids_final ) ALLOCATE( build_ids_final(1:num_build) ) build_ids_final(1:num_build-1) = build_ids_final_tmp(1:num_build-1) build_ids_final(num_build) = build_ids(n) DEALLOCATE( build_ids_final_tmp ) ENDIF ELSE num_build = num_build + 1 ALLOCATE( build_ids_final(1:num_build) ) build_ids_final(num_build) = build_ids(n) ENDIF ENDDO ! !-- Allocate building-data structure array. Note, this is a global array !-- and all building IDs on domain are known by each PE. Further attributes, !-- e.g. height-dependent arrays, however, are only allocated on PEs where !-- the respective building is present (in order to reduce memory demands). ALLOCATE( buildings(1:num_build) ) ! !-- Store building IDs and check if building with certain ID is present on !-- subdomain. DO nb = 1, num_build buildings(nb)%id = build_ids_final(nb) IF ( ANY( building_id_f%var == buildings(nb)%id ) ) & buildings(nb)%on_pe = .TRUE. ENDDO ! !-- Determine the maximum vertical dimension occupied by each building. ALLOCATE( k_min_l(1:num_build) ) ALLOCATE( k_max_l(1:num_build) ) k_min_l = nzt + 1 k_max_l = 0 DO i = nxl, nxr DO j = nys, nyn IF ( building_id_f%var(j,i) /= building_id_f%fill ) THEN nb = MINLOC( ABS( buildings(:)%id - building_id_f%var(j,i) ), & DIM = 1 ) DO k = nzb+1, nzt+1 ! !-- Check if grid point belongs to a building. IF ( BTEST( wall_flags_0(k,j,i), 6 ) ) THEN k_min_l(nb) = MIN( k_min_l(nb), k ) k_max_l(nb) = MAX( k_max_l(nb), k ) ENDIF ENDDO ENDIF ENDDO ENDDO DO nb = 1, num_build #if defined( __parallel ) CALL MPI_ALLREDUCE( k_min_l(nb), buildings(nb)%kb_min, 1, MPI_INTEGER, & MPI_MIN, comm2d, ierr ) CALL MPI_ALLREDUCE( k_max_l(nb), buildings(nb)%kb_max, 1, MPI_INTEGER, & MPI_MAX, comm2d, ierr ) #else buildings(nb)%kb_min = k_min_l(nb) buildings(nb)%kb_max = k_max_l(nb) #endif ENDDO DEALLOCATE( k_min_l ) DEALLOCATE( k_max_l ) ! !-- Calculate building volume DO nb = 1, num_build ! !-- Allocate temporary array for summing-up building volume ALLOCATE( volume(buildings(nb)%kb_min:buildings(nb)%kb_max) ) ALLOCATE( volume_l(buildings(nb)%kb_min:buildings(nb)%kb_max) ) volume = 0.0_wp volume_l = 0.0_wp ! !-- Calculate building volume per height level on each PE where !-- these building is present. IF ( buildings(nb)%on_pe ) THEN ALLOCATE( buildings(nb)%volume(buildings(nb)%kb_min:buildings(nb)%kb_max) ) ALLOCATE( buildings(nb)%vol_frac(buildings(nb)%kb_min:buildings(nb)%kb_max) ) buildings(nb)%volume = 0.0_wp buildings(nb)%vol_frac = 0.0_wp IF ( ANY( building_id_f%var == buildings(nb)%id ) ) THEN DO i = nxl, nxr DO j = nys, nyn DO k = buildings(nb)%kb_min, buildings(nb)%kb_max IF ( building_id_f%var(j,i) /= building_id_f%fill ) & volume_l(k) = dx * dy * dzw(k) ENDDO ENDDO ENDDO ENDIF ENDIF ! !-- Sum-up building volume from all subdomains #if defined( __parallel ) CALL MPI_ALLREDUCE( volume_l, volume, SIZE(volume), MPI_REAL, MPI_SUM, & comm2d, ierr ) #else volume = volume_l #endif ! !-- Save total building volume as well as local fraction on volume on !-- building data structure. IF ( ALLOCATED( buildings(nb)%volume ) ) buildings(nb)%volume = volume ! !-- Determine fraction of local on total building volume IF ( buildings(nb)%on_pe ) buildings(nb)%vol_frac = volume_l / volume DEALLOCATE( volume ) DEALLOCATE( volume_l ) ENDDO ! !-- Allocate arrays for indoor temperature. DO nb = 1, num_build IF ( buildings(nb)%on_pe ) THEN ALLOCATE( buildings(nb)%t_in(buildings(nb)%kb_min:buildings(nb)%kb_max) ) ALLOCATE( buildings(nb)%t_in_l(buildings(nb)%kb_min:buildings(nb)%kb_max) ) buildings(nb)%t_in = 0.0_wp buildings(nb)%t_in_l = 0.0_wp ENDIF ENDDO ! !-- Allocate arrays for number of facades per height level. Distinguish between !-- horizontal and vertical facades. DO nb = 1, num_build IF ( buildings(nb)%on_pe ) THEN ALLOCATE( buildings(nb)%num_facade_h(buildings(nb)%kb_min:buildings(nb)%kb_max) ) ALLOCATE( buildings(nb)%num_facade_v(buildings(nb)%kb_min:buildings(nb)%kb_max) ) buildings(nb)%num_facade_h = 0 buildings(nb)%num_facade_v = 0 ENDIF ENDDO ! !-- Determine number of facade elements per building on local subdomain. !-- Distinguish between horizontal and vertical facade elements. ! !-- Horizontal facades buildings(:)%num_facades_per_building_h_l = 0 DO m = 1, surf_usm_h%ns ! !-- For the current facade element determine corresponding building index. !-- First, obtain j,j,k indices of the building. Please note the !-- offset between facade/surface element and building location (for !-- horizontal surface elements the horizontal offsets are zero). i = surf_usm_h%i(m) + surf_usm_h%ioff j = surf_usm_h%j(m) + surf_usm_h%joff k = surf_usm_h%k(m) + surf_usm_h%koff ! !-- Determine building index and check whether building is on PE nb = MINLOC( ABS( buildings(:)%id - building_id_f%var(j,i) ), DIM = 1 ) IF ( buildings(nb)%on_pe ) THEN ! !-- Count number of facade elements at each height level. buildings(nb)%num_facade_h(k) = buildings(nb)%num_facade_h(k) + 1 ! !-- Moreover, sum up number of local facade elements per building. buildings(nb)%num_facades_per_building_h_l = & buildings(nb)%num_facades_per_building_h_l + 1 ENDIF ENDDO ! !-- Vertical facades buildings(:)%num_facades_per_building_v_l = 0 DO l = 0, 3 DO m = 1, surf_usm_v(l)%ns ! !-- For the current facade element determine corresponding building index. !-- First, obtain j,j,k indices of the building. Please note the !-- offset between facade/surface element and building location (for !-- vertical surface elements the vertical offsets are zero). i = surf_usm_v(l)%i(m) + surf_usm_v(l)%ioff j = surf_usm_v(l)%j(m) + surf_usm_v(l)%joff k = surf_usm_v(l)%k(m) + surf_usm_v(l)%koff nb = MINLOC( ABS( buildings(:)%id - building_id_f%var(j,i) ), & DIM = 1 ) IF ( buildings(nb)%on_pe ) THEN buildings(nb)%num_facade_v(k) = buildings(nb)%num_facade_v(k) + 1 buildings(nb)%num_facades_per_building_v_l = & buildings(nb)%num_facades_per_building_v_l + 1 ENDIF ENDDO ENDDO ! !-- Determine total number of facade elements per building and assign number to !-- building data type. DO nb = 1, num_build ! !-- Allocate dummy array used for summing-up facade elements. !-- Please note, dummy arguments are necessary as building-date type !-- arrays are not necessarily allocated on all PEs. ALLOCATE( num_facades_h(buildings(nb)%kb_min:buildings(nb)%kb_max) ) ALLOCATE( num_facades_v(buildings(nb)%kb_min:buildings(nb)%kb_max) ) ALLOCATE( receive_dum_h(buildings(nb)%kb_min:buildings(nb)%kb_max) ) ALLOCATE( receive_dum_v(buildings(nb)%kb_min:buildings(nb)%kb_max) ) num_facades_h = 0 num_facades_v = 0 receive_dum_h = 0 receive_dum_v = 0 IF ( buildings(nb)%on_pe ) THEN num_facades_h = buildings(nb)%num_facade_h num_facades_v = buildings(nb)%num_facade_v ENDIF #if defined( __parallel ) CALL MPI_ALLREDUCE( num_facades_h, & receive_dum_h, & buildings(nb)%kb_max - buildings(nb)%kb_min + 1, & MPI_INTEGER, & MPI_SUM, & comm2d, & ierr ) CALL MPI_ALLREDUCE( num_facades_v, & receive_dum_v, & buildings(nb)%kb_max - buildings(nb)%kb_min + 1, & MPI_INTEGER, & MPI_SUM, & comm2d, & ierr ) IF ( ALLOCATED( buildings(nb)%num_facade_h ) ) & !FK: Was wenn not allocated? --> s.o. buildings(nb)%num_facade_h = receive_dum_h IF ( ALLOCATED( buildings(nb)%num_facade_v ) ) & buildings(nb)%num_facade_v = receive_dum_v #else buildings(nb)%num_facade_h = num_facades_h buildings(nb)%num_facade_v = num_facades_v #endif ! !-- Deallocate dummy arrays DEALLOCATE( num_facades_h ) DEALLOCATE( num_facades_v ) DEALLOCATE( receive_dum_h ) DEALLOCATE( receive_dum_v ) ! !-- Allocate index arrays which link facade elements with surface-data type. !-- Please note, no height levels are considered here (information is stored !-- in surface-data type itself). IF ( buildings(nb)%on_pe ) THEN ! !-- Determine number of facade elements per building. buildings(nb)%num_facades_per_building_h = SUM( buildings(nb)%num_facade_h ) buildings(nb)%num_facades_per_building_v = SUM( buildings(nb)%num_facade_v ) ! !-- Allocate arrays which link the building with the horizontal and vertical !-- urban-type surfaces. Please note, linking arrays are allocated over all !-- facade elements, which is required in case a building is located at the !-- subdomain boundaries, where the building and the corresponding surface !-- elements are located on different subdomains. ALLOCATE( buildings(nb)%m_h(1:buildings(nb)%num_facades_per_building_h_l) ) ALLOCATE( buildings(nb)%l_v(1:buildings(nb)%num_facades_per_building_v_l) ) ALLOCATE( buildings(nb)%m_v(1:buildings(nb)%num_facades_per_building_v_l) ) ENDIF ! !-- Determine volume per facade element (vpf) IF ( buildings(nb)%on_pe ) THEN ALLOCATE( buildings(nb)%vpf(buildings(nb)%kb_min:buildings(nb)%kb_max) ) DO k = buildings(nb)%kb_min, buildings(nb)%kb_max buildings(nb)%vpf(k) = buildings(nb)%volume(k) / & ( buildings(nb)%num_facade_h(k) + & buildings(nb)%num_facade_v(k) ) ENDDO ENDIF ENDDO ! !-- Link facade elements with surface data type. !-- Allocate array for counting. ALLOCATE( n_fa(1:num_build) ) n_fa = 1 DO m = 1, surf_usm_h%ns i = surf_usm_h%i(m) + surf_usm_h%ioff j = surf_usm_h%j(m) + surf_usm_h%joff nb = MINLOC( ABS( buildings(:)%id - building_id_f%var(j,i) ), DIM = 1 ) buildings(nb)%m_h(n_fa(nb)) = m n_fa(nb) = n_fa(nb) + 1 ENDDO n_fa = 1 DO l = 0, 3 DO m = 1, surf_usm_v(l)%ns i = surf_usm_v(l)%i(m) + surf_usm_v(l)%ioff j = surf_usm_v(l)%j(m) + surf_usm_v(l)%joff nb = MINLOC( ABS( buildings(:)%id - building_id_f%var(j,i) ), DIM = 1 ) buildings(nb)%l_v(n_fa(nb)) = l buildings(nb)%m_v(n_fa(nb)) = m n_fa(nb) = n_fa(nb) + 1 ENDDO ENDDO DEALLOCATE( n_fa ) ! !-- Building parameters by type of building. Assigned in urban_surface_mod.f90 lambda_layer3 = building_pars(63, building_type) s_layer3 = building_pars(57, building_type) f_c_win = building_pars(119, building_type) g_value_win = building_pars(120, building_type) u_value_win = building_pars(121, building_type) air_change_low = building_pars(122, building_type) air_change_high = building_pars(123, building_type) eta_ve = building_pars(124, building_type) factor_a = building_pars(125, building_type) factor_c = building_pars(126, building_type) lambda_at = building_pars(127, building_type) theta_int_h_set = building_pars(118, building_type) theta_int_c_set = building_pars(117, building_type) phi_h_max = building_pars(128, building_type) phi_c_max = building_pars(129, building_type) qint_high = building_pars(130, building_type) qint_low = building_pars(131, building_type) height_storey = building_pars(132, building_type) height_cei_con = building_pars(133, building_type) ! !-- Setting of initial room temperature [K] !-- (after first loop, use theta_m_t as theta_m_t_prev) theta_m_t_prev = initial_indoor_temperature END SUBROUTINE im_init !------------------------------------------------------------------------------! ! Description: ! ------------ !> Main part of the indoor model. !> Calculation of .... (kanani: Please describe) !------------------------------------------------------------------------------! SUBROUTINE im_main_heatcool USE arrays_3d, & ONLY: ddzw, dzw USE basic_constants_and_equations_mod, & ONLY: c_p USE control_parameters, & ONLY: rho_surface USE date_and_time_mod, & ONLY: time_utc USE grid_variables, & ONLY: dx, dy USE pegrid USE surface_mod, & ONLY: ind_veg_wall, ind_wat_win, surf_usm_h, surf_usm_v USE urban_surface_mod, & ONLY: nzt_wall, t_wall_h, t_wall_v, t_window_h, t_window_v, & building_type IMPLICIT NONE INTEGER(iwp) :: i !< index of facade-adjacent atmosphere grid point in x-direction INTEGER(iwp) :: j !< index of facade-adjacent atmosphere grid point in y-direction INTEGER(iwp) :: k !< index of facade-adjacent atmosphere grid point in z-direction INTEGER(iwp) :: kk !< vertical index of indoor grid point adjacent to facade INTEGER(iwp) :: l !< running index for surface-element orientation INTEGER(iwp) :: m !< running index surface elements INTEGER(iwp) :: nb !< running index for buildings INTEGER(iwp) :: fa !< running index for facade elements of each building REAL(wp) :: indoor_wall_window_temperature !< weighted temperature of innermost wall/window layer REAL(wp) :: near_facade_temperature !< outside air temperature 10cm away from facade REAL(wp) :: time_utc_hour !< time of day (hour UTC) REAL(wp), DIMENSION(:), ALLOCATABLE :: t_in_l_send !< dummy send buffer used for summing-up indoor temperature per kk-level REAL(wp), DIMENSION(:), ALLOCATABLE :: t_in_recv !< dummy recv buffer used for summing-up indoor temperature per kk-level ! !-- Daily schedule, here for 08:00-18:00 = 1, other hours = 0. !-- time_utc_hour is calculated here based on time_utc [s] from !-- date_and_time_mod. !-- (kanani: Does this schedule not depend on if it's an office or resident !-- building?) time_utc_hour = time_utc / 3600.0_wp ! !-- Allocation of the load profiles to the building types !-- Residental Building, panel WBS 70 if (building_type == 1 .OR. & building_type == 2 .OR. & building_type == 3 .OR. & building_type == 10 .OR. & building_type == 11 .OR. & building_type == 12) then ventilation_int_loads = 1 !-- Office, building with large windows else if (building_type == 4 .OR. & building_type == 5 .OR. & building_type == 6 .OR. & building_type == 7 .OR. & building_type == 8 .OR. & building_type == 9) then ventilation_int_loads = 2 !-- Industry, hospitals else if (building_type == 13 .OR. & building_type == 14 .OR. & building_type == 15 .OR. & building_type == 16 .OR. & building_type == 17 .OR. & building_type == 18) then ventilation_int_loads = 3 end if !-- Residental Building, panel WBS 70 if (ventilation_int_loads == 1) THEN if ( time_utc_hour >= 6.0_wp .AND. time_utc_hour <= 8.0_wp ) THEN schedule_d = 1 else if ( time_utc_hour >= 18.0_wp .AND. time_utc_hour <= 23.0_wp ) THEN schedule_d = 1 else schedule_d = 0 end if end if !-- Office, building with large windows if (ventilation_int_loads == 2) THEN if ( time_utc_hour >= 8.0_wp .AND. time_utc_hour <= 18.0_wp ) THEN schedule_d = 1 else schedule_d = 0 end if end if !-- Industry, hospitals if (ventilation_int_loads == 3) THEN if ( time_utc_hour >= 6.0_wp .AND. time_utc_hour <= 22.0_wp ) THEN schedule_d = 1 else schedule_d = 0 end if end if ! !-- Following calculations must be done for each facade element. DO nb = 1, num_build ! !-- First, check whether building is present on local subdomain. IF ( buildings(nb)%on_pe ) THEN ! !-- Initialize/reset indoor temperature buildings(nb)%t_in = 0.0_wp buildings(nb)%t_in_l = 0.0_wp ! !-- Horizontal surfaces DO fa = 1, buildings(nb)%num_facades_per_building_h_l ! !-- Determine index where corresponding surface-type information !-- is stored. m = buildings(nb)%m_h(fa) ! !-- Determine building height level index. kk = surf_usm_h%k(m) + surf_usm_h%koff ! !-- Building geometries --> not time-dependent facade_element_area = dx * dy !< [m2] surface area per facade element floor_area_per_facade = buildings(nb)%vpf(kk) * ddzw(kk) !< [m2] net floor area per facade element indoor_volume_per_facade = buildings(nb)%vpf(kk) !< [m3] indoor air volume per facade element window_area_per_facade = surf_usm_h%frac(ind_wat_win,m) * facade_element_area !< [m2] window area per facade element eff_mass_area = factor_a * floor_area_per_facade !< [m2] standard values according to Table 12 section 12.3.1.2 (calculate over Eq. (65) according to section 12.3.1.2) c_m = factor_c * floor_area_per_facade !< [J/K] standard values according to table 12 section 12.3.1.2 (calculate over Eq. (66) according to section 12.3.1.2) total_area = lambda_at * floor_area_per_facade !< [m2] area of all surfaces pointing to zone Eq. (9) according to section 7.2.2.2 !-- Calculation of heat transfer coefficient for transmission --> not time-dependent h_tr_w = window_area_per_facade * u_value_win !< [W/K] only for windows h_tr_is = total_area * h_is !< [W/K] with h_is = 3.45 W / (m2 K) between surface and air, Eq. (9) h_tr_ms = eff_mass_area * h_ms !< [W/K] with h_ms = 9.10 W / (m2 K) between component and surface, Eq. (64) h_tr_op = 1 / ( 1 / ( ( facade_element_area - window_area_per_facade ) & * lambda_layer3 / s_layer3 * 0.5 ) + 1 / h_tr_ms ) h_tr_em = 1 / ( 1 / h_tr_op - 1 / h_tr_ms ) !< [W/K] Eq. (63), Section 12.2.2 ! !-- internal air loads dependent on the occupacy of the room !-- basical internal heat gains (qint_low) with additional internal heat gains by occupancy (qint_high) (0,5*phi_int) phi_ia = 0.5 * ( ( qint_high * schedule_d + qint_low ) & * floor_area_per_facade ) !< [W] Eq. (C.1) ! !-- Airflow dependent on the occupacy of the room !-- basical airflow (air_change_low) with additional airflow gains by occupancy (air_change_high) air_change = ( air_change_high * schedule_d + air_change_low ) !< [1/h]? ! !-- Heat transfer of ventilation !-- not less than 0.01 W/K to provide division by 0 in further calculations !-- with heat capacity of air 0.33 Wh/m2K h_ve = MAX( 0.01_wp , ( air_change * indoor_volume_per_facade * & 0.33_wp * (1 - eta_ve ) ) ) !< [W/K] from ISO 13789 Eq.(10) !-- Heat transfer coefficient auxiliary variables h_tr_1 = 1 / ( ( 1 / h_ve ) + ( 1 / h_tr_is ) ) !< [W/K] Eq. (C.6) h_tr_2 = h_tr_1 + h_tr_w !< [W/K] Eq. (C.7) h_tr_3 = 1 / ( ( 1 / h_tr_2 ) + ( 1 / h_tr_ms ) ) !< [W/K] Eq. (C.8) ! !-- Net short-wave radiation through window area (was i_global) net_sw_in = surf_usm_h%rad_sw_in(m) - surf_usm_h%rad_sw_out(m) ! !-- Quantities needed for im_calc_temperatures i = surf_usm_h%i(m) j = surf_usm_h%j(m) k = surf_usm_h%k(m) near_facade_temperature = surf_usm_h%pt_10cm(m) indoor_wall_window_temperature = & surf_usm_h%frac(ind_veg_wall,m) * t_wall_h(nzt_wall,m) & + surf_usm_h%frac(ind_wat_win,m) * t_window_h(nzt_wall,m) ! !-- Solar thermal gains. If net_sw_in larger than sun-protection !-- threshold parameter (params_solar_protection), sun protection will !-- be activated IF ( net_sw_in <= params_solar_protection ) THEN solar_protection_off = 1 solar_protection_on = 0 ELSE solar_protection_off = 0 solar_protection_on = 1 ENDIF ! !-- Calculation of total heat gains from net_sw_in through windows [W] in respect on automatic sun protection !-- DIN 4108 - 2 chap.8 phi_sol = ( window_area_per_facade * net_sw_in * solar_protection_off & + window_area_per_facade * net_sw_in * f_c_win * solar_protection_on ) & * g_value_win * ( 1 - params_f_f ) * params_f_w !< [W] ! !-- Calculation of the mass specific thermal load for internal and external heatsources of the inner node phi_m = (eff_mass_area / total_area) * ( phi_ia + phi_sol ) !< [W] Eq. (C.2) with phi_ia=0,5*phi_int ! !-- Calculation mass specific thermal load implied non thermal mass phi_st = ( 1 - ( eff_mass_area / total_area ) - ( h_tr_w / ( 9.1 * total_area ) ) ) & * ( phi_ia + phi_sol ) !< [W] Eq. (C.3) with phi_ia=0,5*phi_int ! !-- Calculations for deriving indoor temperature and heat flux into the wall !-- Step 1: Indoor temperature without heating and cooling !-- section C.4.1 Picture C.2 zone 3) phi_hc_nd = 0 CALL im_calc_temperatures ( i, j, k, indoor_wall_window_temperature, & near_facade_temperature, phi_hc_nd ) ! !-- If air temperature between border temperatures of heating and cooling, assign output variable, then ready IF ( theta_int_h_set <= theta_air .AND. theta_air <= theta_int_c_set ) THEN phi_hc_nd_ac = 0 phi_hc_nd = phi_hc_nd_ac theta_air_ac = theta_air ! !-- Step 2: Else, apply 10 W/m² heating/cooling power and calculate indoor temperature !-- again. ELSE ! !-- Temperature not correct, calculation method according to section C4.2 theta_air_0 = theta_air !< Note temperature without heating/cooling !-- Heating or cooling? IF ( theta_air > theta_int_c_set ) THEN theta_air_set = theta_int_c_set ELSE theta_air_set = theta_int_h_set ENDIF !-- Calculate the temperature with phi_hc_nd_10 phi_hc_nd_10 = 10.0_wp * floor_area_per_facade phi_hc_nd = phi_hc_nd_10 CALL im_calc_temperatures ( i, j, k, indoor_wall_window_temperature, & near_facade_temperature, phi_hc_nd ) theta_air_10 = theta_air !< Note the temperature with 10 W/m2 of heating ! phi_hc_nd_un = phi_hc_nd_10 * (theta_air_set - theta_air_0) & / (theta_air_10 - theta_air_0) !< Eq. (C.13) !-- Step 3: With temperature ratio to determine the heating or cooling capacity !-- If necessary, limit the power to maximum power !-- section C.4.1 Picture C.2 zone 2) and 4) IF ( phi_c_max < phi_hc_nd_un .AND. phi_hc_nd_un < phi_h_max ) THEN phi_hc_nd_ac = phi_hc_nd_un phi_hc_nd = phi_hc_nd_un ELSE !-- Step 4: Inner temperature with maximum heating (phi_hc_nd_un positive) or cooling (phi_hc_nd_un negative) !-- section C.4.1 Picture C.2 zone 1) and 5) IF ( phi_hc_nd_un > 0 ) THEN phi_hc_nd_ac = phi_h_max !< Limit heating ELSE phi_hc_nd_ac = phi_c_max !< Limit cooling ENDIF ENDIF phi_hc_nd = phi_hc_nd_ac ! !-- Calculate the temperature with phi_hc_nd_ac (new) CALL im_calc_temperatures ( i, j, k, indoor_wall_window_temperature, & near_facade_temperature, phi_hc_nd ) theta_air_ac = theta_air ENDIF ! !-- Update theta_m_t_prev theta_m_t_prev = theta_m_t ! !-- Calculate the operating temperature with weighted mean temperature of air and mean solar temperature !-- Will be used for thermal comfort calculations theta_op = 0.3 * theta_air_ac + 0.7 * theta_s !< [degree_C] operative Temperature Eq. (C.12) ! !-- Heat flux into the wall. Value needed in urban_surface_mod to !-- calculate heat transfer through wall layers towards the facade !-- (use c_p * rho_surface to convert [W/m2] into [K m/s]) q_wall_win = h_tr_ms * ( theta_s - theta_m ) & / ( facade_element_area & - window_area_per_facade ) ! !-- Transfer q_wall_win back to USM (innermost wall/window layer) surf_usm_h%iwghf_eb(m) = q_wall_win surf_usm_h%iwghf_eb_window(m) = q_wall_win ! !-- Sum up operational indoor temperature per kk-level. Further below, !-- this temperature is reduced by MPI to one temperature per kk-level !-- and building (processor overlapping) buildings(nb)%t_in_l(kk) = buildings(nb)%t_in_l(kk) + theta_op ! !-- Calculation of waste heat !-- Anthropogenic heat output IF ( phi_hc_nd_ac > 0 ) THEN heating_on = 1 cooling_on = 0 ELSE heating_on = 0 cooling_on = 1 ENDIF q_waste_heat = (phi_hc_nd * (params_waste_heat_h * heating_on + params_waste_heat_c * cooling_on)) !< [W/m2] anthropogenic heat output ! surf_usm_h%shf(m)=q_waste_heat ENDDO !< Horizontal surfaces loop ! !-- Vertical surfaces DO fa = 1, buildings(nb)%num_facades_per_building_v_l ! !-- Determine indices where corresponding surface-type information !-- is stored. l = buildings(nb)%l_v(fa) m = buildings(nb)%m_v(fa) ! !-- Determine building height level index. kk = surf_usm_v(l)%k(m) + surf_usm_v(l)%koff ! !-- Building geometries --> not time-dependent IF ( l == 0 .OR. l == 1 ) facade_element_area = dx * dzw(kk) !< [m2] surface area per facade element IF ( l == 2 .OR. l == 3 ) facade_element_area = dy * dzw(kk) !< [m2] surface area per facade element floor_area_per_facade = buildings(nb)%vpf(kk) * ddzw(kk) !< [m2] net floor area per facade element indoor_volume_per_facade = buildings(nb)%vpf(kk) !< [m3] indoor air volume per facade element window_area_per_facade = surf_usm_v(l)%frac(ind_wat_win,m) * facade_element_area !< [m2] window area per facade element eff_mass_area = factor_a * floor_area_per_facade !< [m2] standard values according to Table 12 section 12.3.1.2 (calculate over Eq. (65) according to section 12.3.1.2) c_m = factor_c * floor_area_per_facade !< [J/K] standard values according to table 12 section 12.3.1.2 (calculate over Eq. (66) according to section 12.3.1.2) total_area = lambda_at * floor_area_per_facade !< [m2] area of all surfaces pointing to zone Eq. (9) according to section 7.2.2.2 ! !-- Calculation of heat transfer coefficient for transmission --> not time-dependent h_tr_w = window_area_per_facade * u_value_win !< [W/K] only for windows h_tr_is = total_area * h_is !< [W/K] with h_is = 3.45 W / (m2 K) between surface and air, Eq. (9) h_tr_ms = eff_mass_area * h_ms !< [W/K] with h_ms = 9.10 W / (m2 K) between component and surface, Eq. (64) h_tr_op = 1 / ( 1 / ( ( facade_element_area - window_area_per_facade ) & * lambda_layer3 / s_layer3 * 0.5 ) + 1 / h_tr_ms ) h_tr_em = 1 / ( 1 / h_tr_op - 1 / h_tr_ms ) !< [W/K] Eq. (63), Section 12.2.2 ! !-- internal air loads dependent on the occupacy of the room !-- basical internal heat gains (qint_low) with additional internal heat gains by occupancy (qint_high) (0,5*phi_int) phi_ia = 0.5 * ( ( qint_high * schedule_d + qint_low ) & * floor_area_per_facade ) !< [W] Eq. (C.1) ! !-- Airflow dependent on the occupacy of the room !-- basical airflow (air_change_low) with additional airflow gains by occupancy (air_change_high) air_change = ( air_change_high * schedule_d + air_change_low ) ! !-- Heat transfer of ventilation !-- not less than 0.01 W/K to provide division by 0 in further calculations !-- with heat capacity of air 0.33 Wh/m2K h_ve = MAX( 0.01_wp , ( air_change * indoor_volume_per_facade * & 0.33_wp * (1 - eta_ve ) ) ) !< [W/K] from ISO 13789 Eq.(10) !-- Heat transfer coefficient auxiliary variables h_tr_1 = 1 / ( ( 1 / h_ve ) + ( 1 / h_tr_is ) ) !< [W/K] Eq. (C.6) h_tr_2 = h_tr_1 + h_tr_w !< [W/K] Eq. (C.7) h_tr_3 = 1 / ( ( 1 / h_tr_2 ) + ( 1 / h_tr_ms ) ) !< [W/K] Eq. (C.8) ! !-- Net short-wave radiation through window area (was i_global) net_sw_in = surf_usm_v(l)%rad_sw_in(m) - surf_usm_v(l)%rad_sw_out(m) ! !-- Quantities needed for im_calc_temperatures i = surf_usm_v(l)%i(m) j = surf_usm_v(l)%j(m) k = surf_usm_v(l)%k(m) near_facade_temperature = surf_usm_v(l)%pt_10cm(m) indoor_wall_window_temperature = & surf_usm_v(l)%frac(ind_veg_wall,m) * t_wall_v(l)%t(nzt_wall,m) & + surf_usm_v(l)%frac(ind_wat_win,m) * t_window_v(l)%t(nzt_wall,m) ! !-- Solar thermal gains. If net_sw_in larger than sun-protection !-- threshold parameter (params_solar_protection), sun protection will !-- be activated IF ( net_sw_in <= params_solar_protection ) THEN solar_protection_off = 1 solar_protection_on = 0 ELSE solar_protection_off = 0 solar_protection_on = 1 ENDIF ! !-- Calculation of total heat gains from net_sw_in through windows [W] in respect on automatic sun protection !-- DIN 4108 - 2 chap.8 phi_sol = ( window_area_per_facade * net_sw_in * solar_protection_off & + window_area_per_facade * net_sw_in * f_c_win * solar_protection_on ) & * g_value_win * ( 1 - params_f_f ) * params_f_w ! !-- Calculation of the mass specific thermal load for internal and external heatsources phi_m = (eff_mass_area / total_area) * ( phi_ia + phi_sol ) !< [W] Eq. (C.2) with phi_ia=0,5*phi_int ! !-- Calculation mass specific thermal load implied non thermal mass phi_st = ( 1 - ( eff_mass_area / total_area ) - ( h_tr_w / ( 9.1 * total_area ) ) ) & * ( phi_ia + phi_sol ) !< [W] Eq. (C.3) with phi_ia=0,5*phi_int ! !-- Calculations for deriving indoor temperature and heat flux into the wall !-- Step 1: Indoor temperature without heating and cooling !-- section C.4.1 Picture C.2 zone 3) phi_hc_nd = 0 CALL im_calc_temperatures ( i, j, k, indoor_wall_window_temperature, & near_facade_temperature, phi_hc_nd ) ! !-- If air temperature between border temperatures of heating and cooling, assign output variable, then ready IF ( theta_int_h_set <= theta_air .AND. theta_air <= theta_int_c_set ) THEN phi_hc_nd_ac = 0 phi_hc_nd = phi_hc_nd_ac theta_air_ac = theta_air ! !-- Step 2: Else, apply 10 W/m² heating/cooling power and calculate indoor temperature !-- again. ELSE ! !-- Temperature not correct, calculation method according to section C4.2 theta_air_0 = theta_air !< Note temperature without heating/cooling !-- Heating or cooling? IF ( theta_air > theta_int_c_set ) THEN theta_air_set = theta_int_c_set ELSE theta_air_set = theta_int_h_set ENDIF !-- Calculate the temperature with phi_hc_nd_10 phi_hc_nd_10 = 10.0_wp * floor_area_per_facade phi_hc_nd = phi_hc_nd_10 CALL im_calc_temperatures ( i, j, k, indoor_wall_window_temperature, & near_facade_temperature, phi_hc_nd ) theta_air_10 = theta_air !< Note the temperature with 10 W/m2 of heating phi_hc_nd_un = phi_hc_nd_10 * (theta_air_set - theta_air_0) & / (theta_air_10 - theta_air_0) !< Eq. (C.13) ! !-- Step 3: With temperature ratio to determine the heating or cooling capacity !-- If necessary, limit the power to maximum power !-- section C.4.1 Picture C.2 zone 2) and 4) IF ( phi_c_max < phi_hc_nd_un .AND. phi_hc_nd_un < phi_h_max ) THEN phi_hc_nd_ac = phi_hc_nd_un phi_hc_nd = phi_hc_nd_un ELSE !-- Step 4: Inner temperature with maximum heating (phi_hc_nd_un positive) or cooling (phi_hc_nd_un negative) !-- section C.4.1 Picture C.2 zone 1) and 5) IF ( phi_hc_nd_un > 0 ) THEN phi_hc_nd_ac = phi_h_max !< Limit heating ELSE phi_hc_nd_ac = phi_c_max !< Limit cooling ENDIF ENDIF phi_hc_nd = phi_hc_nd_ac ! !-- Calculate the temperature with phi_hc_nd_ac (new) CALL im_calc_temperatures ( i, j, k, indoor_wall_window_temperature, & near_facade_temperature, phi_hc_nd ) theta_air_ac = theta_air ENDIF ! !-- Update theta_m_t_prev theta_m_t_prev = theta_m_t ! !-- Calculate the operating temperature with weighted mean of temperature of air and mean !-- Will be used for thermal comfort calculations theta_op = 0.3 * theta_air_ac + 0.7 * theta_s ! !-- Heat flux into the wall. Value needed in urban_surface_mod to !-- calculate heat transfer through wall layers towards the facade q_wall_win = h_tr_ms * ( theta_s - theta_m ) & / ( facade_element_area & - window_area_per_facade ) ! !-- Transfer q_wall_win back to USM (innermost wall/window layer) surf_usm_v(l)%iwghf_eb(m) = q_wall_win surf_usm_v(l)%iwghf_eb_window(m) = q_wall_win ! !-- Sum up operational indoor temperature per kk-level. Further below, !-- this temperature is reduced by MPI to one temperature per kk-level !-- and building (processor overlapping) buildings(nb)%t_in_l(kk) = buildings(nb)%t_in_l(kk) + theta_op ! !-- Calculation of waste heat !-- Anthropogenic heat output IF ( phi_hc_nd_ac > 0 ) THEN heating_on = 1 cooling_on = 0 ELSE heating_on = 0 cooling_on = 1 ENDIF q_waste_heat = (phi_hc_nd * (params_waste_heat_h * heating_on + params_waste_heat_c * cooling_on)) !< [W/m2] , anthropogenic heat output ! surf_usm_v(l)%waste_heat(m)=q_waste_heat ENDDO !< Vertical surfaces loop ENDIF !< buildings(nb)%on_pe ENDDO !< buildings loop ! !-- Determine total number of facade elements per building and assign number to !-- building data type. DO nb = 1, num_build ! !-- Allocate dummy array used for summing-up facade elements. !-- Please note, dummy arguments are necessary as building-date type !-- arrays are not necessarily allocated on all PEs. ALLOCATE( t_in_l_send(buildings(nb)%kb_min:buildings(nb)%kb_max) ) ALLOCATE( t_in_recv(buildings(nb)%kb_min:buildings(nb)%kb_max) ) t_in_l_send = 0.0_wp t_in_recv = 0.0_wp IF ( buildings(nb)%on_pe ) THEN t_in_l_send = buildings(nb)%t_in_l ENDIF #if defined( __parallel ) CALL MPI_ALLREDUCE( t_in_l_send, & t_in_recv, & buildings(nb)%kb_max - buildings(nb)%kb_min + 1, & MPI_REAL, & MPI_SUM, & comm2d, & ierr ) IF ( ALLOCATED( buildings(nb)%t_in ) ) & buildings(nb)%t_in = t_in_recv #else buildings(nb)%t_in = buildings(nb)%t_in_l #endif buildings(nb)%t_in = buildings(nb)%t_in / & ( buildings(nb)%num_facade_h + & buildings(nb)%num_facade_v ) ! !-- Deallocate dummy arrays DEALLOCATE( t_in_l_send ) DEALLOCATE( t_in_recv ) ENDDO END SUBROUTINE im_main_heatcool !------------------------------------------------------------------------------! ! Description: ! ------------ !> Parin for &indoor_parameters for indoor model !------------------------------------------------------------------------------! SUBROUTINE im_parin USE control_parameters, & ONLY: indoor_model IMPLICIT NONE CHARACTER (LEN=80) :: line !< string containing current line of file PARIN NAMELIST /indoor_parameters/ building_type, dt_indoor, & initial_indoor_temperature ! line = ' ' ! !-- Try to find indoor model package REWIND ( 11 ) line = ' ' DO WHILE ( INDEX( line, '&indoor_parameters' ) == 0 ) READ ( 11, '(A)', END=10 ) line ! PRINT*, 'line: ', line ENDDO BACKSPACE ( 11 ) ! !-- Read user-defined namelist READ ( 11, indoor_parameters ) ! !-- Set flag that indicates that the indoor model is switched on indoor_model = .TRUE. ! !-- Activate spinup (maybe later ! IF ( spinup_time > 0.0_wp ) THEN ! coupling_start_time = spinup_time ! end_time = end_time + spinup_time ! IF ( spinup_pt_mean == 9999999.9_wp ) THEN ! spinup_pt_mean = pt_surface ! ENDIF ! spinup = .TRUE. ! ENDIF 10 CONTINUE END SUBROUTINE im_parin END MODULE indoor_model_mod