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

Generate EV schedules #1757

Open
wants to merge 57 commits into
base: ev_batteries
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
19740a7
Generate EV schedules
rajeee Jun 20, 2024
be21d3c
Merge branch 'ev_batteries' into ev_schedules
rajeee Jun 20, 2024
d5db465
Fix test and read from HPXML
rajeee Jun 24, 2024
d377d3c
Merge branch 'ev_batteries' into ev_schedules
rajeee Jun 27, 2024
ce9ff76
Merge branch 'ev_batteries' into ev_schedules
rajeee Jul 1, 2024
d44e1bc
Handle schedule conflict
rajeee Jul 1, 2024
d08ba63
Merge branch 'ev_batteries' into ev_schedules
rajeee Jul 1, 2024
fd0dd49
Binary occupancy
rajeee Jul 18, 2024
25d24d5
Merge branch 'ev_batteries' into ev_schedules
rajeee Jul 31, 2024
d78b0ae
Merge remote-tracking branch 'origin/ev_batteries' into ev_schedules
aspeake Sep 16, 2024
5230cc0
fix bug from merge conflict
aspeake Sep 16, 2024
3c867be
Remove epw arguments
rajeee Sep 19, 2024
b102371
Handle hours per week
rajeee Sep 21, 2024
d15baa1
Output EV occupant occupancy
rajeee Sep 21, 2024
86144f9
Merge branch 'ev_batteries' into ev_schedules
rajeee Oct 2, 2024
b077dcc
Bug fixes and enhancement
rajeee Oct 23, 2024
9e03d1d
Merge branch 'ev_batteries' into ev_schedules
rajeee Oct 23, 2024
8131ce2
Remove byebug line
rajeee Oct 24, 2024
997fbee
Merge branch 'ev_batteries' into ev_schedules
rajeee Oct 24, 2024
bb2036f
Merge branch 'ev_batteries' into ev_schedules
rajeee Oct 30, 2024
bffc05b
Schedule aggregation bug fix
rajeee Nov 12, 2024
3026165
Merge branch 'ev_batteries' into ev_schedules
rajeee Nov 12, 2024
2204599
Use floating division to prevent rounding to zero
rajeee Nov 20, 2024
41ec1db
No EV bug fix and formatting
rajeee Nov 21, 2024
8c21825
Merge remote-tracking branch 'origin/ev_batteries' into ev_schedules
aspeake Nov 21, 2024
57e820f
Update measures, fix CI error.
shorowit Dec 10, 2024
bcd352f
Merge branch 'ev_batteries' of https://github.com/NREL/OpenStudio-HPX…
shorowit Dec 11, 2024
313b6d6
Add unavailable periods entry for new columns
rajeee Dec 11, 2024
1150640
Fill in function signatures
rajeee Dec 17, 2024
30da3d8
Allow override when duplicate column names exist.
rajeee Dec 17, 2024
40ad8e8
Merge branch 'ev_batteries' into ev_schedules
rajeee Jan 2, 2025
127e47c
Update warning message
rajeee Jan 2, 2025
30ff4a7
Refactor schedule generator
rajeee Jan 7, 2025
bea57ba
Rename and reorder
rajeee Jan 7, 2025
2f1f76d
Rename and reorder
rajeee Jan 7, 2025
7b19274
Final cleanup and verified restoration of functionality
rajeee Jan 8, 2025
d4bcffa
Merge branch 'ev_batteries' into ev_schedules
rajeee Jan 8, 2025
7b37014
update measures
shorowit Jan 8, 2025
6e963ae
Fix schedule test
rajeee Jan 8, 2025
b81f29d
Rever allowing duplicate columns
rajeee Jan 8, 2025
45d1405
Merge branch 'master' of https://github.com/NREL/OpenStudio-HPXML int…
shorowit Jan 8, 2025
f18ec53
Debug CI failure
shorowit Jan 8, 2025
06b6e44
Oops.
shorowit Jan 8, 2025
addc070
Updated the wrong one
shorowit Jan 8, 2025
ec7b790
sigh
shorowit Jan 8, 2025
112553b
Add checks for schedule CSVs
shorowit Jan 8, 2025
48a5fd4
Final cleanup/revert.
shorowit Jan 8, 2025
c592ec7
--stat overrides --exit-code, so need to use two separate calls
shorowit Jan 8, 2025
5769f96
Fix git diff command
shorowit Jan 8, 2025
c6bd467
Only generate EV related schedule columns if EV is present
rajeee Jan 8, 2025
1970d68
Merge branch 'ev_batteries' of https://github.com/NREL/OpenStudio-HPX…
shorowit Jan 10, 2025
885c8ba
Merge branch 'ev_batteries' into ev_schedules
rajeee Jan 24, 2025
b6f4d12
Merge branch 'ev_batteries' into ev_schedules
rajeee Jan 24, 2025
916d87d
Merge branch 'ev_batteries' into ev_schedules
rajeee Jan 28, 2025
80e4d97
Merge branch 'ev_batteries' into ev_schedules
rajeee Jan 28, 2025
dd26849
Update xml file name
rajeee Jan 29, 2025
49adc61
Typo fix and column name fix
rajeee Jan 29, 2025
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
9 changes: 7 additions & 2 deletions .github/workflows/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,19 @@ jobs:
git config --global --add safe.directory $(realpath .)
git diff --exit-code --ignore-cr-at-eol *.rb

- name: Check HPXMLs
- name: Check HPXMLs/Schedules
shell: bash
run: |
echo "Regenerating HPXML files..."
openstudio tasks.rb update_hpxmls
echo "Checking for HPXML differences..."
git config --global --add safe.directory $(realpath .)
echo "Checking for HPXML differences..."
echo "If differences are found below, then HPXMLs need to be regenerated using: openstudio tasks.rb update_hpxmls"
git diff --exit-code --ignore-cr-at-eol workflow/*.xml
echo "Checking for schedule CSV differences..."
echo "If differences are found below, then schedule CSVs need to be regenerated using: openstudio tasks.rb update_hpxmls"
git diff --stat --ignore-cr-at-eol HPXMLtoOpenStudio/resources/schedule_files/*.csv
git diff --quiet --ignore-cr-at-eol HPXMLtoOpenStudio/resources/schedule_files/*.csv

- name: Run measure unit tests
run: |
Expand Down
5 changes: 1 addition & 4 deletions BuildResidentialScheduleFile/measure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ def run(model, runner, user_arguments)
epw_path = Location.get_epw_path(hpxml_bldg, hpxml_path)
weather = WeatherFile.new(epw_path: epw_path, runner: runner, hpxml: hpxml)
end

# deterministically vary schedules across building units
args[:random_seed] *= (i + 1)

Expand Down Expand Up @@ -205,7 +204,7 @@ def create_schedules(runner, hpxml, hpxml_bldg, weather, args)
get_generator_inputs(hpxml_bldg, weather, args)

args[:resources_path] = File.join(File.dirname(__FILE__), 'resources')
schedule_generator = ScheduleGenerator.new(runner: runner, **args)
schedule_generator = ScheduleGenerator.new(runner: runner, hpxml_bldg: hpxml_bldg, **args)

success = schedule_generator.create(args: args, weather: weather)
return false if not success
Expand Down Expand Up @@ -244,8 +243,6 @@ def get_simulation_parameters(hpxml, weather, args)
args[:minutes_per_step] = hpxml.header.timestep
end
args[:steps_in_day] = 24 * 60 / args[:minutes_per_step]
args[:mkc_ts_per_day] = 96
args[:mkc_ts_per_hour] = args[:mkc_ts_per_day] / 24

calendar_year = Location.get_sim_calendar_year(hpxml.header.sim_calendar_year, weather)
args[:sim_year] = calendar_year
Expand Down
10 changes: 5 additions & 5 deletions BuildResidentialScheduleFile/measure.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<schema_version>3.1</schema_version>
<name>build_residential_schedule_file</name>
<uid>f770b2db-1a9f-4e99-99a7-7f3161a594b1</uid>
<version_id>c5bb6758-f028-455a-a49d-25f4df40e500</version_id>
<version_modified>2025-01-02T23:31:30Z</version_modified>
<version_id>54e905ce-2e27-4eed-bdc5-f9d3f46626b3</version_id>
<version_modified>2025-01-10T00:56:23Z</version_modified>
<xml_checksum>03F02484</xml_checksum>
<class_name>BuildResidentialScheduleFile</class_name>
<display_name>Schedule File Builder</display_name>
Expand Down Expand Up @@ -133,7 +133,7 @@
<filename>measure.rb</filename>
<filetype>rb</filetype>
<usage_type>script</usage_type>
<checksum>F7D77A2C</checksum>
<checksum>4DA9EA23</checksum>
</file>
<file>
<filename>README.md</filename>
Expand Down Expand Up @@ -229,7 +229,7 @@
<filename>schedules.rb</filename>
<filetype>rb</filetype>
<usage_type>resource</usage_type>
<checksum>F14B1337</checksum>
<checksum>C097736B</checksum>
</file>
<file>
<filename>shower_cluster_size_probability.csv</filename>
Expand Down Expand Up @@ -931,7 +931,7 @@
<filename>test_build_residential_schedule_file.rb</filename>
<filetype>rb</filetype>
<usage_type>test</usage_type>
<checksum>04AE998D</checksum>
<checksum>E9DDC3BC</checksum>
</file>
</files>
</measure>
2,037 changes: 1,180 additions & 857 deletions BuildResidentialScheduleFile/resources/schedules.rb

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,22 @@ def test_zero_occupants
assert_empty(hpxml.buildings[0].header.schedules_filepaths)
end

def test_ev_battery
num_occupants = 1.0

hpxml = _create_hpxml('base-vehicle-ev-charger.xml')
hpxml.buildings[0].building_occupancy.number_of_residents = num_occupants
XMLHelper.write_file(hpxml.to_doc, @tmp_hpxml_path)

@args_hash['output_csv_path'] = File.absolute_path(File.join(@tmp_output_path, 'occupancy-stochastic.csv'))
hpxml, _result = _test_measure()
sf = SchedulesFile.new(schedules_paths: hpxml.buildings[0].header.schedules_filepaths,
year: @year,
output_path: @tmp_schedule_file_path)
assert_in_epsilon(6201, sf.annual_equivalent_full_load_hrs(col_name: SchedulesFile::Columns[:ElectricVehicleCharging].name, schedules: sf.tmp_schedules), @tol)
assert_in_epsilon(729.9, sf.annual_equivalent_full_load_hrs(col_name: SchedulesFile::Columns[:ElectricVehicleDischarging].name, schedules: sf.tmp_schedules), @tol)
end

def test_multiple_buildings
hpxml = _create_hpxml('base-bldgtype-mf-whole-building.xml')
hpxml.buildings.each do |hpxml_bldg|
Expand Down
2 changes: 2 additions & 0 deletions HPXMLtoOpenStudio/resources/data/unavailable_periods.csv
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
Schedule Name,Vacancy,Power Outage,No Space Heating,No Space Cooling
occupants,1,0,0,0
ev_occupant,1,0,0,0
present_occupants,1,0,0,0
lighting_interior,1,1,0,0
lighting_exterior,1,1,0,0
lighting_garage,1,1,0,0
Expand Down
5 changes: 5 additions & 0 deletions HPXMLtoOpenStudio/resources/schedules.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1017,6 +1017,8 @@ def initialize(name, used_by_unavailable_periods, can_be_stochastic, type)
# periods CSV (e.g., heating), and/or C) EnergyPlus-specific schedules (e.g., battery_charging).
Columns = {
Occupants: Column.new('occupants', true, true, :frac),
EVOccupant: Column.new('ev_occupant', true, false, :int),
PresentOccupants: Column.new('present_occupants', true, false, :int),
LightingInterior: Column.new('lighting_interior', true, true, :frac),
LightingExterior: Column.new('lighting_exterior', true, false, :frac),
LightingGarage: Column.new('lighting_garage', true, true, :frac),
Expand Down Expand Up @@ -1081,6 +1083,7 @@ def initialize(runner: nil,
return if schedules_paths.empty?

@year = year
@runner = runner
import(schedules_paths)
create_battery_charging_discharging_schedules
expand_schedules
Expand Down Expand Up @@ -1123,6 +1126,7 @@ def includes_col_name(col_name)
def import(schedules_paths)
num_hrs_in_year = Calendar.num_hours_in_year(@year)
@schedules = {}
col2path = {}
schedules_paths.each do |schedules_path|
# Note: We don't use the CSV library here because it's slow for large files
columns = File.readlines(schedules_path).map(&:strip).map { |r| r.split(',') }.transpose
Expand Down Expand Up @@ -1176,6 +1180,7 @@ def import(schedules_paths)
end

@schedules[col_name] = values
col2path[col_name] = schedules_path
end
end
end
Expand Down
10 changes: 8 additions & 2 deletions workflow/run_simulation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
def run_workflow(basedir, rundir, hpxml, debug, skip_validation, add_comp_loads,
output_format, building_id, ep_input_format, stochastic_schedules,
hourly_outputs, daily_outputs, monthly_outputs, timestep_outputs,
skip_simulation)
skip_simulation, master_seed)

measures_dir = File.join(basedir, '..')
measures = {}
Expand All @@ -32,6 +32,7 @@ def run_workflow(basedir, rundir, hpxml, debug, skip_validation, add_comp_loads,
args['output_csv_path'] = File.join(rundir, 'stochastic.csv')
args['debug'] = debug
args['building_id'] = building_id
args['schedules_random_seed'] = master_seed
measures[measure_subdir] = [args]
end

Expand Down Expand Up @@ -164,6 +165,11 @@ def run_workflow(basedir, rundir, hpxml, debug, skip_validation, add_comp_loads,
options[:stochastic_schedules] = true
end

options[:master_seed] = nil
opts.on('--master-seed SEED', Integer, 'Master seed for random number generation') do |t|
options[:master_seed] = t
end

options[:ep_input_format] = 'idf'
opts.on('--ep-input-format TYPE', 'EnergyPlus input file format (idf, epjson)') do |t|
options[:ep_input_format] = t
Expand Down Expand Up @@ -228,7 +234,7 @@ def run_workflow(basedir, rundir, hpxml, debug, skip_validation, add_comp_loads,
success = run_workflow(basedir, rundir, options[:hpxml], options[:debug], options[:skip_validation], options[:add_comp_loads],
options[:output_format], options[:building_id], options[:ep_input_format], options[:stochastic_schedules],
options[:hourly_outputs], options[:daily_outputs], options[:monthly_outputs], options[:timestep_outputs],
options[:skip_simulation])
options[:skip_simulation], options[:master_seed])

if not success
exit! 1
Expand Down