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

BuildResidentialHPXML: make conditional arguments optional #1867

Open
wants to merge 42 commits into
base: master
Choose a base branch
from

Conversation

joseph-robertson
Copy link
Collaborator

@joseph-robertson joseph-robertson commented Oct 23, 2024

Pull Request Description

Change any required arguments that are ignored based on other arguments, to optional.

Remove setDefaultValue from all OpenStudio arguments. Required arguments must now pass a value.

Create a make_argument wrapper for passing in argument name, type, required, etc and determining/creating appropriate OpenStudio arguments automatically:

  • if there is OS-HPXML default (must be optional argument):
    • choice: append "auto" choice
    • boolean: create a choice argument with choices "true", "false", "auto"
    • double/integer: create a string argument ("auto" can be passed in)
  • arguments with OS-HPXML default gets description about OS-HPXML defaults and href appended

Create convertArgumentValues method called from beginning of run method:

  • delete arguments that passed in "auto"
  • "true" to true, "false" to false, "10" to 10, "10.5" to 10.5, etc

Checklist

Not all may apply:

  • Schematron validator (EPvalidator.xml) has been updated
  • Sample files have been added/updated (openstudio tasks.rb update_hpxmls)
  • Tests have been added/updated (e.g., HPXMLtoOpenStudio/tests/test*.rb and/or workflow/tests/test*.rb)
  • Documentation has been updated
  • Changelog has been updated
  • openstudio tasks.rb update_measures has been run
  • No unexpected changes to simulation results of sample files

@joseph-robertson joseph-robertson self-assigned this Oct 23, 2024
@joseph-robertson joseph-robertson marked this pull request as ready for review October 24, 2024 18:10
Copy link
Contributor

@shorowit shorowit left a comment

Choose a reason for hiding this comment

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

LGTM. Will wait on ResStock testing before merging.

@joseph-robertson
Copy link
Collaborator Author

joseph-robertson commented Oct 30, 2024

Should all optional arguments that use the OS-HPXML default when not provided have a default argument value set? For example, site_type, site_shielding_of_home, site_soil_and_moisture_type use OS-HPXML defaults but don't set a default argument value. Arguments site_iecc_zone, site_city don't set a default argument value either, but don't use OS-HPXML defaults.

The implication of not doing this, as I'm noticing in ResStock, is that to allow "auto" I'd need to check for presence of "OS-HPXML default" in the argument description vs. checking that a default argument value is set.

Edit: Including a default argument value for every argument with description "OS-HPXML default" probably wouldn't work. For example, it makes sense to have the clothes_dryer_fuel_type argument default to "natural gas", but "auto" shouldn't be a valid ResStock argument value.

@joseph-robertson
Copy link
Collaborator Author

joseph-robertson commented Oct 30, 2024

Do arguments ducts_supply_buried_insulation_level and ducts_return_buried_insulation_level need updated argument descriptions using "OS-HPXML default" pointing to https://openstudio-hpxml.readthedocs.io/en/latest/workflow_inputs.html#air-distribution?

@shorowit shorowit modified the milestones: 1.9.0, 1.10.0 Nov 13, 2024
Comment on lines 649 to 657
begin
value = Float(value)
if value % 1 == 0
args[name] = Integer(value)
else
args[name] = value
end
rescue
end
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a bad idea. You should only be converting to integer/float for arguments that we've declared as integer/float, not simply converting anytime it's possible. I assume this is the reason that you then had to change a bunch of code so that it converts back to string.

You'll need to refactor the code so that you have access to the original desired argument type and use it here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, should this really be in meta_measure.rb? Do you anticipate using this anywhere else than the BuildResHPXML measure?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I put it here because I found that ResStock needs to use it (with delete_auto = false).

BuildResidentialHPXML/README.md Outdated Show resolved Hide resolved
Changelog.md Outdated Show resolved Hide resolved
@@ -624,3 +624,38 @@ def is_integer?
return true
end
end

# TODO
Copy link
Contributor

Choose a reason for hiding this comment

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

Do this now (and anywhere else you added TODOs).

Comment on lines 649 to 657
begin
value = Float(value)
if value % 1 == 0
args[name] = Integer(value)
else
args[name] = value
end
rescue
end
Copy link
Contributor

Choose a reason for hiding this comment

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

Also, should this really be in meta_measure.rb? Do you anticipate using this anywhere else than the BuildResHPXML measure?

workflow/sample_files/base-auto.xml Outdated Show resolved Hide resolved
Comment on lines 13 to 27
"cooling_system_cooling_capacity": 24000.0,
"cooling_system_cooling_capacity": "24000.0",
Copy link
Contributor

Choose a reason for hiding this comment

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

Ugh, really? This might be a deal breaker. This is totally confusing and no one will be able to keep track of when they need a number vs a string. I didn't realize OpenStudio was going to require this.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we can update OpenStudio so that it allows this?

Comment on lines 5138 to 5140
# these were previously required arguments with default values set (i.e., arg.setDefaultValue(xxx))
args[:floor_over_foundation_assembly_r] = 28.1 if args[:floor_over_foundation_assembly_r].nil?
args[:floor_over_garage_assembly_r] = 28.1 if args[:floor_over_garage_assembly_r].nil?
Copy link
Contributor

Choose a reason for hiding this comment

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

I was really hoping we wouldn't need these (totally arbitrary) defaults. Why?

But if for some reason we do need them, this is definitely a step back from what we had before. Previously, at least a user opening the measure in the OS App or PAT would see the default value. Now they happen completely behind the scenes.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Some, yes, are totally arbitrary. I can fix/refactor those.

Others, for example heat pump backup fuel, are not. We can report the default value in the argument description (there's already precedent for this) and set it in its respective set_xxx method.

Copy link
Contributor

Choose a reason for hiding this comment

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

Why does heat pump backup fuel need a default?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In progress
Development

Successfully merging this pull request may close these issues.

2 participants