Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Weather module #1650

Merged
merged 59 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
fe46765
add epw class
eringold Dec 21, 2023
59a46de
add StatFile class
eringold Dec 21, 2023
2706dfb
extend and refactor StatFile
eringold Dec 21, 2023
752540f
harmonize Epw.to_json
eringold Dec 21, 2023
feb7f5a
Harmonize StatFile.load
eringold Dec 21, 2023
1f7cd1c
add get epw path and representative cz weather file to information
eringold Dec 21, 2023
a6a1a2f
refactor and replicate changebuildinglocation in Weather.modify
eringold Dec 21, 2023
c8e4431
initial replace model_get_weather_file
eringold Dec 21, 2023
d37ec2f
test stat
eringold Dec 22, 2023
f9501fd
misc weather module corrections
eringold Dec 26, 2023
1953c67
test weather information
eringold Dec 26, 2023
25cd12a
test weather modify
eringold Dec 26, 2023
a107442
clean up test
eringold Dec 26, 2023
b6df36c
Merge remote-tracking branch 'origin/master' into refactor/weather_mo…
eringold Jan 2, 2024
3d4b7af
yard and rubocop fixes
eringold Jan 2, 2024
1763454
correct weather file path call
eringold Jan 4, 2024
6592121
Merge branch 'master' of https://github.com/NREL/openstudio-standards…
eringold Jan 16, 2024
33f9102
Merge branch 'master' of https://github.com/NREL/openstudio-standards…
eringold Jan 17, 2024
fa62912
Merge branch 'master' into refactor/weather_module
eringold Jan 17, 2024
338f4c7
Merge branch 'refactor/weather_module' of https://github.com/NREL/ope…
eringold Jan 17, 2024
8006491
delete Weather.stat_file.rb
mdahlhausen Jan 18, 2024
e0572db
remove redundant methods from Weather.Model.rb
mdahlhausen Jan 18, 2024
f067729
weather method replacements
mdahlhausen Jan 18, 2024
6a54fd6
Merge branch 'master' into refactor/weather_module
mdahlhausen Jan 18, 2024
dfb06d5
replace EnergyPlus::StateFile.new
mdahlhausen Jan 18, 2024
6d956f9
add set undisturbed ground temperature methods
mdahlhausen Jan 19, 2024
d7bab9b
rubocop edits
mdahlhausen Jan 19, 2024
d68fe17
extend weather module methods
mdahlhausen Jan 19, 2024
cf84aa8
delete California weather files
mdahlhausen Jan 19, 2024
888e469
weather module yard doc edits
mdahlhausen Jan 19, 2024
241d8e6
Change stat_file logs to warn instead of error
mdahlhausen Jan 21, 2024
50967e7
replace model_add_ground_temperatures
mdahlhausen Jan 22, 2024
0fa3814
Merge branch 'refactor/weather_module' of https://github.com/NREL/ope…
eringold Jan 22, 2024
74ca35f
weather modify changes, design day defaults
mdahlhausen Jan 22, 2024
1b5311a
split and add weather tests
mdahlhausen Jan 22, 2024
7db5211
replace model_add_design_days_and_weather_file
mdahlhausen Jan 22, 2024
0405af9
remove remaining instances of model_add_design_days_and_weather_file
mdahlhausen Jan 22, 2024
7493411
refactor weather method calls in necb tests
mdahlhausen Jan 22, 2024
6f967ff
update regression tests
mdahlhausen Jan 23, 2024
6422c1e
remove Weather.Model.rb
mdahlhausen Jan 23, 2024
b0f8523
update nil ddy_list test result
eringold Jan 23, 2024
12935ac
calculate design day average global irradiance
mdahlhausen Jan 23, 2024
a433fcd
improve ddy regex lookup
eringold Jan 23, 2024
2d29716
update all heating+cooling ddy test
eringold Jan 23, 2024
dbb4d36
remove Weather.Model.rb
mdahlhausen Jan 24, 2024
3905cf9
fix to hdd lookup
mdahlhausen Jan 24, 2024
11b745b
add annual cooling wetbulb design day to necb regression models
mdahlhausen Jan 24, 2024
e994cc3
Merge branch 'refactor/weather_module' of https://github.com/NREL/ope…
eringold Jan 24, 2024
374d26e
ddy docstrings
eringold Jan 24, 2024
7cfcbf6
fix undefined error
mdahlhausen Jan 24, 2024
3b89ed2
update performance results
mdahlhausen Jan 25, 2024
1f612c4
Fixing typo when using weather_file_path in btap_data.rb.
ckirney Jan 26, 2024
96b1ebb
fix additional typos
mdahlhausen Jan 26, 2024
47012b8
update module weather tests
mdahlhausen Jan 27, 2024
70a51d8
update NECB building regression tests
mdahlhausen Jan 27, 2024
22e971a
update DOE regression models
mdahlhausen Jan 27, 2024
7989168
Merge branch 'master' into refactor/weather_module
mdahlhausen Feb 5, 2024
c818dc1
update warehouse regression models
mdahlhausen Feb 5, 2024
57a4290
fix param name missing for yard doc
mdahlhausen Feb 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .yardopts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
--exclude lib/openstudio-standards/prototypes/common/buildings/Prototype.*.rb
--exclude lib/openstudio-standards/utilities/convert_costing_constructions.rb
--exclude lib/openstudio-standards/prototypes/common/do_not_edit_metaclasses.rb
--exclude lib/openstudio-standards/weather/Weather.Model.rb
--exclude lib/openstudio-standards/utilities/sched_create.rb
--exclude lib/openstudio-standards/utilities/os_sim_extract.rb
--exclude lib/openstudio-standards/utilities/hash.rb
Expand Down
3 changes: 0 additions & 3 deletions lib/openstudio-standards.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@ module OpenstudioStandards
require_relative 'openstudio-standards/weather/modify'
require_relative 'openstudio-standards/weather/stat_file'

# Weather data
require_relative 'openstudio-standards/weather/Weather.Model'

# HVAC standards
require_relative 'openstudio-standards/standards/Standards.Model'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2072,7 +2072,7 @@ def phius_performance_indicators(model)

### Dehumidification degree days
### ('Dehumidification degree-days, base 0.010' in REF: Wright (2019))
dehumidification_degree_days = BTAP::Environment::WeatherFile.new(weather_file_path).calculate_humidity_ratio
dehumidification_degree_days = OpenstudioStandards::Weather.epw_file_get_dehumidification_degree_days(epw_file)

### annual global horizontal irradiance (GHI)
ghi_timeseries = epw_file.getTimeSeries('Global Horizontal Radiation').get
Expand Down
280 changes: 0 additions & 280 deletions lib/openstudio-standards/weather/Weather.Model.rb

This file was deleted.

54 changes: 54 additions & 0 deletions lib/openstudio-standards/weather/information.rb
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,60 @@ def self.design_day_average_global_irradiance(design_day)
return average_daily_global_irradiance
end

# Calculate dehumidification degree days from an epw_file
#
# @param epw_file [OpenStudio::EpwFile] OpenStudio EpwFile object
# @param base_humidity_ratio [Double] base humidity ratio, default is 0.010
# @return [Double] dehumdification degree days
def self.epw_file_get_dehumidification_degree_days(epw_file, base_humidity_ratio: 0.010)
db_temps_c = epw_file.getTimeSeries('Dry Bulb Temperature').get.values
db_temps_k = db_temps_c.map { |v| v + 273.15 }
rh_values = epw_file.getTimeSeries('Relative Humidity').get.values
atm_p_values = epw_file.getTimeSeries('Atmospheric Station Pressure').get.values

# coefficients for the calculation of pws (Reference: ASHRAE Handbook - Fundamentals > CHAPTER 1. PSYCHROMETRICS)
c1 = -5.6745359E+03
c2 = 6.3925247E+00
c3 = -9.6778430E-03
c4 = 6.2215701E-07
c5 = 2.0747825E-09
c6 = -9.4840240E-13
c7 = 4.1635019E+00
c8 = -5.8002206E+03
c9 = 1.3914993E+00
c10 = -4.8640239E-02
c11 = 4.1764768E-05
c12 = -1.4452093E-08
c13 = 6.5459673E+00

# calculate saturation pressure of water vapor (Pa)
sp_values = []
db_temps_k.each do |t|
if t <= 273.15
sp = (c1 / t) + c2 + c3 * t + c4 * t**2 + c5 * t**3 + c6 * t**4 + c7 * Math.log(t, Math.exp(1))

else
sp = (c8 / t) + c9 + c10 * t + c11 * t**2 + c12 * t**3 + c13 * Math.log(t, Math.exp(1))
end
sp_values << Math.exp(1)**sp
end

# calculate partial pressure of water vapor (Pa)
pp_values = sp_values.zip(rh_values).map{ |sp, rh| sp * rh / 100.0 }

# calculate total pressure (Pa)
tp_values = pp_values.zip(atm_p_values).map{ |pp, atm| pp + atm }

# calculate humidity ratio
hr_values = pp_values.zip(tp_values).map{ |pp, tp| (0.621945 * pp) / (tp - pp)}

# calculate dehumidification degree days based on humidity ratio values above the base
hr_values_above_base = hr_values.map{ |hr| hr > base_humidity_ratio ? hr : 0.0}
dehumidification_degree_days = hr_values_above_base.sum / 24.0
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to find any sources for it; the only thing I found is that Graham Wright says in his paper that “DDD was calculated by thresholding the monthly humidity data at a humidity ratio of 0.010”. To me it sounded like they considered monthly average, so I used it as daily humidity ratio…
I tested for Montreal, the two methods give 0.76 using your method and 0.15 using my method… I’m not sure which one would make more sense for what PHIUS is asking for… we can use the same method as heating/cooling degree days as you suggested

Copy link
Collaborator

@mdahlhausen mdahlhausen Jan 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If Graham is using monthly humidity averages, then both of our methods are wrong. It also wouldn't be "degree-days" in the normal meaning of the term. In the standard calculation of heating degree days for example, it's often the case that the sum of monthly heating degree days at 18C are non-zero when the monthly average temperature is above 18C.
I think the best way to resolve this is to write up and implement a proposal to PHIUS to implement a better and clearer regression. But I don't have time for that. Until then I suggest we settle with the methods we have that at least are clear and somewhat defensible.


return dehumidification_degree_days
end

# @!endgroup Information
end
end
2 changes: 1 addition & 1 deletion test/90_1_prm/create_performance_rating_method_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def create_baseline_model(model_name, standard, climate_zone, building_type, cus

model = load_test_model(model_name)

# @todo see Weather.Model.rb for weather file locations for each climate zone
# @todo see weather module for weather file locations for each climate zone
base_rel_path = '../../../data/weather/'
if model.weatherFile.empty?
epw_name = nil
Expand Down
12 changes: 12 additions & 0 deletions test/modules/weather/test_weather_information.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,16 @@ def test_design_day_average_global_irradiance
result_ip = OpenStudio.convert(result, 'W/m^2', 'Btu/ft^2*h').get
assert_in_delta(result_ip, 126.1, 0.1)
end

def test_epw_file_get_dehumidification_degree_days
weather_file_path = @weather.get_standards_weather_file_path('USA_GA_Atlanta-Hartsfield.Jackson.Intl.AP.722190_TMY3.epw')
epw_file = OpenStudio::EpwFile.new(weather_file_path)
result = @weather.epw_file_get_dehumidification_degree_days(epw_file)
assert_in_delta(result, 2.1, 0.1)

weather_file_path = @weather.get_standards_weather_file_path('USA_AZ_Tucson-Davis-Monthan.AFB.722745_TMY3.epw')
epw_file = OpenStudio::EpwFile.new(weather_file_path)
result = @weather.epw_file_get_dehumidification_degree_days(epw_file)
assert_in_delta(result, 0.56, 0.1)
end
end