How to generate a new material in Workbench

M
M Member, Employee Posts: 244
50 Answers 100 Comments 100 Likes Second Anniversary
✭✭✭✭
edited November 13 in Materials

New materials can be created with scripting in Workbench. The data can be hard coded or imported.
The import would need to be parse the data into the correct parameters/properties, but there is no shortage of examples how to import csv data in python.
Here I just show how to go from the parameters to a WB material.
And to enhance this example, simply use the journaling/recording function in Ansys Workbench to figure out the requirements for more complicated material models, here a simple isotropic material is generated, Flubber.

The example assumes you have an analysis system already in WB and it has a Engineering Data container.

material_data = ['flubber', 22,1,0.3] # import data from csv

# parse into individual properties
mat_name = material_data[0]
Tref = material_data[1]
Emod = material_data[2]
Prxy = material_data[3]

system = GetSystem(Name="SYS")
engineeringData = system.GetContainer(ComponentName="Engineering Data")

newmat = engineeringData.CreateMaterial(Name= mat_name )

matlProp = newmat.CreateProperty(Name="Elasticity", Behavior="Isotropic", Qualifiers={"Definition": "","Behavior":"Isotropic"})

matlProp.SetData(SheetName="Elasticity", SheetQualifiers={"Definition": "", "Behavior": "Isotropic", "Derive from": "Young's Modulus and Poisson's Ratio"},Index=-1,Variables=["Temperature"],Values=[[str(Tref)+ "[C]"]])

matlProp.SetData(SheetName="Elasticity",SheetQualifiers={"Definition": "", "Behavior": "Isotropic", "Derive from": "Young's Modulus and Poisson's Ratio"},Variables=["Young's Modulus"],Values=[[str(Emod) + "[MPa]"]])

matlProp.SetData(SheetName="Elasticity",SheetQualifiers={"Definition": "", "Behavior": "Isotropic", "Derive from": "Young's Modulus and Poisson's Ratio"},Variables=["Poisson's Ratio"],Values=[[str(Prxy)]])