Working with External Materials
The External Material Model
A general external material model defines a relationship between a number of input quantities and a number of output quantities, a relationship that may also depend on model parameters and stored states. From the physics interfaces’ point of view, an external material model is a black box, which may implement any relationship between provided input and required output quantities.
The external material model is implemented as a function with a C calling convention, compiled and linked to create a dynamically linked library that can be called from a material feature in COMSOL Multiphysics at runtime. In each solver iteration, current values of the input quantities and model parameters are passed together with previous values of model states as arguments to the external function. The external function is, in return, expected to write new values of model outputs, their partial derivatives with respect to model inputs, as well as updated state values to other preallocated function arguments.
The following sections provide an overview of the external materials framework, as well as details on the built-in interface types and instruction for compiling and linking a shared library.