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

fix electricity emissions column being used by total with mid case sum #246

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,7 @@ lib/
/sampling/truth_data
*.pyc
report.xml

# Rubocop output
/.rubocop
/.rubocop-http*
25 changes: 25 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

AllCops:
Exclude:
- 'build/**/*'
- 'documentation/**/*'
- 'national/**/*'
- 'postprocessing/**/*'
- 'samples/**/*'
- 'sampling/**/*'
- 'test/**/*'
- 'ymls/**/*'
NewCops: enable

inherit_from:
- http://s3.amazonaws.com/openstudio-resources/styles/rubocop.yml

# custom edits to rubocop checks
Metrics/AbcSize:
Max: 200

Metrics/BlockLength:
Max: 100

Style/FrozenStringLiteralComment:
Enabled: false
27 changes: 20 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,32 @@ This is needed if you are a developer making changes to `openstudio-standards` o
7. Contents: `require "C:/openstudio-3.8.0/Ruby/openstudio.rb"` Modify `3.8.0` to the version you installed.
8. Save it here: `C:/Ruby32-x64/lib/ruby/site_ruby/openstudio.rb`

4. `gem install bundler` This installs the `bundler` ruby gem.
4. `gem install bundler:2.4.10` This installs the version of bundler needed for ComStock.
5. Install [Git](https://git-scm.com/).
6. Install [GitHub desktop](https://desktop.github.com/) or another GUI that makes Git easier to use.
7. Clone the [ComStock source code](https://github.com/NREL/ComStock.git) using GitHub desktop (easier) or Git (harder).
8. Run all commands below from the top level `/ComStock` directory
13. `mkdir .custom_gems` This makes a temp directory to install required gems inside.
13. `copy /Y .\resources\Gemfile .\.custom_gems\Gemfile` This copies the Gemfile to the temp directory.
13. `gem install bundler:2.4.10` This installs the version of bundler needed by OpenStudio.
13. `bundle _2.4.10_ install --path "C:/GitRepos/ComStock/.custom_gems" --gemfile "C:/GitRepos/ComStock/.custom_gems/Gemfile" --without test` This will install all ruby gems necessary to develop this code.
14. If running simulations locally, install [BuildStock Batch](https://buildstockbatch.readthedocs.io/en/stable/installation.html#local)
15. Add the following additional Python packages into your `buildstockbatch` environment:
9. `mkdir .custom_gems` This makes a temp directory to install required gems inside.
10. `copy /Y .\resources\Gemfile .\.custom_gems\Gemfile` This copies the Gemfile to the temp directory.
11. `bundle _2.4.10_ install --path "C:/GitRepos/ComStock/.custom_gems" --gemfile "C:/GitRepos/ComStock/.custom_gems/Gemfile" --without test` This will install all ruby gems necessary to develop this code.
12. If running simulations locally, install [BuildStock Batch](https://buildstockbatch.readthedocs.io/en/stable/installation.html#local)
13. Add the following additional Python packages into your `buildstockbatch` environment:
```bash
conda activate buildstockbatch
pip install GHEDesigner==1.0
pip install NREL-PySAM==4.2.0
```

## Measure Tests
1. Follow the developer installation instructions above. In particular, `GHEDesigner==1.0` must be installed with `pip install GHEDesigner==1.0`.
2. Run the measure tests with the rake command:
- `bundle exec rake unit_tests:all_tests` to run all measure tests.
- `bundle exec rake unit_tests:reporting_measure_tests` to run all reporting measure tests.
- `bundle exec rake unit_tests:workflow_measure_tests` to run all workflow measure tests.
- `bundle exec rake unit_tests:upgrade_measure_tests` to run all `upgrade_` measure tests.

## Running Rubocop
1. Follow the developer installation instructions above
2. navigate to the `resources/` directory
3. run `bundle exec rake rubocop:show` in terminal
4. review results by opening the `rubocop-results.html` in the `.rubocop/` directory
115 changes: 78 additions & 37 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,48 +1,89 @@
require 'rake'
require 'rake/testtask'
require 'minitest/reporters' # Require the gem
require 'minitest/reporters'
require 'parallel'
require 'rubocop/rake_task'

# Configure the JUnit reporter

desc 'Perform tasks related to unit tests'
desc 'Run measure tests'
namespace :unit_tests do
desc 'Run measure tests'
Rake::TestTask.new('measure_tests') do |t|
MEASURETESTS_PATH = "test/measure_tests.txt"
if File.exist?(MEASURETESTS_PATH)
# load test files from file.
full_file_list = FileList.new(File.readlines(MEASURETESTS_PATH).map(&:chomp))
full_file_list.select! { |item| item.include?('rb')}
p full_file_list
desc 'Run all measure tests'
task :all_tests => [:measure_tests, :workflow_measure_tests, :upgrade_measure_tests] do
puts 'Running all measure tests:'
end

desc 'Run reporting measure tests'
task :reporting_measure_tests do
puts 'Running all reporting measure tests:'
# load test files from file
file_list = FileList.new(File.readlines('test/reporting_measure_tests.txt').map(&:chomp))
file_list.select! { |item| item.include?('rb') && File.exist?(item) }
Parallel.each(file_list, in_processes: Parallel.processor_count) do |file|
puts "Running test #{file} in process #{Process.pid}"
load file
true
rescue StandardError => e
puts "Error in #{file}: #{e.message}"
Minitest::Reporters.reporter.report_error(file, e)
false
end
t.test_files = full_file_list
p(full_file_list)
t.verbose = false
t.warning = false
end

Rake::TestTask.new('resource_measure_tests') do |t|
RESOURCE_MEASURETESTS_PATH = "test/resource_measure_tests.txt"
if File.exist?(RESOURCE_MEASURETESTS_PATH)
# load test files from file.
full_file_list = FileList.new(File.readlines(RESOURCE_MEASURETESTS_PATH).map(&:chomp))
full_file_list.select! { |item| item.include?('rb') && File.exist?(item) }
p full_file_list
desc 'Run workflow measure tests'
task :workflow_measure_tests do
puts 'Running all workflow measure tests:'
# load test files from file
file_list = FileList.new(File.readlines('test/workflow_measure_tests.txt').map(&:chomp))
file_list.select! { |item| item.include?('rb') && !item.include?('upgrade') && File.exist?(item) }
Parallel.each(file_list, in_processes: Parallel.processor_count) do |file|
puts "Running test #{file} in process #{Process.pid}"
load file
true
rescue StandardError => e
puts "Error in #{file}: #{e.message}"
Minitest::Reporters.reporter.report_error(file, e)
false
end
t.test_files = full_file_list.select do |file|
begin
# Try to load the file to check for syntax errors
load file
true
rescue Exception => e
puts "Error in #{file}: #{e.message}"
Minitest::Reporters.reporter.report_error(file, e)
false
end
end

desc 'Run upgrade measure tests'
task :upgrade_measure_tests do
puts 'Running all upgrade measure tests:'
# load test files from file
file_list = FileList.new(File.readlines('test/upgrade_measure_tests.txt').map(&:chomp))
file_list.select! { |item| item.include?('rb') && item.include?('upgrade') && File.exist?(item) }
Parallel.each(file_list, in_processes: Parallel.processor_count) do |file|
puts "Running test #{file} in process #{Process.pid}"
load file
true
rescue StandardError => e
puts "Error in #{file}: #{e.message}"
Minitest::Reporters.reporter.report_error(file, e)
false
end
p(full_file_list)
t.verbose = false
t.warning = false
end
end

desc 'Check the code for style consistency'
RuboCop::RakeTask.new(:rubocop) do |t|
# Make a folder for the output
out_dir = '.rubocop'
FileUtils.mkdir_p(out_dir)
# Output both XML (CheckStyle format) and HTML
t.options = ["--out=#{out_dir}/rubocop-results.xml", '--format=h', "--out=#{out_dir}/rubocop-results.html", '--format=offenses', "--out=#{out_dir}/rubocop-summary.txt"]
t.requires = ['rubocop/formatter/checkstyle_formatter']
t.formatters = ['RuboCop::Formatter::CheckstyleFormatter']
# don't abort rake on failure
t.fail_on_error = false
end

desc 'Show the rubocop output in a web browser'
task 'rubocop:show' => [:rubocop] do
link = "#{__dir__}/.rubocop/rubocop-results.html"
case RbConfig::CONFIG['host_os']
when /mswin/, /mingw/, /cygwin/
system "start #{link}"
when /darwin/
system "open #{link}"
when /linux/, /bsd/
system "xdg-open #{link}"
end
end
5 changes: 4 additions & 1 deletion documentation/reference_doc/4_2_meta.tex
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,7 @@ \subsection{Space Type Ratios}
\subsection{Weather Data}
ComStock can be run with two different types of weather data: typical meteorological year (TMY3) and actual meteorological year (AMY). AMY data is the data measured during a specific year, taken from weather stations such as those at airports. Because these data are from a particular calendar year, weather patterns that span large areas, such as nationwide heat waves, are captured in the data across multiple locations. Therefore, these weather patterns are captured in the outputs of ComStock. This is important for use cases where coordinated weather patterns influence loads, such as peak load impacts for bulk power grid planning. TMY3 data, in contrast, take the ``most typical'' weather for each calendar month from a 30-year historical record and stitch these months together to form a complete year. The advantage of this method is that the weather data is less influenced by an extremely hot or cold year. However, this approach does not capture wide-area weather patterns, as the month of data used varies from location to location. For a more in-depth discussion of AMY and TMY3 weather data, see \cite{eulp_final_report}.

For geographic granularity, ComStock currently uses one weather file for each county in the United States. For counties with no weather data available (generally sparsely populated rural areas), data from the nearest weather station in the same climate zone are used. See \citep{eulp_final_report} for a more in-depth discussion of the weather data sources, cleaning process, and assignment assumptions.
For geographic granularity, ComStock currently uses one weather file for each county in the United States. For counties with no weather data available (generally sparsely populated rural areas), data from the nearest weather station in the same climate zone are used. See \citep{eulp_final_report} for a more in-depth discussion of the weather data sources, cleaning process, and assignment assumptions.

\subsection{Soil Properties}
Soil thermal conductivity and undisturbed ground temperature are location-dependent properties that are required in the ComStock model by several goethermal heat pump upgrade measures. Therefore, these properties are part of the ComStock sampling workflow and are stored as additionl properties in the building models, which can then be used by downstream measures. Soil thermal conductivity distributions by climate zone were dervied from a dataset produced by the Southern Methodist University Geothermal Lab, and are shown in Table \ref{fig:soil_conductivity} (\cite{smu_soil_conductivity}). The soil thermal conductivity values range from 0.5 to 2.6 W/m-K. Average undisturbed ground temperatures by climate zone were derived from a 2014 Oklahoma State University study and are shown in Table \ref{tab:undisturbed_ground_temp} (\cite{xing2014}).
2 changes: 1 addition & 1 deletion documentation/reference_doc/4_7_plug_and_process.tex
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ \subsection{Kitchen Equipment}

ComStock uses published data to create representative probability distributions of commercial cooking equipment counts, by building type, for both gas and electric appliances. Additionally, the equipment distributions are scaled by area to represent the non-linear scaling suggested in the literature. Although other building types likely include some degree of cooking equipment as well, such as larger offices (\cite{eia2012cbecs}), the current implementation of ComStock only includes cooking equipment in the previously-mentioned six building types plus quick service restaurants found in strip malls.

Commercial kitchens can contain electric or gas cooking equipment, or a mix of both. The prevalence of gas and electric fuel types for each equipment type and the rated powers used in ComStock are derived from a DOE study (\cite{goetzler_commercial_appliances}). These are shown in Table~\ref{tab:kitchen_prev_and_power}.
Commercial kitchens can contain electric or gas cooking equipment, or a mix of both. The prevalence of gas and electric fuel types for each equipment type used in ComStock are derived from a DOE study (\cite{goetzler_commercial_appliances}). ComStock requires rated input power values and fractions of radiant, latent, and lost heat for gas and electric kitchen equipment. These values are primarily derived from the ASHRAE Fundamentals Handbook (\cite{ashrae2017}) after comparisons with other kitchen equipment studies and commercially available products. More details about how these values were determined can be found in the End Use Savings Shapes documentation (\cite{nrel89130}).The assumptions used in ComStock for prevalence, rated input power, and fractions radiant, latent, and lost for gas and electric appliances are shown in Table~\ref{tab:kitchen_prev_and_power}.

\input{tables/kitchen_prev_and_power}

Expand Down
1 change: 1 addition & 0 deletions documentation/reference_doc/6_AppendixA.tex
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,4 @@

\input{tables/kitchen_cook_counts}

\input{tables/undisturbed_ground_temp}
10 changes: 9 additions & 1 deletion documentation/reference_doc/7_AppendixB.tex
Original file line number Diff line number Diff line change
Expand Up @@ -460,4 +460,12 @@
\centering \includegraphics[width=1.0\textwidth]{figures/refrigeration_LTnew.png}
\caption[Compressor performance for large, new, low temperature compressors]{Power and capacity values as a function of suction and discharge temperature for large, new, low-temperature compressors.}
\label{fig:refrig_lt_new}
\end{figure}
\end{figure}

\begin{figure} [ht!]
\includegraphics[width=0.8\textwidth]{figures/soil_conductivity.png}
\centering
\caption[Soil thermal conductivity distributions by climate zone]{Soil thermal conductivity distributions by climate zone.}
\label{fig:soil_conductivity}
\end{figure}

37 changes: 35 additions & 2 deletions documentation/reference_doc/bibliography.bib
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ @misc{trane_foundation
}

@misc{carrier_economiser,
title = {Carrier Economi$er},
title = {Carrier Economizer},
author = {{Carrier}},
year = 2023,
}
Expand Down Expand Up @@ -690,7 +690,7 @@ @misc{zip_to_util
}

@misc{tract_to_zip,
author = {{HUD PD&R}},
author = {{HUD PD\&R}},
institution = {U.S. Department of Housing and Urban Development Office of Policy Development and Research},
title = {HUD USPS ZIP CODE CROSSWALK FILES},
year = 2023,
Expand All @@ -714,4 +714,37 @@ @misc{atus2018
year = 2018,
howpublished = {https://www.bls.gov/tus/},
note = {Accessed: 2023-11-27}
}

@book{ashrae2017,
title = {ASHRAE Handbook - Fundamentals},
publisher = {American Society of Heating, Refrigerating, and Air-Conditioning Engineers, Inc.},
year = {2017},
address = {Atlanta}
}

@techreport{nrel89130,
author = {Marlena Praprost},
title = {End-Use Savings Shapes Measure Documentation: Electric Cooking Equipment},
institution = {National Renewable Energy Laboratory},
year = {2024},
type = {Technical Report},
number = {89130},
url = {https://www.nrel.gov/docs/fy24osti/89130.pdf}
}

@online{smu_soil_conductivity,
author = {{Dedman College of Humanities and Sciences; Roy M Huffington Department of Earth Sciences}},
title = {SMU Geothermal Lab | Data and Maps | Temperature Maps},
year = {2023},
url = {https://www.smu.edu/dedman/academics/departments/earth-sciences/research/geothermallab/datamaps/temperaturemaps},
note = {Accessed: 15 December 2023}
}

@phdthesis{xing2014,
author = {L. Xing},
title = {Estimations of Undisturbed Ground Temperatures Using Numerical and Analytical Modeling},
school = {Oklahoma State University},
address = {Stillwater, Oklahoma},
year = {2014}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions documentation/reference_doc/main.tex
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
\usepackage[section]{placeins}
\usepackage{pdflscape}
\usepackage{soul}
\usepackage{biblatex}
\hypersetup{colorlinks=true}

% -----------------------------------
Expand All @@ -23,6 +24,8 @@
\author{Amy LeBar}
\author{Janghyun Kim}
\author{Lauren Klun}
\author{Eric Ringold}
\author{Wenyi Kuang}
\affil{National Renewable Energy Laboratory}

\fancypagestyle{plain}{}
Expand Down
Loading