From a092b762e59fc1a73b48610844cf23dce0c495fd Mon Sep 17 00:00:00 2001 From: matthew Date: Fri, 17 Jan 2025 12:23:55 +0000 Subject: [PATCH 1/7] Update to default to sample stebbs files if stebbs turned off (patch for users unaware of stebbs) --- src/supy/_load.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/supy/_load.py b/src/supy/_load.py index 34c1f579..2d7b94fb 100644 --- a/src/supy/_load.py +++ b/src/supy/_load.py @@ -1333,7 +1333,19 @@ def load_SUEWS_dict_ModConfig(path_runcontrol, dict_default=dict_RunControl_defa / "SUEWS_SPARTACUS.nml" ) + dict_RunControl_x = {k[0]: v for k, v in load_SUEWS_nml(path_spartacus).items()} + dict_RunControl.update(dict_RunControl_x) + # load STEBBS-specific variables: + if dict_RunControl["stebbsmethod"] == 1: + import pdb; pdb.set_trace() + else: + from ._env import trv_supy_module + + trv_SampleData = trv_supy_module / "sample_run" + path_stebbs_general = trv_SampleData / "Input/test_stebbs_general_params.nml" + path_stebbs_typologies = trv_SampleData / "Input/test_stebbs_building_typologies.nml" + path_stebbs_typologies = ( path_runcontrol.parent / dict_RunControl["fileinputpath"] @@ -1345,9 +1357,6 @@ def load_SUEWS_dict_ModConfig(path_runcontrol, dict_default=dict_RunControl_defa / "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) - dict_RunControl_y = {k[0]: v for k, v in load_SUEWS_nml(path_stebbs_typologies).items()} dict_RunControl.update(dict_RunControl_y) From b18a1c408ee9128addbac812531fac76fe8dea0e Mon Sep 17 00:00:00 2001 From: matthew Date: Fri, 17 Jan 2025 12:31:06 +0000 Subject: [PATCH 2/7] remove unnecessary imports and moved misplaced code --- src/supy/_load.py | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/src/supy/_load.py b/src/supy/_load.py index 2d7b94fb..67881f23 100644 --- a/src/supy/_load.py +++ b/src/supy/_load.py @@ -1338,25 +1338,21 @@ def load_SUEWS_dict_ModConfig(path_runcontrol, dict_default=dict_RunControl_defa # load STEBBS-specific variables: if dict_RunControl["stebbsmethod"] == 1: - import pdb; pdb.set_trace() + path_stebbs_typologies = ( + path_runcontrol.parent + / dict_RunControl["fileinputpath"] + / "test_stebbs_building_typologies.nml" + ) + path_stebbs_general = ( + path_runcontrol.parent + / dict_RunControl["fileinputpath"] + / "test_stebbs_general_params.nml" + ) else: - from ._env import trv_supy_module - trv_SampleData = trv_supy_module / "sample_run" path_stebbs_general = trv_SampleData / "Input/test_stebbs_general_params.nml" path_stebbs_typologies = trv_SampleData / "Input/test_stebbs_building_typologies.nml" - path_stebbs_typologies = ( - path_runcontrol.parent - / dict_RunControl["fileinputpath"] - / "test_stebbs_building_typologies.nml" - ) - path_stebbs_general = ( - path_runcontrol.parent - / dict_RunControl["fileinputpath"] - / "test_stebbs_general_params.nml" - ) - dict_RunControl_y = {k[0]: v for k, v in load_SUEWS_nml(path_stebbs_typologies).items()} dict_RunControl.update(dict_RunControl_y) From 5c7e221eee7ec90a303e30c5664c1d3f3939c450 Mon Sep 17 00:00:00 2001 From: Ting Sun Date: Thu, 23 Jan 2025 17:04:05 +0000 Subject: [PATCH 3/7] Refactor water distribution calculations in suews_phys_waterdist.f95 for improved readability. Split long lines into multiple lines for clarity and maintainability, ensuring the logic remains intact for both snow and non-snow scenarios. --- src/suews/src/suews_phys_waterdist.f95 | 28 +++++++++++++++----------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/suews/src/suews_phys_waterdist.f95 b/src/suews/src/suews_phys_waterdist.f95 index 115834cd..aeb83b06 100644 --- a/src/suews/src/suews_phys_waterdist.f95 +++ b/src/suews/src/suews_phys_waterdist.f95 @@ -789,33 +789,37 @@ SUBROUTINE ReDistributeWater( & REAL(KIND(1D0)), INTENT(out) :: AddWaterRunoff(nsurf) !Fraction of water going to runoff/sub-surface soil (WGWaterDist) [-] REAL(KIND(1D0)), INTENT(out) :: AddWater(nsurf) !Water from other surfaces (WGWaterDist in SUEWS_ReDistributeWater.f95) [mm] - INTEGER :: ii, jj + INTEGER :: i_receiver, i_contributor, i_surface INTEGER :: NSurfDoNotReceiveDrainage = 0 !Number of surfaces that do not receive drainage water (green roof) !Fractions that go to runoff from each surface - DO ii = 1, nsurf - 1 !not water in the calculation - AddWaterRunoff(ii) = WaterDist(8, ii) + DO i_surface = 1, nsurf - 1 !not water in the calculation + AddWaterRunoff(i_surface) = WaterDist(8, i_surface) END DO AddWaterRunoff(WaterSurf) = 0 AddWater = 0 - DO ii = 1, nsurf - NSurfDoNotReceiveDrainage !go through surfaces from 1 to 7. These gain water through drainage - DO jj = 1, nsurf - (NSurfDoNotReceiveDrainage + 1) !From where surface ii can gain water - can't gain water from itself + DO i_receiver = 1, nsurf - NSurfDoNotReceiveDrainage !go through surfaces from 1 to 7. These gain water through drainage + DO i_contributor = 1, nsurf - (NSurfDoNotReceiveDrainage + 1) !From where surface ii can gain water - can't gain water from itself - IF (sfr_surf(ii) /= 0) THEN !Water movement takes place only if surface fraction exists + IF (sfr_surf(i_receiver) /= 0) THEN !Water movement takes place only if surface fraction exists - !No snow calculations! IF (SnowUse == 0) THEN - AddWater(ii) = AddWater(ii) + (Drain(jj)*sfr_surf(jj)/sfr_surf(ii))*WaterDist(ii, jj) !Original + !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 - !Snow included, This needs to be fixed at some point. LJ Mar 2013 ELSE - AddWaterRunoff(jj) = AddWaterRunoff(jj) + WaterDist(ii, jj) !No receiving surface -> runoff + !Snow included, This needs to be fixed at some point. LJ Mar 2013 + AddWaterRunoff(i_contributor) = AddWaterRunoff(i_contributor) & + + WaterDist(i_receiver, i_contributor) !No receiving surface -> runoff END IF ELSE - AddWaterRunoff(jj) = AddWaterRunoff(jj) + WaterDist(ii, jj) !If no receiving surface exists, - !water fraction goes to AddWaterRunoff + !If no receiving surface exists, water fraction goes to AddWaterRunoff + AddWaterRunoff(i_contributor) = AddWaterRunoff(i_contributor) & + + WaterDist(i_receiver, i_contributor) END IF END DO END DO From 332e4a81e24a5ff3e3501da281b0018bc08bbaf2 Mon Sep 17 00:00:00 2001 From: matthew Date: Tue, 28 Jan 2025 12:13:09 +0000 Subject: [PATCH 4/7] Updated expectation for stebbs namelist files --- src/supy/_load.py | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/src/supy/_load.py b/src/supy/_load.py index 66d48533..f4641283 100644 --- a/src/supy/_load.py +++ b/src/supy/_load.py @@ -1371,16 +1371,26 @@ def load_SUEWS_dict_ModConfig(path_runcontrol, dict_default=dict_RunControl_defa ) # load STEBBS-specific variables: - path_stebbs_typologies = ( - path_runcontrol.parent - / dict_RunControl["fileinputpath"] - / "test_stebbs_building_typologies.nml" - ) - path_stebbs_general = ( - path_runcontrol.parent - / dict_RunControl["fileinputpath"] - / "test_stebbs_general_params.nml" - ) + if dict_RunControl["stebbsmethod"] == 1: + 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) From fb49e6a38b804bb23c519e37d66be5df772a7881 Mon Sep 17 00:00:00 2001 From: matthew Date: Tue, 28 Jan 2025 12:13:48 +0000 Subject: [PATCH 5/7] Updated expectation for stebbs namelist files --- src/supy/_load.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/supy/_load.py b/src/supy/_load.py index f4641283..96ebaf53 100644 --- a/src/supy/_load.py +++ b/src/supy/_load.py @@ -1371,7 +1371,7 @@ def load_SUEWS_dict_ModConfig(path_runcontrol, dict_default=dict_RunControl_defa ) # load STEBBS-specific variables: - if dict_RunControl["stebbsmethod"] == 1: + if dict_RunControl["stebbsmethod"] == 2: path_stebbs_typologies = ( path_runcontrol.parent / dict_RunControl["fileinputpath"] From b1b362262d2d244ea9a47dc8fb4eebc76489ce9b Mon Sep 17 00:00:00 2001 From: matthew Date: Tue, 28 Jan 2025 13:22:26 +0000 Subject: [PATCH 6/7] Added full tests for linux_x86_64 python 3.13 --- test/test_supy.py | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/test/test_supy.py b/test/test_supy.py index faebd634..6081ff2c 100644 --- a/test/test_supy.py +++ b/test/test_supy.py @@ -23,12 +23,24 @@ 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 = all( +flag_full_test = any( [ - 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] == 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", + ] + ), ] ) From 63f2dcfd8eec07f52637b20ed05775a8f1f96cd6 Mon Sep 17 00:00:00 2001 From: sunt05 Date: Tue, 28 Jan 2025 23:57:47 +0000 Subject: [PATCH 7/7] [GH Actions] fprettify source code --- src/suews/src/suews_phys_stebbs.f95 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/suews/src/suews_phys_stebbs.f95 b/src/suews/src/suews_phys_stebbs.f95 index 39ee87c8..d5f9fc09 100644 --- a/src/suews/src/suews_phys_stebbs.f95 +++ b/src/suews/src/suews_phys_stebbs.f95 @@ -1647,7 +1647,7 @@ 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)