NREL / OpenStudio

OpenStudio is a cross-platform collection of software tools to support whole building energy modeling using EnergyPlus and advanced daylight analysis using Radiance.
https://www.openstudio.net/
Other
496 stars 190 forks source link

Python plugin next steps #4634

Open joseph-robertson opened 2 years ago

joseph-robertson commented 2 years ago

Extend the python plugin feature that was implemented in #4600. Specifically:

See https://github.com/NREL/OpenStudio/issues/3839 for more information.

joseph-robertson commented 2 years ago

Extend the python plugin feature that was implemented in #4600. Specifically:

@jmarrec @tijcolem

joseph-robertson commented 2 years ago

Another idea mentioned by @DavidGoldwasser, add capability at OSW level for using the plugin. David, can you expand on this?

joseph-robertson commented 1 year ago

Notes from 12/7 meeting:

One issue with the current implementation of PythonPlugin is portability. A single python plugin .py file is not guaranteed to work across multiple models (e.g., zone names are different).

Approach 1 (A) To address this, we could use erb templating. The gist of this approach would be to pass a erb .py template file into PythonPluginInstance pre-substitution, and then make the substitutions based on contents in model. (jinja templating for python?) Update: Instead of passing template file into PythonPluginInstance, is the burden on user to do the rendering in the measure itself?

(B) The optional extension of this approach would be to wait until all measures are applied before making any substitutions. We could potentially create a new "EMS" class of measures that are called after Model measures.

We plan to prototype (A) from above. Update: see https://github.com/NREL/OpenStudio-resources/pull/185 for a demonstration.

Approach 2 Update E+ to load model on E+ warmup, save as a global, etc. Then you could access model by something like state.model() or state.osmodel() from the python plugin file.

shorowit commented 1 year ago

Would be nice to show how this works in the context of a python OpenStudio measure too. I assume it's a lot simpler.

(Personally, I would be okay with the E+ python plugin only being available via python OpenStudio measures if that significantly reduces the development effort.)