Accessing External Material Models for Structural Mechanics

Ed Gonzalez December 1, 2015
Share this on Facebook Share this on Twitter Share this on Google+ Share this on LinkedIn

In structural mechanics, you may want to specify user-defined material models in your simulation. COMSOL Multiphysics® software version 5.2 enables you to access material models derived from external libraries as well as material functions programmed by yourself. We demonstrate how the new functionality works with the example of implementing Mazars’ model to describe damage to concrete.

A New Method for Specifying User-Defined Material Models

In COMSOL Multiphysics, you can access a variety of predefined materials to model mechanical deformation in solids. Material models for plasticity, viscoelasticity, creep, and hyperelasticity are just some of those that are available.

By using the built-in constitutive laws as a starting point, you have the ability to create your own material models based on stress or strain invariants, flow rules, or creep laws directly in the user interface. Extra PDEs or distributed ODEs can also extend a given material law. But what if your material model includes nonlinear expressions that are impossible to express in terms of standard variables, invariants, or additional PDEs?

The latest version of COMSOL Multiphysics — version 5.2 — features a new way for you to specify user-defined material models. In structural mechanics analyses, you are now able to completely define a nonlinear stress-strain relationship, or include an inelastic strain contribution with an existing elastic material. Two new features in the Solid Mechanics interface complement this functionality: the External Strain subnode under the Linear Elastic Material node and the External Stress-Strain Relation material model.

Screenshot showing how to access External Material, External Strain, and External Stress-Strain nodes inside the COMSOL Multiphysics Model Builder.
The External Material, External Strain, and External Stress-Strain Relation nodes in the model tree.

With the added capabilities, implementing external material functions coded in the C programming language is possible. If you write a wrapper function in C code, material functions can also be written in other programming languages, making it easy for you to reuse your legacy code.

Along with programming your own material models, distributing your models to colleagues and customers as add-ons is now an option as well. You can even create easy-to-use apps, by using the Application Builder and incorporating your external material functions, and distribute these to your colleagues and customers as well.

Putting the Added Functionality into Practice

To show you how the functionality works, we have added a tutorial to our Application Gallery that features a series of relevant demonstrations. The examples include a model file, a source C file, and a shared dynamic-link library (DLL) compiled and linked for a 64-bit Windows® operating system. (Running the models on Linux® operating systems and Mac OS X requires additional compilation and linking.)

In the first case, we explain how to write the C code for an isotropic linear elastic material and compare our results to the built-in Linear Elastic Material for a simple uniaxial test. The second, and more realistic, case shows how to implement a nonlinear material model that computes damage in concrete.

Let’s take a closer look at the latter of these two examples.

Using Mazars’ Damage Model for a Concrete Analysis

The deformation of brittle materials under mechanical loads is characterized by an initial elastic deformation. Upon unloading, the material will return back to its original state. However, if a critical stress or strain level is exceeded, a nonlinear fracture phase will follow the elastic phase.

As the critical value is reached, cracks will begin to grow and spread until the material fractures. The occurrence and growth of the cracks play an important role in the failure of concrete structures, and there are a number of theories used to describe such behavior. In the continuum damage mechanics formalism, a “damage” variable represents the amount of deterioration due to crack growth. The damage variable controls the weakening of the material’s stiffness.

Mazars’ model for concrete damage characterizes the fracture behavior within concrete using an isotropic scalar damage variable d. The variable enters the constitutive stress-strain relationship as

\sigma = (1-d)C:\epsilon

Here, \sigma is the stress tensor, C is the elasticity matrix, and \epsilon is the strain tensor.

The material, which behaves as a linear-elastic solid, is undamaged when the damage variable equals zero and fully damaged as the variable approaches one.

The inception and evolution of the damage variable is quite tricky to compute with standard variables in COMSOL Multiphysics. How so? It requires memorizing previous steps and conditional manipulation of variables based on principal stresses and principal strains. To overcome this limitation, we implemented Mazars’ damage model in an external material function, adding the C code for inspection and modification. The C code includes the definition of a number of variables, for loops, and the use of state variables to memorize damage from previous steps.

Image showing the code used to compute Mazars' damage model.
The external material function to compute Mazars’ damage model contains just over one hundred lines of code.

The plot below shows the computed uniaxial stress-strain response using Mazars’ damage model. The results are in excellent agreement with those findings presented in the book Mechanical Behavior of Concrete.

Plot showing the uniaxial stress-strain response.
Uniaxial stress-strain response plot.

Next Steps

  • Download the tutorial: External Material Examples, Structural Mechanics
  • For more details on how to compile the C code for different operating systems, see the section “Working with External Materials” in the COMSOL Multiphysics Reference Manual
  • Interested in learning more about Mazars’ damage model? Check out the following articles:
    • J. Reynouard et al., “Modeling the Macroscopic Behavior of Concrete”, in Mechanical Behavior of Concrete, ed. J. Reynouard, J. Torrenti, and G. Pijaudier-Cabot. 63-119, Wiley 2010
    • J. Mazars et al., “Local Second Gradient Models and Damage Mechanics: 1D Post-Localization Studies in Concrete Specimens”, in Bifurcations, Instabilities, Degradation in Geomechanics, ed. G. Exadaktylos and I. Vardoulakis. 127-142, Springer 2007

Microsoft and Windows are either registered trademarks or trademarks of Microsoft Corporation in the United States and/or other countries.

Linux is a registered trademark of Linus Torvalds.

Mac OS is a trademark of Apple Inc., registered in the U.S. and other countries.

Post Tags

Technical Content


  1. Krishna Kumar Soundararajan March 24, 2016   7:19 am

    Good! However, how can I implement an elasto-plastic constitutive model with external material model?

  2. Henrik Sönnerlind May 13, 2016   1:46 pm

    An elasto-plastic model can be implemented using ‘External Strain’. The external strain entry is used to return an inelastic (i.e. plastic) strain ‘e_inel’, so that the stress ‘s’ is computed by


    where ‘C’ is the elasticity tensor and ‘e’ is the total strain. This is similar to how the built-in plasticity models work if you look at them in Equation View.

    Note however that you have rather large flexibility already without coding through the User Defined yield functions and plastic potentials.

  3. vikash kumar February 10, 2017   2:20 am

    i want to simulate uni axial compression test of polymers (ABS material), further i want stress -strain curve of material . how can i get it?
    your response will be highly appreciated

  4. Ed Gonzalez February 10, 2017   2:29 am

    Vikash, please take a look at this post

  5. Zhipeng Pi August 3, 2017   10:57 am

    how to compile the c code to a dll file? I try to compile the C code-’ Mazars_Damage.c’ into a dll file by using the visual studio 2013, however, the comsol cannot study and report error like ” Feature: Compile Equations: Stationary (sol1/st1)
    Error in multiphysics compilation.
    Error initializing external variables interface.
    – Function: eval”


  6. Ed Gonzalez August 23, 2017   9:42 am

    Zhipeng, please contact our support team in your country.

  7. KAI REN November 22, 2017   5:58 am

    If I want to build a temperature-dependent elasto-plastic constitutive model, how can I use this method? Thank you!

  8. KAI REN November 22, 2017   6:04 am

    If I want to build a temperature-dependent elasto-plastic model for thermal stress study, how can I use this method? Thank you!

  9. Ed Gonzalez November 22, 2017   9:04 am

    Hi KAI REN,
    Please take a look at the post

  10. KAI REN November 22, 2017   10:18 pm

    Hi Dr. Ed Gonzalez,

    Thanks for your reply!
    I have a question about transferring strain fields between two different mph files. Is this method can be used to transfer strain field in different mph files (when thermal strain, plastic strain are involved), so the later mph file can utilize the result of the former mph file as initial value?


  11. Ed Gonzalez November 23, 2017   2:26 am

    Dear Kai,
    Please contact our support team for a detailed explanation on how to transfer strain fields.

  12. Manik Kumar December 27, 2017   7:26 am

    I am currently on magnetostrictive materials. For which we developed the constitutive model for magnetostrictive material but we made a code in MATLAB. SO first we have to convert our MATLAB code to C or directly MATLAB code can be imported to COMSOL.

  13. Manik Kumar December 27, 2017   7:43 am

    If anyone has suggestions for the previous comment please reply at the earliest.

  14. Caty Fairclough January 25, 2018   7:47 am

    Hi Manik,

    Thanks for your comments!

    For questions related to your modeling, please contact our Support team.

    Online Support Center:

Loading Comments...