Many properties and variable values in Ansys Workbench represent physical quantities, which include both a value and a unit in their definition. For more information, see Expressions, Quantities, and Units in the Workbench User's Guide.
The assignments of these quantities are journaled using a "Value
[Unit]"
string syntax. This method ensures that all available
information is recorded in the journal. However, strings may be inconvenient to work with when
writing or modifying scripts that assign quantities.
Specifying Quantities Without Units
As a convenience, Ansys Workbench allows the assignment of a quantity using just the numeric value. When units are omitted, the unit is assumed to be the unit for that quantity in the current project unit system. Although this method is more convenient, you must ensure that the value being supplied is consistent with the current units.
Setting an Entity Property — When setting an entity property that refers to a quantity, the property assignment can be done as a numeric value, and the units will be taken from the project unit system. For example, after setting the Inlet Mass Flow in a VistaTF setup, the following would be recorded in the journal:
vistaTFSetup1 = setup1.GetSetupEntity() vistaTFSetup1.MassFlow = "0.5 [kg s^-1]"
When entering this command or writing script, you can use a direct numeric value:
vistaTFSetup1 = setup1.GetSetupEntity() SetProjectUnitSystem(UnitSystemName="SI") vistaTFSetup1.MassFlow = "0.3 [lbm s^-1]" # Units explicitly provided print vistaTFSetup1.MassFlow >>> 0.3 [lbm s^-1] vistaTFSetup1.MassFlow = 0.3 # Units are taken from the project unit system print vistaTFSetup1.MassFlow >>> 0.3 [kg s^-1]
Setting Quantity in Variable Data Tables — The same principles apply when setting variables in Material Property data tables (used primarily in Engineering Data). For example, after selecting a material and changing the density to 9000 [kg m^-3], the following would be recorded in the journal:
material1= eda1.GetMaterial(Name="Structural Steel") materialProperty1= material1.GetProperty(Name="Density") materialProperty1.SetData( SheetName="Density", Variables=["Density"], Values=[["9000 [kg m^-3]"]])
When writing a script, for convenience, you can omit the units, and they will be taken from the current project unit system. You can also omit the list brackets because only single values are being specified. A condensed version of the above command that is valid when playing back a script is:
material1= eda1.GetMaterial(Name="Structural Steel") materialProperty1= material1.GetProperty(Name="Density") materialProperty1.SetData( Variables="Density", Values=9000)
A more complex example shows the creation of a temperature-dependent property using a script:
# Temperatures in degrees Fahrenheit temperatures = [200,400,600,800,1000] # Coefficient of Thermal Expansion in F^-1 alphas = [6.3e-6, 7.0e-6, 7.46e-6, 7.8e-6, 8.04e-4] # Change to an appropriate unit system #(US Customary, which has an internal tag of "BIN_STANDARD") SetProjectUnitSystem(UnitSystemName="BIN_STANDARD") # Create a new instance of engineering data and # access the Coefficient of Thermal Expansion property of Structural Steel EDAtemplate = GetTemplate(TemplateName="EngData") system = EDAtemplate.CreateSystem() eda = system.GetContainer(ComponentName="Engineering Data") steel = eda.GetMaterial(Name="Structural Steel") alpha = steel.GetProperty(Name="Coefficient of Thermal Expansion") # Set the property data according to the provided data alpha.SetData(Variables=["Temperature","Coefficient of Thermal Expansion"], Values = [temperatures, alphas])