Materials

Material definitions.

Databases Materials

LocalMaterials

class onscale.LocalMaterials(name: str, source: str | None = None)

Access materials defined in a local file.

Constuct a MaterialDatabase.

Parameters:
  • name – Material database to access.

  • source – Material database source.

static from_dict(data: Dict[str, Any], sim: Simulation | None = None) Node

Construct this node from serialized dictionary data

get(key: str) Material

Get a material object from the database.

Parameters:

key – Name of the material to access.

Returns:

Material object defined in this database.

Examples

>>> import onscale as on
>>> with on.Simulation("Static Solve") as sim:
...     mtdb = on.materials.LocalMaterials("/path/to/local/material/file")
...     material = mtdb.get("steel")
to_json() str

Convert this node into JSON representation

property uuid: str

Get the UUID associated with this node.

CloudMaterials

class onscale.CloudMaterials(name: str, source: str | None = None)

Access materials defined in a cloud material repository.

Constuct a MaterialDatabase.

Parameters:
  • name – Material database to access.

  • source – Material database source.

static from_dict(data: Dict[str, Any], sim: Simulation | None = None) Node

Construct this node from serialized dictionary data

get(key: str) Material

Get a material object from the database.

Parameters:

key – Name of the material to access.

Returns:

Material object defined in this database.

Examples

>>> import onscale as on
>>> with on.Simulation("Static Solve") as sim:
...     mtdb = on.materials.LocalMaterials("/path/to/local/material/file")
...     material = mtdb.get("steel")
to_json() str

Convert this node into JSON representation

property uuid: str

Get the UUID associated with this node.

Material

class onscale.Material(database: MaterialDatabase | None, name: str, alias: str | None = None)

An instance of a specific material, taken from a material database.

Examples

>>> import onscale as on
>>> with on.Simulation("Static Solve") as sim:
...     mtdb = on.materials.LocalMaterials("/path/to/local/material/file")
...     on.materials.Material(mtdb, "steel")

Initialize a material.

Parameters:
  • database – Instance of the database this material was taken from.

  • name – Name of the material to use from the database.

  • alias – Optional alias to give material.

set(property_name: str, value: Any) Material

Modify a property of this material by name.

Parameters:
  • property_name – The material property name to override.

  • value – The new value to update.

Returns:

self

apply(other: Node) ApplyMaterial

Apply this material to some object, usually a geometry.

Parameters:

other – The object to apply this material to.

Returns:

Object representing this material’s application.

Examples

>>> import onscale as on
>>> with on.Simulation("Static Solve") as sim:
...     mtdb = on.materials.LocalMaterials("/path/to/local/material/file")
...     material = on.materials.Material(mtdb, "steel")
...     geom = on.CadFile("Swing_Arm.step")
...     material.apply(geom.parts[0])
property apply_types: List[ApplyType]

Get the types you can apply a material to.

static from_dict(data: Dict[str, Any], sim: Simulation | None = None) Node

Construct this node from serialized dictionary data

to_json() str

Convert this node into JSON representation

property uuid: str

Get the UUID associated with this node.

Custom Material

class onscale.CustomMaterial(name: str, alias: str | None = None)

Custom material object for user-defined materials with no database.

Examples

>>> import onscale as on
>>> with on.Simulation("Static Solve") as sim:
...     mat = on.CustomMaterial('my_material')

Initialize a custom material.

add_material_properties(property_name: str) MaterialProperties

Add a material property.

apply(other: Node) ApplyMaterial

Apply this material to some object, usually a geometry.

Parameters:

other – The object to apply this material to.

Returns:

Object representing this material’s application.

Examples

>>> import onscale as on
>>> with on.Simulation("Static Solve") as sim:
...     mtdb = on.materials.LocalMaterials("/path/to/local/material/file")
...     material = on.materials.Material(mtdb, "steel")
...     geom = on.CadFile("Swing_Arm.step")
...     material.apply(geom.parts[0])
property apply_types: List[ApplyType]

Get the types you can apply a material to.

static from_dict(data: Dict[str, Any], sim: Simulation | None = None) Node

Construct this node from serialized dictionary data

set(property_name: str, value: Any) Material

Modify a property of this material by name.

Parameters:
  • property_name – The material property name to override.

  • value – The new value to update.

Returns:

self

to_json() str

Convert this node into JSON representation

property uuid: str

Get the UUID associated with this node.