Skip to content

Commit

Permalink
Set up Vehicles HPXML method to allow for other vehicle types.
Browse files Browse the repository at this point in the history
  • Loading branch information
aspeake committed Jan 14, 2025
1 parent 9337c3b commit ed998a7
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 57 deletions.
1 change: 1 addition & 0 deletions BuildResidentialHPXML/measure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6975,6 +6975,7 @@ def self.set_vehicle(hpxml_bldg, args)
if args[:vehicle_type] == HPXML::VehicleTypeBEV
ev_ct = hpxml_bldg.vehicles.count { |vehicle| vehicle.vehicle_type == HPXML::VehicleTypeBEV }
hpxml_bldg.vehicles.add(id: "ElectricVehicle#{ev_ct + 1}",
vehicle_type: args[:vehicle_type],
nominal_capacity_kwh: args[:vehicle_battery_capacity],
usable_capacity_kwh: args[:vehicle_battery_usable_capacity],
fuel_economy: args[:vehicle_fuel_economy_combined],
Expand Down
18 changes: 3 additions & 15 deletions BuildResidentialHPXML/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_hpxml</name>
<uid>a13a8983-2b01-4930-8af2-42030b6e4233</uid>
<version_id>d2d281c5-4792-4f52-8210-8bc6d89c4bad</version_id>
<version_modified>2025-01-14T00:22:16Z</version_modified>
<version_id>378d0854-499d-49ed-88d8-e6b929c0aff2</version_id>
<version_modified>2025-01-14T17:40:51Z</version_modified>
<xml_checksum>2C38F48B</xml_checksum>
<class_name>BuildResidentialHPXML</class_name>
<display_name>HPXML Builder</display_name>
Expand Down Expand Up @@ -7665,7 +7665,7 @@
<filename>measure.rb</filename>
<filetype>rb</filetype>
<usage_type>script</usage_type>
<checksum>6FF26F8E</checksum>
<checksum>CECE6DCC</checksum>
</file>
<file>
<filename>constants.rb</filename>
Expand All @@ -7685,18 +7685,6 @@
<usage_type>resource</usage_type>
<checksum>0E8669F5</checksum>
</file>
<file>
<filename>extra_files/extra-ev-battery.osm</filename>
<filetype>osm</filetype>
<usage_type>test</usage_type>
<checksum>74DE2DE6</checksum>
</file>
<file>
<filename>extra_files/extra-ev-battery.xml</filename>
<filetype>xml</filetype>
<usage_type>test</usage_type>
<checksum>B9BA3162</checksum>
</file>
<file>
<filename>test_build_residential_hpxml.rb</filename>
<filetype>rb</filetype>
Expand Down
6 changes: 3 additions & 3 deletions HPXMLtoOpenStudio/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>hpxm_lto_openstudio</name>
<uid>b1543b30-9465-45ff-ba04-1d1f85e763bc</uid>
<version_id>41619e76-f0dd-422f-b8be-1d138537b48c</version_id>
<version_modified>2025-01-13T23:20:45Z</version_modified>
<version_id>b47e5bc1-d61f-47e6-a666-87ee96ba5a14</version_id>
<version_modified>2025-01-14T17:40:54Z</version_modified>
<xml_checksum>D8922A73</xml_checksum>
<class_name>HPXMLtoOpenStudio</class_name>
<display_name>HPXML to OpenStudio Translator</display_name>
Expand Down Expand Up @@ -363,7 +363,7 @@
<filename>hpxml.rb</filename>
<filetype>rb</filetype>
<usage_type>resource</usage_type>
<checksum>02D28BDB</checksum>
<checksum>E35D68B4</checksum>
</file>
<file>
<filename>hpxml_schema/HPXML.xsd</filename>
Expand Down
82 changes: 43 additions & 39 deletions HPXMLtoOpenStudio/resources/hpxml.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9410,46 +9410,50 @@ def to_doc(building)
vehicle = XMLHelper.add_element(vehicles, 'Vehicle')
sys_id = XMLHelper.add_element(vehicle, 'SystemIdentifier')
XMLHelper.add_attribute(sys_id, 'id', @id)
ev_type = XMLHelper.add_element(vehicle, 'VehicleType')
electric_vehicle = XMLHelper.add_element(ev_type, HPXML::VehicleTypeBEV)
battery = XMLHelper.add_element(electric_vehicle, 'Battery')

# Battery
XMLHelper.add_element(battery, 'BatteryType', @battery_type, :string, @battery_type_isdefaulted) unless @battery_type.nil?
if not @nominal_capacity_kwh.nil?
nominal_capacity = XMLHelper.add_element(battery, 'NominalCapacity')
XMLHelper.add_element(nominal_capacity, 'Units', UnitsKwh, :string)
XMLHelper.add_element(nominal_capacity, 'Value', @nominal_capacity_kwh, :float, @nominal_capacity_kwh_isdefaulted)
end
if not @nominal_capacity_ah.nil?
nominal_capacity = XMLHelper.add_element(battery, 'NominalCapacity')
XMLHelper.add_element(nominal_capacity, 'Units', UnitsAh, :string)
XMLHelper.add_element(nominal_capacity, 'Value', @nominal_capacity_ah, :float, @nominal_capacity_ah_isdefaulted)
end
if not @usable_capacity_kwh.nil?
usable_capacity = XMLHelper.add_element(battery, 'UsableCapacity')
XMLHelper.add_element(usable_capacity, 'Units', UnitsKwh, :string)
XMLHelper.add_element(usable_capacity, 'Value', @usable_capacity_kwh, :float, @usable_capacity_kwh_isdefaulted)
end
if not @usable_capacity_ah.nil?
usable_capacity = XMLHelper.add_element(battery, 'UsableCapacity')
XMLHelper.add_element(usable_capacity, 'Units', UnitsAh, :string)
XMLHelper.add_element(usable_capacity, 'Value', @usable_capacity_ah, :float, @usable_capacity_ah_isdefaulted)
vehicle_type_element = XMLHelper.add_element(vehicle, 'VehicleType')

case @vehicle_type
when HPXML::VehicleTypeBEV
electric_vehicle = XMLHelper.add_element(vehicle_type_element, @vehicle_type)
battery = XMLHelper.add_element(electric_vehicle, 'Battery')

# Battery
XMLHelper.add_element(battery, 'BatteryType', @battery_type, :string, @battery_type_isdefaulted) unless @battery_type.nil?
if not @nominal_capacity_kwh.nil?
nominal_capacity = XMLHelper.add_element(battery, 'NominalCapacity')
XMLHelper.add_element(nominal_capacity, 'Units', UnitsKwh, :string)
XMLHelper.add_element(nominal_capacity, 'Value', @nominal_capacity_kwh, :float, @nominal_capacity_kwh_isdefaulted)
end
if not @nominal_capacity_ah.nil?
nominal_capacity = XMLHelper.add_element(battery, 'NominalCapacity')
XMLHelper.add_element(nominal_capacity, 'Units', UnitsAh, :string)
XMLHelper.add_element(nominal_capacity, 'Value', @nominal_capacity_ah, :float, @nominal_capacity_ah_isdefaulted)
end
if not @usable_capacity_kwh.nil?
usable_capacity = XMLHelper.add_element(battery, 'UsableCapacity')
XMLHelper.add_element(usable_capacity, 'Units', UnitsKwh, :string)
XMLHelper.add_element(usable_capacity, 'Value', @usable_capacity_kwh, :float, @usable_capacity_kwh_isdefaulted)
end
if not @usable_capacity_ah.nil?
usable_capacity = XMLHelper.add_element(battery, 'UsableCapacity')
XMLHelper.add_element(usable_capacity, 'Units', UnitsAh, :string)
XMLHelper.add_element(usable_capacity, 'Value', @usable_capacity_ah, :float, @usable_capacity_ah_isdefaulted)
end
XMLHelper.add_element(battery, 'NominalVoltage', @nominal_voltage, :float, @nominal_voltage_isdefaulted) unless @nominal_voltage.nil?
XMLHelper.add_extension(battery, 'LifetimeModel', @lifetime_model, :string, @lifetime_model_isdefaulted) unless @lifetime_model.nil?

# Battery-Electric Vehicle
fraction_charged_location = XMLHelper.add_element(electric_vehicle, 'FractionChargedLocation') unless @fraction_charged_home.nil?
XMLHelper.add_element(fraction_charged_location, 'Location', HPXML::ElectricVehicleChargingLocation, :string) unless @fraction_charged_home.nil?
XMLHelper.add_element(fraction_charged_location, 'Percentage', @fraction_charged_home, :float, @fraction_charged_home_isdefaulted) unless @fraction_charged_home.nil?
if not @ev_charger_idref.nil?
charger = XMLHelper.add_element(electric_vehicle, 'ConnectedCharger')
XMLHelper.add_attribute(charger, 'idref', @ev_charger_idref)
end
XMLHelper.add_extension(electric_vehicle, 'WeekdayScheduleFractions', @ev_charging_weekday_fractions, :string, @ev_charging_weekday_fractions_isdefaulted) unless @ev_charging_weekday_fractions.nil?
XMLHelper.add_extension(electric_vehicle, 'WeekendScheduleFractions', @ev_charging_weekend_fractions, :string, @ev_charging_weekend_fractions_isdefaulted) unless @ev_charging_weekend_fractions.nil?
XMLHelper.add_extension(electric_vehicle, 'MonthlyScheduleMultipliers', @ev_charging_monthly_multipliers, :string, @ev_charging_monthly_multipliers_isdefaulted) unless @ev_charging_monthly_multipliers.nil?
end
XMLHelper.add_element(battery, 'NominalVoltage', @nominal_voltage, :float, @nominal_voltage_isdefaulted) unless @nominal_voltage.nil?
XMLHelper.add_extension(battery, 'LifetimeModel', @lifetime_model, :string, @lifetime_model_isdefaulted) unless @lifetime_model.nil?

# Battery-Electric Vehicle
fraction_charged_location = XMLHelper.add_element(electric_vehicle, 'FractionChargedLocation') unless @fraction_charged_home.nil?
XMLHelper.add_element(fraction_charged_location, 'Location', HPXML::ElectricVehicleChargingLocation, :string) unless @fraction_charged_home.nil?
XMLHelper.add_element(fraction_charged_location, 'Percentage', @fraction_charged_home, :float, @fraction_charged_home_isdefaulted) unless @fraction_charged_home.nil?
if not @ev_charger_idref.nil?
charger = XMLHelper.add_element(electric_vehicle, 'ConnectedCharger')
XMLHelper.add_attribute(charger, 'idref', @ev_charger_idref)
end
XMLHelper.add_extension(electric_vehicle, 'WeekdayScheduleFractions', @ev_charging_weekday_fractions, :string, @ev_charging_weekday_fractions_isdefaulted) unless @ev_charging_weekday_fractions.nil?
XMLHelper.add_extension(electric_vehicle, 'WeekendScheduleFractions', @ev_charging_weekend_fractions, :string, @ev_charging_weekend_fractions_isdefaulted) unless @ev_charging_weekend_fractions.nil?
XMLHelper.add_extension(electric_vehicle, 'MonthlyScheduleMultipliers', @ev_charging_monthly_multipliers, :string, @ev_charging_monthly_multipliers_isdefaulted) unless @ev_charging_monthly_multipliers.nil?

# Vehicle
XMLHelper.add_element(vehicle, 'MilesDrivenPerYear', @miles_per_year, :float, @miles_per_year_isdefaulted) unless @miles_per_year.nil?
Expand Down

0 comments on commit ed998a7

Please sign in to comment.