OpenSite/Guides/Dimensionless material expressions
Assign a Python scalar expression to a dimensionless material property.
- Stable identifier
opensite.help.dimensionless-material-expressions
Prerequisites
A practice user material and the Python expression runtime. This lesson is separate from a material-standard definition.
Steps
Create the material
Use the same practice-material inputs as the material creation lesson.
Choose a dimensionless target
Poisson ratio is dimensionless. A bare Python scalar may fill this quantity destination; it cannot stand in for an arbitrary dimensional length or pressure.
Store and recalculate
The rewritten expression is 0.22 + 0.08 * cos(60°), with degree conversion in Python. Enable consent, then request recalculation.
Check the value
The arithmetic result is 0.26. Read the property from the material object and compare with that independent expected number.
Expected result
The object’s Poisson value is 0.26 within 1e-12.
Limitations
Arithmetic correctness is not validation of the chosen constitutive model or a design standard. Keep source, units and material assumptions together.
Complete example
import math
import opensite
doc = opensite.execute("document.new", {})["document"]
created = opensite.material_create_user(doc, {
"name": "Practice steel", "family": "steel", "role": "structural_steel",
"has_elastic": True, "elastic_pa": 210.0e9,
"has_poisson": True, "poisson": 0.28,
"has_mass_density": True, "mass_density": 7850.0,
"has_thermal": True, "thermal_per_k": 1.2e-5,
})
source = "0.22 + 0.08 * math.cos(math.radians(60))"
opensite.execute("document.set_expression", {
"document": doc, "object": created["id"], "property": "poisson",
"expression": source, "language": "python",
})
opensite.execute("document.set_python_expressions_enabled", {
"document": doc, "enabled": True,
})
opensite.recalculate_python_expressions(doc)
actual = doc.get_object(created["id"]).poisson.si_value
assert abs(actual - 0.26) < 1e-12
print("Dimensionless Poisson value:", actual)