Skip to content

Conversation

@jmarrec
Copy link
Contributor

@jmarrec jmarrec commented Mar 17, 2025

Pull request overview

Link to the Ubuntu 22.04 .deb installer to use for CI Testing. If not set, it will default to latest official release.
[OpenStudio Installer]: http://openstudio-ci-builds.s3-website-us-west-2.amazonaws.com/PR-5369/OpenStudio-3.10.0-alpha%2Bea0e2a7b64-Ubuntu-22.04-x86_64.deb

This Pull Request is concerning:

  • Case 1 - NewTest: a new test for a new model API class,

Case 1: New test for a new model API class

Please include which class(es) you are adding a test to specifically test for.
Include a link to the OpenStudio Pull Request in which you are adding the new classes, or the class itself if already on develop.

Work Checklist

The following has been checked to ensure compliance with the guidelines:

  • Tests pass either:

    • with current develop (incude SHA):
      • The label PendingOSM has been added to this PR
      • A matching OSM test has not yet been added because the official release is pending, but model_tests.rb has a TODO
      • No out.osw have been committed as they need to be run with an official OpenStudio version
  • Ruby test is stable: when run multiple times on the same machine, it produces the same total site kBTU.
    Please paste the heatmap png generated after running the following commands:

    • I ensured that I assign systems/loads/etc in a repeatable manner (eg: if I assign stuff to thermalZones, I do model.getThermalZones.sort_by{|z| z.name.to_s}.each do ... so I am sure I put the same ZoneHVAC systems to the same zones regardless of their order)
    • I tested stability using process_results.py (see python process_results.py --help for usage).
  • Object has been added to autosize_hvac.rb to ensure the autosizedXXX values methods do work: N/A


Review Checklist

  • Code style (indentation, variable names, strip trailing spaces)
  • Functional code review (it has to work!)
  • Matching OSM test has been added or # TODO added to model_tests.rb
  • Appropriate out.osw have been committed
  • Test is stable
  • Object is tested in autosize_hvac as appropriate
  • The appropriate labels have been added to this PR:
    • One of: NewTest, TestFix, NewTestForExisting, Other
    • If NewTest: add PendingOSM or AddedOSM

@jmarrec jmarrec added NewTest PR type: a new test for a new model API class PendingOSM A matching OSM test has yet to be added with the next official OpenStudio Release labels Mar 17, 2025
@jmarrec jmarrec self-assigned this Mar 17, 2025
Comment on lines +1354 to +1366
def test_output_tables_rb
result = sim_test('output_tables.rb')
end

def test_output_tables_py
result = sim_test('output_tables.py')
end

# TODO: To be added in the next official release after: 3.9.0
# def test_output_tables_osm
# result = sim_test('output_tables.osm')
# end

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New Ruby + Python test, with a TODO

Comment on lines 49 to 141
###############################################################################
# OUTPUT:TABLE:MONTHLY #
###############################################################################

# Factory method to creates a OutputTableMonthly from the E+ datasets/StandardReports.idf
# Please use the OutputTableMonthly::validStandardReportNames() static method
# to look up the valid names as it will throw if it cannot find it
standardReportName = OpenStudio::Model::OutputTableMonthly.validStandardReportNames.sort.reverse[0]
output_table_monthly = OpenStudio::Model::OutputTableMonthly.fromStandardReports(model, standardReportName)

# You can of course create one yourself
output_table_monthly = OpenStudio::Model::OutputTableMonthly.new(model)
output_table_monthly.setName('Fan Report')
output_table_monthly.setDigitsAfterDecimal(4)

# To add a group, you can use the convenience method
# bool addMonthlyVariableGroup(std::string variableOrMeterName, std::string aggregationType = "SumOrAverage");

groups = [
# variableOrMeterName, SumOrAverage
['Fan Electricity Energy', 'SumOrAverage'],
['Fan Rise in Air Temperature', 'SumOrAverage'],
['Fan Electricity Rate', 'Maximum'],
['Fan Rise in Air Temperature', 'ValueWhenMaximumOrMinimum'],
]
output_table_monthly.addMonthlyVariableGroup(groups[0][0], groups[0][1])

# This will in turn actually use the helper class MonthlyVariableGroup
output_table_monthly.addMonthlyVariableGroup(OpenStudio::Model::MonthlyVariableGroup.new(groups[1][0], groups[1][1]))

raise unless output_table_monthly.numberofMonthlyVariableGroups == 2
# This is a vector of MonthlyVariableGroup
raise unless output_table_monthly.monthlyVariableGroups.size == 2
first_monthly_group = output_table_monthly.monthlyVariableGroups.first
# This returns an OptionalMonthlyVariableGroup
first_monthly_group_ = output_table_monthly.getMonthlyVariableGroup(0)
raise unless first_monthly_group_.is_initialized
# The equality operator is defined to check for both variableOrMeterName and
# aggregationType
raise unless first_monthly_group == first_monthly_group_.get
raise unless first_monthly_group.variableOrMeterName == 'Fan Electricity Energy'
raise unless first_monthly_group.aggregationType == 'SumOrAverage'

output_table_monthly.removeMonthlyVariableGroup(1)
output_table_monthly.removeAllMonthlyVariableGroups

# There is also a batch add
monthly_groups = groups.map { |g| OpenStudio::Model::MonthlyVariableGroup.new(g[0], g[1]) }
output_table_monthly.addMonthlyVariableGroups(monthly_groups)
raise unless output_table_monthly.numberofMonthlyVariableGroups == 4

###############################################################################
# OUTPUT:TABLE:ANNUAL #
###############################################################################

output_table_annual = OpenStudio::Model::OutputTableAnnual.new(model)
output_table_annual.setName("Electricity Report")
output_table_annual.setSchedule(model.alwaysOnDiscreteSchedule)
output_table_annual.setFilter("Zone 1")
output_table_annual.resetFilter

groups = [
#variableorMeterorEMSVariableorField, aggregationType, digitsAfterDecimal
['Electricity:Facility', 'SumOrAverage', 3],
['Electricity:Facility', 'Maximum', 1],
]

output_table_annual.addAnnualVariableGroup(groups[0][0], groups[0][1], groups[0][2])

# This will in turn actually use the helper class AnnualVariableGroup
output_table_annual.addAnnualVariableGroup(OpenStudio::Model::AnnualVariableGroup.new(groups[1][0], groups[1][1], groups[1][2]))

raise unless output_table_annual.numberofAnnualVariableGroups == 2
# This is a vector of AnnualVariableGroup
raise unless output_table_annual.annualVariableGroups.size == 2
first_annual_group = output_table_annual.annualVariableGroups.first
# This returns an OptionalAnnualVariableGroup
first_annual_group_ = output_table_annual.getAnnualVariableGroup(0)
raise unless first_annual_group_.is_initialized
# The equality operator is defined to check for both variableorMeterorEMSVariableorField and
# aggregationType
raise unless first_annual_group == first_annual_group_.get
raise unless first_annual_group.variableorMeterorEMSVariableorField == 'Electricity:Facility'
raise unless first_annual_group.aggregationType == 'SumOrAverage'
raise unless first_annual_group.digitsAfterDecimal == 3

output_table_annual.removeAnnualVariableGroup(1)
output_table_annual.removeAllAnnualVariableGroups

# There is also a batch add
annual_groups = groups.map { |g| OpenStudio::Model::AnnualVariableGroup.new(g[0], g[1], g[2]) }
output_table_annual.addAnnualVariableGroups(annual_groups)
raise unless output_table_annual.numberofAnnualVariableGroups == 2
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fully demo the extensible API.

…on 1f4d455848) [x86_64-linux], Rubocop 0.81.0)
Copy link
Contributor

@joseph-robertson joseph-robertson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neither of these (Monthly or Annual) is a unique object, right? Should we test when there are multiple of each? What about Annual's schedule -- should we test when it's not always On?

@jmarrec
Copy link
Contributor Author

jmarrec commented Mar 19, 2025

Neither are unique indeed, and there's no problem instantiating several objects, and we don't have a precedent for testing non-uniqueness I think. This test I added has two Monthly ones too.

the OutputTableAnnual_Gtest test (C++) already checks assigning a scheduleconstant. I suppose one thing I could do is to test that the ScheduleTypeRegistry is properly working (something we seldom do, but perhaps we should, I recently fixed an issue related to that)

jmarrec added a commit to NREL/OpenStudio that referenced this pull request Mar 19, 2025
@jmarrec
Copy link
Contributor Author

jmarrec commented Mar 19, 2025

Tested ScheduleTypeRegistry here: NREL/OpenStudio@1445362

@jmarrec jmarrec merged commit 9de5162 into develop Mar 19, 2025
@jmarrec jmarrec deleted the 5368-OutputTable branch March 19, 2025 09:24
@jmarrec jmarrec added AddedOSM A matching OSM test has been added with an official OpenStudio release and removed PendingOSM A matching OSM test has yet to be added with the next official OpenStudio Release labels Jun 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AddedOSM A matching OSM test has been added with an official OpenStudio release NewTest PR type: a new test for a new model API class

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants