Difference between revisions of "Softening Law Implementation"
Line 51: | Line 51: | ||
</dd> | </dd> | ||
<dt><tt>double LinearSoftening::GetFFxn(double delta,double s) const< | <dt><tt>double LinearSoftening::GetFFxn(double delta,double s) const</tt></dt> | ||
<dd>Return <math>f(\delta,s)</math>.</dd> | <dd>Return <math>f(\delta,s)</math>.</dd> | ||
Revision as of 10:47, 8 July 2021
Introduction
Softening Laws are used to implement damage mechanics in softening materials.
Softening Law Definition
Implementation of softening laws starts by define a model that gives strength as a function damage parameter δ. The law if defined in the form
[math]\displaystyle{ F(\delta,s) = \sigma_{init}f(\delta,s) }[/math]
Because the initiation stress is provided by the choosen initiation law, the softening law depends only on [math]\displaystyle{ f(\delta,s) }[/math] that is equal to 1 when [math]\displaystyle{ \delta=0 }[/math] and [math]\displaystyle{ s }[/math] is a scaling function to connecting total energy released to particle volume and crack orientation:
[math]\displaystyle{ s = {A_c \over V_p \sigma_{init}} }[/math]
Writing Softening Law Code
The first steps are to create source files for the new softening law class, to give the law a unique name and number, and to allow the main NairnMPM code to instantiate this softening law when it is needed.
Class Source Code
The parent class for all softening laws are in NewMaterial.cpp and NewMaterial.hpp files. Normally, you will create new files that subclass this class (which can be done by starting with new files or duplicating files from an existing softening law). You can pick any unique name for the softening law source files.
Editing Core Code
Almost all coding will be done in the new softening laws class files, but for that law to be recognized as an option in NairnMPM, one source file in the core code has to be edited first. These should be the only changes needed outside the new softening laws's class files.
- Include the new softening law's header file at the top of NairnMPM/src/Materials/MaterialBaseMPM.cpp:
#include "Materials/MySofteningLaw.hpp"
or the appropriate relative path to the new law's header file.
- In void MaterialBase::SetSofteningLaw(char *lawName,int mode), instantiate you new law based on user input of a name or a number. Pick any name and number that does not conflict with currently implemented softening laws. The new code will look like:
else if(strcmp(lawName,"MyFavoriteLaw")==0 || strcmp(lawName,"9")==0) { sLaw = new MySofteningLaw(); }
Implementing Required Methods
Once source code is created and made available to core code, the next steps are to implement all the required methods for softening laws. The required methods are:
- const char *MySofteningLaw::GetSofteningLawName(void)
- Return a string with name for the law (to be displayed in output files). It should be unique name among all implemented softening laws.
- double LinearSoftening::GetFFxn(double delta,double s) const
- Return [math]\displaystyle{ f(\delta,s) }[/math].
Compiling with make Command
Softening Law Implementation
It is easy to add new softening laws, although not clear if that change would be much different then using the softening laws already available. As explained in Ref. [1], the addition of a softening only requires code to return:
[math]\displaystyle{ f(\delta,s), \quad f'(\delta,s), \quad A(\delta,s), \quad{\rm and}\quad\max\bigl(-f'(\delta,s)\bigr) }[/math]
One internal calculation is to evolve damage. That calculation can be done from the above softening law properties by solving the discrete differential equation[1]
[math]\displaystyle{ d\varepsilon = d\delta + \varepsilon_0 \bigl(f(\delta+d\delta,s) - f(\delta,s)\bigr) }[/math]
where [math]\displaystyle{ d\delta }[/math] is a maximum cracking strain increment associated with strain increment [math]\displaystyle{ d\varepsilon }[/math] during damage evolution. The task is to solve for [math]\displaystyle{ d\delta }[/math], which represents the evolution of damage in the current time step. The generic softening law code solves this equation using Newton's method with bracketing. The initial brackets are:
[math]\displaystyle{ d\varepsilon \le d\delta \le d\varepsilon + \varepsilon_0f(\delta,s) }[/math]
The lower limit is found because the second term is less than or equal to zero for monotonic softening. The upper limit is if failure occurs such that [math]\displaystyle{ f(\delta+d\delta,s)=0 }[/math]. If [math]\displaystyle{ d\delta_n }[/math] is the Newton's method sequence approaching the solution, the next increment by Newton's method is derived to be:
[math]\displaystyle{ d\delta_{n+1} = d\delta - {{d\delta-d\varepsilon\over \varepsilon_0f(\delta,s)} + {f(\delta+d\delta,s)\over f(\delta,s)}-1\over {1\over \varepsilon_0f(\delta,s)} + {f'(\delta+d\delta,s)\over f(\delta,s)}} }[/math]
When the next increment is outside the current brackets, a custom bracketing calculation is used to make the solution always stable. Although generic code can solve this differential equation for any softening law with provided properties listed above, some softening laws may have more efficient solutions. For example Linear Softening can exactly solve the differential equation without needing Newton's method and Exponential Softening can express the solution in terms of branch zero of the Lambert W function for real arguments (although evaluation of that function needs a numerical method). Any new softening laws can override generic functions for Newton's method if they have a more efficient approach.