The Material Syntax
In addition to changing material properties directly inside the physics interfaces, materials available in the entire model can also be created. Such a material can be used by all physics interfaces in the model.
Create a material using the syntax:
model.component(<ctag>).material.create(<mattag>)
where <mattag> is a string that you use to refer to a material definition.
A Material is a collection of material models, where each material model defines a set of material properties, material functions, and model inputs. To add a material model, use the syntax:
mat.materialmodel.create(<mtag>)
where mat is a link to a material node. The string <mtag> refers to the material model.
To define material properties for the model, set the property value pairs by entering:
mat.materialmodel(<mtag>).set(property, <value>)
Copying Material Data From Another Model
Instead of creating the material model from scratch you can copy the material node from another model object, to proceed use the command:
comp.material.insert(modelMat, <mattag>, '')
where comp is the link to the component, modelMat the model MPH-file name that contains the source material node and <mattag> the tag of the material node to import.
Example: Create a Material Node
The section Example: Implement and Solve a Heat Transfer Problem shows how to change a material property inside a physics interface. This example shows how to define a material available globally in the model. These steps assume that the previous example has been followed. Enter:
mat = model.component('comp1').material.create('mat1');
The material automatically creates a material model, def, which can be used to set up basic properties. For example, use it to define the density and the heat capacity:
mat.materialmodel('def').set('density', 400);
mat.materialmodel('def').set('heatcapacity', 2e3);
To use the defined material in a model, set the solid1 feature to use the material node. Enter:
solid.set('k_mat',1,'from_mat');
model.material() in the COMSOL Multiphysics Programming Reference Manual or type at the MATLAB prompt: mphdoc(model.material).