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

Resolves #135 Add in option to support epJSON workflows #136

Merged
merged 9 commits into from
Sep 20, 2021
Merged

Conversation

tijcolem
Copy link
Collaborator

Resolves #135

This PR adds support to pass in an argument to use epJSON file format to run EnergyPlus. Currently, IDF is still the default if this option is not set. The option menu on OpenStudio would look like the below menu where --epjson is a flag to pass into the workflow gem.

openstudio run --help 
Usage: openstudio run [options]

Options:

    -w, --workflow [FILE]            Specify the FILE path to the workflow to run
    -m, --measures_only              Only run the OpenStudio and EnergyPlus measures
    -p, --postprocess_only           Only run the reporting measures
    -e, --epJSON                     use epJSON file format. The default is IDF
    -s, --socket PORT                Pipe status messages to a socket on localhost PORT
        --debug                      Includes additional outputs for debugging failing workflows and does not clean up the run directory
    -h, --help                       Print this help

As an example, to run a workflow using --epJSON you would invoke cli by running:

openstudio run -e -w compact.osw

Currently, the workflow passes around the @registry[:model_idf] to various steps in the workflow and manipulates this in various steps and then calls energyplus as subprocess with the final IDF file. This PR maintains this logic and only converts the final IDF to epJSON if @options[:epjson] is set to True.

I think it would be preferable to work directly with epJSON, but I don't think all the workflow steps can support this as of now. Plus, the entire workflow process is likely to converted into C++ to support Python so it's probably not worth the effort to do that. This at least allows the usage of epJSON that is available in OpenStudio.

@tijcolem
Copy link
Collaborator Author

Converted to draft as need to add test cases.

@tijcolem
Copy link
Collaborator Author

Added test for epJSON. Most of these will fail until NREL/OpenStudio#4419 is resolved.

@tijcolem tijcolem marked this pull request as ready for review September 7, 2021 19:33
@tijcolem tijcolem requested a review from nllong September 7, 2021 19:33
Copy link
Member

@nllong nllong left a comment

Choose a reason for hiding this comment

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

look great! 🔥

# before this can be changed.
if @options[:epjson]
@logger.info 'Beginning the translation to epJSON'
@registry[:time_logger]&.start('Translating to EnergyPlus epJSON')
Copy link
Member

Choose a reason for hiding this comment

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

nice use of the &. operator!


# Run using epJSON if @options[:epjson] true, otherwise use ID
if @options[:epjson]
command = popen_command("\"#{energyplus_exe}\" in.epJSON 2>&1")
Copy link
Member

Choose a reason for hiding this comment

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

is the extension really named epJSON?

logger ||= ::Logger.new($stdout)
logger.info 'Translate IDF to epJSON in preparation for EnergyPlus'
a = ::Time.now
model_epjson = OpenStudio::EPJSON::toJSONString(model_idf)
Copy link
Member

Choose a reason for hiding this comment

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

nice to see EPJSON in OpenStudio natively.

@tijcolem tijcolem merged commit 6d50e5b into develop Sep 20, 2021
@tijcolem tijcolem deleted the issue_135 branch September 20, 2021 19:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add option to export/run epJSON
2 participants