Create Model for OpenStudio returns None.
Hello @wassimj
I have been working on a project that involves using topologic and its energymodelling features. I went and followed the guidance in this video https://www.youtube.com/watch?v=qLe3tEpXQzU and found that a few things did not work for me and I have been struggling to see why.
Here is a simple recreation of what I am doing:
from topologicpy.EnergyModel import EnergyModel
from topologicpy.Topology import Topology
from topologicpy.Cell import Cell
from topologicpy.CellComplex import CellComplex
from topologicpy.Vertex import Vertex
# create two boxes
c = Cell.Prism()
# Specify a glazing (window to wall) ratio:
wwr = 0.5
# decompose cell
d = Cell.Decompose(c)
print(d)
# loop through faces and onlyz get verticalFaces
walls = d['verticalFaces']
apertures = []
for wall in walls:
centroid = Topology.Centroid(wall)
aperture = Topology.Scale(wall, centroid, wwr, wwr, wwr)
apertures.append(aperture)
building = Topology.AddApertures(c, apertures, subTopologyType="face")
print(building)
print(Cell.Decompose(building))
# show the building - note im not seeing the apertures i added above here, please advise
Topology.Show(building)
# # create energy model
model = EnergyModel.ByTopology(building=building, glazingRatio=wwr)
# print(model)
- When I add apertures to my simple prism "building" i dont see the apertures when i show them?
- More importantly, when i try to create the open studio model i get the following error:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
File c:\Users\karim\repos\topology-generator\venv\Lib\site-packages\topologicpy\EnergyModel.py:188, in EnergyModel.ByTopology(building, shadingSurfaces, osModelPath, weatherFilePath, designDayFilePath, floorLevels, buildingName, buildingType, northAxis, glazingRatio, coolingTemp, heatingTemp, defaultSpaceType, spaceNameKey, spaceTypeKey, mantissa, tolerance)
[187](file:///C:/Users/karim/repos/topology-generator/venv/Lib/site-packages/topologicpy/EnergyModel.py:187) try:
--> [188](file:///C:/Users/karim/repos/topology-generator/venv/Lib/site-packages/topologicpy/EnergyModel.py:188) import openstudio
[189](file:///C:/Users/karim/repos/topology-generator/venv/Lib/site-packages/topologicpy/EnergyModel.py:189) openstudio.Logger.instance().standardOutLogger().setLogLevel(openstudio.Fatal)
ModuleNotFoundError: No module named 'openstudio'
During handling of the above exception, another exception occurred:
UnboundLocalError Traceback (most recent call last)
File c:\Users\karim\repos\topology-generator\venv\Lib\site-packages\topologicpy\EnergyModel.py:193, in EnergyModel.ByTopology(building, shadingSurfaces, osModelPath, weatherFilePath, designDayFilePath, floorLevels, buildingName, buildingType, northAxis, glazingRatio, coolingTemp, heatingTemp, defaultSpaceType, spaceNameKey, spaceTypeKey, mantissa, tolerance)
[192](file:///C:/Users/karim/repos/topology-generator/venv/Lib/site-packages/topologicpy/EnergyModel.py:192) try:
--> [193](file:///C:/Users/karim/repos/topology-generator/venv/Lib/site-packages/topologicpy/EnergyModel.py:193) os.system("pip install openstudio")
[194](file:///C:/Users/karim/repos/topology-generator/venv/Lib/site-packages/topologicpy/EnergyModel.py:194) except:
UnboundLocalError: cannot access local variable 'os' where it is not associated with a value
During handling of the above exception, another exception occurred:
UnboundLocalError Traceback (most recent call last)
Cell In[1], [line 35](vscode-notebook-cell:?execution_count=1&line=35)
[32](vscode-notebook-cell:?execution_count=1&line=32) Topology.Show(building)
[34](vscode-notebook-cell:?execution_count=1&line=34) # # create energy model
---> [35](vscode-notebook-cell:?execution_count=1&line=35) model = EnergyModel.ByTopology(building=building, glazingRatio=wwr)
[37](vscode-notebook-cell:?execution_count=1&line=37) # print(model)
File c:\Users\karim\repos\topology-generator\venv\Lib\site-packages\topologicpy\EnergyModel.py:195, in EnergyModel.ByTopology(building, shadingSurfaces, osModelPath, weatherFilePath, designDayFilePath, floorLevels, buildingName, buildingType, northAxis, glazingRatio, coolingTemp, heatingTemp, defaultSpaceType, spaceNameKey, spaceTypeKey, mantissa, tolerance)
[193](file:///C:/Users/karim/repos/topology-generator/venv/Lib/site-packages/topologicpy/EnergyModel.py:193) os.system("pip install openstudio")
[194](file:///C:/Users/karim/repos/topology-generator/venv/Lib/site-packages/topologicpy/EnergyModel.py:194) except:
--> [195](file:///C:/Users/karim/repos/topology-generator/venv/Lib/site-packages/topologicpy/EnergyModel.py:195) os.system("pip install openstudio --user")
[196](file:///C:/Users/karim/repos/topology-generator/venv/Lib/site-packages/topologicpy/EnergyModel.py:196) try:
[197](file:///C:/Users/karim/repos/topology-generator/venv/Lib/site-packages/topologicpy/EnergyModel.py:197) import openstudio
UnboundLocalError: cannot access local variable 'os' where it is not associated with a value
And so i thought maybe i had to install openstudio seperately -- so i tried pip installing openstudio and i get this error:
"EnergyModel.ByTopology - Error: The openstudio model is null. Returning None."
Would be great if I could get some guidance on what I am doing wrong here. Let me know if you need further clarifications
Setup: Windows 11, lenovo snapdragon arm64 Installed Openstudio Application 1.8 (i see that you used 1.5 in the video?) Running in venv pip installed latest topologicpy
When through the documentation again and saw this:
Is this suggesting that there should be a folder in the directory called "assets" where you would save all the oen studio stuff? Perhaps this is part of the issue.
I will prepare a new comprehensive tutorial but it will take me a week or two to get to it. It seems you have not installed openstudio. Anyway, you can also schedule a meeting with me at http://jabiw.ycb.me and we can solve it quicker. Too many things to tell you about. This comment section is not suitable for that.
I did install Openstudio but it seems like the library unsuccessful installs openstudio through pip, so when I installed it myself I still seem to get those errors. regardless I set an appointment with you for next Monday morning. Thanks so much for the swift reply, excited ot get into it!
@wassimj , thanks for the great meeting. I think i figured out the issue. It was nothing other than a few simulation configurations that had not been set to "yes" in the simulation control .osm -- See below what i did
Once i did that i get this:
and therefore was able to visualize the results here:
this was the link that helped me: https://github.com/NREL/EnergyPlus/issues/8146
Happy to fork/propose changes and send you a PR -- i could also create an updated notebook similar ot what we looked at for people to use. lmk
Oh! I wonder how this is happening, but great that you figured it out! Yes, if possible, please send a PR that adds some pythone code to EnergyModel.py to make sure these are set to YES. Or if you do not want to do a full PR, just send them to me over e-mail and I will add to EnergyModel.py and include in the next release (which will be in the next day or so). Thanks!
Just in case you did not find this:
https://s3.amazonaws.com/openstudio-sdk-documentation/cpp/OpenStudio-3.7.0-doc/model/html/classopenstudio_1_1model_1_1_simulation_control.html
I changed the building template to Yes on all the simulation controls. But it is best if this is done also in python before I return the model. If you can figure out the API calls and test that would be very helpful to save me some time. Thanks.