From 2937aeb0d0e8c530a430ba790d5d02eebefa10c6 Mon Sep 17 00:00:00 2001 From: Ting Sun Date: Wed, 29 Jan 2025 00:30:22 +0000 Subject: [PATCH] sync with master to re-implement changes regarding STEBBS improvement #309 --- quick-test.ipynb | 67 ++ src/suews/src/suews_ctrl_const.f95 | 2 +- src/suews/src/suews_ctrl_driver.f95 | 261 ++++--- src/suews/src/suews_ctrl_type.f95 | 179 +++-- src/suews/src/suews_phys_atmmoiststab.f95 | 2 +- src/suews/src/suews_phys_beers.f95 | 29 +- src/suews/src/suews_phys_rslprof.f95 | 14 +- src/suews/src/suews_phys_stebbs.f95 | 876 +++++++++++----------- src/suews/src/suews_phys_waterdist.f95 | 10 +- src/supy/__init__.py | 1 - src/supy/_check.py | 3 +- src/supy/_load.py | 74 +- src/supy/_run.py | 56 +- src/supy/_supy_module.py | 191 ++--- src/supy/meson.build | 2 - src/supy/sample_run/RunControl.nml | 2 +- test/test_supy.py | 24 +- 17 files changed, 815 insertions(+), 978 deletions(-) create mode 100644 quick-test.ipynb diff --git a/quick-test.ipynb b/quick-test.ipynb new file mode 100644 index 000000000..4ffda3abf --- /dev/null +++ b/quick-test.ipynb @@ -0,0 +1,67 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "ename": "ImportError", + "evalue": "re-building the supy meson-python editable wheel package failed", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mCalledProcessError\u001b[0m Traceback (most recent call last)", + "File \u001b[0;32m~/.local/share/mamba/envs/suews-dev/lib/python3.12/site-packages/_supy_editable_loader.py:345\u001b[0m, in \u001b[0;36mMesonpyMetaFinder._rebuild\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 344\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m--> 345\u001b[0m \u001b[43msubprocess\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mrun\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_build_cmd\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mcwd\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_build_path\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43menv\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43menv\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mstdout\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43msubprocess\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mDEVNULL\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mcheck\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mTrue\u001b[39;49;00m\u001b[43m)\u001b[49m\n\u001b[1;32m 346\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m subprocess\u001b[38;5;241m.\u001b[39mCalledProcessError \u001b[38;5;28;01mas\u001b[39;00m exc:\n", + "File \u001b[0;32m~/.local/share/mamba/envs/suews-dev/lib/python3.12/subprocess.py:571\u001b[0m, in \u001b[0;36mrun\u001b[0;34m(input, capture_output, timeout, check, *popenargs, **kwargs)\u001b[0m\n\u001b[1;32m 570\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m check \u001b[38;5;129;01mand\u001b[39;00m retcode:\n\u001b[0;32m--> 571\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m CalledProcessError(retcode, process\u001b[38;5;241m.\u001b[39margs,\n\u001b[1;32m 572\u001b[0m output\u001b[38;5;241m=\u001b[39mstdout, stderr\u001b[38;5;241m=\u001b[39mstderr)\n\u001b[1;32m 573\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m CompletedProcess(process\u001b[38;5;241m.\u001b[39margs, retcode, stdout, stderr)\n", + "\u001b[0;31mCalledProcessError\u001b[0m: Command '['/Users/tingsun/.local/share/mamba/envs/suews-dev/bin/ninja']' returned non-zero exit status 1.", + "\nThe above exception was the direct cause of the following exception:\n", + "\u001b[0;31mImportError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn[2], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;21;01msupy\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mas\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;21;01msp\u001b[39;00m\n", + "File \u001b[0;32m~/.local/share/mamba/envs/suews-dev/lib/python3.12/site-packages/_supy_editable_loader.py:311\u001b[0m, in \u001b[0;36mMesonpyMetaFinder.find_spec\u001b[0;34m(self, fullname, path, target)\u001b[0m\n\u001b[1;32m 309\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_build_path \u001b[38;5;129;01min\u001b[39;00m os\u001b[38;5;241m.\u001b[39menviron\u001b[38;5;241m.\u001b[39mget(MARKER, \u001b[38;5;124m'\u001b[39m\u001b[38;5;124m'\u001b[39m)\u001b[38;5;241m.\u001b[39msplit(os\u001b[38;5;241m.\u001b[39mpathsep):\n\u001b[1;32m 310\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[0;32m--> 311\u001b[0m tree \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_rebuild\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 312\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m find_spec(fullname, tree)\n", + "File \u001b[0;32m~/.local/share/mamba/envs/suews-dev/lib/python3.12/site-packages/_supy_editable_loader.py:347\u001b[0m, in \u001b[0;36mMesonpyMetaFinder._rebuild\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 345\u001b[0m subprocess\u001b[38;5;241m.\u001b[39mrun(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_build_cmd, cwd\u001b[38;5;241m=\u001b[39m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_build_path, env\u001b[38;5;241m=\u001b[39menv, stdout\u001b[38;5;241m=\u001b[39msubprocess\u001b[38;5;241m.\u001b[39mDEVNULL, check\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mTrue\u001b[39;00m)\n\u001b[1;32m 346\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m subprocess\u001b[38;5;241m.\u001b[39mCalledProcessError \u001b[38;5;28;01mas\u001b[39;00m exc:\n\u001b[0;32m--> 347\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mImportError\u001b[39;00m(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mre-building the \u001b[39m\u001b[38;5;132;01m{\u001b[39;00m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_name\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m meson-python editable wheel package failed\u001b[39m\u001b[38;5;124m'\u001b[39m) \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;21;01mexc\u001b[39;00m\n\u001b[1;32m 349\u001b[0m install_plan_path \u001b[38;5;241m=\u001b[39m os\u001b[38;5;241m.\u001b[39mpath\u001b[38;5;241m.\u001b[39mjoin(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_build_path, \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mmeson-info\u001b[39m\u001b[38;5;124m'\u001b[39m, \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mintro-install_plan.json\u001b[39m\u001b[38;5;124m'\u001b[39m)\n\u001b[1;32m 350\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m \u001b[38;5;28mopen\u001b[39m(install_plan_path, \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mr\u001b[39m\u001b[38;5;124m'\u001b[39m, encoding\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mutf8\u001b[39m\u001b[38;5;124m'\u001b[39m) \u001b[38;5;28;01mas\u001b[39;00m f:\n", + "\u001b[0;31mImportError\u001b[0m: re-building the supy meson-python editable wheel package failed" + ] + } + ], + "source": [ + "import supy as sp\n", + "\n", + "df_state_init, df_forcing_tstep = sp.load_SampleData()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "df_forcing_part = df_forcing_tstep.iloc[: 288 * 10]\n", + "df_output, df_state = sp.run_supy(\n", + " df_forcing_part, df_state_init, check_input=True\n", + " )" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.12.8" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/src/suews/src/suews_ctrl_const.f95 b/src/suews/src/suews_ctrl_const.f95 index 10f2e3ec7..5b410aa25 100644 --- a/src/suews/src/suews_ctrl_const.f95 +++ b/src/suews/src/suews_ctrl_const.f95 @@ -1160,7 +1160,7 @@ MODULE data_in ! nCol, & !number of columns of checker board layout in the netCDF output, TS, 09 Dec 2016 DiagnoseDisaggESTM, & !Set to 1 to get print-out of ESTM forcing disaggregation progress DiagQN, DiagQS, & !Set to 1 to print values/components - stebbsuse !Stebbins + stebbsmethod !Stebbins ! For more complex downscaling allow different RainAmongN for different intensities INTEGER, DIMENSION(5) :: MultRainAmongN ! RainAmongN for each intensity bin diff --git a/src/suews/src/suews_ctrl_driver.f95 b/src/suews/src/suews_ctrl_driver.f95 index 325b2c4e1..8d70b02ed 100644 --- a/src/suews/src/suews_ctrl_driver.f95 +++ b/src/suews/src/suews_ctrl_driver.f95 @@ -13,9 +13,9 @@ MODULE SUEWS_Driver SUEWS_SITE, LUMPS_PRM, EHC_PRM, LC_PAVED_PRM, LC_BLDG_PRM, LC_DECTR_PRM, LC_EVETR_PRM, & LC_GRASS_PRM, LC_BSOIL_PRM, LC_WATER_PRM, anthroEmis_STATE, & OHM_STATE, PHENOLOGY_STATE, SNOW_STATE, SUEWS_FORCING, SUEWS_TIMER, & - HYDRO_STATE, HEAT_STATE, STEBBS_STATE, & + HYDRO_STATE, HEAT_STATE, & ROUGHNESS_STATE, solar_State, atm_state, flag_STATE, & - SUEWS_STATE, SUEWS_DEBUG, STEBBS_PRM, BLDG_ARCHTYPE_PRM, & + SUEWS_STATE, SUEWS_DEBUG, STEBBS_STATE, BUILDING_STATE, & output_line, output_block USE meteo, ONLY: qsatf, RH2qa, qa2RH USE AtmMoistStab_module, ONLY: cal_AtmMoist, cal_Stab, stab_psi_heat, stab_psi_mom, SUEWS_update_atmState @@ -46,7 +46,7 @@ MODULE SUEWS_Driver USE DailyState_module, ONLY: SUEWS_update_DailyState USE lumps_module, ONLY: LUMPS_cal_QHQE, LUMPS_cal_QHQE_DTS USE evap_module, ONLY: cal_evap_multi - USE rsl_module, ONLY: RSLProfile + USE rsl_module, ONLY: RSLProfile, RSLProfile_DTS USE anemsn_module, ONLY: AnthropogenicEmissions USE CO2_module, ONLY: CO2_biogen USE allocateArray, ONLY: & @@ -60,8 +60,8 @@ MODULE SUEWS_Driver ncolumnsDataOutSTEBBS USE moist, ONLY: avcp, avdens, lv_J_kg USE solweig_module, ONLY: SOLWEIG_cal_main - USE beers_module, ONLY: BEERS_cal_main_DTS - USE stebbs_module, ONLY: stebbs_cal_main + USE beers_module, ONLY: BEERS_cal_main, BEERS_cal_main_DTS + USE stebbs_module, ONLY: stebbsonlinecouple USE version, ONLY: git_commit, compiler_ver USE time_module, ONLY: SUEWS_cal_dectime_DTS, SUEWS_cal_tstep_DTS, SUEWS_cal_weekday_DTS, & SUEWS_cal_DLS_DTS @@ -434,7 +434,7 @@ SUBROUTINE SUEWS_cal_Main( & !============ roughness sub-layer diagonostics =============== IF (Diagnose == 1) WRITE (*, *) 'Calling RSLProfile...' - CALL RSLProfile( & + CALL RSLProfile_DTS( & timer, config, forcing, siteInfo, & ! input modState, & ! input/output: dataoutLineRSL) ! output @@ -469,9 +469,9 @@ SUBROUTINE SUEWS_cal_Main( & !==============use STEBBS to get localised radiation flux================== ! MP 12 Sep 2024: STEBBS is a simplified BEM - IF (config%STEBBSUse == 1) THEN + IF (config%stebbsmethod == 1) THEN IF (Diagnose == 1) WRITE (*, *) 'Calling STEBBS...' - CALL stebbs_cal_main( & + CALL stebbsonlinecouple( & timer, config, forcing, siteInfo, & ! input modState, & ! input/output: datetimeLine, & ! input @@ -479,7 +479,7 @@ SUBROUTINE SUEWS_cal_Main( & END IF !==============translation of output variables into output array=========== - IF (Diagnose == 1) WRITE (*, *) 'Calling SUEWS_update_outputLine_DTS...' + IF (Diagnose == 1) WRITE (*, *) 'Calling BEERS_cal_main_DTS...' CALL SUEWS_update_outputLine_DTS( & timer, config, forcing, siteInfo, & ! input modState, & ! input/output: @@ -2066,7 +2066,7 @@ SUBROUTINE SUEWS_cal_Water( & WaterDist(5, 1) = pavedPrm%waterdist%to_grass WaterDist(6, 1) = pavedPrm%waterdist%to_bsoil WaterDist(7, 1) = pavedPrm%waterdist%to_water - WaterDist(8, 1) = pavedPrm%waterdist%to_soilstore_or_runoff + WaterDist(8, 1) = pavedPrm%waterdist%to_soilstore WaterDist(1, 2) = bldgPrm%waterdist%to_paved WaterDist(2, 2) = bldgPrm%waterdist%to_bldg @@ -2075,7 +2075,7 @@ SUBROUTINE SUEWS_cal_Water( & WaterDist(5, 2) = bldgPrm%waterdist%to_grass WaterDist(6, 2) = bldgPrm%waterdist%to_bsoil WaterDist(7, 2) = bldgPrm%waterdist%to_water - WaterDist(8, 2) = bldgPrm%waterdist%to_soilstore_or_runoff + WaterDist(8, 2) = bldgPrm%waterdist%to_soilstore WaterDist(1, 3) = evetrPrm%waterdist%to_paved WaterDist(2, 3) = evetrPrm%waterdist%to_bldg @@ -2084,7 +2084,7 @@ SUBROUTINE SUEWS_cal_Water( & WaterDist(5, 3) = evetrPrm%waterdist%to_grass WaterDist(6, 3) = evetrPrm%waterdist%to_bsoil WaterDist(7, 3) = evetrPrm%waterdist%to_water - WaterDist(8, 3) = evetrPrm%waterdist%to_soilstore_or_runoff + WaterDist(8, 3) = evetrPrm%waterdist%to_soilstore WaterDist(1, 4) = dectrPrm%waterdist%to_paved WaterDist(2, 4) = dectrPrm%waterdist%to_bldg @@ -2093,7 +2093,7 @@ SUBROUTINE SUEWS_cal_Water( & WaterDist(5, 4) = dectrPrm%waterdist%to_grass WaterDist(6, 4) = dectrPrm%waterdist%to_bsoil WaterDist(7, 4) = dectrPrm%waterdist%to_water - WaterDist(8, 4) = dectrPrm%waterdist%to_soilstore_or_runoff + WaterDist(8, 4) = dectrPrm%waterdist%to_soilstore WaterDist(1, 5) = grassPrm%waterdist%to_paved WaterDist(2, 5) = grassPrm%waterdist%to_bldg @@ -2102,7 +2102,7 @@ SUBROUTINE SUEWS_cal_Water( & WaterDist(5, 5) = grassPrm%waterdist%to_grass WaterDist(6, 5) = grassPrm%waterdist%to_bsoil WaterDist(7, 5) = grassPrm%waterdist%to_water - WaterDist(8, 5) = grassPrm%waterdist%to_soilstore_or_runoff + WaterDist(8, 5) = grassPrm%waterdist%to_soilstore WaterDist(1, 6) = bsoilPrm%waterdist%to_paved WaterDist(2, 6) = bsoilPrm%waterdist%to_bldg @@ -2111,7 +2111,7 @@ SUBROUTINE SUEWS_cal_Water( & WaterDist(5, 6) = bsoilPrm%waterdist%to_grass WaterDist(6, 6) = bsoilPrm%waterdist%to_bsoil WaterDist(7, 6) = bsoilPrm%waterdist%to_water - WaterDist(8, 6) = bsoilPrm%waterdist%to_soilstore_or_runoff + WaterDist(8, 6) = bsoilPrm%waterdist%to_soilstore ! Retain previous surface state_id and soil moisture state_id ! stateOld = state_id !state_id of each surface [mm] for the previous timestep @@ -4124,10 +4124,8 @@ SUBROUTINE SUEWS_cal_multitsteps( & veg_ssa_sw, air_ext_lw, air_ssa_lw, veg_ssa_lw, & veg_fsd_const, veg_contact_fraction_const, & ground_albedo_dir_mult_fact, use_sw_direct_albedo, & !input - STEBBSUse, & ! stebbs building input - BuildingCount, Occupants, & - ! hhs0, age_0_4, age_5_11, age_12_18, age_19_64, age_65plus, - stebbs_Height, & + stebbsmethod, & ! stebbs building input + BuildingCount, Occupants, hhs0, age_0_4, age_5_11, age_12_18, age_19_64, age_65plus, stebbs_Height, & FootprintArea, WallExternalArea, RatioInternalVolume, WWR, WallThickness, WallEffectiveConductivity, & WallDensity, WallCp, Wallx1, WallExternalEmissivity, WallInternalEmissivity, WallTransmissivity, & WallAbsorbtivity, WallReflectivity, FloorThickness, GroundFloorEffectiveConductivity, & @@ -4247,7 +4245,7 @@ SUBROUTINE SUEWS_cal_multitsteps( & LOGICAL, INTENT(IN) :: use_sw_direct_albedo !boolean, Specify ground and roof albedos separately for direct solar radiation [-] INTEGER, INTENT(IN) :: OHMIncQF ! Determines whether the storage heat flux calculation uses Q* or ( Q* +QF) [-] ! INTEGER, INTENT(IN) :: nbtype ! number of building types [-] STEBBS - INTEGER, INTENT(IN) :: STEBBSUse ! method to calculate building energy use [-] STEBBS + INTEGER, INTENT(IN) :: stebbsmethod ! method to calculate building energy use [-] STEBBS ! ---lumps-related variables TYPE(LUMPS_PRM) :: lumpsPrm @@ -4519,7 +4517,6 @@ SUBROUTINE SUEWS_cal_multitsteps( & REAL(KIND(1D0)), DIMENSION(6, NSURF), INTENT(INOUT) :: StoreDrainPrm !coefficients used in drainage calculation [-] ! ---stebbs related states - TYPE(STEBBS_PRM) :: stebbsPrm TYPE(STEBBS_STATE) :: stebbsState REAL(KIND(1D0)) :: WallInternalConvectionCoefficient REAL(KIND(1D0)) :: InternalMassConvectionCoefficient @@ -4587,15 +4584,15 @@ SUBROUTINE SUEWS_cal_multitsteps( & REAL(KIND(1D0)) :: MinimumVolumeOfDHWinUse ! ---stebbs building related states - TYPE(BLDG_ARCHTYPE_PRM) :: bldgarchtypePrm + TYPE(BUILDING_STATE) :: bldgState REAL(KIND(1D0)) :: BuildingCount REAL(KIND(1D0)) :: Occupants - ! REAL(KIND(1D0)) :: hhs0 - ! REAL(KIND(1D0)) :: age_0_4 - ! REAL(KIND(1D0)) :: age_5_11 - ! REAL(KIND(1D0)) :: age_12_18 - ! REAL(KIND(1D0)) :: age_19_64 - ! REAL(KIND(1D0)) :: age_65plus + REAL(KIND(1D0)) :: hhs0 + REAL(KIND(1D0)) :: age_0_4 + REAL(KIND(1D0)) :: age_5_11 + REAL(KIND(1D0)) :: age_12_18 + REAL(KIND(1D0)) :: age_19_64 + REAL(KIND(1D0)) :: age_65plus REAL(KIND(1D0)) :: stebbs_Height REAL(KIND(1D0)) :: FootprintArea REAL(KIND(1D0)) :: WallExternalArea @@ -4769,11 +4766,11 @@ SUBROUTINE SUEWS_cal_multitsteps( & config%use_sw_direct_albedo = use_sw_direct_albedo config%ohmIncQF = OHMIncQF config%localClimateMethod = localClimateMethod - config%STEBBSUse = STEBBSUse ! these options are fixed config%DiagQS = 0 config%EvapMethod = 2 config%LAImethod = 1 + config%stebbsmethod = stebbsmethod ! testing flag config%flag_test = flag_test @@ -5008,7 +5005,7 @@ SUBROUTINE SUEWS_cal_multitsteps( & pavedPrm%waterdist%to_grass = WaterDist(5, PavSurf) pavedPrm%waterdist%to_bsoil = WaterDist(6, PavSurf) pavedPrm%waterdist%to_water = WaterDist(7, PavSurf) - pavedPrm%waterdist%to_soilstore_or_runoff = WaterDist(8, PavSurf) + pavedPrm%waterdist%to_soilstore = WaterDist(8, PavSurf) bldgPrm%sfr = sfr_surf(BldgSurf) bldgPrm%faibldg = FAIBldg @@ -5050,7 +5047,7 @@ SUBROUTINE SUEWS_cal_multitsteps( & bldgPrm%waterdist%to_grass = WaterDist(5, BldgSurf) bldgPrm%waterdist%to_bsoil = WaterDist(6, BldgSurf) bldgPrm%waterdist%to_water = WaterDist(7, BldgSurf) - bldgPrm%waterdist%to_soilstore_or_runoff = WaterDist(8, BldgSurf) + bldgPrm%waterdist%to_soilstore = WaterDist(8, BldgSurf) dectrPrm%sfr = sfr_surf(DecidSurf) dectrPrm%emis = emis(DecidSurf) @@ -5116,7 +5113,7 @@ SUBROUTINE SUEWS_cal_multitsteps( & dectrPrm%waterdist%to_grass = WaterDist(5, DecidSurf) dectrPrm%waterdist%to_bsoil = WaterDist(6, DecidSurf) dectrPrm%waterdist%to_water = WaterDist(7, DecidSurf) - dectrPrm%waterdist%to_soilstore_or_runoff = WaterDist(8, DecidSurf) + dectrPrm%waterdist%to_soilstore = WaterDist(8, DecidSurf) evetrPrm%sfr = sfr_surf(ConifSurf) evetrPrm%emis = emis(ConifSurf) @@ -5177,7 +5174,7 @@ SUBROUTINE SUEWS_cal_multitsteps( & evetrPrm%waterdist%to_grass = WaterDist(5, ConifSurf) evetrPrm%waterdist%to_bsoil = WaterDist(6, ConifSurf) evetrPrm%waterdist%to_water = WaterDist(7, ConifSurf) - evetrPrm%waterdist%to_soilstore_or_runoff = WaterDist(8, ConifSurf) + evetrPrm%waterdist%to_soilstore = WaterDist(8, ConifSurf) grassPrm%sfr = sfr_surf(GrassSurf) grassPrm%emis = emis(GrassSurf) @@ -5236,7 +5233,7 @@ SUBROUTINE SUEWS_cal_multitsteps( & grassPrm%waterdist%to_grass = WaterDist(5, GrassSurf) grassPrm%waterdist%to_bsoil = WaterDist(6, GrassSurf) grassPrm%waterdist%to_water = WaterDist(7, GrassSurf) - grassPrm%waterdist%to_soilstore_or_runoff = WaterDist(8, GrassSurf) + grassPrm%waterdist%to_soilstore = WaterDist(8, GrassSurf) bsoilPrm%sfr = sfr_surf(BSoilSurf) bsoilPrm%emis = emis(BSoilSurf) @@ -5282,7 +5279,7 @@ SUBROUTINE SUEWS_cal_multitsteps( & bsoilPrm%waterdist%to_grass = WaterDist(5, BSoilSurf) bsoilPrm%waterdist%to_bsoil = WaterDist(6, BSoilSurf) bsoilPrm%waterdist%to_water = WaterDist(7, BSoilSurf) - bsoilPrm%waterdist%to_soilstore_or_runoff = WaterDist(8, BSoilSurf) + bsoilPrm%waterdist%to_soilstore = WaterDist(8, BSoilSurf) waterPrm%sfr = sfr_surf(WaterSurf) waterPrm%emis = emis(WaterSurf) @@ -5376,59 +5373,28 @@ SUBROUTINE SUEWS_cal_multitsteps( & phenState%StoreDrainPrm = StoreDrainPrm ! assign stebbs values - stebbsPrm%WallInternalConvectionCoefficient = WallInternalConvectionCoefficient - stebbsPrm%InternalMassConvectionCoefficient = InternalMassConvectionCoefficient - stebbsPrm%FloorInternalConvectionCoefficient = FloorInternalConvectionCoefficient - stebbsPrm%WindowInternalConvectionCoefficient = WindowInternalConvectionCoefficient - stebbsPrm%WallExternalConvectionCoefficient = WallExternalConvectionCoefficient - stebbsPrm%WindowExternalConvectionCoefficient = WindowExternalConvectionCoefficient - stebbsPrm%GroundDepth = GroundDepth - stebbsPrm%ExternalGroundConductivity = ExternalGroundConductivity - stebbsPrm%IndoorAirDensity = IndoorAirDensity - stebbsPrm%IndoorAirCp = IndoorAirCp - stebbsPrm%WallBuildingViewFactor = WallBuildingViewFactor - stebbsPrm%WallGroundViewFactor = WallGroundViewFactor - stebbsPrm%WallSkyViewFactor = WallSkyViewFactor - stebbsPrm%MetabolicRate = MetabolicRate - stebbsPrm%LatentSensibleRatio = LatentSensibleRatio - stebbsPrm%ApplianceRating = ApplianceRating - stebbsPrm%TotalNumberofAppliances = TotalNumberofAppliances - stebbsPrm%ApplianceUsageFactor = ApplianceUsageFactor - stebbsPrm%HeatingSystemEfficiency = HeatingSystemEfficiency - stebbsPrm%MaxCoolingPower = MaxCoolingPower - stebbsPrm%CoolingSystemCOP = CoolingSystemCOP - stebbsPrm%VentilationRate = VentilationRate - - stebbsPrm%WaterTankWallThickness = WaterTankWallThickness - stebbsPrm%WaterTankSurfaceArea = WaterTankSurfaceArea - stebbsPrm%HotWaterHeatingSetpointTemperature = HotWaterHeatingSetpointTemperature - stebbsPrm%HotWaterTankWallEmissivity = HotWaterTankWallEmissivity - - stebbsPrm%DHWVesselWallThickness = DHWVesselWallThickness - stebbsPrm%DHWWaterVolume = DHWWaterVolume - stebbsPrm%DHWSurfaceArea = DHWSurfaceArea - stebbsPrm%DHWVesselEmissivity = DHWVesselEmissivity - stebbsPrm%HotWaterFlowRate = HotWaterFlowRate - stebbsPrm%DHWDrainFlowRate = DHWDrainFlowRate - stebbsPrm%DHWSpecificHeatCapacity = DHWSpecificHeatCapacity - stebbsPrm%HotWaterTankSpecificHeatCapacity = HotWaterTankSpecificHeatCapacity - stebbsPrm%DHWVesselSpecificHeatCapacity = DHWVesselSpecificHeatCapacity - stebbsPrm%DHWDensity = DHWDensity - stebbsPrm%HotWaterTankWallDensity = HotWaterTankWallDensity - stebbsPrm%DHWVesselDensity = DHWVesselDensity - stebbsPrm%HotWaterTankBuildingWallViewFactor = HotWaterTankBuildingWallViewFactor - stebbsPrm%HotWaterTankInternalMassViewFactor = HotWaterTankInternalMassViewFactor - stebbsPrm%HotWaterTankWallConductivity = HotWaterTankWallConductivity - stebbsPrm%HotWaterTankInternalWallConvectionCoefficient = HotWaterTankInternalWallConvectionCoefficient - stebbsPrm%HotWaterTankExternalWallConvectionCoefficient = HotWaterTankExternalWallConvectionCoefficient - stebbsPrm%DHWVesselWallConductivity = DHWVesselWallConductivity - stebbsPrm%DHWVesselInternalWallConvectionCoefficient = DHWVesselInternalWallConvectionCoefficient - stebbsPrm%DHWVesselExternalWallConvectionCoefficient = DHWVesselExternalWallConvectionCoefficient - stebbsPrm%DHWVesselWallEmissivity = DHWVesselWallEmissivity - stebbsPrm%HotWaterHeatingEfficiency = HotWaterHeatingEfficiency - stebbsPrm%MinimumVolumeOfDHWinUse = MinimumVolumeOfDHWinUse - - stebbsState%MainsWaterTemperature = MainsWaterTemperature + stebbsState%WallInternalConvectionCoefficient = WallInternalConvectionCoefficient + stebbsState%InternalMassConvectionCoefficient = InternalMassConvectionCoefficient + stebbsState%FloorInternalConvectionCoefficient = FloorInternalConvectionCoefficient + stebbsState%WindowInternalConvectionCoefficient = WindowInternalConvectionCoefficient + stebbsState%WallExternalConvectionCoefficient = WallExternalConvectionCoefficient + stebbsState%WindowExternalConvectionCoefficient = WindowExternalConvectionCoefficient + stebbsState%GroundDepth = GroundDepth + stebbsState%ExternalGroundConductivity = ExternalGroundConductivity + stebbsState%IndoorAirDensity = IndoorAirDensity + stebbsState%IndoorAirCp = IndoorAirCp + stebbsState%WallBuildingViewFactor = WallBuildingViewFactor + stebbsState%WallGroundViewFactor = WallGroundViewFactor + stebbsState%WallSkyViewFactor = WallSkyViewFactor + stebbsState%MetabolicRate = MetabolicRate + stebbsState%LatentSensibleRatio = LatentSensibleRatio + stebbsState%ApplianceRating = ApplianceRating + stebbsState%TotalNumberofAppliances = TotalNumberofAppliances + stebbsState%ApplianceUsageFactor = ApplianceUsageFactor + stebbsState%HeatingSystemEfficiency = HeatingSystemEfficiency + stebbsState%MaxCoolingPower = MaxCoolingPower + stebbsState%CoolingSystemCOP = CoolingSystemCOP + stebbsState%VentilationRate = VentilationRate stebbsState%IndoorAirStartTemperature = IndoorAirStartTemperature stebbsState%IndoorMassStartTemperature = IndoorMassStartTemperature stebbsState%WallIndoorSurfaceTemperature = WallIndoorSurfaceTemperature @@ -5440,59 +5406,87 @@ SUBROUTINE SUEWS_cal_multitsteps( & stebbsState%WaterTankTemperature = WaterTankTemperature stebbsState%InternalWallWaterTankTemperature = InternalWallWaterTankTemperature stebbsState%ExternalWallWaterTankTemperature = ExternalWallWaterTankTemperature + stebbsState%WaterTankWallThickness = WaterTankWallThickness + stebbsState%MainsWaterTemperature = MainsWaterTemperature + stebbsState%WaterTankSurfaceArea = WaterTankSurfaceArea + stebbsState%HotWaterHeatingSetpointTemperature = HotWaterHeatingSetpointTemperature + stebbsState%HotWaterTankWallEmissivity = HotWaterTankWallEmissivity stebbsState%DomesticHotWaterTemperatureInUseInBuilding = DomesticHotWaterTemperatureInUseInBuilding stebbsState%InternalWallDHWVesselTemperature = InternalWallDHWVesselTemperature stebbsState%ExternalWallDHWVesselTemperature = ExternalWallDHWVesselTemperature + stebbsState%DHWVesselWallThickness = DHWVesselWallThickness + stebbsState%DHWWaterVolume = DHWWaterVolume + stebbsState%DHWSurfaceArea = DHWSurfaceArea + stebbsState%DHWVesselEmissivity = DHWVesselEmissivity + stebbsState%HotWaterFlowRate = HotWaterFlowRate + stebbsState%DHWDrainFlowRate = DHWDrainFlowRate + stebbsState%DHWSpecificHeatCapacity = DHWSpecificHeatCapacity + stebbsState%HotWaterTankSpecificHeatCapacity = HotWaterTankSpecificHeatCapacity + stebbsState%DHWVesselSpecificHeatCapacity = DHWVesselSpecificHeatCapacity + stebbsState%DHWDensity = DHWDensity + stebbsState%HotWaterTankWallDensity = HotWaterTankWallDensity + stebbsState%DHWVesselDensity = DHWVesselDensity + stebbsState%HotWaterTankBuildingWallViewFactor = HotWaterTankBuildingWallViewFactor + stebbsState%HotWaterTankInternalMassViewFactor = HotWaterTankInternalMassViewFactor + stebbsState%HotWaterTankWallConductivity = HotWaterTankWallConductivity + stebbsState%HotWaterTankInternalWallConvectionCoefficient = HotWaterTankInternalWallConvectionCoefficient + stebbsState%HotWaterTankExternalWallConvectionCoefficient = HotWaterTankExternalWallConvectionCoefficient + stebbsState%DHWVesselWallConductivity = DHWVesselWallConductivity + stebbsState%DHWVesselInternalWallConvectionCoefficient = DHWVesselInternalWallConvectionCoefficient + stebbsState%DHWVesselExternalWallConvectionCoefficient = DHWVesselExternalWallConvectionCoefficient + stebbsState%DHWVesselWallEmissivity = DHWVesselWallEmissivity + stebbsState%HotWaterHeatingEfficiency = HotWaterHeatingEfficiency + stebbsState%MinimumVolumeOfDHWinUse = MinimumVolumeOfDHWinUse ! assign stebbs building parameters ! bldgState%BuildingCode ! bldgState%BuildingClass ! bldgState%BuildingType ! bldgState%BuildingName - bldgarchtypePrm%BuildingCount = BuildingCount - bldgarchtypePrm%Occupants = Occupants - ! bldgState%hhs0 = hhs0 - ! bldgState%age_0_4 = age_0_4 - ! bldgState%age_5_11 = age_5_11 - ! bldgState%age_12_18 = age_12_18 - ! bldgState%age_19_64 = age_19_64 - ! bldgState%age_65plus = age_65plus - bldgarchtypePrm%stebbs_Height = stebbs_Height - bldgarchtypePrm%FootprintArea = FootprintArea - bldgarchtypePrm%WallExternalArea = WallExternalArea - bldgarchtypePrm%RatioInternalVolume = RatioInternalVolume - bldgarchtypePrm%WWR = WWR - bldgarchtypePrm%WallThickness = WallThickness - bldgarchtypePrm%WallEffectiveConductivity = WallEffectiveConductivity - bldgarchtypePrm%WallDensity = WallDensity - bldgarchtypePrm%WallCp = WallCp - bldgarchtypePrm%Wallx1 = Wallx1 - bldgarchtypePrm%WallExternalEmissivity = WallExternalEmissivity - bldgarchtypePrm%WallInternalEmissivity = WallInternalEmissivity - bldgarchtypePrm%WallTransmissivity = WallTransmissivity - bldgarchtypePrm%WallAbsorbtivity = WallAbsorbtivity - bldgarchtypePrm%WallReflectivity = WallReflectivity - bldgarchtypePrm%FloorThickness = FloorThickness - bldgarchtypePrm%GroundFloorEffectiveConductivity = GroundFloorEffectiveConductivity - bldgarchtypePrm%GroundFloorDensity = GroundFloorDensity - bldgarchtypePrm%GroundFloorCp = GroundFloorCp - bldgarchtypePrm%WindowThickness = WindowThickness - bldgarchtypePrm%WindowEffectiveConductivity = WindowEffectiveConductivity - bldgarchtypePrm%WindowDensity = WindowDensity - bldgarchtypePrm%WindowCp = WindowCp - bldgarchtypePrm%WindowExternalEmissivity = WindowExternalEmissivity - bldgarchtypePrm%WindowInternalEmissivity = WindowInternalEmissivity - bldgarchtypePrm%WindowTransmissivity = WindowTransmissivity - bldgarchtypePrm%WindowAbsorbtivity = WindowAbsorbtivity - bldgarchtypePrm%WindowReflectivity = WindowReflectivity - bldgarchtypePrm%InternalMassDensity = InternalMassDensity - bldgarchtypePrm%InternalMassCp = InternalMassCp - bldgarchtypePrm%InternalMassEmissivity = InternalMassEmissivity - bldgarchtypePrm%MaxHeatingPower = MaxHeatingPower - bldgarchtypePrm%WaterTankWaterVolume = WaterTankWaterVolume - bldgarchtypePrm%MaximumHotWaterHeatingPower = MaximumHotWaterHeatingPower - bldgarchtypePrm%HeatingSetpointTemperature = HeatingSetpointTemperature - bldgarchtypePrm%CoolingSetpointTemperature = CoolingSetpointTemperature + bldgState%BuildingCount = BuildingCount + bldgState%Occupants = Occupants + bldgState%hhs0 = hhs0 + bldgState%age_0_4 = age_0_4 + bldgState%age_5_11 = age_5_11 + bldgState%age_12_18 = age_12_18 + bldgState%age_19_64 = age_19_64 + bldgState%age_65plus = age_65plus + bldgState%stebbs_Height = stebbs_Height + bldgState%FootprintArea = FootprintArea + bldgState%WallExternalArea = WallExternalArea + bldgState%RatioInternalVolume = RatioInternalVolume + bldgState%WWR = WWR + bldgState%WallThickness = WallThickness + bldgState%WallEffectiveConductivity = WallEffectiveConductivity + bldgState%WallDensity = WallDensity + bldgState%WallCp = WallCp + bldgState%Wallx1 = Wallx1 + bldgState%WallExternalEmissivity = WallExternalEmissivity + bldgState%WallInternalEmissivity = WallInternalEmissivity + bldgState%WallTransmissivity = WallTransmissivity + bldgState%WallAbsorbtivity = WallAbsorbtivity + bldgState%WallReflectivity = WallReflectivity + bldgState%FloorThickness = FloorThickness + bldgState%GroundFloorEffectiveConductivity = GroundFloorEffectiveConductivity + bldgState%GroundFloorDensity = GroundFloorDensity + bldgState%GroundFloorCp = GroundFloorCp + bldgState%WindowThickness = WindowThickness + bldgState%WindowEffectiveConductivity = WindowEffectiveConductivity + bldgState%WindowDensity = WindowDensity + bldgState%WindowCp = WindowCp + bldgState%WindowExternalEmissivity = WindowExternalEmissivity + bldgState%WindowInternalEmissivity = WindowInternalEmissivity + bldgState%WindowTransmissivity = WindowTransmissivity + bldgState%WindowAbsorbtivity = WindowAbsorbtivity + bldgState%WindowReflectivity = WindowReflectivity + bldgState%InternalMassDensity = InternalMassDensity + bldgState%InternalMassCp = InternalMassCp + bldgState%InternalMassEmissivity = InternalMassEmissivity + bldgState%MaxHeatingPower = MaxHeatingPower + bldgState%WaterTankWaterVolume = WaterTankWaterVolume + bldgState%MaximumHotWaterHeatingPower = MaximumHotWaterHeatingPower + bldgState%HeatingSetpointTemperature = HeatingSetpointTemperature + bldgState%CoolingSetpointTemperature = CoolingSetpointTemperature ! ! transfer states into modState mod_State%anthroemisState = anthroEmisState @@ -5502,7 +5496,7 @@ SUBROUTINE SUEWS_cal_multitsteps( & mod_State%snowState = snowState mod_State%phenState = phenState mod_State%stebbsState = stebbsState - mod_State%stebbsPrm = stebbsPrm + mod_State%bldgState = bldgState ! ############# evaluation for DTS variables (end) ############# CALL siteInfo%ALLOCATE(nlayer) @@ -5521,7 +5515,6 @@ SUBROUTINE SUEWS_cal_multitsteps( & siteInfo%lc_grass = grassPrm siteInfo%lc_bsoil = bsoilPrm siteInfo%lc_water = waterPrm - siteInfo%bldg_archtype = bldgarchtypePrm CALL siteInfo%cal_surf(config) ! allocate output arrays diff --git a/src/suews/src/suews_ctrl_type.f95 b/src/suews/src/suews_ctrl_type.f95 index c9c909801..1e92ea770 100644 --- a/src/suews/src/suews_ctrl_type.f95 +++ b/src/suews/src/suews_ctrl_type.f95 @@ -32,7 +32,10 @@ MODULE SUEWS_DEF_DTS INTEGER :: EvapMethod ! Evaporation calculated according to Rutter (1) or Shuttleworth (2) [-] INTEGER :: LAImethod ! boolean to determine if calculate LAI [-] INTEGER :: localClimateMethod ! method to choose local climate variables [-] 0: not use; 1: use local climate variables - INTEGER :: STEBBSUse ! whether to use STEBBS [-] + ! INTEGER :: nbtype ! number of building type [-] + ! INTEGER :: resolution ! STEBBS time resolution [-] + ! CHARACTER(len=256), ALLOCATABLE, DIMENSION(:) :: cases ! case of building type, the array size should be consistent to nbtype [-] + INTEGER :: stebbsmethod ! method to calculate building energy [-] LOGICAL :: flag_test ! FOR DEBUGGING ONLY: boolean to test specific functions [-] END TYPE SUEWS_CONFIG @@ -53,7 +56,7 @@ MODULE SUEWS_DEF_DTS REAL(KIND(1D0)) :: to_grass REAL(KIND(1D0)) :: to_bsoil REAL(KIND(1D0)) :: to_water - REAL(KIND(1D0)) :: to_soilstore_or_runoff + REAL(KIND(1D0)) :: to_soilstore END TYPE WATER_DIST_PRM TYPE, PUBLIC :: bioCO2_PRM @@ -407,58 +410,6 @@ MODULE SUEWS_DEF_DTS REAL(KIND(1D0)) :: flowchange ! special term in water END TYPE LC_WATER_PRM - TYPE, PUBLIC :: BLDG_ARCHTYPE_PRM - ! This type is used to collect building archetypes for STEBBS - ! CHARACTER(LEN=50) :: BuildingCode ! - ! CHARACTER(LEN=50) :: BuildingClass ! - ! CHARACTER(LEN=50) :: BuildingType ! - ! CHARACTER(LEN=50) :: BuildingName ! - REAL(KIND(1D0)) :: BuildingCount ! Number of buildings of this archetype [-] - REAL(KIND(1D0)) :: Occupants ! Number of occupants present in building [-] - ! REAL(KIND(1D0)) :: hhs0 ! - ! REAL(KIND(1D0)) :: age_0_4 ! - ! REAL(KIND(1D0)) :: age_5_11 ! - ! REAL(KIND(1D0)) :: age_12_18 ! - ! REAL(KIND(1D0)) :: age_19_64 ! - ! REAL(KIND(1D0)) :: age_65plus ! - REAL(KIND(1D0)) :: stebbs_Height ! Building height [m] - REAL(KIND(1D0)) :: FootprintArea ! Building footprint area [m2] - REAL(KIND(1D0)) :: WallExternalArea ! External wall area (including window area) [m2] - REAL(KIND(1D0)) :: RatioInternalVolume ! Ratio of internal mass volume to total building volume [-] - REAL(KIND(1D0)) :: WWR ! window to wall ratio [-] - REAL(KIND(1D0)) :: WallThickness ! Thickness of external wall and roof (weighted) [m] - REAL(KIND(1D0)) :: WallEffectiveConductivity ! Effective thermal conductivity of walls and roofs (weighted) [W m-1 K-1] - REAL(KIND(1D0)) :: WallDensity ! Effective density of the walls and roof (weighted) [kg m-3] - REAL(KIND(1D0)) :: WallCp ! Effective specific heat capacity of walls and roof (weighted) [J kg-1 K-1] - REAL(KIND(1D0)) :: Wallx1 ! Weighting factor for heat capacity of walls and roof [-] - REAL(KIND(1D0)) :: WallExternalEmissivity ! Emissivity of the external surface of walls and roof [-] - REAL(KIND(1D0)) :: WallInternalEmissivity ! Emissivity of the internal surface of walls and roof [-] - REAL(KIND(1D0)) :: WallTransmissivity ! Transmissivity of walls and roof [-] - REAL(KIND(1D0)) :: WallAbsorbtivity ! Absorbtivity of walls and roof [-] - REAL(KIND(1D0)) :: WallReflectivity ! Reflectivity of the external surface of walls and roof [-] - REAL(KIND(1D0)) :: FloorThickness ! Thickness of ground floor [m] - REAL(KIND(1D0)) :: GroundFloorEffectiveConductivity ! Effective thermal conductivity of ground floor [W m-1 K-1] - REAL(KIND(1D0)) :: GroundFloorDensity ! Density of the ground floor [kg m-3] - REAL(KIND(1D0)) :: GroundFloorCp ! Effective specific heat capacity of the ground floor [J kg-1 K-1] - REAL(KIND(1D0)) :: WindowThickness ! Window thickness [m] - REAL(KIND(1D0)) :: WindowEffectiveConductivity ! Effective thermal conductivity of windows [W m-1 K-1] - REAL(KIND(1D0)) :: WindowDensity ! Effective density of the windows [kg m-3] - REAL(KIND(1D0)) :: WindowCp ! Effective specific heat capacity of windows [J kg-1 K-1] - REAL(KIND(1D0)) :: WindowExternalEmissivity ! Emissivity of the external surface of windows [-] - REAL(KIND(1D0)) :: WindowInternalEmissivity ! Emissivity of the internal surface of windows [-] - REAL(KIND(1D0)) :: WindowTransmissivity ! Transmissivity of windows [-] - REAL(KIND(1D0)) :: WindowAbsorbtivity ! Absorbtivity of windows [-] - REAL(KIND(1D0)) :: WindowReflectivity ! Reflectivity of the external surface of windows [-] - REAL(KIND(1D0)) :: InternalMassDensity ! Effective density of the internal mass [kg m-3] - REAL(KIND(1D0)) :: InternalMassCp ! Specific heat capacity of internal mass [J kg-1 K-1] - REAL(KIND(1D0)) :: InternalMassEmissivity ! Emissivity of internal mass [-] - REAL(KIND(1D0)) :: MaxHeatingPower ! Maximum power demand of heating system [W] - REAL(KIND(1D0)) :: WaterTankWaterVolume ! Volume of water in hot water tank [m3] - REAL(KIND(1D0)) :: MaximumHotWaterHeatingPower ! Maximum power demand of water heating system [W] - REAL(KIND(1D0)) :: HeatingSetpointTemperature ! Heating setpoint temperature [degC] - REAL(KIND(1D0)) :: CoolingSetpointTemperature ! Cooling setpoint temperature [degC] - END TYPE BLDG_ARCHTYPE_PRM - TYPE, PUBLIC :: SUEWS_SITE REAL(KIND(1D0)) :: lat !latitude [deg] REAL(KIND(1D0)) :: lon !longitude [deg] @@ -502,7 +453,6 @@ MODULE SUEWS_DEF_DTS TYPE(LC_GRASS_PRM) :: lc_grass TYPE(LC_BSOIL_PRM) :: lc_bsoil TYPE(LC_WATER_PRM) :: lc_water - TYPE(BLDG_ARCHTYPE_PRM) :: bldg_archtype CONTAINS PROCEDURE :: ALLOCATE => allocate_site_prm_c @@ -780,21 +730,6 @@ MODULE SUEWS_DEF_DTS REAL(KIND(1D0)) :: TSfc_C ! surface temperature [degC] REAL(KIND(1D0)) :: tsurf !surface temperatue [degC] REAL(KIND(1D0)) :: QH_Init !initialised sensible heat flux [W m-2] - - ! Beers radiation - REAL(KIND(1D0)) :: Kdown2d ! incoming shortwave radiation onto roof [W m-2] - REAL(KIND(1D0)) :: Kup2d ! outgoing shortwave radiation from roof [W m-2] - REAL(KIND(1D0)) :: Kwest ! incoming shortwave radiation from west [W m-2] - REAL(KIND(1D0)) :: Ksouth ! incoming shortwave radiation from south [W m-2] - REAL(KIND(1D0)) :: Knorth ! incoming shortwave radiation from north [W m-2] - REAL(KIND(1D0)) :: Keast ! incoming shortwave radiation from east [W m-2] - REAL(KIND(1D0)) :: Ldown2d ! incoming longwave radiation onto roof [W m-2] - REAL(KIND(1D0)) :: Lup2d ! outgoing longwave radiation from roof [W m-2] - REAL(KIND(1D0)) :: Lwest ! incoming longwave radiation from west [W m-2] - REAL(KIND(1D0)) :: Lsouth ! incoming longwave radiation from south [W m-2] - REAL(KIND(1D0)) :: Lnorth ! incoming longwave radiation from north [W m-2] - REAL(KIND(1D0)) :: Least ! incoming longwave radiation from east [W m-2] - CONTAINS PROCEDURE :: ALLOCATE => allocHeatState_c PROCEDURE :: DEALLOCATE => deallocHeatState_c @@ -819,25 +754,6 @@ MODULE SUEWS_DEF_DTS END TYPE ROUGHNESS_STATE TYPE, PUBLIC :: STEBBS_STATE - ! Temperature-related variables extracted from STEBBS_PRM - REAL(KIND(1D0)) :: IndoorAirStartTemperature ! Initial indoor air temperature [degC] - REAL(KIND(1D0)) :: IndoorMassStartTemperature ! Initial indoor mass temperature [degC] - REAL(KIND(1D0)) :: WallIndoorSurfaceTemperature ! Initial wall/roof indoor surface temperature [degC] - REAL(KIND(1D0)) :: WallOutdoorSurfaceTemperature ! Initial wall/roof outdoor surface temperature [degC] - REAL(KIND(1D0)) :: WindowIndoorSurfaceTemperature ! Initial window indoor surface temperature [degC] - REAL(KIND(1D0)) :: WindowOutdoorSurfaceTemperature ! Initial window outdoor surface temperature [degC] - REAL(KIND(1D0)) :: GroundFloorIndoorSurfaceTemperature ! Initial ground floor indoor surface temperature [degC] - REAL(KIND(1D0)) :: GroundFloorOutdoorSurfaceTemperature ! Initial ground floor indoor surface temperature [degC] - REAL(KIND(1D0)) :: WaterTankTemperature ! Initial water temperature in hot water tank [degC] - REAL(KIND(1D0)) :: InternalWallWaterTankTemperature ! Initial hot water tank internal wall temperature [degC] - REAL(KIND(1D0)) :: ExternalWallWaterTankTemperature ! Initial hot water tank external wall temperature [degC] - REAL(KIND(1D0)) :: MainsWaterTemperature ! Temperature of water coming into the water tank [degC] - REAL(KIND(1D0)) :: DomesticHotWaterTemperatureInUseInBuilding ! Initial water temperature of water held in use in building [degC] - REAL(KIND(1D0)) :: InternalWallDHWVesselTemperature ! Initial hot water vessel internal wall temperature [degC] - REAL(KIND(1D0)) :: ExternalWallDHWVesselTemperature ! Initial hot water vessel external wall temperature [degC] - END TYPE STEBBS_STATE - - TYPE, PUBLIC :: STEBBS_PRM ! Collect general parameters for STEBBS REAL(KIND(1D0)) :: WallInternalConvectionCoefficient ! Internal convection coefficient of walls and roof [W m-2 K-1] REAL(KIND(1D0)) :: InternalMassConvectionCoefficient ! Convection coefficient of internal mass [W m-2 K-1] @@ -861,10 +777,25 @@ MODULE SUEWS_DEF_DTS REAL(KIND(1D0)) :: MaxCoolingPower ! Maximum power demand of cooling system [W] REAL(KIND(1D0)) :: CoolingSystemCOP ! Coefficient of performance of cooling system [-] REAL(KIND(1D0)) :: VentilationRate ! Ventilation rate (air changes per hour, ACH) [h-1] + REAL(KIND(1D0)) :: IndoorAirStartTemperature ! Initial indoor air temperature [degC] + REAL(KIND(1D0)) :: IndoorMassStartTemperature ! Initial indoor mass temperature [degC] + REAL(KIND(1D0)) :: WallIndoorSurfaceTemperature ! Initial wall/roof indoor surface temperature [degC] + REAL(KIND(1D0)) :: WallOutdoorSurfaceTemperature ! Initial wall/roof outdoor surface temperature [degC] + REAL(KIND(1D0)) :: WindowIndoorSurfaceTemperature ! Initial window indoor surface temperature [degC] + REAL(KIND(1D0)) :: WindowOutdoorSurfaceTemperature ! Initial window outdoor surface temperature [degC] + REAL(KIND(1D0)) :: GroundFloorIndoorSurfaceTemperature ! Initial ground floor indoor surface temperature [degC] + REAL(KIND(1D0)) :: GroundFloorOutdoorSurfaceTemperature ! Initial ground floor outdoor surface temperature [degC] + REAL(KIND(1D0)) :: WaterTankTemperature ! Initial water temperature in hot water tank [degC] + REAL(KIND(1D0)) :: InternalWallWaterTankTemperature ! Initial hot water tank internal wall temperature [degC] + REAL(KIND(1D0)) :: ExternalWallWaterTankTemperature ! Initial hot water tank external wall temperature [degC] REAL(KIND(1D0)) :: WaterTankWallThickness ! Hot water tank wall thickness [m] + REAL(KIND(1D0)) :: MainsWaterTemperature ! Temperature of water coming into the water tank [degC] REAL(KIND(1D0)) :: WaterTankSurfaceArea ! Surface area of hot water tank cylinder [m2] REAL(KIND(1D0)) :: HotWaterHeatingSetpointTemperature ! Water tank setpoint temperature [degC] REAL(KIND(1D0)) :: HotWaterTankWallEmissivity ! Effective external wall emissivity of the hot water tank [-] + REAL(KIND(1D0)) :: DomesticHotWaterTemperatureInUseInBuilding ! Initial water temperature of water held in use in building [degC] + REAL(KIND(1D0)) :: InternalWallDHWVesselTemperature ! Initial hot water vessel internal wall temperature [degC] + REAL(KIND(1D0)) :: ExternalWallDHWVesselTemperature ! Initial hot water vessel external wall temperature [degC] REAL(KIND(1D0)) :: DHWVesselWallThickness ! Hot water vessel wall thickness [m] REAL(KIND(1D0)) :: DHWWaterVolume ! Volume of water held in use in building [m3] REAL(KIND(1D0)) :: DHWSurfaceArea ! Surface area of hot water in vessels in building [m2] @@ -889,7 +820,73 @@ MODULE SUEWS_DEF_DTS REAL(KIND(1D0)) :: HotWaterHeatingEfficiency ! Efficiency of hot water system [-] REAL(KIND(1D0)) :: MinimumVolumeOfDHWinUse ! Minimum volume of hot water in use [m3] - END TYPE STEBBS_PRM + ! Beers output for STEBBS + REAL(KIND(1D0)) :: Kdown2d ! incoming shortwave radiation onto roof [W m-2] + REAL(KIND(1D0)) :: Kup2d ! outgoing shortwave radiation from roof [W m-2] + REAL(KIND(1D0)) :: Kwest ! incoming shortwave radiation from west [W m-2] + REAL(KIND(1D0)) :: Ksouth ! incoming shortwave radiation from south [W m-2] + REAL(KIND(1D0)) :: Knorth ! incoming shortwave radiation from north [W m-2] + REAL(KIND(1D0)) :: Keast ! incoming shortwave radiation from east [W m-2] + REAL(KIND(1D0)) :: Ldown2d ! incoming longwave radiation onto roof [W m-2] + REAL(KIND(1D0)) :: Lup2d ! outgoing longwave radiation from roof [W m-2] + REAL(KIND(1D0)) :: Lwest ! incoming longwave radiation from west [W m-2] + REAL(KIND(1D0)) :: Lsouth ! incoming longwave radiation from south [W m-2] + REAL(KIND(1D0)) :: Lnorth ! incoming longwave radiation from north [W m-2] + REAL(KIND(1D0)) :: Least ! incoming longwave radiation from east [W m-2] + + END TYPE STEBBS_STATE + + TYPE, PUBLIC :: BUILDING_STATE + ! This type is used to collect building archetypes for STEBBS + ! CHARACTER(LEN=50) :: BuildingCode ! + ! CHARACTER(LEN=50) :: BuildingClass ! + ! CHARACTER(LEN=50) :: BuildingType ! + ! CHARACTER(LEN=50) :: BuildingName ! + REAL(KIND(1D0)) :: BuildingCount ! Number of buildings of this archetype [-] + REAL(KIND(1D0)) :: Occupants ! Number of occupants present in building [-] + REAL(KIND(1D0)) :: hhs0 ! + REAL(KIND(1D0)) :: age_0_4 ! + REAL(KIND(1D0)) :: age_5_11 ! + REAL(KIND(1D0)) :: age_12_18 ! + REAL(KIND(1D0)) :: age_19_64 ! + REAL(KIND(1D0)) :: age_65plus ! + REAL(KIND(1D0)) :: stebbs_Height ! Building height [m] + REAL(KIND(1D0)) :: FootprintArea ! Building footprint area [m2] + REAL(KIND(1D0)) :: WallExternalArea ! External wall area (including window area) [m2] + REAL(KIND(1D0)) :: RatioInternalVolume ! Ratio of internal mass volume to total building volume [-] + REAL(KIND(1D0)) :: WWR ! window to wall ratio [-] + REAL(KIND(1D0)) :: WallThickness ! Thickness of external wall and roof (weighted) [m] + REAL(KIND(1D0)) :: WallEffectiveConductivity ! Effective thermal conductivity of walls and roofs (weighted) [W m-1 K-1] + REAL(KIND(1D0)) :: WallDensity ! Effective density of the walls and roof (weighted) [kg m-3] + REAL(KIND(1D0)) :: WallCp ! Effective specific heat capacity of walls and roof (weighted) [J kg-1 K-1] + REAL(KIND(1D0)) :: Wallx1 ! Weighting factor for heat capacity of walls and roof [-] + REAL(KIND(1D0)) :: WallExternalEmissivity ! Emissivity of the external surface of walls and roof [-] + REAL(KIND(1D0)) :: WallInternalEmissivity ! Emissivity of the internal surface of walls and roof [-] + REAL(KIND(1D0)) :: WallTransmissivity ! Transmissivity of walls and roof [-] + REAL(KIND(1D0)) :: WallAbsorbtivity ! Absorbtivity of walls and roof [-] + REAL(KIND(1D0)) :: WallReflectivity ! Reflectivity of the external surface of walls and roof [-] + REAL(KIND(1D0)) :: FloorThickness ! Thickness of ground floor [m] + REAL(KIND(1D0)) :: GroundFloorEffectiveConductivity ! Effective thermal conductivity of ground floor [W m-1 K-1] + REAL(KIND(1D0)) :: GroundFloorDensity ! Density of the ground floor [kg m-3] + REAL(KIND(1D0)) :: GroundFloorCp ! Effective specific heat capacity of the ground floor [J kg-1 K-1] + REAL(KIND(1D0)) :: WindowThickness ! Window thickness [m] + REAL(KIND(1D0)) :: WindowEffectiveConductivity ! Effective thermal conductivity of windows [W m-1 K-1] + REAL(KIND(1D0)) :: WindowDensity ! Effective density of the windows [kg m-3] + REAL(KIND(1D0)) :: WindowCp ! Effective specific heat capacity of windows [J kg-1 K-1] + REAL(KIND(1D0)) :: WindowExternalEmissivity ! Emissivity of the external surface of windows [-] + REAL(KIND(1D0)) :: WindowInternalEmissivity ! Emissivity of the internal surface of windows [-] + REAL(KIND(1D0)) :: WindowTransmissivity ! Transmissivity of windows [-] + REAL(KIND(1D0)) :: WindowAbsorbtivity ! Absorbtivity of windows [-] + REAL(KIND(1D0)) :: WindowReflectivity ! Reflectivity of the external surface of windows [-] + REAL(KIND(1D0)) :: InternalMassDensity ! Effective density of the internal mass [kg m-3] + REAL(KIND(1D0)) :: InternalMassCp ! Specific heat capacity of internal mass [J kg-1 K-1] + REAL(KIND(1D0)) :: InternalMassEmissivity ! Emissivity of internal mass [-] + REAL(KIND(1D0)) :: MaxHeatingPower ! Maximum power demand of heating system [W] + REAL(KIND(1D0)) :: WaterTankWaterVolume ! Volume of water in hot water tank [m3] + REAL(KIND(1D0)) :: MaximumHotWaterHeatingPower ! Maximum power demand of water heating system [W] + REAL(KIND(1D0)) :: HeatingSetpointTemperature ! Heating setpoint temperature [degC] + REAL(KIND(1D0)) :: CoolingSetpointTemperature ! Cooling setpoint temperature [degC] + END TYPE BUILDING_STATE ! incorporate all model states into one lumped type TYPE, PUBLIC :: SUEWS_STATE @@ -903,8 +900,8 @@ MODULE SUEWS_DEF_DTS TYPE(HYDRO_STATE) :: hydroState TYPE(HEAT_STATE) :: heatState TYPE(ROUGHNESS_STATE) :: roughnessState - TYPE(STEBBS_PRM) :: stebbsPrm TYPE(STEBBS_STATE) :: stebbsState + TYPE(BUILDING_STATE) :: bldgState CONTAINS PROCEDURE :: ALLOCATE => allocSUEWSState_c PROCEDURE :: DEALLOCATE => deallocSUEWSState_c diff --git a/src/suews/src/suews_phys_atmmoiststab.f95 b/src/suews/src/suews_phys_atmmoiststab.f95 index b443d4f6c..c5c4a4bfd 100644 --- a/src/suews/src/suews_phys_atmmoiststab.f95 +++ b/src/suews/src/suews_phys_atmmoiststab.f95 @@ -1,7 +1,7 @@ MODULE AtmMoistStab_module USE SUEWS_DEF_DTS, ONLY: atm_state, SUEWS_FORCING, SUEWS_TIMER, SUEWS_STATE IMPLICIT NONE - REAL(KIND(1D0)), PARAMETER :: neut_limit = 1.E-4 !Limit for neutral stability + REAL(KIND(1D0)), PARAMETER :: neut_limit = 1.E-2 !Limit for neutral stability REAL(KIND(1D0)), PARAMETER :: k = 0.4 !Von Karman's contant REAL(KIND(1D0)), PARAMETER :: grav = 9.80665 !g - gravity - physics today august 1987 diff --git a/src/suews/src/suews_phys_beers.f95 b/src/suews/src/suews_phys_beers.f95 index 257ca4d80..9a5530fde 100644 --- a/src/suews/src/suews_phys_beers.f95 +++ b/src/suews/src/suews_phys_beers.f95 @@ -347,7 +347,7 @@ SUBROUTINE BEERS_cal_main_DTS( & USE SUEWS_DEF_DTS, ONLY: SUEWS_CONFIG, SUEWS_TIMER, SUEWS_FORCING, SUEWS_SITE, & PHENOLOGY_STATE, LC_PAVED_PRM, LC_BLDG_PRM, & ROUGHNESS_STATE, HEAT_STATE, solar_State, & - SUEWS_STATE, BldgSurf + SUEWS_STATE, BldgSurf, STEBBS_STATE IMPLICIT NONE TYPE(SUEWS_CONFIG), INTENT(IN) :: config @@ -414,7 +414,8 @@ SUBROUTINE BEERS_cal_main_DTS( & roughnessState => modState%roughnessState, & heatState => modState%heatState, & solarState => modState%solarState, & - phenState => modState%phenState & + phenState => modState%phenState, & + stebbsState => modState%stebbsState & ) ASSOCIATE ( & pavedPrm => siteInfo%lc_paved, & @@ -468,18 +469,18 @@ SUBROUTINE BEERS_cal_main_DTS( & StabilityMethod => config%StabilityMethod, & EmissionsMethod => config%EmissionsMethod, & Diagnose => config%Diagnose, & - Kdown2d => heatState%Kdown2d, & - Kup2d => heatState%Kup2d, & - Kwest => heatState%Kwest, & - Keast => heatState%Keast, & - Knorth => heatState%Knorth, & - Ksouth => heatState%Ksouth, & - Ldown2d => heatState%Ldown2d, & - Lup2d => heatState%Lup2d, & - Lwest => heatState%Lwest, & - Least => heatState%Least, & - Lnorth => heatState%Lnorth, & - Lsouth => heatState%Lsouth & + Kdown2d => stebbsState%Kdown2d, & + Kup2d => stebbsState%Kup2d, & + Kwest => stebbsState%Kwest, & + Keast => stebbsState%Keast, & + Knorth => stebbsState%Knorth, & + Ksouth => stebbsState%Ksouth, & + Ldown2d => stebbsState%Ldown2d, & + Lup2d => stebbsState%Lup2d, & + Lwest => stebbsState%Lwest, & + Least => stebbsState%Least, & + Lnorth => stebbsState%Lnorth, & + Lsouth => stebbsState%Lsouth & ) IF (sfr_surf(BldgSurf) > 0) THEN ! do BEERS calculation diff --git a/src/suews/src/suews_phys_rslprof.f95 b/src/suews/src/suews_phys_rslprof.f95 index f370c4b86..5595e2ec7 100644 --- a/src/suews/src/suews_phys_rslprof.f95 +++ b/src/suews/src/suews_phys_rslprof.f95 @@ -10,7 +10,7 @@ MODULE rsl_module CONTAINS - SUBROUTINE RSLProfile_old( & + SUBROUTINE RSLProfile( & DiagMethod, & Zh, z0m, zdm, z0v, & L_MOD, sfr_surf, FAI, PAI, & @@ -384,7 +384,7 @@ SUBROUTINE RSLProfile_old( & ! get relative humidity: RH2 = qa2RH(q2_gkg, press_hPa, T2_C) - END SUBROUTINE RSLProfile_old + END SUBROUTINE RSLProfile ! SUBROUTINE RSLProfile_DTS( & ! DiagMethod, & @@ -759,7 +759,7 @@ END SUBROUTINE RSLProfile_old ! END SUBROUTINE RSLProfile_DTS - SUBROUTINE RSLProfile( & + SUBROUTINE RSLProfile_DTS( & timer, config, forcing, siteInfo, & ! input modState, & ! input/output: dataoutLineRSL) ! output @@ -1062,11 +1062,9 @@ SUBROUTINE RSLProfile( & ! Step 0: Calculate grid-cell dependent constants and Beta (crucial for H&F method) CALL RSL_cal_prms( & StabilityMethod, & !input - !nz_above, zarray(nz_can + 1:nz), & !input - nz_above + 1, zarray(nz_can:nz), & !input + nz_above, zarray(nz_can + 1:nz), & !input zh, L_MOD, sfr_surf, FAI, PAI, & !input - !psihatm_z(nz_can + 1:nz), psihath_z(nz_can + 1:nz), & !output - psihatm_z(nz_can:nz), psihath_z(nz_can:nz), & !output + psihatm_z(nz_can + 1:nz), psihath_z(nz_can + 1:nz), & !output zH_RSL, L_MOD_RSL, & ! output Lc, beta, zd_RSL, z0_RSL, elm, Scc, fx) @@ -1200,7 +1198,7 @@ SUBROUTINE RSLProfile( & END ASSOCIATE END ASSOCIATE - END SUBROUTINE RSLProfile + END SUBROUTINE RSLProfile_DTS FUNCTION interp_z(z_x, z, v) RESULT(v_x) diff --git a/src/suews/src/suews_phys_stebbs.f95 b/src/suews/src/suews_phys_stebbs.f95 index fa0d39704..d1adbfdd3 100644 --- a/src/suews/src/suews_phys_stebbs.f95 +++ b/src/suews/src/suews_phys_stebbs.f95 @@ -1,178 +1,166 @@ MODULE modulestebbsprecision + USE ISO_FORTRAN_ENV, ONLY: REAL64 + IMPLICIT NONE + INTEGER, PARAMETER :: rprc = REAL64 -END MODULE modulestebbsprecision + +END MODULE MODULE modulestebbs - USE modulestebbsprecision, ONLY: rprc + + USE modulestebbsprecision + REAL(rprc), PARAMETER :: sigma = 5.670E-8 + INTEGER, SAVE :: flgtimecheck = 1 INTEGER :: resolution INTEGER :: time_st, time_ed, count_p_sec, count_max ! Time check - INTEGER :: nbtype - !------------------------------------------------------------------- - ! Type: LBM (Lumped Building Model) - ! Description: A simplified building energy model that represents a building as a set of - ! lumped thermal masses (walls, windows, indoor air, etc.) and calculates - ! heat transfer between them. This approach reduces computational complexity - ! while maintaining reasonable accuracy for urban-scale simulations. - ! - ! Key components: - ! - Building geometry (footprint, height, wall areas) - ! - Thermal properties (conductivity, density, heat capacity) - ! - System characteristics (HVAC, hot water) - ! - Energy exchanges (conduction, convection, radiation) - ! - Internal gains (occupants, appliances) - ! - ! References: - ! - Based on simplified building energy parameterisation schemes - ! - Similar to EnergyPlus's "zone" concept but more simplified - ! - ! Note: This is part of STEBBS (Simplified Thermal Energy Balance for Building Scheme) - ! which provides a computationally efficient way to simulate building energy - ! dynamics in urban climate models. - !------------------------------------------------------------------- + INTEGER :: nbtype + CHARACTER(len=256), ALLOCATABLE, DIMENSION(:) :: fnmls, cases TYPE :: LBM CHARACTER(len=256) :: & - BuildingType, & ! Type/usage of building (e.g., residential, office) - BuildingName, & ! Identifier for the building - fnmlLBM, & ! Path to building's namelist file - CASE ! Case identifier + BuildingType, & + BuildingName, & + fnmlLBM, & + CASE INTEGER :: idLBM INTEGER :: flginit = 0 INTEGER :: appliance_totalnumber - REAL(rprc) :: Qtotal_heating - REAL(rprc) :: Qtotal_cooling - REAL(rprc) :: Qmetabolic_sensible - REAL(rprc) :: Qmetabolic_latent - REAL(rprc) :: Qtotal_water_tank - REAL(rprc) :: qhwtDrain - REAL(rprc) :: ratio_window_wall - REAL(rprc) :: Afootprint - REAL(rprc) :: height_building - REAL(rprc) :: wallExternalArea - REAL(rprc) :: ratioInternalVolume - REAL(rprc) :: thickness_wallroof - REAL(rprc) :: thickness_groundfloor - REAL(rprc) :: depth_ground - REAL(rprc) :: thickness_window - REAL(rprc) :: conv_coeff_intwallroof - REAL(rprc) :: conv_coeff_indoormass - REAL(rprc) :: conv_coeff_intgroundfloor - REAL(rprc) :: conv_coeff_intwindow - REAL(rprc) :: conv_coeff_extwallroof - REAL(rprc) :: conv_coeff_extwindow - REAL(rprc) :: conductivity_wallroof - REAL(rprc) :: conductivity_groundfloor - REAL(rprc) :: conductivity_window - REAL(rprc) :: conductivity_ground - REAL(rprc) :: density_wallroof - REAL(rprc) :: weighting_factor_heatcapacity_wallroof - REAL(rprc) :: density_groundfloor - REAL(rprc) :: density_window - REAL(rprc) :: density_indoormass - REAL(rprc) :: density_air_ind - REAL(rprc) :: cp_wallroof - REAL(rprc) :: cp_groundfloor - REAL(rprc) :: cp_window - REAL(rprc) :: cp_indoormass - REAL(rprc) :: cp_air_ind - REAL(rprc) :: emissivity_extwallroof - REAL(rprc) :: emissivity_intwallroof - REAL(rprc) :: emissivity_indoormass - REAL(rprc) :: emissivity_extwindow - REAL(rprc) :: emissivity_intwindow - REAL(rprc) :: windowTransmissivity - REAL(rprc) :: windowAbsorbtivity - REAL(rprc) :: windowReflectivity - REAL(rprc) :: wallTransmisivity - REAL(rprc) :: wallAbsorbtivity - REAL(rprc) :: wallReflectivity - REAL(rprc) :: BVF_extwall - REAL(rprc) :: GVF_extwall - REAL(rprc) :: SVF_extwall - REAL(rprc) :: occupants - REAL(rprc) :: metabolic_rate - REAL(rprc) :: ratio_metabolic_latent_sensible - REAL(rprc) :: appliance_power_rating - REAL(rprc) :: appliance_usage_factor - REAL(rprc) :: maxheatingpower_air - REAL(rprc) :: heating_efficiency_air - REAL(rprc) :: maxcoolingpower_air - REAL(rprc) :: coeff_performance_cooling - REAL(rprc) :: Vair_ind - REAL(rprc) :: ventilation_rate - REAL(rprc) :: Awallroof - REAL(rprc) :: Vwallroof - REAL(rprc) :: Vgroundfloor - REAL(rprc) :: Awindow - REAL(rprc) :: Vwindow - REAL(rprc) :: Vindoormass - REAL(rprc) :: Aindoormass - REAL(rprc) :: Tair_ind - REAL(rprc) :: Tindoormass - REAL(rprc) :: Tintwallroof - REAL(rprc) :: Textwallroof - REAL(rprc) :: Tintwindow - REAL(rprc) :: Textwindow - REAL(rprc) :: Tintgroundfloor - REAL(rprc) :: Textgroundfloor - REAL(rprc) :: Twater_tank - REAL(rprc) :: Tintwall_tank - REAL(rprc) :: Textwall_tank - REAL(rprc) :: thickness_tankwall - REAL(rprc) :: Tincomingwater_tank - REAL(rprc) :: Vwater_tank - REAL(rprc) :: Asurf_tank - REAL(rprc) :: Vwall_tank - REAL(rprc) :: setTwater_tank - REAL(rprc) :: init_wtTs - REAL(rprc) :: Twater_vessel - REAL(rprc) :: Tintwall_vessel - REAL(rprc) :: Textwall_vessel - REAL(rprc) :: thickness_wall_vessel - REAL(rprc) :: Vwater_vessel - REAL(rprc) :: Awater_vessel - REAL(rprc) :: Vwall_vessel - REAL(rprc) :: flowrate_water_supply - REAL(rprc) :: flowrate_water_drain - REAL(rprc) :: single_flowrate_water_supply - REAL(rprc) :: single_flowrate_water_drain - REAL(rprc) :: cp_water - REAL(rprc) :: cp_wall_tank - REAL(rprc) :: cp_wall_vessel - REAL(rprc) :: density_water - REAL(rprc) :: density_wall_tank - REAL(rprc) :: density_wall_vessel - REAL(rprc) :: BVF_tank - REAL(rprc) :: MVF_tank - REAL(rprc) :: conductivity_wall_tank - REAL(rprc) :: conv_coeff_intwall_tank - REAL(rprc) :: conv_coeff_extwall_tank - REAL(rprc) :: emissivity_extwall_tank - REAL(rprc) :: conductivity_wall_vessel - REAL(rprc) :: conv_coeff_intwall_vessel - REAL(rprc) :: conv_coeff_extwall_vessel - REAL(rprc) :: emissivity_extwall_vessel - REAL(rprc) :: maxheatingpower_water - REAL(rprc) :: heating_efficiency_water - REAL(rprc) :: minVwater_vessel - REAL(rprc) :: minHeatingPower_DHW - REAL(rprc) :: HeatingPower_DHW - REAL(rprc) :: qfm_dom ! Metabolic sensible and latent heat - REAL(rprc) :: qheat_dom ! Hourly heating load [W] - REAL(rprc) :: qcool_dom ! Hourly cooling load [W] - REAL(rprc) :: qfb_hw_dom ! Hot water - REAL(rprc) :: qfb_dom_air ! Sensible heat to air [W] - REAL(rprc) :: dom_temp ! Domain temperature [W] - REAL(rprc) :: QStar ! Net radiation [W m-2] - REAL(rprc) :: QEC ! Energy use [W m-2] - REAL(rprc) :: QH ! Sensible heat flux [W m-2] - REAL(rprc) :: QS ! Storage heat flux [W m-2] - REAL(rprc) :: QBAE ! Building exchange [W m-2] - REAL(rprc) :: QWaste ! Waste heating [W m-2] + REAL(rprc) :: & + Qtotal_heating, & + Qtotal_cooling, & + Qmetabolic_sensible, & + Qmetabolic_latent, & + Qtotal_water_tank, & + qhwtDrain, & + ratio_window_wall, & + Afootprint, & + height_building, & + wallExternalArea, & + ratioInternalVolume, & + thickness_wallroof, & + thickness_groundfloor, & + depth_ground, & + thickness_window, & + conv_coeff_intwallroof, & + conv_coeff_indoormass, & + conv_coeff_intgroundfloor, & + conv_coeff_intwindow, & + conv_coeff_extwallroof, & + conv_coeff_extwindow, & + conductivity_wallroof, & + conductivity_groundfloor, & + conductivity_window, & + conductivity_ground, & + density_wallroof, & + weighting_factor_heatcapacity_wallroof, & + density_groundfloor, & + density_window, & + density_indoormass, & + density_air_ind, & + cp_wallroof, & + cp_groundfloor, & + cp_window, & + cp_indoormass, & + cp_air_ind, & + emissivity_extwallroof, & + emissivity_intwallroof, & + emissivity_indoormass, & + emissivity_extwindow, & + emissivity_intwindow, & + windowTransmissivity, & + windowAbsorbtivity, & + windowReflectivity, & + wallTransmisivity, & + wallAbsorbtivity, & + wallReflectivity, & + BVF_extwall, & + GVF_extwall, & + SVF_extwall, & + occupants, & + metabolic_rate, & + ratio_metabolic_latent_sensible, & + appliance_power_rating, & + appliance_usage_factor, & + maxheatingpower_air, & + heating_efficiency_air, & + maxcoolingpower_air, & + coeff_performance_cooling, & + Vair_ind, & + ventilation_rate, & + Awallroof, & + Vwallroof, & + Vgroundfloor, & + Awindow, & + Vwindow, & + Vindoormass, & + Aindoormass, & + Tair_ind, & + Tindoormass, & + Tintwallroof, & + Textwallroof, & + Tintwindow, & + Textwindow, & + Tintgroundfloor, & + Textgroundfloor, & + Twater_tank, & + Tintwall_tank, & + Textwall_tank, & + thickness_tankwall, & + Tincomingwater_tank, & + Vwater_tank, & + Asurf_tank, & + Vwall_tank, & + setTwater_tank, & + init_wtTs, & + Twater_vessel, & + Tintwall_vessel, & + Textwall_vessel, & + thickness_wall_vessel, & + Vwater_vessel, & + Awater_vessel, & + Vwall_vessel, & + flowrate_water_supply, & + flowrate_water_drain, & + single_flowrate_water_supply, & + single_flowrate_water_drain, & + cp_water, & + cp_wall_tank, & + cp_wall_vessel, & + density_water, & + density_wall_tank, & + density_wall_vessel, & + BVF_tank, & + MVF_tank, & + conductivity_wall_tank, & + conv_coeff_intwall_tank, & + conv_coeff_extwall_tank, & + emissivity_extwall_tank, & + conductivity_wall_vessel, & + conv_coeff_intwall_vessel, & + conv_coeff_extwall_vessel, & + emissivity_extwall_vessel, & + maxheatingpower_water, & + heating_efficiency_water, & + minVwater_vessel, & + minHeatingPower_DHW, & + HeatingPower_DHW + REAL(rprc) :: & + qfm_dom, & ! Metabolic sensible and latent heat + qheat_dom, & ! Hourly heating load [W] + qcool_dom, & ! Hourly cooling load [W] + qfb_hw_dom, & ! Hot water + qfb_dom_air, & ! Sensible heat to air [W] + dom_temp, & ! Domain temperature [W] + QStar, & ! Net radiation [W m-2] + QEC, & ! Energy use [W m-2] + QH, & ! Sensible heat flux [W m-2] + QS, & ! Storage heat flux [W m-2] + QBAE, & ! Building exchange [W m-2] + QWaste ! Waste heating [W m-2] REAL(rprc), DIMENSION(2) :: Ts, initTs REAL(rprc), DIMENSION(4) :: h_i, k_eff REAL(rprc), DIMENSION(2) :: h_o @@ -186,17 +174,12 @@ MODULE modulestebbs REAL(rprc), DIMENSION(3) :: HWPowerAverage REAL(rprc), DIMENSION(25) :: EnergyExchanges = 0.0 END TYPE - - ! bldg: Array of LBM objects - make this a fixed size array - 10 for now; - ! TODO: the number 10 to be decided if appropriate in the future - TYPE(LBM), DIMENSION(10) :: bldg + TYPE(LBM), ALLOCATABLE, DIMENSION(:) :: blds END MODULE modulestebbs - MODULE modulestebbsfunc - USE modulestebbsprecision, ONLY: rprc + USE modulestebbsprecision IMPLICIT NONE CONTAINS - !------------------------------------------------------------------- ! Function: waterUseEnergyLossToDrains ! Parameters: @@ -209,14 +192,13 @@ MODULE modulestebbsfunc ! q_wt - energy lost to drains [J] !------------------------------------------------------------------- FUNCTION waterUseEnergyLossToDrains(rho, Cp, vFRo, Tout, timeResolution) RESULT(q_wt) - + USE modulestebbsprecision IMPLICIT NONE INTEGER, INTENT(in) :: timeResolution REAL(rprc), INTENT(in) :: rho, Cp, vFRo, Tout REAL(rprc) :: q_wt q_wt = rho*Cp*Tout*(vFRo*timeResolution) - END FUNCTION waterUseEnergyLossToDrains - + END FUNCTION !------------------------------------------------------------------- ! Function: indoorConvectionHeatTransfer ! Description: Indoor Convection on wall surfaces: convective heat transfer between air node and wall node(s) @@ -229,12 +211,12 @@ END FUNCTION waterUseEnergyLossToDrains ! ind_cht - [W] !------------------------------------------------------------------- FUNCTION indoorConvectionHeatTransfer(h, A, Twi, Ti) RESULT(ind_cht) + USE modulestebbsprecision IMPLICIT NONE REAL(rprc), INTENT(in) :: h, A, Twi, Ti REAL(rprc) :: ind_cht ind_cht = h*A*(Ti - Twi) END FUNCTION indoorConvectionHeatTransfer - !------------------------------------------------------------------- ! Function: internalConvectionHeatTransfer ! Description: Indoor Convection on wall surfaces: convective heat transfer between air node and wall node(s) @@ -247,12 +229,12 @@ END FUNCTION indoorConvectionHeatTransfer ! int_cht - heat transfer to internal objects [W] !------------------------------------------------------------------- FUNCTION internalConvectionHeatTransfer(h, A, Tio, Ti) RESULT(int_cht) + USE modulestebbsprecision IMPLICIT NONE REAL(rprc), INTENT(in) :: h, A, Tio, Ti REAL(rprc) :: int_cht int_cht = h*A*(Ti - Tio) END FUNCTION internalConvectionHeatTransfer - !------------------------------------------------------------------- ! Function: indoorRadiativeHeatTransfer (NOT IMPLEMENTED) ! Description: Indoor radiative exchange between wall surfaces and mass internal object @@ -261,12 +243,12 @@ END FUNCTION internalConvectionHeatTransfer ! q - !------------------------------------------------------------------- FUNCTION indoorRadiativeHeatTransfer() RESULT(q) + USE modulestebbsprecision IMPLICIT NONE REAL(rprc) :: q q = 0.0 RETURN END FUNCTION indoorRadiativeHeatTransfer - !------------------------------------------------------------------- ! Function: outdoorConvectionHeatTransfer ! Description: Outdoor Convection on surfaces. Convective heat transfer between outside wall surface and ambient air node @@ -279,13 +261,13 @@ END FUNCTION indoorRadiativeHeatTransfer ! out_cht - [W] !------------------------------------------------------------------- FUNCTION outdoorConvectionHeatTransfer(h, A, Two, Ta) RESULT(out_cht) + USE modulestebbsprecision IMPLICIT NONE REAL(rprc), INTENT(in) :: h, A, Two, Ta REAL(rprc) :: out_cht out_cht = h*A*(Two - Ta) RETURN END FUNCTION outdoorConvectionHeatTransfer - !------------------------------------------------------------------- ! Function: outdoorRadiativeHeatTransfer ! Description: Outdoor Convection on surfaces. Convective heat transfer between outside wall surface and ambient air node @@ -299,6 +281,7 @@ END FUNCTION outdoorConvectionHeatTransfer ! out_cht - [W] !------------------------------------------------------------------- FUNCTION outdoorRadiativeHeatTransfer(f, A, emis, Two, Ts) RESULT(q) + USE modulestebbsprecision USE modulestebbs, ONLY: sigma IMPLICIT NONE REAL(rprc), INTENT(in) :: f, A, emis, Two, Ts @@ -306,7 +289,6 @@ FUNCTION outdoorRadiativeHeatTransfer(f, A, emis, Two, Ts) RESULT(q) q = A*f*sigma*emis*(Two**4.0 - Ts**4.0) RETURN END FUNCTION outdoorRadiativeHeatTransfer - !------------------------------------------------------------------- ! Function: lwoutdoorRadiativeHeatTransfer ! Description: Longwave radiative heat transfer between outside surface and ambient air @@ -319,6 +301,7 @@ END FUNCTION outdoorRadiativeHeatTransfer ! q - Longwave radiative heat transfer [W] !------------------------------------------------------------------- FUNCTION lwoutdoorRadiativeHeatTransfer(A, emis, Two, lw) RESULT(q) + USE modulestebbsprecision USE modulestebbs, ONLY: sigma IMPLICIT NONE REAL(rprc), INTENT(in) :: A, emis, Two, lw @@ -326,7 +309,6 @@ FUNCTION lwoutdoorRadiativeHeatTransfer(A, emis, Two, lw) RESULT(q) q = A*sigma*emis*(Two**4.0) - emis*lw*a ! Revised based on Yiqing's discovery RETURN END FUNCTION lwoutdoorRadiativeHeatTransfer - !------------------------------------------------------------------- ! Function: windowInsolation ! Description: Window Solar Insolation. This should be added as heat gain to internal single mass object @@ -338,13 +320,13 @@ END FUNCTION lwoutdoorRadiativeHeatTransfer ! wi_in - Window Insolation [W] !------------------------------------------------------------------- FUNCTION windowInsolation(Irr, Tr, A) RESULT(wi_in) + USE modulestebbsprecision IMPLICIT NONE REAL(rprc), INTENT(in) :: Irr, Tr, A REAL(rprc) :: wi_in wi_in = Irr*Tr*A RETURN END FUNCTION windowInsolation - !------------------------------------------------------------------- ! Function: wallInsolation ! Description: Solar Insolation on surface. This should be added as heat gain to external surface of wall @@ -356,13 +338,13 @@ END FUNCTION windowInsolation ! wa_in - [W] !------------------------------------------------------------------- FUNCTION wallInsolation(Irr, Ab, A) RESULT(wa_in) + USE modulestebbsprecision IMPLICIT NONE REAL(rprc), INTENT(in) :: Irr, Ab, A REAL(rprc) :: wa_in wa_in = Irr*Ab*A RETURN END FUNCTION wallInsolation - !------------------------------------------------------------------- ! Function: wallConduction ! Description: Wall Component Conduction (can be floor/roof/wall/window) @@ -376,12 +358,12 @@ END FUNCTION wallInsolation ! wa_co - [W] !------------------------------------------------------------------- FUNCTION wallConduction(k_eff, A, Twi, Two, L) RESULT(wa_co) + USE modulestebbsprecision IMPLICIT NONE REAL(rprc), INTENT(in) :: k_eff, Twi, Two, A, L REAL(rprc) :: wa_co wa_co = k_eff*A*((Twi - Two)/L) END FUNCTION wallConduction - !------------------------------------------------------------------- ! Function: windowConduction ! Description: Window Component Conduction (same as wall) @@ -395,12 +377,12 @@ END FUNCTION wallConduction ! wi_co - [W] !------------------------------------------------------------------- FUNCTION windowConduction(k_eff, A, Twi, Two, L) RESULT(wi_co) + USE modulestebbsprecision IMPLICIT NONE REAL(rprc), INTENT(in) :: k_eff, Twi, Two, A, L REAL(rprc) :: wi_co wi_co = k_eff*A*((Twi - Two)/L) END FUNCTION windowConduction - !------------------------------------------------------------------- ! Function: heating ! Description: Heating injected to building @@ -413,6 +395,7 @@ END FUNCTION windowConduction ! q_heating - [W] !------------------------------------------------------------------- FUNCTION heating(Ts, Ti, epsilon, P) RESULT(q_heating) + USE modulestebbsprecision IMPLICIT NONE REAL(rprc), INTENT(in) :: Ts, Ti, epsilon, P REAL(rprc) :: q_heating @@ -421,7 +404,6 @@ FUNCTION heating(Ts, Ti, epsilon, P) RESULT(q_heating) q_heating = (P - (P/EXP(Ts - Ti)))*epsilon END IF END FUNCTION heating - !------------------------------------------------------------------- ! Function: ventilationHeatTransfer ! Description: Building Ventilation rate heat transfer (i.e. not recirculated air) @@ -435,12 +417,12 @@ END FUNCTION heating ! q_in - the heat flux resulting in the building [W] !------------------------------------------------------------------- FUNCTION ventilationHeatTransfer(rho, Cp, V, To, Ti) RESULT(q_in) + USE modulestebbsprecision IMPLICIT NONE REAL(rprc), INTENT(in) :: rho, Cp, V, To, Ti REAL(rprc) :: q_in q_in = rho*Cp*V*(To - Ti) END FUNCTION ventilationHeatTransfer - !------------------------------------------------------------------- ! Function: additionalSystemHeatingEnergy ! Description: Calculates the additional heat from the heating system due to system efficiency @@ -451,13 +433,13 @@ END FUNCTION ventilationHeatTransfer ! qH_additional - additional heating energy [W] !------------------------------------------------------------------- FUNCTION additionalSystemHeatingEnergy(q_heating, epsilon) RESULT(qH_additional) + USE modulestebbsprecision IMPLICIT NONE REAL(rprc), INTENT(in) :: q_heating, epsilon REAL(rprc) :: qH_additional qH_additional = 0.0 qH_additional = (q_heating/epsilon) - q_heating END FUNCTION additionalSystemHeatingEnergy - !------------------------------------------------------------------- ! Function: cooling ! Description: Cooling of building (heat ejected) @@ -470,6 +452,7 @@ END FUNCTION additionalSystemHeatingEnergy ! q_cooling - [W] !------------------------------------------------------------------- FUNCTION cooling(Ts, Ti, COP, P) RESULT(q_cooling) + USE modulestebbsprecision IMPLICIT NONE REAL(rprc), INTENT(in) :: Ts, Ti, COP, P REAL(rprc) :: q_cooling @@ -478,7 +461,6 @@ FUNCTION cooling(Ts, Ti, COP, P) RESULT(q_cooling) q_cooling = P - (P/EXP(Ti - Ts)) END IF END FUNCTION cooling - !------------------------------------------------------------------- ! Function: additionalSystemCoolingEnergy ! Description: Calculates the additional heat from the cooling system due to system COP @@ -489,12 +471,12 @@ END FUNCTION cooling ! qC_additional - additional cooling energy [W] !------------------------------------------------------------------- FUNCTION additionalSystemCoolingEnergy(q_cooling, COP) RESULT(qC_additional) + USE modulestebbsprecision IMPLICIT NONE REAL(rprc), INTENT(in) :: q_cooling, COP REAL(rprc) :: qC_additional qC_additional = q_cooling/COP END FUNCTION additionalSystemCoolingEnergy - !------------------------------------------------------------------- ! Function: internalOccupancyGains ! Description: Calculates the internal gains from building occupants @@ -506,6 +488,7 @@ END FUNCTION additionalSystemCoolingEnergy ! qSL - latent heat and sensible heat from all occupants [W] !------------------------------------------------------------------- FUNCTION internalOccupancyGains(Occupants, metRate, LSR) RESULT(qSL) + USE modulestebbsprecision IMPLICIT NONE REAL(rprc), INTENT(in) :: Occupants, metRate, LSR REAL(rprc) :: qSen, qLat @@ -513,7 +496,6 @@ FUNCTION internalOccupancyGains(Occupants, metRate, LSR) RESULT(qSL) qSL(1) = (metRate*Occupants)/(1.0 + LSR) qSL(2) = (metRate*Occupants)*LSR/(1.0 + LSR) END FUNCTION internalOccupancyGains - !------------------------------------------------------------------- ! Function: internalApplianceGains ! Description: @@ -525,13 +507,13 @@ END FUNCTION internalOccupancyGains ! qapp - total energy of appliances - assume all goes to heat (sensible) [W] !------------------------------------------------------------------- FUNCTION internalApplianceGains(P, f, n) RESULT(qapp) + USE modulestebbsprecision IMPLICIT NONE INTEGER, INTENT(in) :: n REAL(rprc), INTENT(in) :: P, f REAL(rprc) :: qapp qapp = P*f*n END FUNCTION internalApplianceGains - !------------------------------------------------------------------- ! Function: ext_conv_coeff ! Description: Calculates the external convection coefficient using Eq. 11 Cole & Sturrock (1977) @@ -542,6 +524,8 @@ END FUNCTION internalApplianceGains ! hc - External convection coefficient [W m-2 K-1] !------------------------------------------------------------------- FUNCTION ext_conv_coeff(wind_speed, dT) RESULT(hc) + + USE modulestebbsprecision IMPLICIT NONE REAL(rprc), INTENT(in) :: wind_speed, dT REAL(rprc) :: hn, a, b, Rf, hcglass, hc @@ -553,15 +537,14 @@ FUNCTION ext_conv_coeff(wind_speed, dT) RESULT(hc) hc = hn + Rf*(hcglass - hn) END FUNCTION ext_conv_coeff END MODULE modulestebbsfunc - MODULE modulesuewsstebbscouple - USE modulestebbsprecision, ONLY: rprc + USE modulestebbsprecision IMPLICIT NONE REAL(rprc) :: Tair_out, Tsurf, Tground_deep, & density_air_out, cp_air_out, & Qsw_dn_extroof, Qsw_dn_extwall, & Qlw_dn_extwall, Qlw_dn_extroof - TYPE :: STEBBS_OUT + TYPE :: suewsprop INTEGER :: ntstep, timestep CHARACTER(len=256), ALLOCATABLE, DIMENSION(:) :: datetime, hourmin REAL(rprc), ALLOCATABLE, DIMENSION(:) :: Tair, Tsurf, Kwall, Kroof, ws, Lroof, Lwall @@ -569,12 +552,11 @@ MODULE modulesuewsstebbscouple CHARACTER(len=256), ALLOCATABLE, DIMENSION(:) :: datetime_exch, hourmin_exch REAL(rprc), ALLOCATABLE, DIMENSION(:) :: Tair_exch, Tsurf_exch, Kwall_exch, Kroof_exch, ws_exch, Lroof_exch, Lwall_exch END TYPE - TYPE(STEBBS_OUT) :: stebbs_output + TYPE(suewsprop) :: sout END MODULE modulesuewsstebbscouple - SUBROUTINE setdatetime(datetimeLine) - USE modulesuewsstebbscouple, ONLY: stebbs_output - USE modulestebbsprecision, ONLY: rprc + USE modulestebbsprecision + USE modulesuewsstebbscouple, ONLY: sout IMPLICIT NONE REAL(rprc), DIMENSION(5), INTENT(in) :: datetimeLine INTEGER :: i @@ -602,29 +584,28 @@ SUBROUTINE setdatetime(datetimeLine) WRITE (chour, '(i2.2)') INT(datetimeLine(3)) WRITE (cmin, '(i2.2)') INT(datetimeLine(4)) WRITE (csec, '(i2.2)') 0 - stebbs_output%datetime(1) = TRIM(cyear//'-'//cmonth//'-'//cday) - stebbs_output%hourmin(1) = TRIM(chour//':'//cmin//':'//csec) + sout%datetime(1) = TRIM(cyear//'-'//cmonth//'-'//cday) + sout%hourmin(1) = TRIM(chour//':'//cmin//':'//csec) RETURN END SUBROUTINE setdatetime - MODULE stebbs_module CONTAINS - SUBROUTINE stebbs_cal_main( & + SUBROUTINE stebbsonlinecouple( & timer, config, forcing, siteInfo, & ! Input modState, & ! Input/Output datetimeLine, & dataOutLineSTEBBS) ! Output - USE modulestebbs, ONLY: bldg, resolution - USE modulesuewsstebbscouple, ONLY: stebbs_output ! Defines stebbs_output + USE modulestebbs, ONLY: blds, cases, resolution + USE modulesuewsstebbscouple, ONLY: sout ! Defines sout USE modulestebbsprecision, ONLY: rprc ! Defines rprc as REAL64 USE allocateArray, ONLY: ncolumnsDataOutSTEBBS USE SUEWS_DEF_DTS, ONLY: SUEWS_CONFIG, SUEWS_TIMER, SUEWS_FORCING, LC_PAVED_PRM, LC_BLDG_PRM, & LC_EVETR_PRM, LC_DECTR_PRM, LC_GRASS_PRM, & LC_BSOIL_PRM, LC_WATER_PRM, & SUEWS_SITE, atm_state, ROUGHNESS_STATE, & - HEAT_STATE, SUEWS_STATE, STEBBS_PRM, BLDG_ARCHTYPE_PRM, STEBBS_STATE + HEAT_STATE, SUEWS_STATE, STEBBS_STATE, BUILDING_STATE IMPLICIT NONE TYPE(SUEWS_CONFIG), INTENT(IN) :: config TYPE(SUEWS_TIMER), INTENT(IN) :: timer @@ -648,7 +629,7 @@ SUBROUTINE stebbs_cal_main( & REAL(KIND(1D0)), DIMENSION(4) :: wallStatesK, wallStatesL REAL(rprc) :: Kwall_sout, Lwall_sout - ! REAL(rprc) :: Tsurf_sout + REAL(rprc) :: Tsurf_sout REAL(rprc) :: qheat_dom, qcool_dom, dom_temp, qfb_hw_dom, qfm_dom, qfb_dom_air, & Qsw_transmitted_window, Qsw_absorbed_window, Qsw_absorbed_wallroof, & @@ -663,25 +644,24 @@ SUBROUTINE stebbs_cal_main( & atmState => modState%atmState, & roughnessState => modState%roughnessState, & stebbsState => modState%stebbsState, & - stebbsPrm => modState%stebbsPrm, & - bldgarchtypePrm => siteInfo%bldg_archtype & + bldgState => modState%bldgState & ) ASSOCIATE ( & ws => atmState%U10_ms, & Tair_sout => atmState%t2_C, & Tsurf_sout => heatState%Tsurf, & - Kroof_sout => heatState%Kdown2d, & - Lroof_sout => heatState%Ldown2d, & + Kroof_sout => stebbsState%Kdown2d, & + Lroof_sout => stebbsState%Ldown2d, & ! Create an array of the wall states - Knorth => heatState%Knorth, & - Ksouth => heatState%Ksouth, & - Keast => heatState%Keast, & - Kwest => heatState%Kwest, & - Lnorth => heatState%Lnorth, & - Lsouth => heatState%Lsouth, & - Least => heatState%Least, & - Lwest => heatState%Lwest & + Knorth => stebbsState%Knorth, & + Ksouth => stebbsState%Ksouth, & + Keast => stebbsState%Keast, & + Kwest => stebbsState%Kwest, & + Lnorth => stebbsState%Lnorth, & + Lsouth => stebbsState%Lsouth, & + Least => stebbsState%Least, & + Lwest => stebbsState%Lwest & ) wallStatesK(1) = Knorth @@ -700,9 +680,11 @@ SUBROUTINE stebbs_cal_main( & ! ! IF (flginit == 0) THEN + ALLOCATE (cases(1)) WRITE (*, *) 'Initialising STEBBS' + ALLOCATE (blds(1)) resolution = 1 - CALL gen_building(stebbsPrm, stebbsState, bldgarchtypePrm, bldg(1)) + CALL gen_building(stebbsState, bldgState, blds(1)) ! call create_building(cases(1),blds(1),1) ! Print out all values of blds(1) to check initialization @@ -860,51 +842,51 @@ SUBROUTINE stebbs_cal_main( & ! WRITE (*, *) 'QS: ', blds(1)%QS ! WRITE (*, *) 'QBAE: ', blds(1)%QBAE ! WRITE (*, *) 'QWaste: ', blds(1)%QWaste - stebbs_output%ntstep = 1 - ALLOCATE (stebbs_output%datetime(stebbs_output%ntstep)) - ALLOCATE (stebbs_output%hourmin(stebbs_output%ntstep)) - ALLOCATE (stebbs_output%Tair(stebbs_output%ntstep)) - ALLOCATE (stebbs_output%Tsurf(stebbs_output%ntstep)) - ALLOCATE (stebbs_output%Kwall(stebbs_output%ntstep)) - ALLOCATE (stebbs_output%Kroof(stebbs_output%ntstep)) - ALLOCATE (stebbs_output%ws(stebbs_output%ntstep)) - ALLOCATE (stebbs_output%Lroof(stebbs_output%ntstep)) - ALLOCATE (stebbs_output%Lwall(stebbs_output%ntstep)) - ALLOCATE (stebbs_output%datetime_exch(stebbs_output%ntstep)) - ALLOCATE (stebbs_output%hourmin_exch(stebbs_output%ntstep)) - ALLOCATE (stebbs_output%Tair_exch(stebbs_output%ntstep)) - ALLOCATE (stebbs_output%Tsurf_exch(stebbs_output%ntstep)) - ALLOCATE (stebbs_output%Kwall_exch(stebbs_output%ntstep)) - ALLOCATE (stebbs_output%Kroof_exch(stebbs_output%ntstep)) - ALLOCATE (stebbs_output%ws_exch(stebbs_output%ntstep)) - ALLOCATE (stebbs_output%Lroof_exch(stebbs_output%ntstep)) - ALLOCATE (stebbs_output%Lwall_exch(stebbs_output%ntstep)) + sout%ntstep = 1 + ALLOCATE (sout%datetime(sout%ntstep)) + ALLOCATE (sout%hourmin(sout%ntstep)) + ALLOCATE (sout%Tair(sout%ntstep)) + ALLOCATE (sout%Tsurf(sout%ntstep)) + ALLOCATE (sout%Kwall(sout%ntstep)) + ALLOCATE (sout%Kroof(sout%ntstep)) + ALLOCATE (sout%ws(sout%ntstep)) + ALLOCATE (sout%Lroof(sout%ntstep)) + ALLOCATE (sout%Lwall(sout%ntstep)) + ALLOCATE (sout%datetime_exch(sout%ntstep)) + ALLOCATE (sout%hourmin_exch(sout%ntstep)) + ALLOCATE (sout%Tair_exch(sout%ntstep)) + ALLOCATE (sout%Tsurf_exch(sout%ntstep)) + ALLOCATE (sout%Kwall_exch(sout%ntstep)) + ALLOCATE (sout%Kroof_exch(sout%ntstep)) + ALLOCATE (sout%ws_exch(sout%ntstep)) + ALLOCATE (sout%Lroof_exch(sout%ntstep)) + ALLOCATE (sout%Lwall_exch(sout%ntstep)) ! END IF - stebbs_output%Tair(1) = Tair_sout - stebbs_output%Tsurf(1) = Tsurf_sout - stebbs_output%Kroof(1) = Kroof_sout - stebbs_output%Kwall(1) = Kwall_sout - stebbs_output%Lwall(1) = Lwall_sout - stebbs_output%Lroof(1) = Lroof_sout - stebbs_output%timestep = timestep + sout%Tair(1) = Tair_sout + sout%Tsurf(1) = Tsurf_sout + sout%Kroof(1) = Kroof_sout + sout%Kwall(1) = Kwall_sout + sout%Lwall(1) = Lwall_sout + sout%Lroof(1) = Lroof_sout + sout%timestep = timestep ! sout%timestep = 3600 - stebbs_output%Tair_exch(1) = Tair_sout - stebbs_output%Tsurf_exch(1) = Tsurf_sout - stebbs_output%ws(1) = ws - stebbs_output%ws_exch(1) = ws + sout%Tair_exch(1) = Tair_sout + sout%Tsurf_exch(1) = Tsurf_sout + sout%ws(1) = ws + sout%ws_exch(1) = ws CALL setdatetime(datetimeLine) ! nbtype = SIZE(blds) ! DO i = 1, nbtype, 1 - CALL stebbs_cal(bldg(1), flginit, datetimeLine, & - qheat_dom, qcool_dom, dom_temp, qfb_hw_dom, qfm_dom, qfb_dom_air, & - Qsw_transmitted_window, Qsw_absorbed_window, Qsw_absorbed_wallroof, & - Qcond_ground, Qlw_net_extwallroof_to_outair, Qlw_net_extwindow_to_outair, & - Qconv_extwallroof_to_outair, Qconv_extwindow_to_outair, & - QStar, QEC, QH, QS, QBAE, QWaste, & - Textwallroof, Tintwallroof, Textwindow, Tintwindow, Tair_ind & - ) + CALL suewsstebbscouple(blds(1), flginit, datetimeLine, & + qheat_dom, qcool_dom, dom_temp, qfb_hw_dom, qfm_dom, qfb_dom_air, & + Qsw_transmitted_window, Qsw_absorbed_window, Qsw_absorbed_wallroof, & + Qcond_ground, Qlw_net_extwallroof_to_outair, Qlw_net_extwindow_to_outair, & + Qconv_extwallroof_to_outair, Qconv_extwindow_to_outair, & + QStar, QEC, QH, QS, QBAE, QWaste, & + Textwallroof, Tintwallroof, Textwindow, Tintwindow, Tair_ind & + ) ! END DO flginit = 1 @@ -920,87 +902,85 @@ SUBROUTINE stebbs_cal_main( & END ASSOCIATE END ASSOCIATE - END SUBROUTINE stebbs_cal_main + END SUBROUTINE stebbsonlinecouple END MODULE stebbs_module - -! SUBROUTINE readsuewsout() -! USE modulesuewsstebbscouple -! IMPLICIT NONE -! INTEGER :: i, reason, icrop -! stebbs_output%timestep = 3600 ! 1hr, hard-coded for the test -! OPEN (8, file='./SUEWS_output_res.csv', form='formatted') - -! i = 0 -! DO WHILE (.TRUE.) -! READ (8, *, iostat=reason) -! IF (reason < 0) go to 333 -! i = i + 1 -! END DO -! 333 CONTINUE -! stebbs_output%ntstep = i - 1 -! ALLOCATE (stebbs_output%datetime(stebbs_output%ntstep)) -! ALLOCATE (stebbs_output%hourmin(stebbs_output%ntstep)) -! ALLOCATE (stebbs_output%Tair(stebbs_output%ntstep)) -! ALLOCATE (stebbs_output%Tsurf(stebbs_output%ntstep)) -! ALLOCATE (stebbs_output%Kwall(stebbs_output%ntstep)) -! ALLOCATE (stebbs_output%Kroof(stebbs_output%ntstep)) -! ALLOCATE (stebbs_output%ws(stebbs_output%ntstep)) -! ALLOCATE (stebbs_output%Lroof(stebbs_output%ntstep)) -! ALLOCATE (stebbs_output%Lwall(stebbs_output%ntstep)) -! ALLOCATE (stebbs_output%datetime_exch(stebbs_output%ntstep)) -! ALLOCATE (stebbs_output%hourmin_exch(stebbs_output%ntstep)) -! ALLOCATE (stebbs_output%Tair_exch(stebbs_output%ntstep)) -! ALLOCATE (stebbs_output%Tsurf_exch(stebbs_output%ntstep)) -! ALLOCATE (stebbs_output%Kwall_exch(stebbs_output%ntstep)) -! ALLOCATE (stebbs_output%Kroof_exch(stebbs_output%ntstep)) -! ALLOCATE (stebbs_output%ws_exch(stebbs_output%ntstep)) -! ALLOCATE (stebbs_output%Lroof_exch(stebbs_output%ntstep)) -! ALLOCATE (stebbs_output%Lwall_exch(stebbs_output%ntstep)) -! REWIND (8) -! READ (8, *) -! DO i = 1, stebbs_output%ntstep, 1 -! READ (8, *) stebbs_output%datetime(i), stebbs_output%hourmin(i), stebbs_output%Tair(i), stebbs_output%Tsurf(i), & -! stebbs_output%Kwall(i), stebbs_output%Kroof(i), stebbs_output%ws(i), stebbs_output%Lroof(i), stebbs_output%Lwall(i) -! END DO -! WRITE (*, *) ' + SUEWS output profile' -! WRITE (*, *) ' + Date : ', TRIM(stebbs_output%datetime(1)), ' ', TRIM(stebbs_output%hourmin(1)), ' - ', & -! TRIM(stebbs_output%datetime(stebbs_output%ntstep)), ' ', TRIM(stebbs_output%hourmin(stebbs_output%ntstep)) -! WRITE (*, *) ' + Total data step : ', stebbs_output%ntstep -! CLOSE (8) -! stebbs_output%ntskip = 12 -! OPEN (8, file='./SUEWS_output.csv', form='formatted') -! READ (8, *) - -! DO i = 1, stebbs_output%ntstep*stebbs_output%ntskip, 1 -! IF (MOD(i - 1, stebbs_output%ntskip) == 0) THEN -! icrop = INT((i - 1)/stebbs_output%ntskip) + 1 -! READ (8, *) stebbs_output%datetime_exch(icrop), stebbs_output%hourmin_exch(icrop), & -! stebbs_output%Tair_exch(icrop), stebbs_output%Tsurf_exch(icrop), & -! stebbs_output%Kwall_exch(icrop), stebbs_output%Kroof_exch(icrop), & -! stebbs_output%ws_exch(icrop), stebbs_output%Lroof_exch(icrop), & -! stebbs_output%Lwall_exch(icrop) -! ELSE -! READ (8, *) -! END IF -! END DO -! CLOSE (8) -! RETURN -! END SUBROUTINE readsuewsout - -SUBROUTINE stebbs_cal(self, flginit, datetimeLine, & - qheat_dom, qcool_dom, dom_temp, qfb_hw_dom, qfm_dom, qfb_dom_air, & - Qsw_transmitted_window, Qsw_absorbed_window, Qsw_absorbed_wallroof, & - Qcond_ground, Qlw_net_extwallroof_to_outair, Qlw_net_extwindow_to_outair, & - Qconv_extwallroof_to_outair, Qconv_extwindow_to_outair, & - QStar, QEC, QH, QS, QBAE, QWaste, & - Textwallroof, Tintwallroof, Textwindow, Tintwindow, Tair_ind & - ) ! Output - - USE modulestebbsprecision, ONLY: rprc +SUBROUTINE readsuewsout() + USE modulesuewsstebbscouple + IMPLICIT NONE + INTEGER :: i, reason, icrop + sout%timestep = 3600 ! 1hr, hard-coded for the test + OPEN (8, file='./SUEWS_output_res.csv', form='formatted') + + i = 0 + DO WHILE (.TRUE.) + READ (8, *, iostat=reason) + IF (reason < 0) go to 333 + i = i + 1 + END DO +333 CONTINUE + sout%ntstep = i - 1 + ALLOCATE (sout%datetime(sout%ntstep)) + ALLOCATE (sout%hourmin(sout%ntstep)) + ALLOCATE (sout%Tair(sout%ntstep)) + ALLOCATE (sout%Tsurf(sout%ntstep)) + ALLOCATE (sout%Kwall(sout%ntstep)) + ALLOCATE (sout%Kroof(sout%ntstep)) + ALLOCATE (sout%ws(sout%ntstep)) + ALLOCATE (sout%Lroof(sout%ntstep)) + ALLOCATE (sout%Lwall(sout%ntstep)) + ALLOCATE (sout%datetime_exch(sout%ntstep)) + ALLOCATE (sout%hourmin_exch(sout%ntstep)) + ALLOCATE (sout%Tair_exch(sout%ntstep)) + ALLOCATE (sout%Tsurf_exch(sout%ntstep)) + ALLOCATE (sout%Kwall_exch(sout%ntstep)) + ALLOCATE (sout%Kroof_exch(sout%ntstep)) + ALLOCATE (sout%ws_exch(sout%ntstep)) + ALLOCATE (sout%Lroof_exch(sout%ntstep)) + ALLOCATE (sout%Lwall_exch(sout%ntstep)) + REWIND (8) + READ (8, *) + DO i = 1, sout%ntstep, 1 + READ (8, *) sout%datetime(i), sout%hourmin(i), sout%Tair(i), sout%Tsurf(i), & + sout%Kwall(i), sout%Kroof(i), sout%ws(i), sout%Lroof(i), sout%Lwall(i) + END DO + WRITE (*, *) ' + SUEWS output profile' + WRITE (*, *) ' + Date : ', TRIM(sout%datetime(1)), ' ', TRIM(sout%hourmin(1)), ' - ', & + TRIM(sout%datetime(sout%ntstep)), ' ', TRIM(sout%hourmin(sout%ntstep)) + WRITE (*, *) ' + Total data step : ', sout%ntstep + CLOSE (8) + sout%ntskip = 12 + OPEN (8, file='./SUEWS_output.csv', form='formatted') + READ (8, *) + + DO i = 1, sout%ntstep*sout%ntskip, 1 + IF (MOD(i - 1, sout%ntskip) == 0) THEN + icrop = INT((i - 1)/sout%ntskip) + 1 + READ (8, *) sout%datetime_exch(icrop), sout%hourmin_exch(icrop), & + sout%Tair_exch(icrop), sout%Tsurf_exch(icrop), & + sout%Kwall_exch(icrop), sout%Kroof_exch(icrop), & + sout%ws_exch(icrop), sout%Lroof_exch(icrop), & + sout%Lwall_exch(icrop) + ELSE + READ (8, *) + END IF + END DO + CLOSE (8) + RETURN +END SUBROUTINE readsuewsout +SUBROUTINE suewsstebbscouple(self, flginit, datetimeLine, & + qheat_dom, qcool_dom, dom_temp, qfb_hw_dom, qfm_dom, qfb_dom_air, & + Qsw_transmitted_window, Qsw_absorbed_window, Qsw_absorbed_wallroof, & + Qcond_ground, Qlw_net_extwallroof_to_outair, Qlw_net_extwindow_to_outair, & + Qconv_extwallroof_to_outair, Qconv_extwindow_to_outair, & + QStar, QEC, QH, QS, QBAE, QWaste, & + Textwallroof, Tintwallroof, Textwindow, Tintwindow, Tair_ind & + ) ! Output + + USE modulestebbsprecision USE modulestebbs, ONLY: LBM, resolution USE modulestebbsfunc, ONLY: ext_conv_coeff USE modulesuewsstebbscouple, ONLY: & - stebbs_output, & + sout, & Tair_out, Tground_deep, Tsurf, density_air_out, & cp_air_out, & Qsw_dn_extroof, & @@ -1033,43 +1013,43 @@ SUBROUTINE stebbs_cal(self, flginit, datetimeLine, & ! CASE = self%CASE Area = self%Afootprint - DO tstep = 1, stebbs_output%ntstep, 1 - Tair_out = stebbs_output%Tair(tstep) + 273.15 + DO tstep = 1, sout%ntstep, 1 + Tair_out = sout%Tair(tstep) + 273.15 Tground_deep = 273.15 + 10.0 - Tsurf = stebbs_output%Tsurf(tstep) + 273.15 + Tsurf = sout%Tsurf(tstep) + 273.15 density_air_out = 1.225 cp_air_out = 1005.0 - Qsw_dn_extroof = stebbs_output%Kroof(tstep) - Qsw_dn_extwall = stebbs_output%Kwall(tstep) - Qlw_dn_extwall = stebbs_output%Lwall(tstep) - Qlw_dn_extroof = stebbs_output%Lroof(tstep) + Qsw_dn_extroof = sout%Kroof(tstep) + Qsw_dn_extwall = sout%Kwall(tstep) + Qlw_dn_extwall = sout%Lwall(tstep) + Qlw_dn_extroof = sout%Lroof(tstep) debug_array_dir = './debug_array.csv' - IF (stebbs_output%ws_exch(tstep) < 0) THEN - stebbs_output%ws_exch(tstep) = 0.2 + IF (sout%ws_exch(tstep) < 0) THEN + sout%ws_exch(tstep) = 0.2 ! WRITE (*, *) 'Wind speed is negative, set to 0.2' END IF - self%h_o(1) = ext_conv_coeff(stebbs_output%ws_exch(tstep), stebbs_output%Tair_exch(tstep) - stebbs_output%Tsurf_exch(tstep)) - self%h_o(2) = ext_conv_coeff(stebbs_output%ws_exch(tstep), stebbs_output%Tair_exch(tstep) - stebbs_output%Tsurf_exch(tstep)) + self%h_o(1) = ext_conv_coeff(sout%ws_exch(tstep), sout%Tair_exch(tstep) - sout%Tsurf_exch(tstep)) + self%h_o(2) = ext_conv_coeff(sout%ws_exch(tstep), sout%Tair_exch(tstep) - sout%Tsurf_exch(tstep)) CALL timeStepCalculation(self, Tair_out, Tground_deep, Tsurf, & density_air_out, cp_air_out, & Qsw_dn_extroof, Qsw_dn_extwall, & - Qlw_dn_extwall, Qlw_dn_extroof, stebbs_output%timestep, & + Qlw_dn_extwall, Qlw_dn_extroof, sout%timestep, & resolution, & datetimeLine, & flginit & ) bem_qf_1 = (/self%Qtotal_heating, self%Qtotal_cooling, self%EnergyExchanges(8), & self%Qtotal_water_tank, self%Qmetabolic_sensible, self%Qmetabolic_latent/) - bem_qf_1 = bem_qf_1/float(stebbs_output%timestep) + bem_qf_1 = bem_qf_1/float(sout%timestep) qfm_dom = bem_qf_1(5) + bem_qf_1(6) qheat_dom = bem_qf_1(1) qcool_dom = bem_qf_1(2) qfb_hw_dom = bem_qf_1(4) qfb_dom_air = 0 dom_temp = self%Tair_ind - 273.15 ! [K] to deg. - energyEx = self%EnergyExchanges(:)/float(stebbs_output%timestep) + energyEx = self%EnergyExchanges(:)/float(sout%timestep) ! Qsw_transmitted_window = energyEx(1)/Area ! # transmitted solar radiation through windows [W m-2] Qsw_absorbed_window = energyEx(2)/Area ! # absorbed solar radiation by windows [W m-2] @@ -1114,15 +1094,14 @@ SUBROUTINE stebbs_cal(self, flginit, datetimeLine, & self%QWaste = QWaste self%flginit = 1 RETURN -END SUBROUTINE stebbs_cal - +END SUBROUTINE suewsstebbscouple SUBROUTINE timeStepCalculation(self, Tair_out, Tground_deep, Tsurf, & density_air_out, cp_air_out, & Qsw_dn_extroof, Qsw_dn_extwall, & Qlw_dn_extwall, Qlw_dn_extroof, & timestep, resolution, datetimeLine, flginit & ) - USE modulestebbsprecision, ONLY: rprc + USE modulestebbsprecision USE modulestebbs, ONLY: LBM IMPLICIT NONE INTEGER :: timestep, resolution @@ -1221,7 +1200,6 @@ SUBROUTINE timeStepCalculation(self, Tair_out, Tground_deep, Tsurf, & self%Qmetabolic_latent) !qlatent_timestepTotal RETURN END SUBROUTINE timeStepCalculation - SUBROUTINE tstep( & flginit, datetimeLine, Tair_out, Tground_deep, Tsurf, & density_air_out, cp_air_out, & @@ -1254,6 +1232,7 @@ SUBROUTINE tstep( & Tair_ind, Tindoormass, Tintwallroof, Textwallroof, & !IO Tintwindow, Textwindow, Tintgroundfloor, Textgroundfloor, & !IO Ts, & !IO + ! Ts(1), Ts(2), & appliance_totalnumber, timestep, resolution, & Qtotal_water_tank, Twater_tank, Tintwall_tank, & !IO Textwall_tank, thickness_tankwall, Tincomingwater_tank, & !IO @@ -1270,7 +1249,10 @@ SUBROUTINE tstep( & emissivity_extwall_vessel, maxheatingpower_water, & heating_efficiency_water, minVwater_vessel, & weighting_factor_heatcapacity_wallroof, & - Qsw_transmitted_window_tstepTotal, & !EE(1) ! Output only variables & + ! + ! Output only variables + ! + Qsw_transmitted_window_tstepTotal, & !EE(1) Qsw_absorbed_window_tstepTotal, & !EE(2) Qsw_absorbed_wallroof_tstepTotal, & !EE(3) Qconv_indair_to_indoormass_tstepTotal, & !EE(4) @@ -1292,6 +1274,7 @@ SUBROUTINE tstep( & QS_tstepTotal, QS_fabric_tstepTotal, QS_air_tstepTotal, & !EE(23,24,25) Qloss_drain, & !qhwtDrain qsensible_timestepTotal, qlatent_timestepTotal) !Qmetabolic_sensible, Qmetabolic_latent + USE modulestebbsprecision USE modulestebbsfunc IMPLICIT NONE INTEGER, INTENT(in) :: flginit @@ -1480,7 +1463,6 @@ SUBROUTINE tstep( & IF (Awater_vessel > 0.0) THEN VARatio_water_vessel = Vwater_vessel/Awater_vessel END IF - IF (MOD(timestep, resolution) == 0) THEN looptime: DO i = 1, INT(timestep/resolution), 1 Qsw_transmitted_window = windowInsolation(Qsw_dn_extwall, winT, Awindow) @@ -1791,17 +1773,17 @@ SUBROUTINE tstep( & WRITE (*, *) "Timestep: ", timestep, " not equally divisible by given resolution: ", resolution END IF END SUBROUTINE tstep - -SUBROUTINE gen_building(stebbsPrm, stebbsState, bldgarchtypePrm, self) +SUBROUTINE reinitialiseTemperatures +END SUBROUTINE reinitialiseTemperatures +SUBROUTINE gen_building(stebbsState, bldgState, self) USE modulestebbs, ONLY: LBM - USE SUEWS_DEF_DTS, ONLY: BLDG_ARCHTYPE_PRM, STEBBS_PRM, STEBBS_STATE + USE SUEWS_DEF_DTS, ONLY: BUILDING_STATE, STEBBS_STATE IMPLICIT NONE TYPE(LBM) :: self - TYPE(STEBBS_PRM), INTENT(IN) :: stebbsPrm TYPE(STEBBS_STATE), INTENT(IN) :: stebbsState - TYPE(BLDG_ARCHTYPE_PRM), INTENT(IN) :: bldgarchtypePrm + TYPE(BUILDING_STATE), INTENT(IN) :: bldgState ! self%idLBM = bldgState%BuildingName @@ -1817,65 +1799,64 @@ SUBROUTINE gen_building(stebbsPrm, stebbsState, bldgarchtypePrm, self) ! self%BuildingType = bldgState%BuildingType ! self%BuildingName = bldgState%BuildingName - self%ratio_window_wall = bldgarchtypePrm%WWR - self%Afootprint = bldgarchtypePrm%FootprintArea - self%height_building = bldgarchtypePrm%stebbs_Height - self%wallExternalArea = bldgarchtypePrm%WallExternalArea - self%ratioInternalVolume = bldgarchtypePrm%RatioInternalVolume - self%thickness_wallroof = bldgarchtypePrm%WallThickness - self%thickness_groundfloor = bldgarchtypePrm%FloorThickness - self%depth_ground = stebbsPrm%GroundDepth - self%thickness_window = bldgarchtypePrm%WindowThickness - self%conv_coeff_intwallroof = stebbsPrm%WallInternalConvectionCoefficient - self%conv_coeff_indoormass = stebbsPrm%InternalMassConvectionCoefficient - self%conv_coeff_intgroundfloor = stebbsPrm%FloorInternalConvectionCoefficient - self%conv_coeff_intwindow = stebbsPrm%WindowInternalConvectionCoefficient - self%conv_coeff_extwallroof = stebbsPrm%WallExternalConvectionCoefficient - self%conv_coeff_extwindow = stebbsPrm%WindowExternalConvectionCoefficient - self%conductivity_wallroof = bldgarchtypePrm%WallEffectiveConductivity - self%conductivity_groundfloor = bldgarchtypePrm%GroundFloorEffectiveConductivity - self%conductivity_window = bldgarchtypePrm%WindowEffectiveConductivity - self%conductivity_ground = bldgarchtypePrm%GroundFloorEffectiveConductivity - self%density_wallroof = bldgarchtypePrm%WallDensity - self%weighting_factor_heatcapacity_wallroof = bldgarchtypePrm%Wallx1 - self%density_groundfloor = bldgarchtypePrm%GroundFloorDensity - self%density_window = bldgarchtypePrm%WindowDensity - self%density_indoormass = bldgarchtypePrm%InternalMassDensity - self%density_air_ind = stebbsPrm%IndoorAirDensity - self%cp_wallroof = bldgarchtypePrm%WallCp - self%cp_groundfloor = bldgarchtypePrm%GroundFloorCp - self%cp_window = bldgarchtypePrm%WindowCp - self%cp_indoormass = bldgarchtypePrm%InternalMassCp - self%cp_air_ind = stebbsPrm%IndoorAirCp - self%emissivity_extwallroof = bldgarchtypePrm%WallExternalEmissivity - self%emissivity_intwallroof = bldgarchtypePrm%WallInternalEmissivity - self%emissivity_indoormass = bldgarchtypePrm%InternalMassEmissivity - self%emissivity_extwindow = bldgarchtypePrm%WindowExternalEmissivity - self%emissivity_intwindow = bldgarchtypePrm%WindowInternalEmissivity - self%windowTransmissivity = bldgarchtypePrm%WindowTransmissivity - self%windowAbsorbtivity = bldgarchtypePrm%WindowAbsorbtivity - self%windowReflectivity = bldgarchtypePrm%WindowReflectivity - self%wallTransmisivity = bldgarchtypePrm%WallTransmissivity - self%wallAbsorbtivity = bldgarchtypePrm%WallAbsorbtivity - self%wallReflectivity = bldgarchtypePrm%WallReflectivity - self%BVF_extwall = stebbsPrm%WallBuildingViewFactor - self%GVF_extwall = stebbsPrm%WallGroundViewFactor - self%SVF_extwall = stebbsPrm%WallSkyViewFactor - self%occupants = bldgarchtypePrm%Occupants - self%metabolic_rate = stebbsPrm%MetabolicRate - self%ratio_metabolic_latent_sensible = stebbsPrm%LatentSensibleRatio - self%appliance_power_rating = stebbsPrm%ApplianceRating - self%appliance_totalnumber = INT(stebbsPrm%TotalNumberofAppliances) - self%appliance_usage_factor = stebbsPrm%ApplianceUsageFactor - self%maxheatingpower_air = bldgarchtypePrm%MaxHeatingPower - self%heating_efficiency_air = stebbsPrm%HeatingSystemEfficiency - self%maxcoolingpower_air = stebbsPrm%MaxCoolingPower - self%coeff_performance_cooling = stebbsPrm%CoolingSystemCOP - + self%ratio_window_wall = bldgState%WWR + self%Afootprint = bldgState%FootprintArea + self%height_building = bldgState%stebbs_Height + self%wallExternalArea = bldgState%WallExternalArea + self%ratioInternalVolume = bldgState%RatioInternalVolume + self%thickness_wallroof = bldgState%WallThickness + self%thickness_groundfloor = bldgState%FloorThickness + self%depth_ground = stebbsState%GroundDepth + self%thickness_window = bldgState%WindowThickness + self%conv_coeff_intwallroof = stebbsState%WallInternalConvectionCoefficient + self%conv_coeff_indoormass = stebbsState%InternalMassConvectionCoefficient + self%conv_coeff_intgroundfloor = stebbsState%FloorInternalConvectionCoefficient + self%conv_coeff_intwindow = stebbsState%WindowInternalConvectionCoefficient + self%conv_coeff_extwallroof = stebbsState%WallExternalConvectionCoefficient + self%conv_coeff_extwindow = stebbsState%WindowExternalConvectionCoefficient + self%conductivity_wallroof = bldgState%WallEffectiveConductivity + self%conductivity_groundfloor = bldgState%GroundFloorEffectiveConductivity + self%conductivity_window = bldgState%WindowEffectiveConductivity + self%conductivity_ground = bldgState%GroundFloorEffectiveConductivity + self%density_wallroof = bldgState%WallDensity + self%weighting_factor_heatcapacity_wallroof = bldgState%Wallx1 + self%density_groundfloor = bldgState%GroundFloorDensity + self%density_window = bldgState%WindowDensity + self%density_indoormass = bldgState%InternalMassDensity + self%density_air_ind = stebbsState%IndoorAirDensity + self%cp_wallroof = bldgState%WallCp + self%cp_groundfloor = bldgState%GroundFloorCp + self%cp_window = bldgState%WindowCp + self%cp_indoormass = bldgState%InternalMassCp + self%cp_air_ind = stebbsState%IndoorAirCp + self%emissivity_extwallroof = bldgState%WallExternalEmissivity + self%emissivity_intwallroof = bldgState%WallInternalEmissivity + self%emissivity_indoormass = bldgState%InternalMassEmissivity + self%emissivity_extwindow = bldgState%WindowExternalEmissivity + self%emissivity_intwindow = bldgState%WindowInternalEmissivity + self%windowTransmissivity = bldgState%WindowTransmissivity + self%windowAbsorbtivity = bldgState%WindowAbsorbtivity + self%windowReflectivity = bldgState%WindowReflectivity + self%wallTransmisivity = bldgState%WallTransmissivity + self%wallAbsorbtivity = bldgState%WallAbsorbtivity + self%wallReflectivity = bldgState%WallReflectivity + self%BVF_extwall = stebbsState%WallBuildingViewFactor + self%GVF_extwall = stebbsState%WallGroundViewFactor + self%SVF_extwall = stebbsState%WallSkyViewFactor + self%occupants = bldgState%Occupants + self%metabolic_rate = stebbsState%MetabolicRate + self%ratio_metabolic_latent_sensible = stebbsState%LatentSensibleRatio + self%appliance_power_rating = stebbsState%ApplianceRating + self%appliance_totalnumber = INT(stebbsState%TotalNumberofAppliances) + self%appliance_usage_factor = stebbsState%ApplianceUsageFactor + self%maxheatingpower_air = bldgState%MaxHeatingPower + self%heating_efficiency_air = stebbsState%HeatingSystemEfficiency + self%maxcoolingpower_air = stebbsState%MaxCoolingPower + self%coeff_performance_cooling = stebbsState%CoolingSystemCOP self%Vair_ind = & (self%Afootprint*self%height_building)* & (1 - self%ratioInternalVolume) ! # Multiplied by factor that accounts for internal mass - self%ventilation_rate = self%Vair_ind*stebbsPrm%VentilationRate/3600.0 ! Fixed at begining to have no natural ventilation. Given in units of volume of air per second + self%ventilation_rate = self%Vair_ind*stebbsState%VentilationRate/3600.0 ! Fixed at begining to have no natural ventilation. Given in units of volume of air per second self%Awallroof = & (self%wallExternalArea*(1 - self%ratio_window_wall)) + & self%Afootprint ! # last component accounts for the roof as not considered seperately in the model @@ -1916,69 +1897,68 @@ SUBROUTINE gen_building(stebbsPrm, stebbsState, bldgarchtypePrm, self) self%Tintgroundfloor = stebbsState%GroundFloorIndoorSurfaceTemperature + 273.15 ! # Ground floor indoor surface temperature (K) self%Textgroundfloor = stebbsState%GroundFloorOutdoorSurfaceTemperature + 273.15 ! # Ground floor outdoor surface temperature (K) - self%Ts = (/bldgarchtypePrm%HeatingSetpointTemperature + 273.15, & - bldgarchtypePrm%CoolingSetpointTemperature + 273.15/) ! # Heating and Cooling setpoint temperatures (K), respectively - self%initTs = (/bldgarchtypePrm%HeatingSetpointTemperature + 273.15, & - bldgarchtypePrm%CoolingSetpointTemperature + 273.15/) + self%Ts = (/bldgState%HeatingSetpointTemperature + 273.15, & + bldgState%CoolingSetpointTemperature + 273.15/) ! # Heating and Cooling setpoint temperatures (K), respectively + self%initTs = (/bldgState%HeatingSetpointTemperature + 273.15, & + bldgState%CoolingSetpointTemperature + 273.15/) self%HTsAverage = (/18 + 273.15, 18 + 273.15, 18 + 273.15/) ! # self%HWTsAverage = (/10 + 273.15, 10 + 273.15, 10 + 273.15/) self%Twater_tank = stebbsState%WaterTankTemperature + 273.15 ! # Water temperature (K) in Hot Water Tank self%Tintwall_tank = stebbsState%InternalWallWaterTankTemperature + 273.15 ! # Hot water tank internal wall temperature (K) self%Textwall_tank = stebbsState%ExternalWallWaterTankTemperature + 273.15 ! # Hot water tank external wall temperature (K) - self%thickness_tankwall = stebbsPrm%WaterTankWallThickness ! # Hot water tank wall thickness (m) + self%thickness_tankwall = stebbsState%WaterTankWallThickness ! # Hot water tank wall thickness (m) self%Tincomingwater_tank = stebbsState%MainsWaterTemperature + 273.15 ! # Water temperature (K) of Water coming into the Water Tank - self%Vwater_tank = bldgarchtypePrm%WaterTankWaterVolume ! # Volume of Water in Hot Water Tank (m^3) h = 1.5, (2/(1.5*3.14))^0.5 = r = - self%Asurf_tank = stebbsPrm%WaterTankSurfaceArea ! # Surface Area of Hot Water Tank(m^2) - cylinder h= 1.5 + self%Vwater_tank = bldgState%WaterTankWaterVolume ! # Volume of Water in Hot Water Tank (m^3) h = 1.5, (2/(1.5*3.14))^0.5 = r = + self%Asurf_tank = stebbsState%WaterTankSurfaceArea ! # Surface Area of Hot Water Tank(m^2) - cylinder h= 1.5 self%Vwall_tank = self%Asurf_tank*self%thickness_tankwall ! # Wall volume of Hot Water Tank(m^2) - self%setTwater_tank = stebbsPrm%HotWaterHeatingSetpointTemperature + 273.15 ! # Water Tank setpoint temperature (K) - self%init_wtTs = stebbsPrm%HotWaterHeatingSetpointTemperature + 273.15 ! # Initial Water Tank setpoint temperature (K) + self%setTwater_tank = stebbsState%HotWaterHeatingSetpointTemperature + 273.15 ! # Water Tank setpoint temperature (K) + self%init_wtTs = stebbsState%HotWaterHeatingSetpointTemperature + 273.15 ! # Initial Water Tank setpoint temperature (K) self%Twater_vessel = stebbsState%DomesticHotWaterTemperatureInUseInBuilding + 273.15 ! # Water temperature (K) of water held in use in Building self%Tintwall_vessel = stebbsState%InternalWallDHWVesselTemperature + 273.15 ! # Hot water vessel internal wall temperature (K) self%Textwall_vessel = stebbsState%ExternalWallDHWVesselTemperature + 273.15 ! # Hot water vessel external wall temperature (K) - self%thickness_wall_vessel = stebbsPrm%DHWVesselWallThickness ! # DHW vessels wall thickness (m) + self%thickness_wall_vessel = stebbsState%DHWVesselWallThickness ! # DHW vessels wall thickness (m) - self%Vwater_vessel = stebbsPrm%DHWWaterVolume ! # Volume of water held in use in building (m^3) - self%Awater_vessel = stebbsPrm%DHWSurfaceArea ! # Surface Area of Hot Water in Vessels in Building (m^2) + self%Vwater_vessel = stebbsState%DHWWaterVolume ! # Volume of water held in use in building (m^3) + self%Awater_vessel = stebbsState%DHWSurfaceArea ! # Surface Area of Hot Water in Vessels in Building (m^2) self%Vwall_vessel = self%Awater_vessel*self%thickness_wall_vessel ! # Wall volume of Hot water Vessels in Building - self%flowrate_water_supply = stebbsPrm%HotWaterFlowRate ! # Hot Water Flow Rate in m^3 / s - self%flowrate_water_drain = stebbsPrm%DHWDrainFlowRate ! # Draining of Domestic Hot Water held in building + self%flowrate_water_supply = stebbsState%HotWaterFlowRate ! # Hot Water Flow Rate in m^3 / s + self%flowrate_water_drain = stebbsState%DHWDrainFlowRate ! # Draining of Domestic Hot Water held in building - self%single_flowrate_water_supply = stebbsPrm%HotWaterFlowRate ! # Hot Water Flow Rate in m^3 s^-1 for a single HW unit - self%single_flowrate_water_drain = stebbsPrm%DHWDrainFlowRate ! # Draining of Domestic Hot Water held in building + self%single_flowrate_water_supply = stebbsState%HotWaterFlowRate ! # Hot Water Flow Rate in m^3 s^-1 for a single HW unit + self%single_flowrate_water_drain = stebbsState%DHWDrainFlowRate ! # Draining of Domestic Hot Water held in building - self%cp_water = stebbsPrm%DHWSpecificHeatCapacity ! # Specific Heat Capacity of Domestic Hot Water (J/kg K) - self%cp_wall_tank = stebbsPrm%HotWaterTankSpecificHeatCapacity ! # Specific Heat Capacity of Hot Water Tank wall - self%cp_wall_vessel = stebbsPrm%DHWVesselSpecificHeatCapacity ! # Specific Heat Capacity of Vessels containing DHW in use in Building (value here is based on MDPE) + self%cp_water = stebbsState%DHWSpecificHeatCapacity ! # Specific Heat Capacity of Domestic Hot Water (J/kg K) + self%cp_wall_tank = stebbsState%HotWaterTankSpecificHeatCapacity ! # Specific Heat Capacity of Hot Water Tank wall + self%cp_wall_vessel = stebbsState%DHWVesselSpecificHeatCapacity ! # Specific Heat Capacity of Vessels containing DHW in use in Building (value here is based on MDPE) - self%density_water = stebbsPrm%DHWDensity ! # Density of water - self%density_wall_tank = stebbsPrm%HotWaterTankWallDensity ! # Density of hot water tank wall - self%density_wall_vessel = stebbsPrm%DHWVesselDensity ! # Density of vessels containing DHW in use in buildings + self%density_water = stebbsState%DHWDensity ! # Density of water + self%density_wall_tank = stebbsState%HotWaterTankWallDensity ! # Density of hot water tank wall + self%density_wall_vessel = stebbsState%DHWVesselDensity ! # Density of vessels containing DHW in use in buildings - self%BVF_tank = stebbsPrm%HotWaterTankBuildingWallViewFactor ! # water tank - building wall view factor - self%MVF_tank = stebbsPrm%HotWaterTankInternalMassViewFactor ! # water tank - building internal mass view factor + self%BVF_tank = stebbsState%HotWaterTankBuildingWallViewFactor ! # water tank - building wall view factor + self%MVF_tank = stebbsState%HotWaterTankInternalMassViewFactor ! # water tank - building internal mass view factor - self%conductivity_wall_tank = stebbsPrm%HotWaterTankWallConductivity ! # Effective Wall conductivity of the Hot Water Tank (based on polyurethan foam given in https://www.lsta.lt/files/events/28_jarfelt.pdf and from https://www.sciencedirect.com/science/article/pii/S0360544214011189?via%3Dihub) - self%conv_coeff_intwall_tank = stebbsPrm%HotWaterTankInternalWallConvectionCoefficient ! # Effective Internal Wall convection coefficient of the Hot Water Tank (W/m2 . K) given in http://orbit.dtu.dk/fedora/objects/orbit:77843/datastreams/file_2640258/content - self%conv_coeff_extwall_tank = stebbsPrm%HotWaterTankExternalWallConvectionCoefficient ! # Effective External Wall convection coefficient of the Hot Water Tank (W/m2 . K) given in http://orbit.dtu.dk/fedora/objects/orbit:77843/datastreams/file_2640258/content + self%conductivity_wall_tank = stebbsState%HotWaterTankWallConductivity ! # Effective Wall conductivity of the Hot Water Tank (based on polyurethan foam given in https://www.lsta.lt/files/events/28_jarfelt.pdf and from https://www.sciencedirect.com/science/article/pii/S0360544214011189?via%3Dihub) + self%conv_coeff_intwall_tank = stebbsState%HotWaterTankInternalWallConvectionCoefficient ! # Effective Internal Wall convection coefficient of the Hot Water Tank (W/m2 . K) given in http://orbit.dtu.dk/fedora/objects/orbit:77843/datastreams/file_2640258/content + self%conv_coeff_extwall_tank = stebbsState%HotWaterTankExternalWallConvectionCoefficient ! # Effective External Wall convection coefficient of the Hot Water Tank (W/m2 . K) given in http://orbit.dtu.dk/fedora/objects/orbit:77843/datastreams/file_2640258/content - self%emissivity_extwall_tank = stebbsPrm%HotWaterTankWallEmissivity - self%conductivity_wall_vessel = stebbsPrm%DHWVesselWallConductivity - self%conv_coeff_intwall_vessel = stebbsPrm%DHWVesselInternalWallConvectionCoefficient - self%conv_coeff_extwall_vessel = stebbsPrm%HotWaterTankExternalWallConvectionCoefficient ! # Effective Enternal Wall convection coefficient of the Vessels holding DHW in use in Building - self%emissivity_extwall_vessel = stebbsPrm%DHWVesselWallConductivity ! # Effective External Wall emissivity of hot water being used within building + self%emissivity_extwall_tank = stebbsState%HotWaterTankWallEmissivity + self%conductivity_wall_vessel = stebbsState%DHWVesselWallConductivity + self%conv_coeff_intwall_vessel = stebbsState%DHWVesselInternalWallConvectionCoefficient + self%conv_coeff_extwall_vessel = stebbsState%HotWaterTankExternalWallConvectionCoefficient ! # Effective Enternal Wall convection coefficient of the Vessels holding DHW in use in Building + self%emissivity_extwall_vessel = stebbsState%DHWVesselWallConductivity ! # Effective External Wall emissivity of hot water being used within building - self%maxheatingpower_water = bldgarchtypePrm%MaximumHotWaterHeatingPower ! # Watts - self%heating_efficiency_water = stebbsPrm%HotWaterHeatingEfficiency - self%minVwater_vessel = stebbsPrm%MinimumVolumeOfDHWinUse ! # m3 + self%maxheatingpower_water = bldgState%MaximumHotWaterHeatingPower ! # Watts + self%heating_efficiency_water = stebbsState%HotWaterHeatingEfficiency + self%minVwater_vessel = stebbsState%MinimumVolumeOfDHWinUse ! # m3 - self%minHeatingPower_DHW = bldgarchtypePrm%MaximumHotWaterHeatingPower - self%HeatingPower_DHW = bldgarchtypePrm%MaximumHotWaterHeatingPower + self%minHeatingPower_DHW = bldgState%MaximumHotWaterHeatingPower + self%HeatingPower_DHW = bldgState%MaximumHotWaterHeatingPower self%HWPowerAverage = (/30000, 30000, 30000/) END SUBROUTINE gen_building - SUBROUTINE create_building(CASE, self, icase) USE modulestebbs, ONLY: LBM IMPLICIT NONE diff --git a/src/suews/src/suews_phys_waterdist.f95 b/src/suews/src/suews_phys_waterdist.f95 index 37b760f8f..aeb83b069 100644 --- a/src/suews/src/suews_phys_waterdist.f95 +++ b/src/suews/src/suews_phys_waterdist.f95 @@ -806,9 +806,9 @@ SUBROUTINE ReDistributeWater( & IF (SnowUse == 0) THEN !No snow calculations! - AddWater(i_receiver) = AddWater(i_receiver) & - + (Drain(i_contributor)*sfr_surf(i_contributor) & - /sfr_surf(i_receiver))*WaterDist(i_receiver, i_contributor) !Original + AddWater(i_receiver) = AddWater(i_receiver) + & + (Drain(i_contributor)*sfr_surf(i_contributor) & + /sfr_surf(i_receiver))*WaterDist(i_receiver, i_contributor) !Original ELSE !Snow included, This needs to be fixed at some point. LJ Mar 2013 @@ -817,9 +817,9 @@ SUBROUTINE ReDistributeWater( & END IF ELSE + !If no receiving surface exists, water fraction goes to AddWaterRunoff AddWaterRunoff(i_contributor) = AddWaterRunoff(i_contributor) & - + WaterDist(i_receiver, i_contributor) !If no receiving surface exists, - !water fraction goes to AddWaterRunoff + + WaterDist(i_receiver, i_contributor) END IF END DO END DO diff --git a/src/supy/__init__.py b/src/supy/__init__.py index 9ecae90a5..6c1dd002c 100644 --- a/src/supy/__init__.py +++ b/src/supy/__init__.py @@ -17,7 +17,6 @@ from ._supy_module import ( init_supy, load_SampleData, - load_sample_data, load_forcing_grid, run_supy, save_supy, diff --git a/src/supy/_check.py b/src/supy/_check.py index fa6bc3638..6be9195db 100644 --- a/src/supy/_check.py +++ b/src/supy/_check.py @@ -84,8 +84,7 @@ def check_method(ser_to_check: pd.Series, rule_var: dict) -> Tuple: description = "" is_accepted_flag = False - # for value in np.nditer(ser_to_check.values): - for value in ser_to_check.values: + for value in np.nditer(ser_to_check.values): if value in list_val: is_accepted_flag = True else: diff --git a/src/supy/_load.py b/src/supy/_load.py index ea97d2aa5..67881f239 100644 --- a/src/supy/_load.py +++ b/src/supy/_load.py @@ -614,14 +614,7 @@ def resample_linear_avg(data_raw_avg, tstep_in, tstep_mod): # resample input met forcing to tstep required by model def resample_forcing_met( - data_met_raw, - tstep_in, - tstep_mod, - lat=51, - lon=0, - alt=100, - timezone=0, - kdownzen=0, + data_met_raw, tstep_in, tstep_mod, lat=51, lon=0, alt=100, timezone=0, kdownzen=0 ): if tstep_in % tstep_mod != 0: raise RuntimeError( @@ -815,43 +808,6 @@ def load_SUEWS_Forcing_met_df_pattern(path_input, file_pattern): return df_forcing_met -def load_SUEWS_Forcing_met_df_yaml(path_forcing): - from pathlib import Path - from .util._io import read_suews - - if isinstance(path_forcing, (str, Path)): - path_forcing = Path(path_forcing).resolve() - df_forcing_met = read_suews(path_forcing) - elif isinstance(path_forcing, list): - path_forcing = [Path(p).resolve() for p in path_forcing] - df_forcing_met = pd.concat([read_suews(fn) for fn in path_forcing]) - else: - import pdb - - pdb.set_trace() - # `drop_duplicates` in case some duplicates mixed - df_forcing_met = df_forcing_met.drop_duplicates() - # drop `isec`: redundant for this dataframe - col_suews_met_forcing = list(dict_var_type_forcing.keys())[:-1] - # rename these columns to match variables via the driver interface - df_forcing_met.columns = col_suews_met_forcing - - # convert unit from kPa to hPa - df_forcing_met["pres"] *= 10 - - # add `isec` for WRF-SUEWS interface - df_forcing_met["isec"] = 0 - - # set correct data types - df_forcing_met[["iy", "id", "it", "imin", "isec"]] = df_forcing_met[ - ["iy", "id", "it", "imin", "isec"] - ].astype(np.int64) - - df_forcing_met = set_index_dt(df_forcing_met) - - return df_forcing_met - - # TODO: add support for loading multi-grid forcing datasets # def load_SUEWS_Forcing_df(dir_site, ser_mod_cfg, df_state_init): # pass @@ -1286,10 +1242,9 @@ def load_SUEWS_SurfaceChar_df(path_input): elif var == "waterdist": dim_x = dict_var_ndim[var] # [-1::-1] val_x0 = val.reshape((len_grid, 9, 6)) - # directly load the values for common land covers + # directly load the values for commen land covers val_x1 = val_x0[:, :7] # process the ToSoilStore and ToRunoff entries - # since only one of ToSoilStore and ToRunoff can be non-zero for each row, we sum them up and combine them val_x2 = val_x0[:, 7:].reshape(len_grid, 6, 2).sum(axis=2).reshape(-1, 1, 6) # combine valuees of common land convers and special cases val_x = np.hstack((val_x1, val_x2)) @@ -1358,7 +1313,7 @@ def trim_df_state(df_state: pd.DataFrame, set_var_use=set_var_use) -> pd.DataFra "kdownzen": 1, "suppresswarnings": 0, "resolutionfilesin": 0, - "stebbsuse": 0, + "stebbsmethod": 0, } @@ -1378,29 +1333,6 @@ def load_SUEWS_dict_ModConfig(path_runcontrol, dict_default=dict_RunControl_defa / "SUEWS_SPARTACUS.nml" ) - - # load STEBBS-specific variables: - if dict_RunControl["stebbsmethod"] == 2: - path_stebbs_typologies = ( - path_runcontrol.parent - / dict_RunControl["fileinputpath"] - / "stebbs_building_typologies.nml" - ) - path_stebbs_general = ( - path_runcontrol.parent - / dict_RunControl["fileinputpath"] - / "stebbs_general_params.nml" - ) - else: - path_stebbs_typologies = ( - trv_supy_module / "sample_run" / "Input" - / "test_stebbs_building_typologies.nml" - ) - path_stebbs_general = ( - trv_supy_module / "sample_run" / "Input" - / "test_stebbs_general_params.nml" - ) - dict_RunControl_x = {k[0]: v for k, v in load_SUEWS_nml(path_spartacus).items()} dict_RunControl.update(dict_RunControl_x) diff --git a/src/supy/_run.py b/src/supy/_run.py index 5bfd896dd..988af716c 100644 --- a/src/supy/_run.py +++ b/src/supy/_run.py @@ -8,6 +8,7 @@ # import logging import traceback +from ast import literal_eval from pathlib import Path from typing import Tuple import pandas @@ -564,55 +565,10 @@ def run_supy_par(df_forcing_tstep, df_state_init_m, save_state, chunk_day, debug # pack one Series of var into np.array -def pack_var(ser_var: pd.Series) -> np.ndarray: - """Convert a pandas Series with tuple-like index strings into a numpy array. - - Parameters - ---------- - ser_var : pandas.Series - Series with index strings like '(0,1)' representing dimensions - - Returns - ------- - numpy.ndarray - Reshaped array based on index dimensions - """ - # Handle scalar values (single element Series) - if len(ser_var) == 1: - return np.array([ser_var.iloc[0]]) - - try: - # Convert index strings to tuples of integers - # e.g. '(1,2)' -> (1,2) - # import pdb; pdb.set_trace() - index_tuples = [ - tuple(map(int, filter(None, idx.strip('()').split(',')))) - for idx in ser_var.index - ] - - # Create new Series with tuple indices for proper sorting - ser_var_indexed = pd.Series( - ser_var.values, - index=index_tuples - ).sort_index() - - # Get dimensions from max indices - # Add 1 since indices are 0-based - dimensions = np.array(ser_var_indexed.index[-1]) + 1 - - # Reshape using Fortran-style ordering to match original - res = np.array(ser_var_indexed.values).reshape(dimensions, order="F") - - try: - return res.astype(float) - except: - return res.astype(str) - - except (ValueError, AttributeError) as e: - # Log error and fall back to scalar handling - print(f"Error reshaping Series: {e}") - return np.array([ser_var.iloc[0]]) - +def pack_var(ser_var): + dim = np.array(literal_eval(ser_var.index[-1])) + 1 + val = np.array(ser_var.values.reshape(dim), order="F") + return val # pack one Series of grid vars into dict of `np.array`s @@ -624,7 +580,7 @@ def pack_grid_dict(ser_grid): dict_var = {} for var in list_var: if var not in ["file_init"]: - dict_var[var] = pack_var(ser_grid[var]) + dict_var[var] = pack_var(ser_grid[var]).astype(float) else: pass # dict_var = { diff --git a/src/supy/_supy_module.py b/src/supy/_supy_module.py index 4ba803301..70cf21077 100644 --- a/src/supy/_supy_module.py +++ b/src/supy/_supy_module.py @@ -33,13 +33,10 @@ load_SUEWS_dict_ModConfig, load_df_state, resample_forcing_met, - load_SUEWS_Forcing_met_df_yaml, ) from ._run import run_supy_par, run_supy_ser from ._save import get_save_info, save_df_output, save_df_state, save_initcond_nml -from .util._config import init_config_from_yaml - # set up logging module logger_supy.setLevel(logging.INFO) @@ -101,31 +98,20 @@ def init_supy( except FileNotFoundError: logger_supy.exception(f"{path_init_x} does not exists!") else: - if path_init_x.suffix == ".yml": - # SUEWS `config_suews.yaml`: - logger_supy.info("Loading config from yaml") - df_state_init = init_config_from_yaml(path=path_init_x).to_df_state() + if path_init_x.suffix == ".nml": + # SUEWS `RunControl.nml`: + df_state_init = load_InitialCond_grid_df( + path_init_x, + force_reload=force_reload, + ) + elif path_init_x.suffix == ".csv": + # SuPy `df_state.csv`: + df_state_init = load_df_state(path_init_x) else: - logger_supy.warning( - "Input is not a yaml file, loading from other sources. These methods will be deprecated in later versions.", - stacklevel=2, + logger_supy.critical( + f"{path_init_x} is NOT a valid file to initialise SuPy!" ) - if path_init_x.suffix == ".nml": - # SUEWS `RunControl.nml`: - df_state_init = load_InitialCond_grid_df( - path_init_x, - force_reload=force_reload, - ) - elif path_init_x.suffix == ".csv": - # SuPy `df_state.csv`: - df_state_init = load_df_state(path_init_x) - else: - logger_supy.critical( - f"{path_init_x} is NOT a valid file to initialise SuPy!" - ) - raise RuntimeError( - "{path_init_x} is NOT a valid file to initialise SuPy!" - ) + raise RuntimeError("{path_init_x} is NOT a valid file to initialise SuPy!") if check_input: try: list_issues = check_state(df_state_init) @@ -149,11 +135,10 @@ def init_supy( # TODO: # to be superseded by a more generic wrapper: load_forcing def load_forcing_grid( - path_init: str, + path_runcontrol: str, grid: int, check_input=False, force_reload=True, - df_state_init: pd.DataFrame = None, ) -> pd.DataFrame: """Load forcing data for a specific grid included in the index of `df_state_init `. @@ -187,95 +172,51 @@ def load_forcing_grid( """ try: - path_init = Path(path_init).expanduser().resolve() + path_runcontrol = Path(path_runcontrol).expanduser().resolve() except FileNotFoundError: - logger_supy.exception(f"{path_init} does not exists!") + logger_supy.exception(f"{path_runcontrol} does not exists!") else: - if path_init.suffix == ".nml": - # load settings from RunControl.nml - dict_mod_cfg = load_SUEWS_dict_ModConfig(path_init) - # load setting variables from dict_mod_cfg - ( - filecode, - kdownzen, - tstep_met_in, - tstep_ESTM_in, - multiplemetfiles, - multipleestmfiles, - dir_input_cfg, - ) = ( - dict_mod_cfg[x] - for x in [ - "filecode", - "kdownzen", - "resolutionfilesin", - "resolutionfilesinestm", - "multiplemetfiles", - "multipleestmfiles", - "fileinputpath", - ] - ) - - path_site = path_init.parent - path_input = path_site / dict_mod_cfg["fileinputpath"] - else: - config = init_config_from_yaml(path=path_init) - path_site = path_init.parent - path_input = path_site / config.model.control.forcing_file.value - + dict_mod_cfg = load_SUEWS_dict_ModConfig(path_runcontrol) + df_state_init = init_supy(path_runcontrol, force_reload) + + # load setting variables from dict_mod_cfg + ( + filecode, + kdownzen, + tstep_met_in, + tstep_ESTM_in, + multiplemetfiles, + multipleestmfiles, + dir_input_cfg, + ) = ( + dict_mod_cfg[x] + for x in [ + "filecode", + "kdownzen", + "resolutionfilesin", + "resolutionfilesinestm", + "multiplemetfiles", + "multipleestmfiles", + "fileinputpath", + ] + ) tstep_mod, lat, lon, alt, timezone = df_state_init.loc[ - grid, - [ - (x, "0") - for x in [ - "tstep", - "lat", - "lng", - "alt", - "timezone", - ] - ], + grid, [(x, "0") for x in ["tstep", "lat", "lng", "alt", "timezone"]] ].values + path_site = path_runcontrol.parent + path_input = path_site / dict_mod_cfg["fileinputpath"] + # load raw data # met forcing - if path_init.suffix == ".nml": - df_forcing_met = load_SUEWS_Forcing_met_df_raw( - path_input, filecode, grid, tstep_met_in, multiplemetfiles - ) - # resample raw data from tstep_in to tstep_mod - df_forcing_met_tstep = resample_forcing_met( - df_forcing_met, - tstep_met_in, - tstep_mod, - lat, - lon, - alt, - timezone, - kdownzen, - ) - elif path_init.suffix == ".yml": - df_forcing_met = load_SUEWS_Forcing_met_df_yaml(path_input) - tstep_met_in = df_forcing_met.index[1] - df_forcing_met.index[0] - tstep_met_in = int(tstep_met_in.total_seconds()) - kdownzen = init_config_from_yaml( - path=path_init - ).model.control.kdownzen.value - if kdownzen is None: - df_forcing_met_tstep = resample_forcing_met( - df_forcing_met, tstep_met_in, tstep_mod, lat, lon, alt, timezone - ) - else: - df_forcing_met_tstep = resample_forcing_met( - df_forcing_met, - tstep_met_in, - tstep_mod, - lat, - lon, - alt, - timezone, - kdownzen, - ) + df_forcing_met = load_SUEWS_Forcing_met_df_raw( + path_input, filecode, grid, tstep_met_in, multiplemetfiles + ) + + # resample raw data from tstep_in to tstep_mod + df_forcing_met_tstep = resample_forcing_met( + df_forcing_met, tstep_met_in, tstep_mod, lat, lon, alt, timezone, kdownzen + ) # coerced precision here to prevent numerical errors inside Fortran df_forcing = df_forcing_met_tstep.round(10) @@ -301,14 +242,6 @@ def load_forcing_grid( # load sample data for quickly starting a demo run # TODO: to deprecate this by renaming for case consistency: load_SampleData-->load_sample_data def load_SampleData() -> Tuple[pandas.DataFrame, pandas.DataFrame]: - logger_supy.warning( - "This function name will be deprecated. Please use `load_sample_data()` instead.", - stacklevel=2, - ) - return load_sample_data() - - -def load_sample_data() -> Tuple[pandas.DataFrame, pandas.DataFrame]: """Load sample data for quickly starting a demo run. Returns @@ -320,16 +253,15 @@ def load_sample_data() -> Tuple[pandas.DataFrame, pandas.DataFrame]: Examples -------- - >>> df_state_init, df_forcing = supy.load_sample_data() + >>> df_state_init, df_forcing = supy.load_SampleData() """ + from ._env import trv_supy_module - trv_sample_data = trv_supy_module / "sample_run" - path_config_default = trv_sample_data / "defaultConfig.yml" - df_state_init = init_supy(path_config_default, force_reload=False) - df_forcing = load_forcing_grid( - path_config_default, df_state_init.index[0], df_state_init=df_state_init - ) + trv_SampleData = trv_supy_module / "sample_run" + path_runcontrol = trv_SampleData / "RunControl.nml" + df_state_init = init_supy(path_runcontrol, force_reload=False) + df_forcing = load_forcing_grid(path_runcontrol, df_state_init.index[0]) return df_state_init, df_forcing @@ -444,14 +376,10 @@ def run_supy( if n_grid > 1 and os.name != "nt" and (not serial_mode): logger_supy.info(f"SuPy is running in parallel mode") - res_supy = run_supy_par( - df_forcing, df_state_init, save_state, chunk_day, debug_mode - ) + res_supy = run_supy_par(df_forcing, df_state_init, save_state, chunk_day, debug_mode) else: logger_supy.info(f"SuPy is running in serial mode") - res_supy = run_supy_ser( - df_forcing, df_state_init, save_state, chunk_day, debug_mode - ) + res_supy = run_supy_ser(df_forcing, df_state_init, save_state, chunk_day, debug_mode) # try: # res_supy = run_supy_ser(df_forcing, df_state_init, save_state, chunk_day) # except: @@ -472,6 +400,7 @@ def run_supy( return df_output, df_state_final + ############################################################################## # 3. save results of a supy run def save_supy( diff --git a/src/supy/meson.build b/src/supy/meson.build index e2fcaa9ad..4aa297aff 100644 --- a/src/supy/meson.build +++ b/src/supy/meson.build @@ -25,7 +25,6 @@ py.install_sources( 'util/_UMEP2epw.py', 'util/__init__.py', 'util/_atm.py', - 'util/_config.py', 'util/_converter.py', 'util/_debug.py', 'util/_era5.py', @@ -41,7 +40,6 @@ py.install_sources( 'util/rules.csv', ], [ - 'sample_run/sample_config.yml', 'sample_run/RunControl.nml', 'sample_run/Input/ESTMinput.nml', 'sample_run/Input/GridLayoutKc.nml', diff --git a/src/supy/sample_run/RunControl.nml b/src/supy/sample_run/RunControl.nml index d4be2b999..fbcb36fc9 100644 --- a/src/supy/sample_run/RunControl.nml +++ b/src/supy/sample_run/RunControl.nml @@ -34,5 +34,5 @@ SuppressWarnings = 1 KdownZen = 0 diagnose = 0 diagMethod = 2 -stebbsuse = 0 +stebbsmethod = 0 / diff --git a/test/test_supy.py b/test/test_supy.py index 006ca2d1a..faebd6349 100644 --- a/test/test_supy.py +++ b/test/test_supy.py @@ -23,29 +23,17 @@ p_df_sample = Path(test_data_dir) / "sample_output.pkl" # if platform is macOS and python version is 3.12, set flag_full_test to True -flag_full_test = any( +flag_full_test = all( [ - all( - [ - sys.version_info[0] == 3, - sys.version_info[1] == 12, - platform.system() == "Darwin", - platform.machine() == "arm64", - ] - ), - all( - [ - sys.version_info[0] == 3, - sys.version_info[1] == 13, - platform.system() == "Linux", - platform.machine() == "x86_64", - ] - ), + sys.version_info[0] == 3, + sys.version_info[1] == 12, + platform.system() == "Darwin", + platform.machine() == "arm64", ] ) # Load sample data once, as it will be used frequently later to save time. -df_state_init, df_forcing_tstep = sp.load_sample_data() +df_state_init, df_forcing_tstep = sp.load_SampleData() class TestSuPy(TestCase):