Skip to content

Commit

Permalink
Merge pull request #98 from BuildingSync/fix/97
Browse files Browse the repository at this point in the history
fix/97 - simulation issues
  • Loading branch information
corymosiman12 authored Dec 16, 2020
2 parents 4928579 + 4d6c5c1 commit fe0673e
Show file tree
Hide file tree
Showing 106 changed files with 35,736 additions and 11,050 deletions.
37 changes: 29 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,31 +31,52 @@ jobs:
- $SH "bundle exec rspec spec/tests/model_articulation_test/facility_spec.rb"
- $SH "bundle exec rspec spec/tests/model_articulation_test/hvac_system_spec.rb"
- $SH "bundle exec rspec spec/tests/model_articulation_test/loads_system_spec.rb"
- $SH "bundle exec rspec spec/tests/model_articulation_test/lighting_system_type_spec.rb"
- $SH "bundle exec rspec spec/tests/model_articulation_test/service_hot_water_system_spec.rb"
- $SH "bundle exec rspec spec/tests/model_articulation_test/site_spec.rb"
# - $SH "bundle exec rspec spec/tests/model_articulation_test/weather_file_download_spec.rb" // fails sometimes due to connection issues, so we exclude it here
name: "Model Articulation Tests"
- script:
- travis_wait 40 $SH "bundle exec rspec spec/tests/model_articulation_test/hospital_occupancy_type_spec.rb"
name: "Model Articulation Hospital Occupancy Type Spec"
- script:
- $SH "bundle exec rspec spec/tests/model_articulation_test/occupancy_types_spec.rb"
name: "Model Articulation Occupancy Types Spec"
- script:
- travis_wait 50 $SH "bundle exec rspec spec/tests/translator_spec.rb"
name: "Translator Spec"
- script:
- travis_wait 40 $SH "bundle exec rspec spec/tests/model_articulation_test/hospital_occupancy_type_spec.rb"
name: "Hospital Occupancy Type Spec"
- $SH "bundle exec rspec spec/tests/translator_sizing_run_spec.rb"
name: "Translator Sizing Run Spec"
- script:
- $SH "bundle exec rspec spec/tests/translator_baseline_simulation_spec.rb"
name: "Translator Perform SR and Baseline Simulation Spec"
- script:
- $SH "bundle exec rspec spec/tests/model_articulation_test/occupancy_types_spec.rb"
name: "Occupancy Types Spec"
- $SH "bundle exec rspec spec/tests/translator_baseline_gather_save_spec.rb"
name: "Translator Perform SR and Baseline Simulations, Gather and Save Results Spec"
- script:
- $SH "bundle exec rspec spec/tests/translator_baseline_generation_spec.rb"
- $SH "bundle exec rspec spec/tests/translator_scenario_generation_spec.rb"
name: "Translator Generation Specs"
- script:
- $SH "bundle exec rspec spec/tests/translator_baseline_simulation_spec.rb"
name: "Translator Baseline Simulation Spec"
- script:
- $SH "bundle exec rspec spec/tests/translator_scenario_simulations_spec.rb"
name: "Translator Scenario Simulation Spec"
- script:
- $SH "bundle exec rspec spec/tests/report_spec.rb"
- $SH "bundle exec rspec spec/tests/utility_spec.rb"
- $SH "bundle exec rspec spec/tests/scenario_spec.rb"
- $SH "bundle exec rspec spec/tests/time_series_spec.rb"
- $SH "bundle exec rspec spec/tests/resource_use_spec.rb"
- $SH "bundle exec rspec spec/tests/all_resource_total_spec.rb"
name: "Report and Scenario Related Specs"
- script:
- $SH "bundle exec rspec spec/tests/workflow_maker_spec.rb"
name: "WorkflowMaker Spec"
- script:
- $SH "bundle exec rspec spec/tests/building_sync_spec.rb"
- $SH "bundle exec rspec spec/tests/epw_test_spec.rb"
- $SH "bundle exec rspec spec/tests/constants_spec.rb"
- $SH "bundle exec rspec spec/tests/generator_spec.rb"
- $SH "bundle exec rspec spec/tests/helper_spec.rb"
- $SH "bundle exec rspec spec/tests/xml_get_set_spec.rb"
# - $SH "bundle exec rspec spec/tests/selection_tool_spec.rb" # selection tool is not working with ASHRAE level 1.5 yet
name: "Other Specs"
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

source 'http://rubygems.org'

gemspec
Expand Down
28 changes: 22 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,34 @@ Or install it yourself as:
All of the features described above are provided by the translator class, as shown in the following sample code:

```ruby
building_sync_xml_file_path = 'path/to/bsync.xml'
out_path = 'path/to/output_dir'

# initializing the translator
translator = BuildingSync::Translator.new(building_sync_xml_file_path, out_path)
# generating the OpenStudio Model and writing the osm file
translator.write_osm

# generating the OpenStudio Model and writing the osm file.
# path/to/output_dir/SR and path/to/output_dir/in.osm created
translator.setup_and_sizing_run

# generating the OpenStudio workflows and writing the osw files
# auc:Scenario elements with measures are turned into new simulation dirs
# path/to/output_dir/scenario_name
translator.write_osws
# running the baseline simulations
translator.run_osm
# running all simulations

# running the baseline simulation
# path/to/output_dir/Baseline/in.osm
translator.run_baseline_osm

# run all simulations
translator.run_osws
# gather the results and save them to an BuildingSync.XML

# gather the results for all scenarios found in out_path
translator.gather_results(out_path)

# write results to xml
save_file = File.join(out_path, 'results.xml')
translator.save_xml(save_file)
```
## Testing

Expand Down
27 changes: 27 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# *******************************************************************************
# OpenStudio(R), Copyright (c) 2008-2020, Alliance for Sustainable Energy, LLC.
# All rights reserved.
Expand Down Expand Up @@ -47,4 +49,29 @@ require 'openstudio/model_articulation'
rake_task = OpenStudio::Extension::RakeTask.new
rake_task.set_extension_class(OpenStudio::ModelArticulation::Extension)

desc 'Convert tabs to spaces'
task :remove_tabs do
Dir['examples/**/*.xml', 'BuildingSync.xsd'].each do |file|
puts " Cleaning #{file}"
doc = Nokogiri.XML(File.read(file)) do |config|
config.default_xml.noblanks
end

doc.xpath('//comment()').each do |node|
if node.text.match?(/XMLSpy/)
node.remove
end
end

File.open(file, 'w') { |f| f << doc.to_xml(indent: 2) }
end

if File.exist? 'BuildingSync.json'
f = JSON.parse(File.read('BuildingSync.json'))
File.open('BuildingSync.json', 'w') do |file|
file << JSON.pretty_generate(f)
end
end
end

task default: :spec
1 change: 1 addition & 0 deletions bin/console
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require 'bundler/setup'
require 'buildingsync'
Expand Down
2 changes: 2 additions & 0 deletions buildingsync.gemspec
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

lib = File.expand_path('lib', __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'buildingsync/version'
Expand Down
2 changes: 2 additions & 0 deletions lib/buildingsync.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# *******************************************************************************
# OpenStudio(R), Copyright (c) 2008-2020, Alliance for Sustainable Energy, LLC.
# BuildingSync(R), Copyright (c) 2015-2020, Alliance for Sustainable Energy, LLC.
Expand Down
54 changes: 54 additions & 0 deletions lib/buildingsync/all_resource_total.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# frozen_string_literal: true

# *******************************************************************************
# OpenStudio(R), Copyright (c) 2008-2020, Alliance for Sustainable Energy, LLC.
# BuildingSync(R), Copyright (c) 2015-2020, Alliance for Sustainable Energy, LLC.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# (1) Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# (2) Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# (3) Neither the name of the copyright holder nor the names of any contributors
# may be used to endorse or promote products derived from this software without
# specific prior written permission from the respective party.
#
# (4) Other than as required in clauses (1) and (2), distributions in any form
# of modifications or other derivative works may not use the "OpenStudio"
# trademark, "OS", "os", or any other confusingly similar designation without
# specific prior written permission from Alliance for Sustainable Energy, LLC.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND ANY CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S), ANY CONTRIBUTORS, THE
# UNITED STATES GOVERNMENT, OR THE UNITED STATES DEPARTMENT OF ENERGY, NOR ANY OF
# THEIR EMPLOYEES, BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
# OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# *******************************************************************************

module BuildingSync
# AllResourceTotal class
class AllResourceTotal
include BuildingSync::Helper
include BuildingSync::XmlGetSet
# @param base_xml [REXML::Element]
# @param ns [String]
def initialize(base_xml, ns)
@base_xml = base_xml
@ns = ns

help_element_class_type_check(base_xml, 'AllResourceTotal')
end
end
end
54 changes: 54 additions & 0 deletions lib/buildingsync/audit_date.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# frozen_string_literal: true

# *******************************************************************************
# OpenStudio(R), Copyright (c) 2008-2020, Alliance for Sustainable Energy, LLC.
# BuildingSync(R), Copyright (c) 2015-2020, Alliance for Sustainable Energy, LLC.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# (1) Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# (2) Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# (3) Neither the name of the copyright holder nor the names of any contributors
# may be used to endorse or promote products derived from this software without
# specific prior written permission from the respective party.
#
# (4) Other than as required in clauses (1) and (2), distributions in any form
# of modifications or other derivative works may not use the "OpenStudio"
# trademark, "OS", "os", or any other confusingly similar designation without
# specific prior written permission from Alliance for Sustainable Energy, LLC.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND ANY CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S), ANY CONTRIBUTORS, THE
# UNITED STATES GOVERNMENT, OR THE UNITED STATES DEPARTMENT OF ENERGY, NOR ANY OF
# THEIR EMPLOYEES, BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
# OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# *******************************************************************************

module BuildingSync
# AuditDate class
class AuditDate
include BuildingSync::Helper
include BuildingSync::XmlGetSet
# @param base_xml [REXML::Element]
# @param ns [String]
def initialize(base_xml, ns)
@base_xml = base_xml
@ns = ns

help_element_class_type_check(base_xml, 'AuditDate')
end
end
end
48 changes: 48 additions & 0 deletions lib/buildingsync/constants.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# frozen_string_literal: true

# *******************************************************************************
# OpenStudio(R), Copyright (c) 2008-2020, Alliance for Sustainable Energy, LLC.
# BuildingSync(R), Copyright (c) 2015-2020, Alliance for Sustainable Energy, LLC.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# (1) Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# (2) Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# (3) Neither the name of the copyright holder nor the names of any contributors
# may be used to endorse or promote products derived from this software without
# specific prior written permission from the respective party.
#
# (4) Other than as required in clauses (1) and (2), distributions in any form
# of modifications or other derivative works may not use the "OpenStudio"
# trademark, "OS", "os", or any other confusingly similar designation without
# specific prior written permission from Alliance for Sustainable Energy, LLC.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND ANY CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S), ANY CONTRIBUTORS, THE
# UNITED STATES GOVERNMENT, OR THE UNITED STATES DEPARTMENT OF ENERGY, NOR ANY OF
# THEIR EMPLOYEES, BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
# OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# *******************************************************************************

SCHEMA_2_0_URL = 'https://raw.githubusercontent.com/BuildingSync/schema/v2.0/BuildingSync.xsd'
SCHEMA_2_2_0_URL = 'https://raw.githubusercontent.com/BuildingSync/schema/v2.2.0/BuildingSync.xsd'
PHASE_0_BASE_OSW_FILE_PATH = File.expand_path(File.join(__dir__, 'makers/phase_zero_base.osw'))
WORKFLOW_MAKER_JSON_FILE_PATH = File.expand_path(File.join(__dir__, 'makers/workflow_maker.json'))
BUILDING_AND_SYSTEMS_FILE_PATH = File.expand_path(File.join(__dir__, 'model_articulation/building_and_system_types.json'))

# Standards strings
ASHRAE90_1 = 'ASHRAE90.1'
CA_TITLE24 = 'CaliforniaTitle24'
54 changes: 54 additions & 0 deletions lib/buildingsync/contact.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# frozen_string_literal: true

# *******************************************************************************
# OpenStudio(R), Copyright (c) 2008-2020, Alliance for Sustainable Energy, LLC.
# BuildingSync(R), Copyright (c) 2015-2020, Alliance for Sustainable Energy, LLC.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# (1) Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# (2) Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# (3) Neither the name of the copyright holder nor the names of any contributors
# may be used to endorse or promote products derived from this software without
# specific prior written permission from the respective party.
#
# (4) Other than as required in clauses (1) and (2), distributions in any form
# of modifications or other derivative works may not use the "OpenStudio"
# trademark, "OS", "os", or any other confusingly similar designation without
# specific prior written permission from Alliance for Sustainable Energy, LLC.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND ANY CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S), ANY CONTRIBUTORS, THE
# UNITED STATES GOVERNMENT, OR THE UNITED STATES DEPARTMENT OF ENERGY, NOR ANY OF
# THEIR EMPLOYEES, BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
# OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# *******************************************************************************

module BuildingSync
# Contact class
class Contact
include BuildingSync::Helper
include BuildingSync::XmlGetSet
# @param base_xml [REXML::Element]
# @param ns [String]
def initialize(base_xml, ns)
@base_xml = base_xml
@ns = ns

help_element_class_type_check(base_xml, 'Contact')
end
end
end
2 changes: 2 additions & 0 deletions lib/buildingsync/extension.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# *******************************************************************************
# OpenStudio(R), Copyright (c) 2008-2020, Alliance for Sustainable Energy, LLC.
# BuildingSync(R), Copyright (c) 2015-2020, Alliance for Sustainable Energy, LLC.
Expand Down
Loading

0 comments on commit fe0673e

Please sign in to comment.