Assigning a Fluid or Solid Material

Assigning an Existing Fluid or Solid Material

In the following example, the selection mode is set to volume. A single part (ID=2) is selected, and assigned the Air_Constant material. Two more parts are then selected, and assigned the Steel_Variable material. Note that this is done using only the Analysis class methods and properties:

a.selectionMode = "Volume";

a.select(2);

a.applyMaterial("Air_Constant");

a.select(1);

a.select(3);

a.applyMaterial("Steel_Variable");

Creating a New Fluid or Solid Material

In this example, a solid material is created by reading an existing material, and changing the conductivity. The new material is then assigned to two parts.

m = new Material("Solid");

m.name = "new-al";

m.readFrom(a.Material("Aluminum_Constant"));

p = m.property("X-Direction");

p.type = "Conductivity";

v = p.Variation("Constant");

v.setValue(220, "K-in/W");

p.apply(v);

a.selectionMode = "Surface";

a.select(“SINK1”);

a.select(“SINK2”);

a.applyMaterial(m);

A line-by-line description of this is given:

>>>A new material object, m, is created, and solid is set as the material type:

m = new Material("Solid");

>>>The material name is set to “new-al”. This is analogous to entering a name in the Name field on the Material Editor:

m.name = "new-al";

>>>Reads from the existing material called Aluminum_Constant, and assigns the properties to the “m” material object:

m.readFrom(a.material("Aluminum_Constant"));

>>>Creates a property object called “p”, and selects X-Direction as the property to edit:

p = m.property("X-Direction");

>>>selects conductivity as the quantity to set (the alternative is resistivity):

p.type = "Conductivity";

>>>creates a variation object called “v”, and sets the variation method to constant. The value of 220 W/m-K is then assigned:

v = p.variation("Constant");

v.setValue(220, "W/m-K");

>>>This step assigns the completed variation back to the property. It is the equivalent to hitting the Apply button on the Material Editor:

p.apply(v);

>>>Sets the selection mode to volume, selects two parts by name, and applies the material just created:

a.selectionMode = "Volume";

a.select(“SINK1”);

a.select(“SINK2”);

a.applyMaterial(m);