1

Create a new Material with Python bindings

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?

clima337's avatar
51
clima337
asked 2023-11-01 12:54:20 -0500
Aaron Boranian's avatar
14.1k
Aaron Boranian
updated 2023-11-01 14:24:51 -0500
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

1 Answer

4

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

Julien Marrec's avatar
29.7k
Julien Marrec
answered 2023-11-06 02:36:59 -0500
edit flag offensive 0 remove flag delete link

Comments

add a comment see more comments