PageRenderTime 58ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

/wrfv2_fire/phys/module_sf_bem.F

http://github.com/jbeezley/wrf-fire
FORTRAN Legacy | 2345 lines | 1181 code | 600 blank | 564 comment | 45 complexity | eba7fd746f42e2808e01b8d95dc369de MD5 | raw file
Possible License(s): AGPL-1.0
  1. MODULE module_sf_bem
  2. ! -----------------------------------------------------------------------
  3. ! Variables and constants used in the BEM module
  4. ! -----------------------------------------------------------------------
  5. real emins !emissivity of the internal walls
  6. parameter (emins=0.9)
  7. real albins !albedo of the internal walls
  8. !! parameter (albins=0.5)
  9. parameter (albins=0.3)
  10. real thickwin !thickness of the window [m]
  11. parameter (thickwin=0.006)
  12. real cswin !Specific heat of the windows [J/(m3.K)]
  13. parameter(cswin= 2.268e+06)
  14. real temp_rat !power of the A.C. heating/cooling the indoor air [K/s]
  15. parameter(temp_rat=0.001)
  16. real hum_rat !power of the A.C. drying/moistening the indoor air [(Kg/kg)/s]
  17. parameter(hum_rat=1.e-06)
  18. CONTAINS
  19. !====6================================================================72
  20. !====6================================================================72
  21. subroutine BEM(nzcanm,nlev,nhourday,dt,bw,bl,dzlev, &
  22. nwal,nflo,nrof,ngrd,hswalout,gswal, &
  23. hswinout,hsrof,gsrof, &
  24. latent,sigma,albwal,albwin,albrof, &
  25. emrof,emwal,emwin,rswal,rlwal,rair,cp, &
  26. rhoout,tout,humout,press, &
  27. rs,rl,dzwal,cswal,kwal,pwin,cop,beta,sw_cond, &
  28. timeon,timeoff,targtemp,gaptemp,targhum,gaphum, &
  29. perflo,hsesf,hsequip,dzflo, &
  30. csflo,kflo,dzgrd,csgrd,kgrd,dzrof,csrof, &
  31. krof,tlev,shumlev,twal,twin,tflo,tgrd,trof, &
  32. hsout,hlout,consump,hsvent,hlvent)
  33. ! ---------------------------------------------------------------------
  34. implicit none
  35. ! ---------------------------------------------------------------------
  36. ! TOP
  37. ! ---------------------
  38. ! ! ----------------- !--->roof (-) : level number
  39. ! ! ! ! ! rem: the windows are given
  40. ! ! !---------------! ! with respect to the
  41. ! ! !---------------! ! vertical walls-->win(2)
  42. ! (n)! !(1) (1)!-!(n)
  43. ! ! !---------------! ! 2D vision of the building
  44. ! WEST ! !-------4-------! ! EAST
  45. ! I ! ! 1 ilev 2! ! II ^
  46. ! ! !-------3--------! ! !
  47. ! ! !---------------! !--->floor 1 !
  48. ! ! ! ! ! !
  49. ! ! ! ! ! !
  50. ! ! ----------------- ! <--------------(n)
  51. ! ------------------------>ground ------------(1)
  52. ! BOTTOM
  53. ! i(6)
  54. ! i
  55. ! +---------v-----+
  56. ! /| /| 3D vision of a room
  57. ! / | 4 / |
  58. ! / | / |
  59. ! / | / |
  60. ! / | / |
  61. ! +---------------+ |
  62. ! | 1 | | 2 |
  63. ! | +---------|-----+
  64. ! dzlev | / | /
  65. ! | / 3 | /
  66. ! | /bw | /
  67. ! | / | /
  68. ! |/ |/
  69. ! +---------------+
  70. ! ^ bl
  71. ! i
  72. ! i
  73. ! (5)
  74. !-----------------------------------------------------------------------
  75. ! Input:
  76. ! -----
  77. real dt !time step [s]
  78. integer nzcanm !Maximum number of vertical levels in the urban grid
  79. integer nlev !number of floors in the building
  80. integer nwal !number of levels inside the wall
  81. integer nrof !number of levels inside the roof
  82. integer nflo !number of levels inside the floor
  83. integer ngrd !number of levels inside the ground
  84. real dzlev !vertical grid resolution [m]
  85. real bl !Building length [m]
  86. real bw !Building width [m]
  87. real albwal !albedo of the walls
  88. real albwin !albedo of the windows
  89. real albrof !albedo of the roof
  90. real emwal !emissivity of the walls
  91. real emrof !emissivity of the roof
  92. real emwin !emissivity of the windows
  93. real pwin !window proportion
  94. real, intent(in) :: cop !Coefficient of performance of the A/C systems
  95. real, intent(in) :: beta !Thermal efficiency of the heat exchanger
  96. integer, intent(in) :: sw_cond ! Air Conditioning switch
  97. real, intent(in) :: timeon ! Initial local time of A/C systems
  98. real, intent(in) :: timeoff ! Ending local time of A/C systems
  99. real, intent(in) :: targtemp ! Target temperature of A/C systems
  100. real, intent(in) :: gaptemp ! Comfort range of indoor temperature
  101. real, intent(in) :: targhum ! Target humidity of A/C systems
  102. real, intent(in) :: gaphum ! Comfort range of specific humidity
  103. real, intent(in) :: perflo ! Peak number of occupants per unit floor area
  104. real, intent(in) :: hsesf !
  105. real, intent(in) :: hsequip(24) !
  106. real cswal(nwal) !Specific heat of the wall [J/(m3.K)]
  107. real csflo(nflo) !Specific heat of the floor [J/(m3.K)]
  108. real csrof(nrof) !Specific heat of the roof [J/(m3.K)]
  109. real csgrd(ngrd) !Specific heat of the ground [J/(m3.K)]
  110. real kwal(nwal+1) !Thermal conductivity in each layers of the walls (face) [W/(m.K)]
  111. real kflo(nflo+1) !Thermal diffusivity in each layers of the floors (face) [W/(m.K)]
  112. real krof(nrof+1) !Thermal diffusivity in each layers of the roof (face) [W/(m.K)]
  113. real kgrd(ngrd+1) !Thermal diffusivity in each layers of the ground (face) [W/(m.K)]
  114. real dzwal(nwal) !Layer sizes of walls [m]
  115. real dzflo(nflo) !Layer sizes of floors [m]
  116. real dzrof(nrof) !Layer sizes of roof [m]
  117. real dzgrd(ngrd) !Layer sizes of ground [m]
  118. real latent !latent heat of evaporation [J/Kg]
  119. real rs !external short wave radiation [W/m2]
  120. real rl !external long wave radiation [W/m2]
  121. real rswal(4,nzcanm) !short wave radiation reaching the exterior walls [W/m2]
  122. real rlwal(4,nzcanm) !long wave radiation reaching the walls [W/m2]
  123. real rhoout(nzcanm) !exterior air density [kg/m3]
  124. real tout(nzcanm) !external temperature [K]
  125. real humout(nzcanm) !absolute humidity [Kgwater/Kgair]
  126. real press(nzcanm) !external air pressure [Pa]
  127. real hswalout(4,nzcanm) !outside walls sensible heat flux [W/m2]
  128. real hswinout(4,nzcanm) !outside window sensible heat flux [W/m2]
  129. real hsrof !Sensible heat flux at the roof [W/m2]
  130. real rair !ideal gas constant [J.kg-1.K-1]
  131. real sigma !parameter (wall is not black body) [W/m2.K4]
  132. real cp !specific heat of air [J/kg.K]
  133. !Input-Output
  134. !------------
  135. real tlev(nzcanm) !temperature of the floors [K]
  136. real shumlev(nzcanm) !specific humidity of the floor [kg/kg]
  137. real twal(4,nwal,nzcanm) !walls temperatures [K]
  138. real twin(4,nzcanm) !windows temperatures [K]
  139. real tflo(nflo,nzcanm-1) !floor temperatures [K]
  140. real tgrd(ngrd) !ground temperature [K]
  141. real trof(nrof) !roof temperature [K]
  142. real hsout(nzcanm) !sensible heat emitted outside the floor [W]
  143. real hlout(nzcanm) !latent heat emitted outside the floor [W]
  144. real consump(nzcanm) !Consumption for the a.c. in each floor [W]
  145. real hsvent(nzcanm) !sensible heat generated by natural ventilation [W]
  146. real hlvent(nzcanm) !latent heat generated by natural ventilation [W]
  147. real gsrof !heat flux flowing inside the roof [W/mË›]
  148. real gswal(4,nzcanm) !heat flux flowing inside the floors [W/mË›]
  149. ! Local:
  150. ! -----
  151. integer swwal !swich for the physical coefficients calculation
  152. integer ilev !index for rooms
  153. integer iwal !index for walls
  154. integer iflo !index for floors
  155. integer ivw !index for vertical walls
  156. integer igrd !index for ground
  157. integer irof !index for roof
  158. real hseqocc(nzcanm) !sensible heat generated by equipments and occupants [W]
  159. real hleqocc(nzcanm) !latent heat generated by occupants [W]
  160. real hscond(nzcanm) !sensible heat generated by wall conduction [W]
  161. real hslev(nzcanm) !sensible heat flux generated inside the room [W]
  162. real hllev(nzcanm) !latent heat flux generatd inside the room [W]
  163. real surwal(6,nzcanm) !Surface of the walls [m2]
  164. real surwal1D(6) !wall surfaces of a generic room [m2]
  165. real rsint(6) !short wave radiation reaching the indoor walls[W/m2]
  166. real rswalins(6,nzcanm) !internal short wave radiation for the building [W/m2]
  167. real twin1D(4) !temperature of windows for a particular room [K]
  168. real twal_int(6) !temperature of the first internal layers of a room [K]
  169. real rlint(6) !internal wall long wave radiation [w/m2]
  170. real rlwalins(6,nzcanm) !internal long wave radiation for the building [W/m2]
  171. real hrwalout(4,nzcanm) !external radiative flux to the walls [W/m2]
  172. real hrwalins(6,nzcanm) !inside radiative flux to the walls [W/m2]
  173. real hrwinout(4,nzcanm) !external radiative flux to the window [W/m2]
  174. real hrwinins(4,nzcanm) !inside radiative flux to the window [W/m2]
  175. real hrrof !external radiative flux to the roof [W/m2]
  176. real hs
  177. real hsneed(nzcanm) !sensible heat needed by the room [W]
  178. real hlneed(nzcanm) !latent heat needed by the room [W]
  179. real hswalins(6,nzcanm) !inside walls sensible heat flux [W/m2]
  180. real hswalins1D(6)
  181. real hswinins(4,nzcanm) !inside window sensible heat flux [W/m2]
  182. real hswinins1D(4)
  183. real htot(2) !total heat flux at the wall [W/m2]
  184. real twal1D(nwal)
  185. real tflo1D(nflo)
  186. real tgrd1D(ngrd)
  187. real trof1D(nrof)
  188. real rswal1D(4)
  189. real Qb !Overall heat capacity of the indoor air [J/K]
  190. real vollev !volume of the room [m3]
  191. real rhoint !density of the internal air [Kg/m3]
  192. real cpint !specific heat of the internal air [J/kg.K]
  193. real humdry !specific humidiy of dry air [kg water/kg dry air]
  194. real radflux !Function to compute the total radiation budget
  195. real consumpbuild !Energetic consumption for the entire building [KWh/s]
  196. real hsoutbuild !Total sensible heat ejected into the atmosphere[W]
  197. !by the air conditioning system and per building
  198. real nhourday !number of hours from midnight, local time
  199. !--------------------------------------------
  200. !Initialization
  201. !--------------------------------------------
  202. do ilev=1,nzcanm
  203. hseqocc(ilev)=0.
  204. hleqocc(ilev)=0.
  205. hscond(ilev)=0.
  206. hslev(ilev)=0.
  207. hllev(ilev)=0.
  208. enddo
  209. !Calculation of the surfaces of the building
  210. !--------------------------------------------
  211. do ivw=1,6
  212. do ilev=1,nzcanm
  213. surwal(ivw,ilev)=1. !initialisation
  214. end do
  215. end do
  216. do ilev=1,nlev
  217. do ivw=1,2
  218. surwal(ivw,ilev)=dzlev*bw
  219. end do
  220. do ivw=3,4
  221. surwal(ivw,ilev)=dzlev*bl
  222. end do
  223. do ivw=5,6
  224. surwal(ivw,ilev)=bw*bl
  225. end do
  226. end do
  227. ! Calculation of the short wave radiations at the internal walls
  228. ! ---------------------------------------------------------------
  229. do ilev=1,nlev
  230. do ivw=1,4
  231. rswal1D(ivw)=rswal(ivw,ilev)
  232. end do
  233. do ivw=1,6
  234. surwal1D(ivw)=surwal(ivw,ilev)
  235. end do
  236. call int_rsrad(albwin,albins,pwin,rswal1D,&
  237. surwal1D,bw,bl,dzlev,rsint)
  238. do ivw=1,6
  239. rswalins(ivw,ilev)=rsint(ivw)
  240. end do
  241. end do !ilev
  242. ! Calculation of the long wave radiation at the internal walls
  243. !-------------------------------------------------------------
  244. !Intermediate rooms
  245. if (nlev.gt.2) then
  246. do ilev=2,nlev-1
  247. do ivw=1,4
  248. twin1D(ivw)=twin(ivw,ilev)
  249. twal_int(ivw)=twal(ivw,1,ilev)
  250. end do
  251. twal_int(5)=tflo(nflo,ilev-1)
  252. twal_int(6)=tflo(1,ilev)
  253. call int_rlrad(emins,emwin,sigma,twal_int,twin1D,&
  254. pwin,bw,bl,dzlev,rlint)
  255. do ivw=1,6
  256. rlwalins(ivw,ilev)=rlint(ivw)
  257. end do
  258. end do !ilev
  259. end if
  260. if (nlev.ne.1) then
  261. !bottom room
  262. do ivw=1,4
  263. twin1D(ivw)=twin(ivw,1)
  264. twal_int(ivw)=twal(ivw,1,1)
  265. end do
  266. twal_int(5)=tgrd(ngrd)
  267. twal_int(6)=tflo(1,1)
  268. call int_rlrad(emins,emwin,sigma,twal_int,twin1D,&
  269. pwin,bw,bl,dzlev,rlint)
  270. do ivw=1,6
  271. rlwalins(ivw,1)=rlint(ivw)
  272. end do
  273. !top room
  274. do ivw=1,4
  275. twin1D(ivw)=twin(ivw,nlev)
  276. twal_int(ivw)=twal(ivw,1,nlev)
  277. end do
  278. twal_int(5)=tflo(nflo,nlev-1)
  279. twal_int(6)=trof(1)
  280. call int_rlrad(emins,emwin,sigma,twal_int,twin1D,&
  281. pwin,bw,bl,dzlev,rlint)
  282. do ivw=1,6
  283. rlwalins(ivw,nlev)=rlint(ivw)
  284. end do
  285. else !Top <---> Bottom
  286. do ivw=1,4
  287. twin1D(ivw)=twin(ivw,1)
  288. twal_int(ivw)=twal(ivw,1,1)
  289. end do
  290. twal_int(5)=tgrd(ngrd)
  291. twal_int(6)=trof(1)
  292. call int_rlrad(emins,emwin,sigma,twal_int,twin1D, &
  293. pwin,bw,bl,dzlev,rlint)
  294. do ivw=1,6
  295. rlwalins(ivw,1)=rlint(ivw)
  296. end do
  297. end if
  298. ! Calculation of the radiative fluxes
  299. ! -----------------------------------
  300. !External vertical walls and windows
  301. do ilev=1,nlev
  302. do ivw=1,4
  303. call radfluxs(radflux,albwal,rswal(ivw,ilev), &
  304. emwal,rlwal(ivw,ilev),sigma, &
  305. twal(ivw,nwal,ilev))
  306. hrwalout(ivw,ilev)=radflux
  307. hrwinout(ivw,ilev)=emwin*rlwal(ivw,ilev)- &
  308. emwin*sigma*(twin(ivw,ilev)**4)
  309. end do ! ivw
  310. end do ! ilev
  311. !Roof
  312. call radfluxs(radflux,albrof,rs,emrof,rl,sigma,trof(nrof))
  313. hrrof=radflux
  314. !Internal walls for intermediate rooms
  315. if(nlev.gt.2) then
  316. do ilev=2,nlev-1
  317. do ivw=1,4
  318. call radfluxs(radflux,albins,rswalins(ivw,ilev), &
  319. emins,rlwalins(ivw,ilev),sigma, &
  320. twal(ivw,1,ilev))
  321. hrwalins(ivw,ilev)=radflux
  322. end do !ivw
  323. call radfluxs(radflux,albins,rswalins(5,ilev), &
  324. emins,rlwalins(5,ilev),sigma,&
  325. tflo(nflo,ilev-1))
  326. hrwalins(5,ilev)=radflux
  327. call radfluxs(radflux,albins,rswalins(6,ilev), &
  328. emins,rlwalins(6,ilev),sigma,&
  329. tflo(1,ilev))
  330. hrwalins(6,ilev)=radflux
  331. end do !ilev
  332. end if
  333. !Internal walls for the bottom and the top room
  334. !
  335. if (nlev.ne.1) then
  336. !bottom floor
  337. do ivw=1,4
  338. call radfluxs(radflux,albins,rswalins(ivw,1), &
  339. emins,rlwalins(ivw,1),sigma, &
  340. twal(ivw,1,1))
  341. hrwalins(ivw,1)=radflux
  342. end do
  343. call radfluxs(radflux,albins,rswalins(5,1),&
  344. emins,rlwalins(5,1),sigma,& !bottom
  345. tgrd(ngrd))
  346. hrwalins(5,1)=radflux
  347. call radfluxs(radflux,albins,rswalins(6,1),&
  348. emins,rlwalins(6,1),sigma,&
  349. tflo(1,1))
  350. hrwalins(6,1)=radflux
  351. !roof floor
  352. do ivw=1,4
  353. call radfluxs(radflux,albins,rswalins(ivw,nlev), &
  354. emins,rlwalins(ivw,nlev),sigma,&
  355. twal(ivw,1,nlev))
  356. hrwalins(ivw,nlev)=radflux
  357. end do !top
  358. call radfluxs(radflux,albins,rswalins(5,nlev), &
  359. emins,rlwalins(5,nlev),sigma,&
  360. tflo(nflo,nlev-1))
  361. hrwalins(5,nlev)=radflux
  362. call radfluxs(radflux,albins,rswalins(6,nlev), &
  363. emins,rlwalins(6,nlev),sigma,&
  364. trof(1))
  365. hrwalins(6,nlev)=radflux
  366. else ! Top <---> Bottom room
  367. do ivw=1,4
  368. call radfluxs(radflux,albins,rswalins(ivw,1),&
  369. emins,rlwalins(ivw,1),sigma, &
  370. twal(ivw,1,1))
  371. hrwalins(ivw,1)=radflux
  372. end do
  373. call radfluxs(radflux,albins,rswalins(5,1),&
  374. emins,rlwalins(5,1),sigma, &
  375. tgrd(ngrd))
  376. hrwalins(5,1)=radflux
  377. call radfluxs(radflux,albins,rswalins(6,nlev), &
  378. emins,rlwalins(6,nlev),sigma,&
  379. trof(1))
  380. hrwalins(6,1)=radflux
  381. end if
  382. !Windows
  383. do ilev=1,nlev
  384. do ivw=1,4
  385. hrwinins(ivw,ilev)=emwin*rlwalins(ivw,ilev)- &
  386. emwin*sigma*(twin(ivw,ilev)**4)
  387. end do
  388. end do
  389. ! Calculation of the sensible heat fluxes
  390. ! ---------------------------------------
  391. !Vertical fluxes for walls
  392. do ilev=1,nlev
  393. do ivw=1,4
  394. call hsinsflux (2,2,tlev(ilev),twal(ivw,1,ilev),hs)
  395. hswalins(ivw,ilev)=hs
  396. end do ! ivw
  397. end do ! ilev
  398. !Vertical fluxes for windows
  399. do ilev=1,nlev
  400. do ivw=1,4
  401. call hsinsflux (2,1,tlev(ilev),twin(ivw,ilev),hs)
  402. hswinins(ivw,ilev)=hs
  403. end do ! ivw
  404. end do !ilev
  405. !Horizontal fluxes
  406. if (nlev.gt.2) then
  407. do ilev=2,nlev-1
  408. call hsinsflux (1,2,tlev(ilev),tflo(nflo,ilev-1),hs)
  409. hswalins(5,ilev)=hs
  410. call hsinsflux (1,2,tlev(ilev),tflo(1,ilev),hs)
  411. hswalins(6,ilev)=hs
  412. end do ! ilev
  413. end if
  414. if (nlev.ne.1) then
  415. call hsinsflux (1,2,tlev(1),tgrd(ngrd),hs)
  416. hswalins(5,1)=hs !Bottom room
  417. call hsinsflux (1,2,tlev(1),tflo(1,1),hs)
  418. hswalins(6,1)=hs
  419. call hsinsflux (1,2,tlev(nlev),tflo(nflo,nlev-1),hs)
  420. hswalins(5,nlev)=hs !Top room
  421. call hsinsflux (1,2,tlev(nlev),trof(1),hs)
  422. hswalins(6,nlev)=hs
  423. else ! Bottom<--->Top
  424. call hsinsflux (1,2,tlev(1),tgrd(ngrd),hs)
  425. hswalins(5,1)=hs
  426. call hsinsflux (1,2,tlev(nlev),trof(1),hs)
  427. hswalins(6,nlev)=hs
  428. end if
  429. !Calculation of the temperature for the different surfaces
  430. ! --------------------------------------------------------
  431. ! Vertical walls
  432. swwal=1
  433. do ilev=1,nlev
  434. do ivw=1,4
  435. htot(1)=hswalins(ivw,ilev)+hrwalins(ivw,ilev)
  436. htot(2)=hswalout(ivw,ilev)+hrwalout(ivw,ilev)
  437. gswal(ivw,ilev)=htot(2)
  438. do iwal=1,nwal
  439. twal1D(iwal)=twal(ivw,iwal,ilev)
  440. end do
  441. call wall(swwal,nwal,dt,dzwal,kwal,cswal,htot,twal1D)
  442. do iwal=1,nwal
  443. twal(ivw,iwal,ilev)=twal1D(iwal)
  444. end do
  445. end do ! ivw
  446. end do ! ilev
  447. ! Windows
  448. do ilev=1,nlev
  449. do ivw=1,4
  450. htot(1)=hswinins(ivw,ilev)+hrwinins(ivw,ilev)
  451. htot(2)=hswinout(ivw,ilev)+hrwinout(ivw,ilev)
  452. twin(ivw,ilev)=twin(ivw,ilev)+(dt/(cswin*thickwin))* &
  453. (htot(1)+htot(2))
  454. end do ! ivw
  455. end do ! ilev
  456. ! Horizontal floors
  457. if (nlev.gt.1) then
  458. swwal=1
  459. do ilev=1,nlev-1
  460. htot(1)=hrwalins(6,ilev)+hswalins(6,ilev)
  461. htot(2)=hrwalins(5,ilev+1)+hswalins(5,ilev+1)
  462. do iflo=1,nflo
  463. tflo1D(iflo)=tflo(iflo,ilev)
  464. end do
  465. call wall(swwal,nflo,dt,dzflo,kflo,csflo,htot,tflo1D)
  466. do iflo=1,nflo
  467. tflo(iflo,ilev)=tflo1D(iflo)
  468. end do
  469. end do ! ilev
  470. end if
  471. ! Ground
  472. swwal=1
  473. htot(1)=0. !Diriclet b.c. at the internal boundary
  474. htot(2)=hswalins(5,1)+hrwalins(5,1)
  475. do igrd=1,ngrd
  476. tgrd1D(igrd)=tgrd(igrd)
  477. end do
  478. call wall(swwal,ngrd,dt,dzgrd,kgrd,csgrd,htot,tgrd1D)
  479. do igrd=1,ngrd
  480. tgrd(igrd)=tgrd1D(igrd)
  481. end do
  482. ! Roof
  483. swwal=1
  484. htot(1)=hswalins(6,nlev)+hrwalins(6,nlev)
  485. htot(2)=hsrof+hrrof
  486. gsrof=htot(2)
  487. do irof=1,nrof
  488. trof1D(irof)=trof(irof)
  489. end do
  490. call wall(swwal,nrof,dt,dzrof,krof,csrof,htot,trof1D)
  491. do irof=1,nrof
  492. trof(irof)=trof1D(irof)
  493. end do
  494. ! Calculation of the heat fluxes and of the temperature of the rooms
  495. ! ------------------------------------------------------------------
  496. do ilev=1,nlev
  497. !Calculation of the heat generated by equipments and occupants
  498. call fluxeqocc(nhourday,bw,bl,perflo,hsesf,hsequip,hseqocc(ilev),hleqocc(ilev))
  499. !Calculation of the heat generated by natural ventilation
  500. vollev=bw*bl*dzlev
  501. humdry=shumlev(ilev)/(1.-shumlev(ilev))
  502. rhoint=(press(ilev))/(rair*(1.+0.61*humdry)*tlev(ilev))
  503. cpint=cp*(1.+0.84*humdry)
  504. call fluxvent(cpint,rhoint,vollev,tlev(ilev),tout(ilev), &
  505. latent,humout(ilev),rhoout(ilev),shumlev(ilev),&
  506. beta,hsvent(ilev),hlvent(ilev))
  507. !Calculation of the heat generated by conduction
  508. do iwal=1,6
  509. hswalins1D(iwal)=hswalins(iwal,ilev)
  510. surwal1D(iwal)=surwal(iwal,ilev)
  511. end do
  512. do iwal=1,4
  513. hswinins1D(iwal)=hswinins(iwal,ilev)
  514. end do
  515. call fluxcond(hswalins1D,hswinins1D,surwal1D,pwin,&
  516. hscond(ilev))
  517. !Calculation of the heat generated inside the room
  518. call fluxroo(hseqocc(ilev),hleqocc(ilev),hsvent(ilev), &
  519. hlvent(ilev),hscond(ilev),hslev(ilev),hllev(ilev))
  520. !Evolution of the temperature and of the specific humidity
  521. Qb=rhoint*cpint*vollev
  522. ! temperature regulation
  523. call regtemp(sw_cond,nhourday,dt,Qb,hslev(ilev), &
  524. tlev(ilev),timeon,timeoff,targtemp,gaptemp,hsneed(ilev))
  525. ! humidity regulation
  526. call reghum(sw_cond,nhourday,dt,vollev,rhoint,latent, &
  527. hllev(ilev),shumlev(ilev),timeon,timeoff,&
  528. targhum,gaphum,hlneed(ilev))
  529. !
  530. !performance of the air conditioning system for the test
  531. !
  532. call air_cond(hsneed(ilev),hlneed(ilev),dt, &
  533. hsout(ilev),hlout(ilev),consump(ilev), cop)
  534. tlev(ilev)=tlev(ilev)+(dt/Qb)*(hslev(ilev)-hsneed(ilev))
  535. shumlev(ilev)=shumlev(ilev)+(dt/(vollev*rhoint*latent))* &
  536. (hllev(ilev)-hlneed(ilev))
  537. end do !ilev
  538. call consump_total(nzcanm,nlev,consumpbuild,hsoutbuild, &
  539. hsout,consump)
  540. return
  541. end subroutine BEM
  542. !====6=8===============================================================72
  543. !====6=8===============================================================72
  544. subroutine wall(swwall,nz,dt,dz,k,cs,flux,temp)
  545. !______________________________________________________________________
  546. !The aim of this subroutine is to solve the 1D heat fiffusion equation
  547. !for roof, walls and streets:
  548. !
  549. ! dT/dt=d/dz[K*dT/dz] where:
  550. !
  551. ! -T is the surface temperature(wall, street, roof)
  552. ! -Kz is the heat diffusivity inside the material.
  553. !
  554. !The resolution is done implicitly with a FV discretisation along the
  555. !different layers of the material:
  556. ! ____________________________
  557. ! n *
  558. ! *
  559. ! *
  560. ! ____________________________
  561. ! i+2
  562. ! I+1
  563. ! ____________________________
  564. ! i+1
  565. ! I ==> [T(I,n+1)-T(I,n)]/DT=
  566. ! ____________________________ [F(i+1)-F(i)]/DZI
  567. ! i
  568. ! I-1 ==> A*T(n+1)=B where:
  569. ! ____________________________
  570. ! i-1 * * A is a TRIDIAGONAL matrix.
  571. ! * * B=T(n)+S takes into account the sources.
  572. ! *
  573. ! 1 ____________________________
  574. !________________________________________________________________
  575. implicit none
  576. !Input:
  577. !-----
  578. integer nz !Number of layers inside the material
  579. real dt !Time step
  580. real dz(nz) !Layer sizes [m]
  581. real cs(nz) !Specific heat of the material [J/(m3.K)]
  582. real k(nz+1) !Thermal conductivity in each layers (face) [W/(m.K)]
  583. real flux(2) !Internal and external flux terms.
  584. !Input-Output:
  585. !-------------
  586. integer swwall !swich for the physical coefficients calculation
  587. real temp(nz) !Temperature at each layer
  588. !Local:
  589. !-----
  590. real a(-1:1,nz) ! a(-1,*) lower diagonal A(i,i-1)
  591. ! a(0,*) principal diagonal A(i,i)
  592. ! a(1,*) upper diagonal A(i,i+1).
  593. real b(nz) !Coefficients of the second term.
  594. real k1(20)
  595. real k2(20)
  596. real kc(20)
  597. save k1,k2,kc
  598. integer iz
  599. !________________________________________________________________
  600. !
  601. !Calculation of the coefficients
  602. if (swwall.eq.1) then
  603. if (nz.gt.20) then
  604. write(*,*) 'number of layers in the walls/roofs too big ',nz
  605. write(*,*) 'please decrease under of',20
  606. stop
  607. endif
  608. call wall_coeff(nz,dt,dz,cs,k,k1,k2,kc)
  609. swwall=0
  610. end if
  611. !Computation of the first value (iz=1) of A and B:
  612. a(-1,1)=0.
  613. a(0,1)=1+k2(1)
  614. a(1,1)=-k2(1)
  615. b(1)=temp(1)+flux(1)*kc(1)
  616. !!
  617. !!We can fixed the internal temperature
  618. !!
  619. !! a(-1,1)=0.
  620. !! a(0,1)=1
  621. !! a(1,1)=0.
  622. !!
  623. !! b(1)=temp(1)
  624. !!
  625. !Computation of the internal values (iz=2,...,n-1) of A and B:
  626. do iz=2,nz-1
  627. a(-1,iz)=-k1(iz)
  628. a(0,iz)=1+k1(iz)+k2(iz)
  629. a(1,iz)=-k2(iz)
  630. b(iz)=temp(iz)
  631. end do
  632. !Computation of the external value (iz=n) of A and B:
  633. a(-1,nz)=-k1(nz)
  634. a(0,nz)=1+k1(nz)
  635. a(1,nz)=0.
  636. b(nz)=temp(nz)+flux(2)*kc(nz)
  637. !Resolution of the system A*T(n+1)=B
  638. call tridia(nz,a,b,temp)
  639. return
  640. end subroutine wall
  641. !====6=8===============================================================72
  642. !====6=8===============================================================72
  643. subroutine wall_coeff(nz,dt,dz,cs,k,k1,k2,kc)
  644. implicit none
  645. !---------------------------------------------------------------------
  646. !Input
  647. !-----
  648. integer nz !Number of layers inside the material
  649. real dt !Time step
  650. real dz(nz) !Layer sizes [m]
  651. real cs(nz) !Specific heat of the material [J/(m3.K)]
  652. real k(nz+1) !Thermal diffusivity in each layers (face) [W/(m.K)]
  653. !Input-Output
  654. !------------
  655. real flux(2) !Internal and external flux terms.
  656. !Output
  657. !------
  658. real k1(20)
  659. real k2(20)
  660. real kc(20)
  661. !Local
  662. !-----
  663. integer iz
  664. real kf(nz)
  665. !------------------------------------------------------------------
  666. do iz=2,nz
  667. kc(iz)=dt/(dz(iz)*cs(iz))
  668. kf(iz)=2*k(iz)/(dz(iz)+dz(iz-1))
  669. end do
  670. kc(1)=dt/(dz(1)*cs(1))
  671. kf(1)=2*k(1)/(dz(1))
  672. do iz=1,nz
  673. k1(iz)=kc(iz)*kf(iz)
  674. end do
  675. do iz=1,nz-1
  676. k2(iz)=kc(iz)*kf(iz+1)*cs(iz)/cs(iz+1)
  677. end do
  678. return
  679. end subroutine wall_coeff
  680. !====6=8===============================================================72
  681. !====6=8===============================================================72
  682. subroutine hsinsflux(swsurf,swwin,tin,tw,hsins)
  683. implicit none
  684. ! --------------------------------------------------------------------
  685. ! This routine computes the internal sensible heat flux.
  686. ! The swsurf, makes rhe difference between a vertical and a
  687. ! horizontal surface.
  688. ! The values of the heat conduction coefficients hc are obtained from the book
  689. ! "Energy Simulation in Building Design". J.A. Clarke.
  690. ! Adam Hilger, Bristol, 362 pp.
  691. ! --------------------------------------------------------------------
  692. !Input
  693. !----
  694. integer swsurf !swich for the type of surface (horizontal/vertical)
  695. integer swwin !swich for the type of surface (window/wall)
  696. real tin !Inside temperature [K]
  697. real tw !Internal wall temperature [K]
  698. !Output
  699. !------
  700. real hsins !internal sensible heat flux [W/m2]
  701. !Local
  702. !-----
  703. real hc !heat conduction coefficient [W/°C.m2]
  704. !--------------------------------------------------------------------
  705. if (swsurf.eq.2) then !vertical surface
  706. if (swwin.eq.1) then
  707. hc=5.678*0.99 !window surface (smooth surface)
  708. else
  709. hc=5.678*1.09 !wall surface (rough surface)
  710. endif
  711. hsins=hc*(tin-tw)
  712. endif
  713. if (swsurf.eq.1) then !horizontal surface
  714. if (swwin.eq.1) then
  715. hc=5.678*0.99 !window surface (smooth surface)
  716. else
  717. hc=5.678*1.09 !wall surface (rough surface)
  718. endif
  719. hsins=hc*(tin-tw)
  720. endif
  721. return
  722. end subroutine hsinsflux
  723. !====6=8===============================================================72
  724. !====6=8===============================================================72
  725. subroutine int_rsrad(albwin,albwal,pwin,rswal,&
  726. surwal,bw,bl,zw,rsint)
  727. ! ------------------------------------------------------------------
  728. implicit none
  729. ! ------------------------------------------------------------------
  730. !Input
  731. !-----
  732. real albwin !albedo of the windows
  733. real albwal !albedo of the internal wall
  734. real rswal(4) !incoming short wave radiation [W/m2]
  735. real surwal(6) !surface of the indoor walls [m2]
  736. real bw,bl !width of the walls [m]
  737. real zw !height of the wall [m]
  738. real pwin !window proportion
  739. !Output
  740. !------
  741. real rsint(6) !internal walls short wave radiation [W/m2]
  742. !Local
  743. !-----
  744. real transmit !transmittance of the direct/diffused radiation
  745. real rstr !solar radiation transmitted through the windows
  746. real surtotwal !total indoor surface of the walls in the room
  747. integer iw
  748. real b(6) !second member for the system
  749. real a(6,6) !matrix for the system
  750. !-------------------------------------------------------------------
  751. ! Calculation of the solar radiation transmitted through windows
  752. rstr = 0.
  753. do iw=1,4
  754. transmit=1.-albwin
  755. rstr = rstr+(surwal(iw)*pwin)*(transmit*rswal(iw))
  756. enddo
  757. !We suppose that the radiation is spread isotropically within the
  758. !room when it passes through the windows, so the flux [W/mË›] in every
  759. !wall is:
  760. surtotwal=0.
  761. do iw=1,6
  762. surtotwal=surtotwal+surwal(iw)
  763. enddo
  764. rstr=rstr/surtotwal
  765. !Computation of the short wave radiation reaching the internal walls
  766. call algebra_short(rstr,albwal,albwin,bw,bl,zw,pwin,a,b)
  767. call gaussjbem(a,6,b,6)
  768. do iw=1,6
  769. rsint(iw)=b(iw)
  770. enddo
  771. return
  772. end subroutine int_rsrad
  773. !====6=8===============================================================72
  774. !====6=8===============================================================72
  775. subroutine int_rlrad(emwal,emwin,sigma,twal_int,twin,&
  776. pwin,bw,bl,zw,rlint)
  777. ! ------------------------------------------------------------------
  778. implicit none
  779. ! ------------------------------------------------------------------
  780. !Input
  781. !-----
  782. real emwal !emissivity of the internal walls
  783. real emwin !emissivity of the window
  784. real sigma !Stefan-Boltzmann constant [W/m2.K4]
  785. real twal_int(6)!temperature of the first internal layers of a room [K]
  786. real twin(4) !temperature of the windows [K]
  787. real bw !width of the wall
  788. real bl !length of the wall
  789. real zw !height of the wall
  790. real pwin !window proportion
  791. !Output
  792. !------
  793. real rlint(6) !internal walls long wave radiation [W/m2]
  794. !Local
  795. !------
  796. real b(6) !second member vector for the system
  797. real a(6,6) !matrix for the system
  798. integer iw
  799. !----------------------------------------------------------------
  800. !Compute the long wave radiation reachs the internal walls
  801. call algebra_long(emwal,emwin,sigma,twal_int,twin,pwin,&
  802. bw,bl,zw,a,b)
  803. call gaussjbem(a,6,b,6)
  804. do iw=1,6
  805. rlint(iw)=b(iw)
  806. enddo
  807. return
  808. end subroutine int_rlrad
  809. !====6=8===============================================================72
  810. !====6=8===============================================================72
  811. subroutine algebra_short(rstr,albwal,albwin,aw,bw,zw,pwin,a,b)
  812. !--------------------------------------------------------------------
  813. !This routine calculates the algebraic system that will be solved for
  814. !the computation of the total shortwave radiation that reachs every
  815. !indoor wall in a floor.
  816. !Write the matrix system ax=b to solve
  817. !
  818. ! -Rs(1)+a(1,2)Rs(2)+.................+a(1,6)Rs(6)=-Rs=b(1)
  819. !a(2,1)Rs(1)- Rs(2)+.................+a(2,6)Rs(6)=-Rs=b(2)
  820. !a(3,1)Rs(1)+a(3,2)Rs(3)-Rs(3)+...........+a(3,6)Rs(6)=-Rs=b(3)
  821. !a(4,1)Rs(1)+.................-Rs(4)+.....+a(4,6)Rs(6)=-Rs=b(4)
  822. !a(5,1)Rs(1)+.......................-Rs(5)+a(5,6)Rs(6)=-Rs=b(5)
  823. !a(6,1)Rs(1)+....................................-R(6)=-Rs=b(6)
  824. !
  825. !This version suppose the albedo of the indoor walls is the same.
  826. !--------------------------------------------------------------------
  827. implicit none
  828. !--------------------------------------------------------------------
  829. !Input
  830. !-----
  831. real rstr !solar radiation transmitted through the windows
  832. real albwal !albedo of the internal walls
  833. real albwin !albedo of the windows.
  834. real bw !length of the wall
  835. real aw !width of the wall
  836. real zw !height of the wall
  837. real fprl_int !view factor
  838. real fnrm_int !view factor
  839. real pwin !window proportion
  840. !Output
  841. !------
  842. real a(6,6) !Matrix for the system
  843. real b(6) !Second member for the system
  844. !Local
  845. !-----
  846. integer iw,jw
  847. real albm !averaged albedo
  848. !----------------------------------------------------------------
  849. !Initialise the variables
  850. do iw=1,6
  851. b(iw)= 0.
  852. do jw=1,6
  853. a(iw,jw)= 0.
  854. enddo
  855. enddo
  856. !Calculation of the second member b
  857. do iw=1,6
  858. b(iw)=-rstr
  859. end do
  860. !Calculation of the averaged albedo
  861. albm=pwin*albwin+(1-pwin)*albwal
  862. !Calculation of the matrix a
  863. a(1,1)=-1.
  864. call fprl_ints(fprl_int,aw/bw,zw/bw)
  865. a(1,2)=albm*fprl_int
  866. call fnrm_ints(fnrm_int,aw/zw,bw/zw,(aw*aw+bw*bw)/(zw*zw))
  867. a(1,3)=albm*(bw/aw)*fnrm_int
  868. a(1,4)=a(1,3)
  869. call fnrm_ints(fnrm_int,zw/aw,bw/aw,(bw*bw+zw*zw)/(aw*aw))
  870. a(1,5)=albwal*(bw/zw)*fnrm_int
  871. a(1,6)=a(1,5)
  872. a(2,1)=a(1,2)
  873. a(2,2)=-1.
  874. a(2,3)=a(1,3)
  875. a(2,4)=a(1,4)
  876. a(2,5)=a(1,5)
  877. a(2,6)=a(1,6)
  878. call fnrm_ints(fnrm_int,bw/zw,aw/zw,(bw*bw+aw*aw)/(zw*zw))
  879. a(3,1)=albm*(aw/bw)*fnrm_int
  880. a(3,2)=a(3,1)
  881. a(3,3)=-1.
  882. call fprl_ints(fprl_int,zw/aw,bw/aw)
  883. a(3,4)=albm*fprl_int
  884. call fnrm_ints(fnrm_int,zw/bw,aw/bw,(aw*aw+zw*zw)/(bw*bw))
  885. a(3,5)=albwal*(aw/zw)*fnrm_int
  886. a(3,6)=a(3,5)
  887. a(4,1)=a(3,1)
  888. a(4,2)=a(3,2)
  889. a(4,3)=a(3,4)
  890. a(4,4)=-1.
  891. a(4,5)=a(3,5)
  892. a(4,6)=a(3,6)
  893. call fnrm_ints(fnrm_int,bw/aw,zw/aw,(bw*bw+zw*zw)/(aw*aw))
  894. a(5,1)=albm*(zw/bw)*fnrm_int
  895. a(5,2)=a(5,1)
  896. call fnrm_ints(fnrm_int,aw/bw,zw/bw,(aw*aw+zw*zw)/(bw*bw))
  897. a(5,3)=albm*(zw/aw)*fnrm_int
  898. a(5,4)=a(5,3)
  899. a(5,5)=-1.
  900. call fprl_ints(fprl_int,aw/zw,bw/zw)
  901. a(5,6)=albwal*fprl_int
  902. a(6,1)=a(5,1)
  903. a(6,2)=a(5,2)
  904. a(6,3)=a(5,3)
  905. a(6,4)=a(5,4)
  906. a(6,5)=a(5,6)
  907. a(6,6)=-1.
  908. return
  909. end subroutine algebra_short
  910. !====6=8===============================================================72
  911. !====6=8===============================================================72
  912. subroutine algebra_long(emwal,emwin,sigma,twalint,twinint,&
  913. pwin,aw,bw,zw,a,b)
  914. !--------------------------------------------------------------------
  915. !This routine computes the algebraic system that will be solved to
  916. !compute the longwave radiation that reachs the indoor
  917. !walls in a floor.
  918. !Write the matrix system ax=b to solve
  919. !
  920. !a(1,1)Rl(1)+.............................+Rl(6)=b(1)
  921. !a(2,1)Rl(1)+.................+Rl(5)+a(2,6)Rl(6)=b(2)
  922. !a(3,1)Rl(1)+.....+Rl(3)+...........+a(3,6)Rl(6)=b(3)
  923. !a(4,1)Rl(1)+...........+Rl(4)+.....+a(4,6)Rl(6)=b(4)
  924. ! Rl(1)+.......................+a(5,6)Rl(6)=b(5)
  925. !a(6,1)Rl(1)+Rl(2)+.................+a(6,6)Rl(6)=b(6)
  926. !
  927. !--------------------------------------------------------------------
  928. implicit none
  929. !--------------------------------------------------------------------
  930. !Input
  931. !-----
  932. real pwin !window proportion
  933. real emwal !emissivity of the internal walls
  934. real emwin !emissivity of the window
  935. real sigma !Stefan-Boltzmann constant [W/m2.K4]
  936. real twalint(6) !temperature of the first internal layers of a room [K]
  937. real twinint(4) !temperature of the windows [K]
  938. real aw !width of the wall
  939. real bw !length of the wall
  940. real zw !height of the wall
  941. real fprl_int !view factor
  942. real fnrm_int !view factor
  943. real fnrm_intx !view factor
  944. real fnrm_inty !view factor
  945. !Output
  946. !------
  947. real b(6) !second member vector for the system
  948. real a(6,6) !matrix for the system
  949. !Local
  950. !-----
  951. integer iw,jw
  952. real b_wall(6)
  953. real b_wind(6)
  954. real emwal_av !averadge emissivity of the wall
  955. real emwin_av !averadge emissivity of the window
  956. real em_av !averadge emissivity
  957. real twal_int(6) !twalint
  958. real twin(4) !twinint
  959. !------------------------------------------------------------------
  960. !Initialise the variables
  961. !-------------------------
  962. do iw=1,6
  963. b(iw)= 0.
  964. b_wall(iw)=0.
  965. b_wind(iw)=0.
  966. do jw=1,6
  967. a(iw,jw)= 0.
  968. enddo
  969. enddo
  970. do iw=1,6
  971. twal_int(iw)=twalint(iw)
  972. enddo
  973. do iw=1,4
  974. twin(iw)=twinint(iw)
  975. enddo
  976. !Calculation of the averadge emissivities
  977. !-----------------------------------------
  978. emwal_av=(1-pwin)*emwal
  979. emwin_av=pwin*emwin
  980. em_av=emwal_av+emwin_av
  981. !Calculation of the second term for the walls
  982. !-------------------------------------------
  983. call fprl_ints(fprl_int,aw/zw,bw/zw)
  984. call fnrm_ints(fnrm_intx,aw/bw,zw/bw,(aw*aw+zw*zw)/(bw*bw))
  985. call fnrm_ints(fnrm_inty,bw/aw,zw/aw,(bw*bw+zw*zw)/(aw*aw))
  986. b_wall(1)=(emwal*sigma*(twal_int(5)**4)* &
  987. fprl_int)+ &
  988. (sigma*(emwal_av*(twal_int(3)**4)+ &
  989. emwal_av*(twal_int(4)**4))* &
  990. (zw/aw)*fnrm_intx)+ &
  991. (sigma*(emwal_av*(twal_int(1)**4)+ &
  992. emwal_av*(twal_int(2)**4))* &
  993. (zw/bw)*fnrm_inty)
  994. call fprl_ints(fprl_int,aw/zw,bw/zw)
  995. call fnrm_ints(fnrm_intx,aw/bw,zw/bw,(aw*aw+zw*zw)/(bw*bw))
  996. call fnrm_ints(fnrm_inty,bw/aw,zw/aw,(bw*bw+zw*zw)/(aw*aw))
  997. b_wall(2)=(emwal*sigma*(twal_int(6)**4)* &
  998. fprl_int)+ &
  999. (sigma*(emwal_av*(twal_int(3)**4)+ &
  1000. emwal_av*(twal_int(4)**4))* &
  1001. (zw/aw)*fnrm_intx)+ &
  1002. (sigma*(emwal_av*(twal_int(1)**4)+ &
  1003. emwal_av*(twal_int(2)**4))* &
  1004. (zw/bw)*fnrm_inty)
  1005. call fprl_ints(fprl_int,zw/aw,bw/aw)
  1006. call fnrm_ints(fnrm_intx,bw/zw,aw/zw,(bw*bw+aw*aw)/(zw*zw))
  1007. call fnrm_ints(fnrm_inty,zw/bw,aw/bw,(aw*aw+zw*zw)/(bw*bw))
  1008. b_wall(3)=(emwal_av*sigma*(twal_int(4)**4)* &
  1009. fprl_int)+ &
  1010. (sigma*(emwal_av*(twal_int(2)**4)+ &
  1011. emwal_av*(twal_int(1)**4))* &
  1012. (aw/bw)*fnrm_intx)+ &
  1013. (sigma*(emwal*(twal_int(5)**4)+ &
  1014. emwal*(twal_int(6)**4))* &
  1015. (aw/zw)*fnrm_inty)
  1016. call fprl_ints(fprl_int,zw/aw,bw/aw)
  1017. call fnrm_ints(fnrm_intx,bw/zw,aw/zw,(bw*bw+aw*aw)/(zw*zw))
  1018. call fnrm_ints(fnrm_inty,zw/bw,aw/bw,(aw*aw+zw*zw)/(bw*bw))
  1019. b_wall(4)=(emwal_av*sigma*(twal_int(3)**4)* &
  1020. fprl_int)+ &
  1021. (sigma*(emwal_av*(twal_int(2)**4)+ &
  1022. emwal_av*(twal_int(1)**4))* &
  1023. (aw/bw)*fnrm_intx)+ &
  1024. (sigma*(emwal*(twal_int(5)**4)+ &
  1025. emwal*(twal_int(6)**4))* &
  1026. (aw/zw)*fnrm_inty)
  1027. call fprl_ints(fprl_int,aw/bw,zw/bw)
  1028. call fnrm_ints(fnrm_intx,aw/zw,bw/zw,(aw*aw+bw*bw)/(zw*zw))
  1029. call fnrm_ints(fnrm_inty,zw/aw,bw/aw,(bw*bw+zw*zw)/(aw*aw))
  1030. b_wall(5)=(emwal_av*sigma*(twal_int(2)**4)* &
  1031. fprl_int)+ &
  1032. (sigma*(emwal_av*(twal_int(3)**4)+ &
  1033. emwal_av*(twal_int(4)**4))* &
  1034. (bw/aw)*fnrm_intx)+ &
  1035. (sigma*(emwal*(twal_int(5)**4)+ &
  1036. emwal*(twal_int(6)**4))* &
  1037. (bw/zw)*fnrm_inty)
  1038. call fprl_ints(fprl_int,aw/bw,zw/bw)
  1039. call fnrm_ints(fnrm_intx,aw/zw,bw/zw,(aw*aw+bw*bw)/(zw*zw))
  1040. call fnrm_ints(fnrm_inty,zw/aw,bw/aw,(bw*bw+zw*zw)/(aw*aw))
  1041. b_wall(6)=(emwal_av*sigma*(twal_int(1)**4)* &
  1042. fprl_int)+ &
  1043. (sigma*(emwal_av*(twal_int(3)**4)+ &
  1044. emwal_av*(twal_int(4)**4))* &
  1045. (bw/aw)*fnrm_intx)+ &
  1046. (sigma*(emwal*(twal_int(5)**4)+ &
  1047. emwal*(twal_int(6)**4))* &
  1048. (bw/zw)*fnrm_inty)
  1049. !Calculation of the second term for the windows
  1050. !---------------------------------------------
  1051. call fnrm_ints(fnrm_intx,aw/bw,zw/bw,(aw*aw+zw*zw)/(bw*bw))
  1052. call fnrm_ints(fnrm_inty,bw/aw,zw/aw,(bw*bw+zw*zw)/(aw*aw))
  1053. b_wind(1)=(sigma*(emwin_av*(twin(3)**4)+ &
  1054. emwin_av*(twin(4)**4))* &
  1055. (zw/aw)*fnrm_intx)+ &
  1056. (sigma*(emwin_av*(twin(1)**4)+ &
  1057. emwin_av*(twin(2)**4))* &
  1058. (zw/bw)*fnrm_inty)
  1059. call fnrm_ints(fnrm_intx,aw/bw,zw/bw,(aw*aw+zw*zw)/(bw*bw))
  1060. call fnrm_ints(fnrm_inty,bw/aw,zw/aw,(bw*bw+zw*zw)/(aw*aw))
  1061. b_wind(2)=(sigma*(emwin_av*(twin(3)**4)+ &
  1062. emwin_av*(twin(4)**4))* &
  1063. (zw/aw)*fnrm_intx)+ &
  1064. (sigma*(emwin_av*(twin(1)**4)+ &
  1065. emwin_av*(twin(2)**4))* &
  1066. (zw/bw)*fnrm_inty)
  1067. call fprl_ints(fprl_int,zw/aw,bw/aw)
  1068. call fnrm_ints(fnrm_int,bw/zw,aw/zw,(bw*bw+aw*aw)/(zw*zw))
  1069. b_wind(3)=emwin_av*sigma*(twin(4)**4)* &
  1070. fprl_int+(sigma*(emwin_av* &
  1071. (twin(2)**4)+emwin_av*(twin(1)**4))* &
  1072. (aw/bw)*fnrm_int)
  1073. call fprl_ints(fprl_int,zw/aw,bw/aw)
  1074. call fnrm_ints(fnrm_int,bw/zw,aw/zw,(bw*bw+aw*aw)/(zw*zw))
  1075. b_wind(4)=emwin_av*sigma*(twin(3)**4)* &
  1076. fprl_int+(sigma*(emwin_av* &
  1077. (twin(2)**4)+emwin_av*(twin(1)**4))* &
  1078. (aw/bw)*fnrm_int)
  1079. call fprl_ints(fprl_int,aw/bw,zw/bw)
  1080. call fnrm_ints(fnrm_int,aw/zw,bw/zw,(aw*aw+bw*bw)/(zw*zw))
  1081. b_wind(5)=emwin_av*sigma*(twin(2)**4)* &
  1082. fprl_int+(sigma*(emwin_av* &
  1083. (twin(3)**4)+emwin_av*(twin(4)**4))* &
  1084. (bw/aw)*fnrm_int)
  1085. call fprl_ints(fprl_int,aw/bw,zw/bw)
  1086. call fnrm_ints(fnrm_int,aw/zw,bw/zw,(aw*aw+bw*bw)/(zw*zw))
  1087. b_wind(6)=emwin_av*sigma*(twin(1)**4)* &
  1088. fprl_int+(sigma*(emwin_av* &
  1089. (twin(3)**4)+emwin_av*(twin(4)**4))* &
  1090. (bw/aw)*fnrm_int)
  1091. !Calculation of the total b term
  1092. !-------------------------------
  1093. do iw=1,6
  1094. b(iw)=b_wall(iw)+b_wind(iw)
  1095. end do
  1096. !Calculation of the matrix of the system
  1097. !----------------------------------------
  1098. call fnrm_ints(fnrm_int,bw/aw,zw/aw,(bw*bw+zw*zw)/(aw*aw))
  1099. a(1,1)=(em_av-1.)*(zw/bw)*fnrm_int
  1100. a(1,2)=a(1,1)
  1101. call fnrm_ints(fnrm_int,aw/bw,zw/bw,(aw*aw+zw*zw)/(bw*bw))
  1102. a(1,3)=(em_av-1.)*(zw/aw)*fnrm_int
  1103. a(1,4)=a(1,3)
  1104. call fprl_ints(fprl_int,aw/zw,bw/zw)
  1105. a(1,5)=(emwal-1.)*fprl_int
  1106. a(1,6)=1.
  1107. a(2,1)=a(1,1)
  1108. a(2,2)=a(1,2)
  1109. a(2,3)=a(1,3)
  1110. a(2,4)=a(1,4)
  1111. a(2,5)=1.
  1112. a(2,6)=a(1,5)
  1113. call fnrm_ints(fnrm_int,bw/zw,aw/zw,(bw*bw+aw*aw)/(zw*zw))
  1114. a(3,1)=(em_av-1.)*(aw/bw)*fnrm_int
  1115. a(3,2)=a(3,1)
  1116. a(3,3)=1.
  1117. call fprl_ints(fprl_int,zw/aw,bw/aw)
  1118. a(3,4)=(em_av-1.)*fprl_int
  1119. call fnrm_ints(fnrm_int,zw/bw,aw/bw,(aw*aw+zw*zw)/(bw*bw))
  1120. a(3,5)=(emwal-1.)*(aw/zw)*fnrm_int
  1121. a(3,6)=a(3,5)
  1122. a(4,1)=a(3,1)
  1123. a(4,2)=a(3,2)
  1124. a(4,3)=a(3,4)
  1125. a(4,4)=1.
  1126. a(4,5)=a(3,5)
  1127. a(4,6)=a(3,6)
  1128. a(5,1)=1.
  1129. call fprl_ints(fprl_int,aw/bw,zw/bw)
  1130. a(5,2)=(em_av-1.)*fprl_int
  1131. call fnrm_ints(fnrm_int,aw/zw,bw/zw,(aw*aw+bw*bw)/(zw*zw))
  1132. a(5,3)=(em_av-1.)*(bw/aw)*fnrm_int
  1133. a(5,4)=a(5,3)
  1134. call fnrm_ints(fnrm_int,zw/aw,bw/aw,(bw*bw+zw*zw)/(aw*aw))
  1135. a(5,5)=(emwal-1.)*(bw/zw)*fnrm_int
  1136. a(5,6)=a(5,5)
  1137. a(6,1)=a(5,2)
  1138. a(6,2)=1.
  1139. a(6,3)=a(5,3)
  1140. a(6,4)=a(5,4)
  1141. a(6,5)=a(5,5)
  1142. a(6,6)=a(6,5)
  1143. return
  1144. end subroutine algebra_long
  1145. !====6=8===============================================================72
  1146. !====6=8===============================================================72
  1147. subroutine fluxroo(hseqocc,hleqocc,hsvent,hlvent, &
  1148. hscond,hslev,hllev)
  1149. !-----------------------------------------------------------------------
  1150. !This routine calculates the heat flux generated inside the room
  1151. !and the heat ejected to the atmosphere.
  1152. !----------------------------------------------------------------------
  1153. implicit none
  1154. !-----------------------------------------------------------------------
  1155. !Input
  1156. !-----
  1157. real hseqocc !sensible heat generated by equipments and occupants [W]
  1158. real hleqocc !latent heat generated by occupants [W]
  1159. real hsvent !sensible heat generated by natural ventilation [W]
  1160. real hlvent !latent heat generated by natural ventilation [W]
  1161. real hscond !sensible heat generated by wall conduction
  1162. !Output
  1163. !------
  1164. real hslev !sensible heat flux generated inside the room [W]
  1165. real hllev !latent heat flux generatd inside the room
  1166. !Calculation of the total sensible heat generated inside the room
  1167. hslev=hseqocc+hsvent+hscond
  1168. !Calculation of the total latent heat generated inside the room
  1169. hllev=hleqocc+hlvent
  1170. return
  1171. end subroutine fluxroo
  1172. !====6=8===============================================================72
  1173. !====6=8===============================================================72
  1174. subroutine phirat(nhourday,rocc)
  1175. !----------------------------------------------------------------------
  1176. !This routine calculates the occupation ratio of a floor
  1177. !By now we suppose a constant value
  1178. !----------------------------------------------------------------------
  1179. implicit none
  1180. !Input
  1181. !-----
  1182. real nhourday ! number of hours from midnight (local time)
  1183. !Output
  1184. !------
  1185. real rocc !value between 0 and 1
  1186. !!TEST
  1187. rocc=1.
  1188. return
  1189. end subroutine phirat
  1190. !====6=8===============================================================72
  1191. !====6=8===============================================================72
  1192. subroutine phiequ(nhourday,hsesf,hsequip,hsequ)
  1193. !----------------------------------------------------------------------
  1194. !This routine calculates the sensible heat gain from equipments
  1195. !----------------------------------------------------------------------
  1196. implicit none
  1197. !Input
  1198. !-----
  1199. real nhourday ! number of hours from midnight, Local time
  1200. real, intent(in) :: hsesf
  1201. real, intent(in), dimension(24) :: hsequip
  1202. !Output
  1203. !------
  1204. real hsequ !sensible heat gain from equipment [WmŻ2]
  1205. !---------------------------------------------------------------------
  1206. hsequ = hsequip(int(nhourday)+1) * hsesf
  1207. end subroutine phiequ
  1208. !====6=8===============================================================72
  1209. !====6=8===============================================================72
  1210. subroutine fluxeqocc(nhourday,bw,bl,perflo,hsesf,hsequip,hseqocc,hleqocc)
  1211. implicit none
  1212. !---------------------------------------------------------------------
  1213. !This routine calculates the sensible and the latent heat flux
  1214. !generated by equipments and occupants
  1215. !---------------------------------------------------------------------
  1216. !Input
  1217. !-----
  1218. real bw !Room width [m]
  1219. real bl !Room lengzh [m]
  1220. real nhourday !number of hours from the beginning of the day
  1221. real, intent(in) :: perflo ! Peak number of occupants per unit floor area
  1222. real, intent(in) :: hsesf
  1223. real, intent(in), dimension(24) :: hsequip
  1224. !Output
  1225. !------
  1226. real hseqocc !sensible heat generated by equipments and occupants [W]
  1227. real hleqocc !latent heat generated by occupants [W]
  1228. !Local
  1229. !-----
  1230. real Af !Air conditioned floor area [m2]
  1231. real rocc !Occupation ratio of the floor [0,1]
  1232. real hsequ !Heat generated from equipments
  1233. real hsocc !Sensible heat generated by a person [W/Person]
  1234. !Source Boundary Layer Climates,page 195 (book)
  1235. parameter (hsocc=160.)
  1236. real hlocc !Latent heat generated by a person [W/Person]
  1237. !Source Boundary Layer Climates,page 225 (book)
  1238. parameter (hlocc=1.96e6/86400.)
  1239. !------------------------------------------------------------------
  1240. ! Sensible heat flux
  1241. ! ------------------
  1242. Af=bw*bl
  1243. call phirat(nhourday,rocc)
  1244. call phiequ(nhourday,hsesf,hsequip,hsequ)
  1245. hseqocc=Af*rocc*perflo*hsocc+Af*hsequ
  1246. !
  1247. ! Latent heat
  1248. ! -----------
  1249. !
  1250. hleqocc=Af*rocc*perflo*hlocc
  1251. return
  1252. end subroutine fluxeqocc
  1253. !====6=8===============================================================72
  1254. !====6=8===============================================================72
  1255. subroutine fluxvent(cpint,rhoint,vollev,tlev,tout,latent,&
  1256. humout,rhoout,humlev,beta,hsvent,hlvent)
  1257. implicit none
  1258. !---------------------------------------------------------------------
  1259. !This routine calculates the sensible and the latent heat flux
  1260. !generated by natural ventilation
  1261. !---------------------------------------------------------------------
  1262. !Input
  1263. !-----
  1264. real cpint !specific heat of the indoor air [J/kg.K]
  1265. real rhoint !density of the indoor air [Kg/m3]
  1266. real vollev !volume of the room [m3]
  1267. real tlev !Room temperature [K]
  1268. real tout !outside air temperature [K]
  1269. real latent !latent heat of evaporation [J/Kg]
  1270. real humout !outside absolute humidity [Kgwater/Kgair]
  1271. real rhoout !air density [kg/m3]
  1272. real humlev !Specific humidity of the indoor air [Kgwater/Kgair]
  1273. real, intent(in) :: beta!Thermal efficiency of the heat exchanger
  1274. !Output
  1275. !------
  1276. real hsvent !sensible heat generated by natural ventilation [W]
  1277. real hlvent !latent heat generated by natural ventilation [W]
  1278. !Local
  1279. !-----
  1280. !----------------------------------------------------------------------
  1281. ! Sensible heat flux
  1282. ! ------------------
  1283. hsvent=(1.-beta)*cpint*rhoint*(vollev/3600.)* &
  1284. (tout-tlev)
  1285. ! Latent heat flux
  1286. ! ----------------
  1287. hlvent=(1.-beta)*latent*rhoint*(vollev/3600.)* &
  1288. (humout-humlev)
  1289. return
  1290. end subroutine fluxvent
  1291. !====6=8===============================================================72
  1292. !====6=8===============================================================72
  1293. subroutine fluxcond(hswalins,hswinins,surwal,pwin,hscond)
  1294. implicit none
  1295. !---------------------------------------------------------------------
  1296. !This routine calculates the sensible heat flux generated by
  1297. !wall conduction.
  1298. !---------------------------------------------------------------------
  1299. !Input
  1300. !-----
  1301. real hswalins(6) !sensible heat at the internal layers of the wall [W/m2]
  1302. real hswinins(4) !internal window sensible heat flux [W/m2]
  1303. real surwal(6) !surfaces of the room walls [m2]
  1304. real pwin !window proportion
  1305. !Output
  1306. !------
  1307. real hscond !sensible heat generated by wall conduction [W]
  1308. !Local
  1309. !-----
  1310. integer ivw
  1311. !----------------------------------------------------------------------
  1312. hscond=0.
  1313. do ivw=1,4
  1314. hscond=hscond+surwal(ivw)*(1-pwin)*hswalins(ivw)+ &
  1315. surwal(ivw)*pwin*hswinins(ivw)
  1316. end do
  1317. do ivw=5,6
  1318. hscond=hscond+surwal(ivw)*hswalins(ivw)
  1319. end do
  1320. !
  1321. !Finally we must change the sign in hscond to be proportional
  1322. !to the difference (Twall-Tindoor).
  1323. !
  1324. hscond=(-1)*hscond
  1325. return
  1326. end subroutine fluxcond
  1327. !====6=8===============================================================72
  1328. !====6=8===============================================================72
  1329. subroutine regtemp(swcond,nhourday,dt,Qb,hsroo, &
  1330. tlev,timeon,timeoff,targtemp,gaptemp,hsneed)
  1331. implicit none
  1332. !---------------------------------------------------------------------
  1333. !This routine calculates the sensible heat fluxes,
  1334. !after anthropogenic regulation (air conditioning)
  1335. !---------------------------------------------------------------------
  1336. !Input:
  1337. !-----.
  1338. integer swcond !swich air conditioning
  1339. real nhourday !number of hours from the beginning of the day real
  1340. real dt !time step [s]
  1341. real Qb !overall heat capacity of the indoor air [J/K]
  1342. real hsroo !sensible heat flux generated inside the room [W]
  1343. real tlev !room air temperature [K]
  1344. real, intent(in) :: timeon ! Initial local time of A/C systems
  1345. real, intent(in) :: timeoff ! Ending local time of A/C systems
  1346. real, intent(in) :: targtemp! Target temperature of A/C systems
  1347. real, intent(in) :: gaptemp ! Comfort range of indoor temperature
  1348. !Local:
  1349. !-----.
  1350. real templev !hipotetical room air temperature [K]
  1351. real alpha !variable to control the heating/cooling of
  1352. !the air conditining system
  1353. !Output:
  1354. !-----.
  1355. real hsneed !sensible heat extracted to the indoor air [W]
  1356. !---------------------------------------------------------------------
  1357. !initialize variables
  1358. !---------------------
  1359. templev = 0.
  1360. alpha = 0.
  1361. if (swcond.eq.0) then ! there is not air conditioning in the floor
  1362. hsneed = 0.
  1363. goto 100
  1364. else
  1365. if ((nhourday.ge.timeon).and.(nhourday.le.timeoff)) then
  1366. templev=tlev+(dt/Qb)*hsroo
  1367. goto 200
  1368. else
  1369. hsneed = 0. ! air conditioning is switched off
  1370. goto 100
  1371. endif
  1372. endif
  1373. 200 continue
  1374. if (abs(templev-targtemp).le.gaptemp) then
  1375. hsneed = 0.
  1376. else
  1377. if (templev.gt.(targtemp+gaptemp)) then
  1378. hsneed=hsroo-(Qb/dt)*(targtemp+gaptemp-tlev)
  1379. alpha=(abs(hsneed-hsroo)/Qb)
  1380. if (alpha.gt.temp_rat) then
  1381. hsneed=hsroo+temp_rat*Qb
  1382. goto 100
  1383. else
  1384. goto 100
  1385. endif
  1386. else
  1387. hsneed=hsroo-(Qb/dt)*(targtemp-gaptemp-tlev)
  1388. alpha=(abs(hsneed-hsroo)/Qb)
  1389. if (alpha.gt.temp_rat) then
  1390. hsneed=hsroo-temp_rat*Qb
  1391. goto 100
  1392. else
  1393. goto 100
  1394. endif
  1395. endif
  1396. endif
  1397. 100 continue
  1398. return
  1399. end subroutine regtemp
  1400. !====6=8==============================================================72
  1401. !====6=8==============================================================72
  1402. subroutine reghum(swcond,nhourday,dt,volroo,rhoint,latent, &
  1403. hlroo,shumroo,timeon,timeoff,targhum,gaphum,hlneed)
  1404. implicit none
  1405. !---------------------------------------------------------------------
  1406. !This routine calculates the latent heat fluxes,
  1407. !after anthropogenic regulation (air conditioning)
  1408. !---------------------------------------------------------------------
  1409. !Input:
  1410. !-----.
  1411. integer swcond !swich air conditioning
  1412. real nhourday !number of hours from the beginning of the day real[h]
  1413. real dt !time step [s]
  1414. real volroo !volume of the room [m3]
  1415. real rhoint !density of the internal air [Kg/m3]
  1416. real latent !latent heat of evaporation [J/Kg]
  1417. real hlroo !latent heat flux generated inside the room [W]
  1418. real shumroo !specific humidity of the indoor air [kg/kg]
  1419. real, intent(in) :: timeon ! Initial local time of A/C systems
  1420. real, intent(in) :: timeoff ! Ending local time of A/C systems
  1421. real, intent(in) :: targhum ! Target humidity of the A/C systems
  1422. real, intent(in) :: gaphum ! comfort range of the specific humidity
  1423. !Local:
  1424. !-----.
  1425. real humlev !hipotetical specific humidity of the indoor [kg/kg]
  1426. real betha !variable to control the drying/moistening of
  1427. !the air conditioning system
  1428. !Output:
  1429. !-----.
  1430. real hlneed !latent heat extracted to the indoor air [W]
  1431. !------------------------------------------------------------------------
  1432. !initialize variables
  1433. !---------------------
  1434. humlev = 0.
  1435. betha = 0.
  1436. if (swcond.eq.0) then ! there is not air conditioning in the floor
  1437. hlneed = 0.
  1438. goto 100
  1439. else
  1440. if ((nhourday.ge.timeon).and.(nhourday.le.timeoff)) then
  1441. humlev=shumroo+(dt/(latent*rhoint*volroo))*hlroo
  1442. goto 200
  1443. else
  1444. hlneed = 0. ! air conditioning is switched off
  1445. goto 100
  1446. endif
  1447. endif
  1448. 200 continue
  1449. if (abs(humlev-targhum).le.gaphum) then
  1450. hlneed = 0.
  1451. else
  1452. if (humlev.gt.(targhum+gaphum)) then
  1453. hlneed=hlroo-((latent*rhoint*volroo)/dt)* &
  1454. (targhum+gaphum-shumroo)
  1455. betha=abs(hlneed-hlroo)/(latent*rhoint*volroo)
  1456. if (betha.gt.hum_rat) then
  1457. hlneed=hlroo+hum_rat*(latent*rhoint*volroo)
  1458. goto 100
  1459. else
  1460. goto 100
  1461. endif
  1462. else
  1463. hlneed=hlroo-((latent*rhoint*volroo)/dt)* &
  1464. (targhum-gaphum-shumroo)
  1465. betha=abs(hlneed-hlroo)/(latent*rhoint*volroo)
  1466. if (betha.gt.hum_rat) then
  1467. hlneed=hlroo-hum_rat*(latent*rhoint*volroo)
  1468. goto 100
  1469. else
  1470. goto 100
  1471. endif
  1472. endif
  1473. endif
  1474. 100 continue
  1475. return
  1476. end subroutine reghum
  1477. !====6=8==============================================================72
  1478. !====6=8==============================================================72
  1479. subroutine air_cond(hsneed,hlneed,dt,hsout,hlout,consump,cop)
  1480. implicit none
  1481. !
  1482. !Performance of the air conditioning system
  1483. !
  1484. !INPUT/OUTPUT VARIABLES
  1485. real, intent(in) :: cop
  1486. !
  1487. !INPUT/OUTPUT VARIABLES
  1488. !
  1489. real hsneed !sensible heat that is necessary for cooling/heating
  1490. !the indoor air temperature [W]
  1491. real hlneed !latent heat that is necessary for controling
  1492. !the humidity of the indoor air [W]
  1493. real dt !time step [s]
  1494. !
  1495. !OUTPUT VARIABLES
  1496. !
  1497. real hsout !sensible heat pumped out into the atmosphere [W]
  1498. real hlout !latent heat pumped out into the atmosphere [W]
  1499. real consump !Electrical consumption of the air conditioning system [W]
  1500. !
  1501. !Performance of the air conditioning system
  1502. !
  1503. if (hsneed.gt.0) then ! air conditioning is cooling
  1504. ! and the heat is pumped out into the atmosphere
  1505. hsout=(1/cop)*(abs(hsneed)+abs(hlneed))+hsneed
  1506. hlout=hlneed
  1507. consump=(1./cop)*(abs(hsneed)+abs(hlneed))
  1508. !! hsout=0.
  1509. !! hlout=0.
  1510. else if(hsneed.eq.0.) then !air conditioning is not working to regulate the indoor temperature
  1511. hlneed=0. !no humidity regulation is considered
  1512. hsout=0. !no output into the atmosphere (sensible heat)
  1513. hlout=0. !no output into the atmosphere (latent heat)
  1514. consump=0. !no electrical consumption
  1515. else !! hsneed < 0. !air conditioning is heating
  1516. hlneed=0. !no humidity regulation is considered
  1517. hlout=0. !no output into the atmosphere (latent heat)
  1518. consump=(1./cop)*(abs(hsneed)+abs(hlneed))
  1519. !
  1520. !!We have two possibilities
  1521. !
  1522. !! hsout=(1./cop)*(abs(hsneed)+abs(hlneed)) !output into the atmosphere
  1523. hsout=0. !no output into the atmosphere
  1524. end if
  1525. return
  1526. end subroutine air_cond
  1527. !====6=8==============================================================72
  1528. !====6=8==============================================================72
  1529. subroutine consump_total(nzcanm,nlev,consumpbuild,hsoutbuild, &
  1530. hsout,consump)
  1531. implicit none
  1532. !-----------------------------------------------------------------------
  1533. !Compute the total consumption in kWh/s (1kWh=3.6e+6 J) and sensible heat
  1534. !ejected into the atmosphere per building
  1535. !------------------------------------------------------------------------
  1536. !
  1537. !INPUT VARIABLES
  1538. !
  1539. !
  1540. integer nzcanm !Maximum number of vertical levels in the urban grid
  1541. real hsout(nzcanm) !sensible heat emitted outside the room [W]
  1542. real consump(nzcanm) !Electricity consumption for the a.c. in each floor[W]
  1543. !
  1544. !OUTPUT VARIABLES
  1545. !
  1546. real consumpbuild !Energetic consumption for the entire building[kWh/s]
  1547. real hsoutbuild !Total sensible heat ejected into the atmosphere
  1548. !by the air conditioning systems per building [W]
  1549. !
  1550. !LOCAL VARIABLES
  1551. !
  1552. integer ilev
  1553. !
  1554. !INPUT VARIABLES
  1555. !
  1556. integer nlev
  1557. !
  1558. !INITIALIZE VARIABLES
  1559. !
  1560. consumpbuild=0.
  1561. hsoutbuild=0.
  1562. !
  1563. do ilev=1,nlev
  1564. consumpbuild=consumpbuild+consump(ilev)
  1565. hsoutbuild=hsoutbuild+hsout(ilev)
  1566. enddo !ilev
  1567. consumpbuild=consumpbuild/(3.6e+06)
  1568. return
  1569. end subroutine consump_total
  1570. !====6=8==============================================================72
  1571. !====6=8==============================================================72
  1572. subroutine tridia(n,a,b,x)
  1573. ! ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1574. ! + by A. Clappier, EPFL, CH 1015 Lausanne +
  1575. ! + phone: ++41-(0)21-693-61-60 +
  1576. ! + email:alain.clappier@epfl.ch +
  1577. ! ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1578. ! ----------------------------------------------------------------------
  1579. ! Resolution of a * x = b where a is a tridiagonal matrix
  1580. !
  1581. ! ----------------------------------------------------------------------
  1582. implicit none
  1583. ! Input
  1584. integer n
  1585. real a(-1:1,n) ! a(-1,*) lower diagonal A(i,i-1)
  1586. ! a(0,*) principal diagonal A(i,i)
  1587. ! a(1,*) upper diagonal A(i,i+1)
  1588. real b(n)
  1589. ! Output
  1590. real x(n)
  1591. ! Local
  1592. integer i
  1593. ! ----------------------------------------------------------------------
  1594. do i=n-1,1,-1
  1595. b(i)=b(i)-a(1,i)*b(i+1)/a(0,i+1)
  1596. a(0,i)=a(0,i)-a(1,i)*a(-1,i+1)/a(0,i+1)
  1597. enddo
  1598. do i=2,n
  1599. b(i)=b(i)-a(-1,i)*b(i-1)/a(0,i-1)
  1600. enddo
  1601. do i=1,n
  1602. x(i)=b(i)/a(0,i)
  1603. enddo
  1604. return
  1605. end subroutine tridia
  1606. !====6=8===============================================================72
  1607. !====6=8===============================================================72
  1608. subroutine gaussjbem(a,n,b,np)
  1609. ! ----------------------------------------------------------------------
  1610. ! This routine solve a linear system of n equations of the form
  1611. ! A X = B
  1612. ! where A is a matrix a(i,j)
  1613. ! B a vector and X the solution
  1614. ! In output b is replaced by the solution
  1615. ! ----------------------------------------------------------------------
  1616. implicit none
  1617. ! ----------------------------------------------------------------------
  1618. ! INPUT:
  1619. ! ----------------------------------------------------------------------
  1620. integer np
  1621. real a(np,np)
  1622. ! ----------------------------------------------------------------------
  1623. ! OUTPUT:
  1624. ! ----------------------------------------------------------------------
  1625. real b(np)
  1626. ! ----------------------------------------------------------------------
  1627. ! LOCAL:
  1628. ! ----------------------------------------------------------------------
  1629. integer nmax
  1630. parameter (nmax=150)
  1631. real big,dum
  1632. integer i,icol,irow
  1633. integer j,k,l,ll,n
  1634. integer ipiv(nmax)
  1635. real pivinv
  1636. ! ----------------------------------------------------------------------
  1637. ! END VARIABLES DEFINITIONS
  1638. ! ----------------------------------------------------------------------
  1639. do j=1,n
  1640. ipiv(j)=0.
  1641. enddo
  1642. do i=1,n
  1643. big=0.
  1644. do j=1,n
  1645. if(ipiv(j).ne.1)then
  1646. do k=1,n
  1647. if(ipiv(k).eq.0)then
  1648. if(abs(a(j,k)).ge.big)then
  1649. big=abs(a(j,k))
  1650. irow=j
  1651. icol=k
  1652. endif
  1653. elseif(ipiv(k).gt.1)then
  1654. pause 'singular matrix in gaussjbem'
  1655. endif
  1656. enddo
  1657. endif
  1658. enddo
  1659. ipiv(icol)=ipiv(icol)+1
  1660. if(irow.ne.icol)then
  1661. do l=1,n
  1662. dum=a(irow,l)
  1663. a(irow,l)=a(icol,l)
  1664. a(icol,l)=dum
  1665. enddo
  1666. dum=b(irow)
  1667. b(irow)=b(icol)
  1668. b(icol)=dum
  1669. endif
  1670. if(a(icol,icol).eq.0)pause 'singular matrix in gaussjbem'
  1671. pivinv=1./a(icol,icol)
  1672. a(icol,icol)=1
  1673. do l=1,n
  1674. a(icol,l)=a(icol,l)*pivinv
  1675. enddo
  1676. b(icol)=b(icol)*pivinv
  1677. do ll=1,n
  1678. if(ll.ne.icol)then
  1679. dum=a(ll,icol)
  1680. a(ll,icol)=0.
  1681. do l=1,n
  1682. a(ll,l)=a(ll,l)-a(icol,l)*dum
  1683. enddo
  1684. b(ll)=b(ll)-b(icol)*dum
  1685. endif
  1686. enddo
  1687. enddo
  1688. return
  1689. end subroutine gaussjbem
  1690. !====6=8===============================================================72
  1691. !====6=8===============================================================72
  1692. subroutine radfluxs(radflux,alb,rs,em,rl,sigma,twal)
  1693. implicit none
  1694. !-------------------------------------------------------------------
  1695. !This function calculates the radiative fluxe at a surface
  1696. !-------------------------------------------------------------------
  1697. real alb !albedo of the surface
  1698. real rs !shor wave radiation
  1699. real em !emissivity of the surface
  1700. real rl !lon wave radiation
  1701. real sigma !parameter (wall is not black body) [W/m2.K4]
  1702. real twal !wall temperature [K]
  1703. real radflux
  1704. radflux=(1.-alb)*rs+em*rl-em*sigma*twal**4
  1705. return
  1706. end subroutine radfluxs
  1707. !====6=8==============================================================72
  1708. !====6=8==============================================================72
  1709. !
  1710. ! we define the view factors fprl and fnrm, which are the angle
  1711. ! factors between two equal and parallel planes, fprl, and two
  1712. ! equal and orthogonal planes, fnrm, respectively
  1713. !
  1714. subroutine fprl_ints(fprl_int,vx,vy)
  1715. implicit none
  1716. real vx,vy
  1717. real fprl_int
  1718. fprl_int=(2./(3.141592653*vx*vy))* &
  1719. (log(sqrt((1.+vx*vx)*(1.+vy*vy)/(1.+vx*vx+vy*vy)))+ &
  1720. (vy*sqrt(1.+vx*vx)*atan(vy/sqrt(1.+vx*vx)))+ &
  1721. (vx*sqrt(1.+vy*vy)*atan(vx/sqrt(1.+vy*vy)))- &
  1722. vy*atan(vy)-vx*atan(vx))
  1723. return
  1724. end subroutine fprl_ints
  1725. !====6=8==============================================================72
  1726. !====6=8==============================================================72
  1727. !
  1728. ! we define the view factors fprl and fnrm, which are the angle
  1729. ! factors between two equal and parallel planes, fprl, and two
  1730. ! equal and orthogonal planes, fnrm, respectively
  1731. !
  1732. subroutine fnrm_ints(fnrm_int,wx,wy,wz)
  1733. implicit none
  1734. real wx,wy,wz
  1735. real fnrm_int
  1736. fnrm_int=(1./(3.141592653*wy))*(wy*atan(1./wy)+wx*atan(1./wx)- &
  1737. (sqrt(wz)*atan(1./sqrt(wz)))+ &
  1738. (1./4.)*(log((1.+wx*wx)*(1.+wy*wy)/(1.+wz))+ &
  1739. wy*wy*log(wy*wy*(1.+wz)/(wz*(1.+wy*wy)))+ &
  1740. wx*wx*log(wx*wx*(1.+wz)/(wz*(1.+wx*wx)))))
  1741. return
  1742. end subroutine fnrm_ints
  1743. !====6=8==============================================================72
  1744. !====6=8==============================================================72
  1745. END MODULE module_sf_bem