openstudio-standards 0.8.5 → 0.8.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/data/standards/test_performance_expected_dd_results.csv +90 -90
- data/lib/openstudio-standards/btap/activity.rb +858 -61
- data/lib/openstudio-standards/btap/attributes.rb +297 -103
- data/lib/openstudio-standards/btap/bridging.rb +1335 -593
- data/lib/openstudio-standards/btap/btap.rb +60 -181
- data/lib/openstudio-standards/btap/carbon/btap_carbon.rb +199 -142
- data/lib/openstudio-standards/btap/common/constructions.json +1275 -0
- data/lib/openstudio-standards/btap/common/costs.csv +1969 -0
- data/lib/openstudio-standards/btap/common/costs_local_factors.csv +2315 -0
- data/lib/openstudio-standards/btap/common/materials_glazing.csv +61 -0
- data/lib/openstudio-standards/btap/{common_resources → common}/materials_hvac.csv +1685 -1685
- data/lib/openstudio-standards/btap/{common_resources → common}/materials_lighting.csv +266 -266
- data/lib/openstudio-standards/btap/common/materials_opaque.csv +214 -0
- data/lib/openstudio-standards/btap/common/necb_building_types.csv +35 -0
- data/lib/openstudio-standards/btap/common/necb_space_types.csv +110 -0
- data/lib/openstudio-standards/btap/common/thermal_bridging.csv +73 -0
- data/lib/openstudio-standards/btap/costing/btap_costing.rb +346 -429
- data/lib/openstudio-standards/btap/costing/database.rb +104 -0
- data/lib/openstudio-standards/btap/costing/daylighting_sensor_control_costing.rb +356 -344
- data/lib/openstudio-standards/btap/costing/dcv_costing.rb +282 -296
- data/lib/openstudio-standards/btap/costing/envelope_costing.rb +179 -192
- data/lib/openstudio-standards/btap/costing/heating_cooling_costing.rb +2477 -2316
- data/lib/openstudio-standards/btap/costing/led_lighting_costing.rb +127 -142
- data/lib/openstudio-standards/btap/costing/lighting_costing.rb +216 -198
- data/lib/openstudio-standards/btap/costing/nv_costing.rb +522 -523
- data/lib/openstudio-standards/btap/costing/pv_ground_costing.rb +649 -649
- data/lib/openstudio-standards/btap/costing/shw_costing.rb +626 -625
- data/lib/openstudio-standards/btap/costing/thermal_bridging_costing.rb +72 -0
- data/lib/openstudio-standards/btap/costing/ventilation_costing.rb +2363 -2361
- data/lib/openstudio-standards/btap/deprecated.rb +1033 -0
- data/lib/openstudio-standards/btap/envelope.rb +313 -572
- data/lib/openstudio-standards/btap/fileio.rb +152 -1070
- data/lib/openstudio-standards/btap/geometry.rb +486 -766
- data/lib/openstudio-standards/btap/linear_regression.rb +130 -0
- data/lib/openstudio-standards/btap/paths.rb +46 -0
- data/lib/openstudio-standards/btap/qaqc/analysis.rb +163 -0
- data/lib/openstudio-standards/btap/qaqc/data.rb +2293 -0
- data/lib/openstudio-standards/btap/qaqc/datapoint.rb +641 -0
- data/lib/openstudio-standards/btap/schedules.rb +11 -611
- data/lib/openstudio-standards/btap/structure.rb +574 -189
- data/lib/openstudio-standards/constructions/materials/information.rb +1 -1
- data/lib/openstudio-standards/create_typical/create_typical.rb +1 -1
- data/lib/openstudio-standards/exterior_lighting/create.rb +135 -85
- data/lib/openstudio-standards/exterior_lighting/data/typical_exterior_lighting.json +20 -0
- data/lib/openstudio-standards/exterior_lighting/information.rb +23 -2
- data/lib/openstudio-standards/geometry/create.rb +7 -3
- data/lib/openstudio-standards/prototypes/ashrae_90_1/ashrae_90_1_2016/ashrae_90_1_2016.Model.rb +3 -2
- data/lib/openstudio-standards/prototypes/ashrae_90_1/ashrae_90_1_2019/ashrae_90_1_2019.Model.rb +3 -2
- data/lib/openstudio-standards/prototypes/common/data/thermostat_schedule_lookup.json +84 -84
- data/lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb +4 -4
- data/lib/openstudio-standards/refrigeration/create_walkin.rb +45 -5
- data/lib/openstudio-standards/refrigeration/data/refrigerated_walkins.csv +75 -75
- data/lib/openstudio-standards/schedules/parametric.rb +6 -0
- data/lib/openstudio-standards/service_water_heating/create_typical.rb +10 -3
- data/lib/openstudio-standards/service_water_heating/create_water_heating_loop.rb +30 -14
- data/lib/openstudio-standards/service_water_heating/information.rb +4 -1
- data/lib/openstudio-standards/sql_file/unmet_hours.rb +2 -1
- data/lib/openstudio-standards/standards/Standards.CoilCoolingDXSingleSpeed.rb +3 -1
- data/lib/openstudio-standards/standards/Standards.CoilHeatingDXSingleSpeed.rb +3 -1
- data/lib/openstudio-standards/standards/ashrae_90_1/ashrae_90_1_2004/data/ashrae_90_1_2004.boilers.json +12 -0
- data/lib/openstudio-standards/standards/ashrae_90_1/ashrae_90_1_2004/data/ashrae_90_1_2004.construction_properties.json +18432 -3072
- data/lib/openstudio-standards/standards/ashrae_90_1/ashrae_90_1_2007/data/ashrae_90_1_2007.boilers.json +26 -0
- data/lib/openstudio-standards/standards/ashrae_90_1/ashrae_90_1_2007/data/ashrae_90_1_2007.construction_properties.json +8532 -1422
- data/lib/openstudio-standards/standards/ashrae_90_1/ashrae_90_1_2010/data/ashrae_90_1_2010.boilers.json +26 -0
- data/lib/openstudio-standards/standards/ashrae_90_1/ashrae_90_1_2010/data/ashrae_90_1_2010.construction_properties.json +8532 -1422
- data/lib/openstudio-standards/standards/ashrae_90_1/ashrae_90_1_2013/data/ashrae_90_1_2013.boilers.json +16 -0
- data/lib/openstudio-standards/standards/ashrae_90_1/ashrae_90_1_2013/data/ashrae_90_1_2013.computer_room_acs.json +30 -30
- data/lib/openstudio-standards/standards/ashrae_90_1/ashrae_90_1_2013/data/ashrae_90_1_2013.construction_properties.json +7560 -1260
- data/lib/openstudio-standards/standards/ashrae_90_1/ashrae_90_1_2016/ashrae_90_1_2016.PumpVariableSpeed.rb +1 -2
- data/lib/openstudio-standards/standards/ashrae_90_1/ashrae_90_1_2016/data/ashrae_90_1_2016.boilers.json +16 -0
- data/lib/openstudio-standards/standards/ashrae_90_1/ashrae_90_1_2016/data/ashrae_90_1_2016.construction_properties.json +7560 -1260
- data/lib/openstudio-standards/standards/ashrae_90_1/ashrae_90_1_2019/ashrae_90_1_2019.AirLoopHVAC.rb +3 -3
- data/lib/openstudio-standards/standards/ashrae_90_1/ashrae_90_1_2019/ashrae_90_1_2019.PumpVariableSpeed.rb +1 -2
- data/lib/openstudio-standards/standards/ashrae_90_1/ashrae_90_1_2019/data/ashrae_90_1_2019.boilers.json +22 -0
- data/lib/openstudio-standards/standards/ashrae_90_1/ashrae_90_1_2019/data/ashrae_90_1_2019.construction_properties.json +7236 -1206
- data/lib/openstudio-standards/standards/ashrae_90_1/ashrae_90_1_2019/data/ashrae_90_1_2019.furnaces.json +223 -19
- data/lib/openstudio-standards/standards/ashrae_90_1/data/ashrae_90_1.schedules.json +37 -1
- data/lib/openstudio-standards/standards/ashrae_90_1_prm/ashrae_90_1_prm_2019/data/ashrae_90_1_prm_2019.boilers.json +3 -0
- data/lib/openstudio-standards/standards/ashrae_90_1_prm/ashrae_90_1_prm_2019/data/ashrae_90_1_prm_2019.construction_properties.json +6900 -1150
- data/lib/openstudio-standards/standards/cbes/data/cbes.schedules.json +1 -1
- data/lib/openstudio-standards/standards/deer/data/deer.schedules.json +1 -1
- data/lib/openstudio-standards/standards/necb/BTAP1980TO2010/data/surface_thermal_transmittance.json +76 -40
- data/lib/openstudio-standards/standards/necb/BTAPPRE1980/data/surface_thermal_transmittance.json +76 -40
- data/lib/openstudio-standards/standards/necb/ECMS/hvac_systems.rb +6 -4
- data/lib/openstudio-standards/standards/necb/NECB2011/NECB2011_QAQC.json +2988 -0
- data/lib/openstudio-standards/standards/necb/NECB2011/autozone.rb +25 -3
- data/lib/openstudio-standards/standards/necb/NECB2011/building_envelope.rb +672 -534
- data/lib/openstudio-standards/standards/necb/NECB2011/data/geometry/Hospital.osm +1791 -1792
- data/lib/openstudio-standards/standards/necb/NECB2011/data/geometry/LEEPMultiTower.osm +7 -1
- data/lib/openstudio-standards/standards/necb/NECB2011/data/geometry/LEEPTownHouse.osm +7 -1
- data/lib/openstudio-standards/standards/necb/NECB2011/data/geometry/LargeHotel.osm +5 -6
- data/lib/openstudio-standards/standards/necb/NECB2011/data/geometry/LargeOffice.osm +8 -9
- data/lib/openstudio-standards/standards/necb/NECB2011/data/geometry/NorthernEducation.osm +10 -4
- data/lib/openstudio-standards/standards/necb/NECB2011/data/geometry/NorthernHealthCare.osm +14 -15
- data/lib/openstudio-standards/standards/necb/NECB2011/data/geometry/Outpatient.osm +7 -1
- data/lib/openstudio-standards/standards/necb/NECB2011/data/surface_thermal_transmittance.json +76 -40
- data/lib/openstudio-standards/standards/necb/NECB2011/hvac_systems.rb +14 -6
- data/lib/openstudio-standards/standards/necb/NECB2011/necb_2011.rb +542 -130
- data/lib/openstudio-standards/standards/necb/NECB2011/qaqc/necb_qaqc.rb +30 -63
- data/lib/openstudio-standards/standards/necb/NECB2011/service_water_heating.rb +7 -2
- data/lib/openstudio-standards/standards/necb/NECB2015/data/surface_thermal_transmittance.json +90 -0
- data/lib/openstudio-standards/standards/necb/NECB2015/necb_2015.rb +8 -6
- data/lib/openstudio-standards/standards/necb/NECB2017/data/surface_thermal_transmittance.json +76 -40
- data/lib/openstudio-standards/standards/necb/NECB2017/necb_2017.rb +2 -1
- data/lib/openstudio-standards/standards/necb/NECB2020/building_envelope.rb +0 -117
- data/lib/openstudio-standards/standards/necb/NECB2020/data/surface_thermal_transmittance.json +76 -45
- data/lib/openstudio-standards/standards/necb/NECB2020/necb_2020.rb +218 -0
- data/lib/openstudio-standards/standards/necb/common/construction_defaults.osm +12 -7
- data/lib/openstudio-standards/standards/standard.rb +1 -1
- data/lib/openstudio-standards/version.rb +1 -1
- data/lib/openstudio-standards.rb +9 -4
- metadata +59 -66
- data/data/inventory/thermal_bridging.csv +0 -90
- data/data/standards/OpenStudio_Standards-ashrae_90_1-ALL-comstock(space_types).xlsx +0 -0
- data/data/standards/openstudio_standards_duplicates_log.csv +0 -7962
- data/lib/openstudio-standards/btap/NECB_building_types.csv +0 -35
- data/lib/openstudio-standards/btap/NECB_space_types.csv +0 -109
- data/lib/openstudio-standards/btap/WeatherData1.json +0 -2110
- data/lib/openstudio-standards/btap/WeatherData1.xlsx +0 -0
- data/lib/openstudio-standards/btap/btap_result.rb +0 -1144
- data/lib/openstudio-standards/btap/btap_test_helper.rb +0 -86
- data/lib/openstudio-standards/btap/common_paths.rb +0 -81
- data/lib/openstudio-standards/btap/common_resources/ConstructionProperties.csv +0 -52
- data/lib/openstudio-standards/btap/common_resources/Constructions.csv +0 -37
- data/lib/openstudio-standards/btap/common_resources/construction_sets.csv +0 -1270
- data/lib/openstudio-standards/btap/common_resources/constructions_glazing.csv +0 -121
- data/lib/openstudio-standards/btap/common_resources/constructions_opaque.csv +0 -2256
- data/lib/openstudio-standards/btap/common_resources/costs.csv +0 -1897
- data/lib/openstudio-standards/btap/common_resources/costs_local_factors.csv +0 -2315
- data/lib/openstudio-standards/btap/common_resources/materials_glazing.csv +0 -35
- data/lib/openstudio-standards/btap/common_resources/materials_opaque.csv +0 -164
- data/lib/openstudio-standards/btap/costing/btap_measure_helper.rb +0 -359
- data/lib/openstudio-standards/btap/costing/btap_workflow.rb +0 -117
- data/lib/openstudio-standards/btap/costing/copy_test_results_files_to_expected_results.rb +0 -11
- data/lib/openstudio-standards/btap/costing/cost_building_from_file.rb +0 -136
- data/lib/openstudio-standards/btap/costing/costing_database_wrapper.rb +0 -173
- data/lib/openstudio-standards/btap/costing/dummy.epw +0 -8768
- data/lib/openstudio-standards/btap/costing/dummy.osm +0 -5320
- data/lib/openstudio-standards/btap/costing/neb_end_use_prices.csv +0 -42
- data/lib/openstudio-standards/btap/costing/necb_2011_spacetype_info.csv +0 -225
- data/lib/openstudio-standards/btap/costing/necb_reference_runs.csv +0 -28705
- data/lib/openstudio-standards/btap/costing/parallel_tests.rb +0 -92
- data/lib/openstudio-standards/btap/costing/test_list.txt +0 -15
- data/lib/openstudio-standards/btap/costing/test_run_all_test_locally.rb +0 -27
- data/lib/openstudio-standards/btap/costing/test_run_costing_tests.rb +0 -80
- data/lib/openstudio-standards/btap/necb_2011_spacetype_info.csv +0 -225
- data/lib/openstudio-standards/btap/utilities/Add_template_field_to_json.rb +0 -22
- data/lib/openstudio-standards/btap/utilities/convert_surfaces_to_adiabatic_necb_8426.rb +0 -204
- data/lib/openstudio-standards/btap/utilities/generate_space_types.rb +0 -8
- data/lib/openstudio-standards/btap/utilities/necb_to_epw_map.rb +0 -50
- data/lib/openstudio-standards/btap/utilities/os_sim_extract.rb +0 -48
- data/lib/openstudio-standards/btap/utilities/rename_surfaces.rb +0 -24
- data/lib/openstudio-standards/btap/utilities/round_surf_coords.rb +0 -32
- data/lib/openstudio-standards/btap/utilities/sched_create.rb +0 -145
- data/lib/openstudio-standards/btap/utilities/set_mult_to_adiabatic.rb +0 -53
- data/lib/openstudio-standards/btap/utilities/space_type.rb +0 -78
- data/lib/openstudio-standards/btap/utilities/weatherData1_xlsx_to_json.rb +0 -56
- data/lib/openstudio-standards/btap/vintagizer.rb +0 -161
- data/lib/openstudio-standards/btap/visualization.rb +0 -72
- data/lib/openstudio-standards/standards/necb/NECB2011/data/necb_2011_spacetype_info.csv +0 -225
- data/lib/openstudio-standards/standards/necb/common/btap_analysis.rb +0 -79
- data/lib/openstudio-standards/standards/necb/common/btap_data.rb +0 -2656
- data/lib/openstudio-standards/standards/necb/common/btap_datapoint.rb +0 -653
- data/lib/openstudio-standards/standards/necb/common/necb_reference_runs.csv +0 -28705
- data/lib/openstudio-standards/standards/necb/common/utility_pricing_2025-02-20.csv +0 -92
- /data/lib/openstudio-standards/btap/{common_resources → common}/carbon_frame.csv +0 -0
- /data/lib/openstudio-standards/btap/{common_resources → common}/carbon_glazing.csv +0 -0
- /data/lib/openstudio-standards/btap/{common_resources → common}/carbon_opaque.csv +0 -0
- /data/lib/openstudio-standards/btap/{common_resources → common}/hvac_vent_ahu.csv +0 -0
- /data/lib/openstudio-standards/btap/{common_resources → common}/lighting.csv +0 -0
- /data/lib/openstudio-standards/btap/{common_resources → common}/lighting_sets.csv +0 -0
- /data/lib/openstudio-standards/btap/{common_resources → common}/locations.csv +0 -0
- /data/lib/openstudio-standards/btap/{costing → common}/mech_sizing.json +0 -0
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
require_relative '../../../../lib/openstudio-standards.rb'
|
|
2
|
-
|
|
3
|
-
class BTAPWorkflow
|
|
4
|
-
attr_accessor :workflow
|
|
5
|
-
|
|
6
|
-
def initialize(measures_folder: File.join(__dir__, '../../measures'))
|
|
7
|
-
@model = nil
|
|
8
|
-
@run_dir = nil
|
|
9
|
-
@sql_path = nil
|
|
10
|
-
@idf_name = 'in.idf'
|
|
11
|
-
@osm_name = 'in.osm'
|
|
12
|
-
@osw_name = 'out.osw'
|
|
13
|
-
@epw_path = 'in.epw'
|
|
14
|
-
@workflow = OpenStudio::WorkflowJSON.new
|
|
15
|
-
@workflow.addMeasurePath(measures_folder)
|
|
16
|
-
@run_cli_verbose = true
|
|
17
|
-
@os_measures = []
|
|
18
|
-
@ep_measures = []
|
|
19
|
-
@report_measures = []
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def set_run_dir(run_dir: "#{Dir.pwd}/Run")
|
|
23
|
-
puts "set run folder to #{run_dir}"
|
|
24
|
-
@run_dir = run_dir
|
|
25
|
-
@sql_path = OpenStudio::Path.new("#{@run_dir}/run/eplusout.sql")
|
|
26
|
-
return self
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def add_os_measure(measure)
|
|
30
|
-
@os_measures << measure
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def add_ep_measure(measure)
|
|
34
|
-
@ep_measures << measure
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def add_reporting_measure(measure)
|
|
38
|
-
@report_measures << measure
|
|
39
|
-
return self
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def add_measures_to_workflow
|
|
43
|
-
unless @os_measures.empty?
|
|
44
|
-
measure_type = OpenStudio::MeasureType.new("ModelMeasure")
|
|
45
|
-
@workflow.setMeasureSteps(measure_type, @os_measures)
|
|
46
|
-
end
|
|
47
|
-
unless @ep_measures.empty?
|
|
48
|
-
measure_type = OpenStudio::MeasureType.new("EnergyPlusMeasure")
|
|
49
|
-
@workflow.setMeasureSteps(measure_type, @ep_measures)
|
|
50
|
-
end
|
|
51
|
-
unless @report_measures.empty?
|
|
52
|
-
measure_type = OpenStudio::MeasureType.new("ReportingMeasure")
|
|
53
|
-
@workflow.setMeasureSteps(measure_type, @report_measures)
|
|
54
|
-
end
|
|
55
|
-
@workflow
|
|
56
|
-
return self
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
def add_btap_create_necb_prototype_building_measure(building_type:, epw_file:, template:, primary_heating_fuel:)
|
|
60
|
-
os_measure_type = OpenStudio::MeasureType.new("ModelMeasure")
|
|
61
|
-
create_prototype_measure = OpenStudio::MeasureStep.new("btap_create_necb_prototype_building")
|
|
62
|
-
create_prototype_measure.setName("btap_create_necb_prototype_building")
|
|
63
|
-
create_prototype_measure.setArgument('building_type', building_type)
|
|
64
|
-
create_prototype_measure.setArgument('epw_file', epw_file)
|
|
65
|
-
create_prototype_measure.setArgument('template', template)
|
|
66
|
-
create_prototype_measure.setArgument('primary_heating_fuel', primary_heating_fuel)
|
|
67
|
-
@os_measures << create_prototype_measure
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
def add_btap_results_measure
|
|
72
|
-
reporting_measure_type = OpenStudio::MeasureType.new("ReportingMeasure")
|
|
73
|
-
btap_results = OpenStudio::MeasureStep.new("btap_results")
|
|
74
|
-
btap_results.setName("btap_results")
|
|
75
|
-
btap_results.setArgument('generate_hourly_report', 'false')
|
|
76
|
-
btap_results.setArgument('output_diet', false)
|
|
77
|
-
btap_results.setArgument('envelope_costing', true)
|
|
78
|
-
btap_results.setArgument('lighting_costing', true)
|
|
79
|
-
btap_results.setArgument('boilers_costing', true)
|
|
80
|
-
btap_results.setArgument('chillers_costing', true)
|
|
81
|
-
btap_results.setArgument('cooling_towers_costing', true)
|
|
82
|
-
btap_results.setArgument('shw_costing', true)
|
|
83
|
-
btap_results.setArgument('ventilation_costing', true)
|
|
84
|
-
btap_results.setArgument('zone_system_costing', true)
|
|
85
|
-
@report_measures << btap_results
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
def run_command(command:)
|
|
90
|
-
stdout_str, stderr_str, status = Open3.capture3({}, command)
|
|
91
|
-
if status.success?
|
|
92
|
-
puts "Command completed successfully"
|
|
93
|
-
puts "stdout: #{stdout_str}"
|
|
94
|
-
puts "stderr: #{stderr_str}"
|
|
95
|
-
return true
|
|
96
|
-
else
|
|
97
|
-
puts "Error running command: '#{command}'"
|
|
98
|
-
puts "stdout: #{stdout_str}"
|
|
99
|
-
puts "stderr: #{stderr_str}"
|
|
100
|
-
return false
|
|
101
|
-
end
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
def run_workflow(postprocess_only: nil, osw_path:)
|
|
105
|
-
#command to run workflow
|
|
106
|
-
os_ruby_cli = "bundle exec ruby #{File.join(File.dirname(OpenStudio.getOpenStudioCLI.to_s), '..', 'Ruby', 'openstudio_cli.rb')}"
|
|
107
|
-
extra_args = ' --postprocess_only ' if postprocess_only == true
|
|
108
|
-
cmd = "#{os_ruby_cli} run #{extra_args} --debug --workflow \"#{osw_path}\""
|
|
109
|
-
puts "running cli command: #{cmd}"
|
|
110
|
-
OpenStudio.logFree(OpenStudio::Info, 'openstudio.model.Model', "running cli command: #{cmd}")
|
|
111
|
-
self.run_command(command: cmd)
|
|
112
|
-
OpenStudio.logFree(OpenStudio::Info, 'openstudio.model.Model', 'Finished cli run.')
|
|
113
|
-
#Ensure items are written to disk.
|
|
114
|
-
sleep 3
|
|
115
|
-
return true
|
|
116
|
-
end
|
|
117
|
-
end
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
require 'fileutils'
|
|
2
|
-
|
|
3
|
-
folder_path = "#{File.dirname(__FILE__)}/btap_results/tests/regression_files/"
|
|
4
|
-
puts folder_path
|
|
5
|
-
Dir.glob(folder_path + "/*test_result.cost.json").sort.each do |f|
|
|
6
|
-
new_file = f.gsub("test_result.cost.json","expected_result.cost.json")
|
|
7
|
-
FileUtils.cp(f,new_file )
|
|
8
|
-
FileUtils.rm(f, :force => true)
|
|
9
|
-
puts "created new #{new_file}"
|
|
10
|
-
end
|
|
11
|
-
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
require 'fileutils'
|
|
2
|
-
require 'json'
|
|
3
|
-
require 'optparse'
|
|
4
|
-
require_relative './btap_costing.rb'
|
|
5
|
-
|
|
6
|
-
# This script is used to apply costs to a list of costing items produced by btap_costing. Right now it can only be run
|
|
7
|
-
# from the btap_results resources folder because it uses btap_costing.rb. It can be used elsewhere probably but then
|
|
8
|
-
# the require_relative statement has to be changed. It takes in the following command line arguments:
|
|
9
|
-
# -c (string, required) Location of the json containing the list of items to be costed and the original costing City and
|
|
10
|
-
# Province.
|
|
11
|
-
# -d (string, optional) Location of a custom costing database containing the costing information for the items that
|
|
12
|
-
# need costing. This is used only if you do not want to use the standard costing database. It must have the same
|
|
13
|
-
# structure as the 'costs' hash in the default costing database
|
|
14
|
-
# -t (string, optional) The city to use when finding localization factors (only if you do not want to use the city that
|
|
15
|
-
# used in the original run).
|
|
16
|
-
# -p (string, optional) Same as -t only for Province.
|
|
17
|
-
# -o (string, optional) The location and name of the output file containing the costs. If a name and path are not
|
|
18
|
-
# provided then one called cost_list_output.json will be put in the same directory as this file.
|
|
19
|
-
#
|
|
20
|
-
# The output of this script is a json file containing the following cost summary:
|
|
21
|
-
# {
|
|
22
|
-
# envelope: (float) Building envelope costs (to 2 decimal places).
|
|
23
|
-
# lighting: (float) Ligting costs (to 2 decimal places).
|
|
24
|
-
# heating_and_cooling: (float) Heating and cooling costs (not related to ventilation) (to 2 decimal places).
|
|
25
|
-
# shw: (float) Service hot water costs (to 2 decimal places).
|
|
26
|
-
# ventilation: (float) Ventilation (including ventilation air heating and cooling) costs (to 2 decimal places).
|
|
27
|
-
# grand_total: (float) Total costs (to 2 decimal places).
|
|
28
|
-
# }
|
|
29
|
-
class BTAPCostFromFile
|
|
30
|
-
def cost_file()
|
|
31
|
-
# Get the commond line arguments
|
|
32
|
-
args = {}
|
|
33
|
-
OptionParser.new do |opts|
|
|
34
|
-
opts.banner = "Usage: example.rb [options]"
|
|
35
|
-
opts.on("-c", "--costlist_location=NAME", "Costing List File Location") do |n|
|
|
36
|
-
args['cost_file'] = n
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
opts.on("-d", "--custom_costing=NAME", "Custom Costing Database Location") do |n|
|
|
40
|
-
args['custom_db_file'] = n
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
opts.on("-t", "--custom_city=NAME", "Custom Costing City") do |n|
|
|
44
|
-
args['custom_city'] = n
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
opts.on("-p", "--custom_province=NAME", "Custom Costing Province") do |n|
|
|
48
|
-
args['custom_province'] = n
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
opts.on("-o", "--output_name=NAME", "Output file name and location") do |n|
|
|
52
|
-
args['output_loc'] = n
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
opts.on("-h", "--help", "Prints this help") do
|
|
56
|
-
puts opts
|
|
57
|
-
exit
|
|
58
|
-
end
|
|
59
|
-
end.parse!
|
|
60
|
-
|
|
61
|
-
curr_folder = (File.dirname(__FILE__)).to_s + "/"
|
|
62
|
-
|
|
63
|
-
# Get the output file location from the arguments
|
|
64
|
-
outputLoc = args['output_loc']
|
|
65
|
-
if outputLoc.nil?
|
|
66
|
-
outputFile = "./cost_list_output.json"
|
|
67
|
-
elsif outputLoc[0] == "."
|
|
68
|
-
if outputLoc[1] == "."
|
|
69
|
-
outputFile = curr_folder + outputLoc
|
|
70
|
-
elsif outputLoc[1] == "/"
|
|
71
|
-
outputFile = curr_folder + outputLoc[2..-1]
|
|
72
|
-
else
|
|
73
|
-
outputFile = curr_folder + outputLoc[1..-1]
|
|
74
|
-
end
|
|
75
|
-
elsif outputLoc[0] == "/"
|
|
76
|
-
outputFile = outputLoc
|
|
77
|
-
else
|
|
78
|
-
outputFile = curr_folder + outputLoc
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
# Get the cost list location from the arguments
|
|
82
|
-
costListLoc = args['cost_file']
|
|
83
|
-
if costListLoc.nil?
|
|
84
|
-
raise("No cost list location specified. Please enter the location and name of the costed item list after the -c")
|
|
85
|
-
elsif costListLoc[0] == "."
|
|
86
|
-
if costListLoc[1] == "."
|
|
87
|
-
cost_loc = curr_folder + costListLoc
|
|
88
|
-
elsif costListLoc[1] == "/"
|
|
89
|
-
cost_loc = curr_folder + costListLoc[2..-1]
|
|
90
|
-
else
|
|
91
|
-
cost_loc = curr_folder + costListLoc[1..-1]
|
|
92
|
-
end
|
|
93
|
-
elsif costListLoc[0] == "/"
|
|
94
|
-
cost_loc = costListLoc
|
|
95
|
-
else
|
|
96
|
-
cost_loc = curr_folder + costListLoc
|
|
97
|
-
end
|
|
98
|
-
|
|
99
|
-
# Get the custom costing database location from the arguments
|
|
100
|
-
custDB = args['custom_db_file']
|
|
101
|
-
if custDB.nil?
|
|
102
|
-
db_loc = nil
|
|
103
|
-
else
|
|
104
|
-
if custDB[0] == "."
|
|
105
|
-
if custDB[1] == "."
|
|
106
|
-
db_loc = curr_folder + custDB
|
|
107
|
-
elsif custDB[1] == "/"
|
|
108
|
-
db_loc = curr_folder + custDB[2..-1]
|
|
109
|
-
else
|
|
110
|
-
db_loc = curr_folder + custDB[1..-1]
|
|
111
|
-
end
|
|
112
|
-
elsif custDB[0] == "/"
|
|
113
|
-
db_loc = custDB
|
|
114
|
-
else
|
|
115
|
-
db_loc = curr_folder + custDB
|
|
116
|
-
end
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
# Set the custom costing city and province location if specified
|
|
120
|
-
args['custom_city'].nil? ? customCity = nil : customCity = args['custom_city'].to_s
|
|
121
|
-
args['custom_province'].nil? ? customProv = nil : customProv = args['custom_province'].to_s
|
|
122
|
-
|
|
123
|
-
# Get the costed items list
|
|
124
|
-
costList = JSON.parse(File.read(cost_loc))
|
|
125
|
-
|
|
126
|
-
# Create a BTAPCosting object and pass the btap_items list, and optional costing database, costing City and costing
|
|
127
|
-
# Province arguments. Get the resulting costs and save them in a json (see the description of the -o inline
|
|
128
|
-
# arguments above for more information).
|
|
129
|
-
btapCosting = BTAPCosting.new()
|
|
130
|
-
costResults = btapCosting.cost_list_items(btap_items: costList, custom_costing: custDB, custCity: customCity, custProvince: customProv)
|
|
131
|
-
|
|
132
|
-
File.write(outputFile, JSON.pretty_generate(costResults))
|
|
133
|
-
end
|
|
134
|
-
end
|
|
135
|
-
# Create a 'BTAPCostFromFile' object and call the 'cost_file' method to run the above script.
|
|
136
|
-
BTAPCostFromFile.new().cost_file()
|
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
require 'singleton'
|
|
2
|
-
require 'json'
|
|
3
|
-
require 'csv'
|
|
4
|
-
|
|
5
|
-
# Singleton class to centralize all database operations
|
|
6
|
-
class CostingDatabase
|
|
7
|
-
include Singleton
|
|
8
|
-
|
|
9
|
-
def initialize
|
|
10
|
-
@cp = CommonPaths.instance # Stores paths
|
|
11
|
-
@db = Hash.new # Stores the costing database
|
|
12
|
-
|
|
13
|
-
# Load the database from the individual CSV files
|
|
14
|
-
# Load costing data
|
|
15
|
-
@db['costs'] = [] # Costing data
|
|
16
|
-
@db['localization_factors'] = [] # Local costing factors
|
|
17
|
-
@db['raw'] = {} # Raw data
|
|
18
|
-
@db['db_errors'] = []
|
|
19
|
-
|
|
20
|
-
data_costs = CSV.read(@cp.costs_path)
|
|
21
|
-
|
|
22
|
-
1.upto data_costs.length - 1 do |i|
|
|
23
|
-
row = data_costs[i]
|
|
24
|
-
index = row.each
|
|
25
|
-
item = Hash.new
|
|
26
|
-
item["baseCosts"] = Hash.new
|
|
27
|
-
costs = item["baseCosts"]
|
|
28
|
-
|
|
29
|
-
item["id"] = index.next
|
|
30
|
-
item["sheet"] = index.next
|
|
31
|
-
item["source"] = index.next
|
|
32
|
-
item["description"] = index.next
|
|
33
|
-
item["city"] = index.next
|
|
34
|
-
item["province_state"] = index.next
|
|
35
|
-
costs["materialOpCost"] = index.next.to_f
|
|
36
|
-
costs["laborOpCost"] = index.next.to_f
|
|
37
|
-
costs["equipmentOpCost"] = index.next.to_f
|
|
38
|
-
|
|
39
|
-
@db["costs"] << item
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
# Load the localization factors
|
|
43
|
-
data_factors = CSV.read(@cp.costs_local_factors_path)
|
|
44
|
-
|
|
45
|
-
1.upto data_factors.length - 1 do |i|
|
|
46
|
-
row = data_factors[i]
|
|
47
|
-
index = row.each
|
|
48
|
-
item = Hash.new
|
|
49
|
-
|
|
50
|
-
item["province_state"] = index.next
|
|
51
|
-
item["city"] = index.next
|
|
52
|
-
item["division"] = index.next
|
|
53
|
-
item["code_prefix"] = index.next
|
|
54
|
-
item["material"] = index.next.to_f
|
|
55
|
-
item["installation"] = index.next.to_f
|
|
56
|
-
item["total"] = index.next.to_f
|
|
57
|
-
|
|
58
|
-
@db["localization_factors"] << item
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
# Load the raw data
|
|
62
|
-
raw_data_names = [
|
|
63
|
-
'locations',
|
|
64
|
-
'construction_sets',
|
|
65
|
-
'constructions_opaque',
|
|
66
|
-
'materials_opaque',
|
|
67
|
-
'constructions_glazing',
|
|
68
|
-
'materials_glazing',
|
|
69
|
-
'Constructions',
|
|
70
|
-
'ConstructionProperties',
|
|
71
|
-
'lighting_sets',
|
|
72
|
-
'lighting',
|
|
73
|
-
'materials_lighting',
|
|
74
|
-
'hvac_vent_ahu',
|
|
75
|
-
'materials_hvac'
|
|
76
|
-
]
|
|
77
|
-
|
|
78
|
-
0.upto(raw_data_names.length - 1) do |i|
|
|
79
|
-
data_path = @cp.raw_paths[i]
|
|
80
|
-
unless File.exist?(data_path)
|
|
81
|
-
raise("Error: Could not find #{data_path}")
|
|
82
|
-
end
|
|
83
|
-
@db['raw'][raw_data_names[i]] = CSV.read(data_path, headers: true).map { |row| row.to_hash}
|
|
84
|
-
end
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
# Validate the construction sets and the AHU items.
|
|
88
|
-
def validate_database()
|
|
89
|
-
validate_constructions_sets()
|
|
90
|
-
validate_ahu_items_and_quantities()
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
def validate_constructions_sets()
|
|
94
|
-
construction_sets = @db['raw']['construction_sets']
|
|
95
|
-
failed = false
|
|
96
|
-
templates = ["NECB2011", "NECB2015", "NECB2017", "NECB2020", "BTAPPRE1980", "BTAP1980TO2010"]
|
|
97
|
-
bad_records = {}
|
|
98
|
-
bad_records[:invalid_space_type_names] = []
|
|
99
|
-
bad_records[:min_max_floor_range_errors] = []
|
|
100
|
-
# CHECK if spacetype names are valid in costing database
|
|
101
|
-
valid_space_types = []
|
|
102
|
-
templates.each do |template|
|
|
103
|
-
valid_space_types += Standard.build(template.gsub(/\s+/, "")).get_all_spacetype_names.map { |spacetype| (template + '-' + spacetype[0].to_s + '-' + spacetype[1].to_s).strip }
|
|
104
|
-
end
|
|
105
|
-
# construction_sets
|
|
106
|
-
|
|
107
|
-
construction_sets.each do |row|
|
|
108
|
-
target_space_type = "#{row['template'].gsub(/\s+/, "") + '-' + row['building_type']}-#{row['space_type']}".strip
|
|
109
|
-
unless valid_space_types.include?(target_space_type.to_s)
|
|
110
|
-
bad_records[:invalid_space_type_names] << {template: row['template'].gsub(/\s+/, ""), space_type: target_space_type}
|
|
111
|
-
end
|
|
112
|
-
end
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
# Check if # of floors contains 1 to 999
|
|
116
|
-
#Get Unique spacetypes.
|
|
117
|
-
bad_evelope_story_ranges = []
|
|
118
|
-
space_types = construction_sets.map { |row| {template: row["template"], building_type: row["building_type"], space_type: row["space_type"]} }.uniq
|
|
119
|
-
space_types.each do |space_type|
|
|
120
|
-
range = Array.new
|
|
121
|
-
instances = construction_sets.select { |row| row['template'] == space_type[:template] && row['building_type'] == space_type[:building_type] && row['space_type'] == space_type[:space_type] }
|
|
122
|
-
instances.each do |instance|
|
|
123
|
-
min_val = instance['min_stories'].to_i
|
|
124
|
-
min_val = 0 if min_val == 1
|
|
125
|
-
max_val = instance['max_stories'].to_i
|
|
126
|
-
range << min_val
|
|
127
|
-
range << max_val
|
|
128
|
-
failed = true
|
|
129
|
-
end
|
|
130
|
-
range.sort!
|
|
131
|
-
incomplete_range = (range.first != 0 or range.last < 999)
|
|
132
|
-
possible_duplicate = (range.uniq.size != range.size)
|
|
133
|
-
if incomplete_range or possible_duplicate
|
|
134
|
-
space_type[:range] = range
|
|
135
|
-
space_type[:error] = {incomplete_range: incomplete_range, possible_duplicate: possible_duplicate}
|
|
136
|
-
bad_records[:min_max_floor_range_errors] << space_type
|
|
137
|
-
end
|
|
138
|
-
end
|
|
139
|
-
if bad_records[:min_max_floor_range_errors].size > 0 or bad_records[:invalid_space_type_names].size > 0
|
|
140
|
-
puts "Errors in ConstructionSets Costing Table."
|
|
141
|
-
puts JSON.pretty_generate(bad_records)
|
|
142
|
-
raise("costing spreadsheet validation failed")
|
|
143
|
-
end
|
|
144
|
-
end
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
# This method verifies that, for a given row the number of items listed in the 'id_layers' column is the same as the
|
|
148
|
-
# number of quantities listed in the 'Id_layers_quantity_multipliers' column in the 'hvac_vent_ahu' sheet in the
|
|
149
|
-
# costing spreadsheet. If there is a difference in the number of items and number of quantities in a row then that
|
|
150
|
-
# row needs to be investigated and fixed.
|
|
151
|
-
def validate_ahu_items_and_quantities()
|
|
152
|
-
# Find out if there are a different number of items and number oof quantities in any row of the 'hvac_vent_ahu'
|
|
153
|
-
# sheet.
|
|
154
|
-
diff_id_quantities = @db['raw']['hvac_vent_ahu'].select{|data| data['id_layers'].to_s.split(',').size != data['Id_layers_quantity_multipliers'].to_s.split(',').size}
|
|
155
|
-
# If there is a difference (that is the diff_id_quantities has something in it) then raise an error.
|
|
156
|
-
unless diff_id_quantities.empty?
|
|
157
|
-
puts "Errors in the hvac_vent_ahu Costing Table. The number of id_layers does not match the number of"
|
|
158
|
-
puts "Id_layers_quantity_multipliers for the following item(s):"
|
|
159
|
-
puts JSON.pretty_generate(diff_id_quantities)
|
|
160
|
-
raise("costing spreadsheet validation failed")
|
|
161
|
-
end
|
|
162
|
-
end
|
|
163
|
-
|
|
164
|
-
# Overload the element of operator for database accesses
|
|
165
|
-
def [](element)
|
|
166
|
-
@db[element]
|
|
167
|
-
end
|
|
168
|
-
|
|
169
|
-
# Overload the element assignment operator for inputting additional data
|
|
170
|
-
def []=(element, value)
|
|
171
|
-
@db[element] = value
|
|
172
|
-
end
|
|
173
|
-
end
|