Materials > Working with External Materials > External Material

External Material
The External Material node () sets up an interface between a physics feature and functions in an external shared library. In addition, it contains most of the functionality of a standard Material node, letting you add arbitrary material properties and property groups. Some aspects of a material can be handled by an external library, while others are defined internally in property groups.
The External Material node is only available under the Global Definitions>Materials node, not under Materials inside components. To use property groups under an External Material as domain material on geometric entities in a component, use a Material Link node.
External Material Model
Enter a Library path and name (the complete network path), or click Browse to locate a library to import. Depending on the platform, the library can be a DLL, .so, or .dylib file.
If the external material DLL is not thread safe, clear the Thread safe check box. If the DLL is thread safe, several threads can make calls to the DLL at the same time. By clearing the Thread safe check box, you prevent the DLL from being used by more than one thread at the same time.
Select the appropriate Interface type matching your library. The default is None; other options may vary between COMSOL installations. The following types are preinstalled:
If required by the chosen interface type, set the Number of states that must be stored at each evaluation point and provide a State name which will be used as a basis for creating state variables. Actual state variables are created by adding the <matname>.state. namespace as a prefix and appending a state index to the given name. For example, if for a material with name extmat1 you request two states with State name p, the state values can be accessed during and after a solution as extmat1.state.p1 and extmat1.state.p2.
Also, if allowed for the chosen interface type, select the Pass arguments as complex check box to use complex rather than double as the base type in all numeric array arguments to the external functions.
The Required input quantities, Output quantities, and Model states tables provide an overview of the interface, including which quantities are passed to and from calling physics features, which states are declared, and which component variables are defined by the material feature. Note that all variables are defined in the material’s namespace. To directly access, for example, the first axial component of a second Piola-Kirchhoff stress output outside the scope of an External Material node with the name extmat1, use the variable name extmat1.output.S11.
Components of the Required input quantities are normally defined by a physics feature calling the external material. When using an external material in equation-based modeling, you can set the inputs up manually by defining the required input components (in the material’s namespace) as global variables. For example, if external material extmat1 requires the temperature T as input, define a global variable called extmat1.input.T.
Use the Init column in the Model states table to specify initial values for all internal states used by the external function. This includes both specific states required by the chosen Interface type and numbered states added by this feature.
Material Properties
The Material Properties section of an external material is identical to the same section in a common Material feature. See The Settings Window for Material for more information.
Material Contents
The Material Contents section of an external material is very similar to the same section in a common Material feature (see The Settings Window for Material for more information). The only real difference is that the table shows not only defined output properties and properties required by some physics feature, but also properties required as input to the external material functions. Depending on the selected Interface type, these may appear either as individually named properties or as a single generic, arbitrary-length property array. In the latter case, any particular external library typically requires a specific set of properties in a certain order to be specified as an array inside curly brackets. For example, two required parameters can be specified as {2e11,0.33}.
Appearance
The Appearance section of an external material is identical to the same section in a common Material feature. See The Settings Window for Material for more information.