Question-and-Answer Resource for the Building Energy Modeling Community
Get started with the Help page
Ask Your Question
1

Create a new Material with Python bindings

asked 2023-11-01 12:54:20 -0500

clima337's avatar

updated 2023-11-01 14:24:51 -0500

Hello, I am looking to edit buildings by increasing the thermal insulation of walls. I think there are multiple ways to do this, including changing the thermal conductance of surfaces, but it seems like the best way is to edit the layered construction of the surface and add the insulation material. To do this, I am trying to create that material with code.

From the limited documentation I can see, something like this should work:

import openstudio as osm  
osm1 = 'osm_path' 
b1 = osm.model.Model.load(osm1).get() 
mat = osm.openstudiomodelresources.Material(b1) 
mat.setThickness(0.3)

However, this does not work. I get an error on the mat = osm. line like this:

TypeError: Wrong number or type of arguments for overloaded function 'new_Material'.
  Possible C/C++ prototypes are:
    openstudio::model::Material::Material(openstudio::model::Material const &)
    openstudio::model::Material::Material(openstudio::model::Material &&)

I cannot find any documentation on the proper way to instantiate an object of class Material (or any other class for that matter). Anyone know?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
4

answered 2023-11-06 02:36:59 -0500

Material is an abstract base class. You cannot instantiate it. You probably want StandardOpaqueMaterial since you mean to set a thickness (otherwise MasslessOpaqueMaterial is a possibility)

In [1]: import openstudio

In [2]: m = openstudio.model.Model()

In [3]: mat = openstudio.model.StandardOpaqueMaterial(m)

In [4]: mat.setThickness(0.3)
Out[4]: True

In [5]: print(mat)
OS:Material,
  {355d42fb-f0e5-4e57-b0e8-a8d34651f095}, !- Handle
  Material 1,                             !- Name
  Smooth,                                 !- Roughness
  0.3,                                    !- Thickness {m}
  0.1,                                    !- Conductivity {W/m-K}
  0.1,                                    !- Density {kg/m3}
  1400;                                   !- Specific Heat {J/kg-K}

Take a look at the inheritance diagram: https://s3.amazonaws.com/openstudio-s...

image description

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Training Workshops

Careers

Question Tools

1 follower

Stats

Asked: 2023-11-01 12:54:20 -0500

Seen: 667 times

Last updated: Nov 06 '23