1% How to use `MFront` in `CalculiX` 2% Thomas Helfer, Rafal Brzegowy 3% 2/02/2017 4 5<div id="slideshow"> 6 <ul class="slides"> 7 <li> 8 <video style="display:block; margin: 0 auto;" width="640" height="320" controls> 9 <source src="media/CalculiXSheetForming-50.mp4" type="video/mp4"> 10 Your browser does not support the video tag. 11 </video> 12 </li> 13 <li><img src="img/CalculiX_MFRONT_WSL.png" width="620" height="320" alt="Forming test by Rafal Brzegowy" /></li> 14 </ul> 15 <span class="arrow previous"></span> 16 <span class="arrow next"></span> 17</div> 18<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> 19<script src="js/slideshow.js"></script> 20 21# User defined behaviour in `CalculiX` 22 23User-defined mechanical behavior can be implemented using three 24different interfaces: 25 26- The native `CalculiX` interface. 27- The `ABAQUS` `umat` routines for linear materials (small strain 28 analyses). 29- The `ABAQUSNL` `umat` routines for non linear materials (finite 30 strain analyses). 31 32There are two ways of introducing user-defined mechanical behavior: 33 34- Modify the `CalculiX` sources. This option is supported for the 35 three interfaces. 36- Call a behavior defined in shared libraries. 37 38Each of these approaches has its own advantages and its own 39pitfalls. 40 41The first one is intrusive and requires a partial recompilation of 42`CalculiX`, which means having access to the sources and the rights to 43install the executable if it is meant to be deployed on a system-wide 44location. 45 46The second one does not require any modification to `CalculiX`, is 47generally easier to set up and is very flexible. There is no intrinsic 48limitations on the number of shared libraries and functions that can 49be dynamically loaded. It is thus quite feasible to create mechanical 50behaviours databases by creating a shared library by specific 51material. Such libraries will only be loaded if needed. In such an 52approach, the mechanical behaviour is dedicated to a specific material 53and is self-contained: it has no external parameter. 54 55Shared libraries can be shared between co-workers by moving them on a 56shared folder. 57 58However, experience shows that using shared libraries can be confusing 59for some user as they have to update their environment variables 60(`PATH` on Windows or `LD_LIBRARY_PATH` on Unixes) for the libraries 61to be usable. Shared libraries can also be more sensible to system 62updates. 63 64> **Note** 65> 66> Calling external libraries from `CalculiX` for the `ABAQUS` and 67> `ABAQUSNL` is supported in `CalculiX` since version `2.12`. If you 68> are compiling `CalculiX` from the sources, you must use the 69> `Makefile_MFront` file (which is part from the sources) to enable 70> it. 71> 72> Calling external libraries from `CalculiX` for the native interface 73> requires a patch in version `2.12` that can be downloaded 74> [here](downloads/patchs-CalculiX-2.12.tar.bz2). 75 76## Using the `CalculiX` native interface 77 78When compiling a `MFront` behaviour, the `CalculiX` native interface 79is invoked as follows: 80 81~~~~{.bash} 82$ mfront --obuild --interface=calculix Chaboche.mfront 83Treating target : all 84The following library has been built : 85- libCALCULIXBEHAVIOUR.so : CHABOCHE 86~~~~ 87 88The `libCALCULIXBEHAVIOUR.so` is generated in the `src` 89subdirectory. This library shall be copied in a location where the 90dynamic loade can find it. Another solution is to add the `src` 91directory to the `LD_LIBRARY_PATH` as follows: 92 93~~~~{.bash} 94$ export LD_LIBRARY_PATH=$(pwd)/src:$LD_LIBRARY_PATH 95~~~~ 96 97An template for the behaviour declaration has been generated in the 98`calculix` subdirectory. 99 100~~~~{.fortran} 101** 102** File generated by MFront from the Chaboche.mfront source 103** Example of how to use the Chaboche behaviour law 104** Author Jean - Michel Proix 105** Date 26 / 11 / 2013 106** 107 108*Material, name=@CALCULIXBEHAVIOUR_CHABOCHE 109*Depvar 11019 111** The material properties are given as if we used parameters to explicitly 112** display their names. Users shall replace those declaration by 113** theirs values 114*User Material, constants=12 115<YoungModulus>, <PoissonRatio>, <R_inf>, <R_0>, <b>, <k>, <w>, <C_inf_0>, 116<C_inf_1>, <g_0_0>, <g_0_1>, <a_inf> 117~~~~ 118 119The interesting part here is the name of the material: 120`CALCULIXBEHAVIOUR_CHABOCHE`, which can be decomposed in two parts 121separated by the underscore character (`_`): 122 123- The first part, `CALCULIXBEHAVIOUR`, is used to determine in which 124 library the external function is implemented. 125- The second part, `CHABOCHE`, gives the name of external function to 126 be called. 127 128Here, the library name has been stripped from system-specific 129convention (the leading `lib` and the `.so` extension). **The base 130name of the library and the name of the function must be 131upper-cased**. This is due to the way `CalculiX` interprets the input 132file. 133 134The material name can optionally ends with an identifier beginning by 135the `@` character. This character can be followed by any character and 136is used to declare two distinct materials based on the same external 137behaviour having different material coefficients. For example, the 138following example declares two distinct materials relying on the same 139external behaviour: 140 141~~~~{.fortran} 142*Material, name=@CALCULIXBEHAVIOUR_ELASTICITY@1 143** The material properties are given as if we used parameters to explicitly 144** display their names. Users shall replace those declaration by 145** theirs values 146*User Material, constants=2 147150000,0.3 148 149*Material, name=@CALCULIXBEHAVIOUR_ELASTICITY@2 150*User Material, constants=2 151200000,0.3 152~~~~ 153 154### Using a small strain behaviour in finite strain analysis 155 156In finite strain, `CalculiX` replaces the linearised strain by the 157Green-Lagrange strain and interprets the output of the behaviour as 158the second Piola-Kirchhoff stress. This allows small strain behaviours 159to be used in the context of finite rotations and this procedures is 160equivalent to the `FiniteRotationSmallStrain` introduced by `MFront` 161in most interfaces. However, this procedure is said to be limited to 162small strain because the trace of the Green-Lagrange strain is not 163related to the change of volume, which is basis of most behaviours 164describing plasticity and viscoplasticity in small strain: indeed, 165even though the plastic strain is traceless, the plastic flow will not 166be *isochoric*. 167 168The situation is quite different in the `ABAQUSNL` interface where the 169Hencky strain (logarithmic strain) is used (see below): the trace of 170the logarithimc strain is directly linked to the change of volume. 171 172This situation is also different from the strategy used in 173`Abaqus/Standard` which tries to integrate the behaviour in rate form 174and then uses the Jauman objective stress rate to ensure objectivity 175(see [@hughes_finite_1980]): this approach is based of the fact that 176the trace of the deformation rate is directly linked to the change of 177volume. 178 179To describe plasticity and viscoplasticity at finite strain using an 180additive decomposition of the strain, we recommend using the 181'MieheApelLambrechtLogarithmicStrain' finite strain strategy in 182`MFront` which is also based on the Hencky strain but interprets the 183output of the behaviour as the dual of the Hencky strain, which is 184consistent from the point of view of energy and automatically ensures 185objectivity. See [@miehe_anisotropic_2002] for details. 186 187## Using the `Abaqus/Standard` interface 188 189For performance reasons, `CalculiX` supports two kinds of interfaces 190to `Abaqus/Standard`'s `umat` behaviours: 191 192- `ABAQUS` is meant to describe linear materials. 193- `ABAQUSNL` is meant to describe no linear materials. For nonlinear 194 materials the logarithmic strain and infinitesimal rotation are 195 calculated, which slows down the calculation. Consequently, the 196 nonlinear routine should only be used if necessary. 197 198Those two interface supports the call to behaviours in external shared 199libraries. 200 201Calling shared libraries is triggered by putting the `@` character in 202front material name. The material name is then decomposed into three 203parts, separated by the `_` character: 204 205- The name of the interface (`ABAQUS` or `ABAQUSNL`). 206- The base name of the shared library (see below). 207- The name of the function implementing the behavior. 208 209For instance, if we want to call a small strain behavior in a linear 210analysis, implemented by the `CHABOCHE` function in the 211`libABAQUSBEHAVIOURS.so` shared library (Under `Windows`, the library 212name has the `dll` extension.), one would declare the following 213material name: 214 215`@ABAQUS_ABAQUSBEHAVIOURS_CHABOCHE` 216 217## Using the `MFront` behaviours generated through the `abaqus` interface 218 219As described in the previous section, calling shared libraries in only 220supported for the `ABAQUS` or `ABAQUSNL` interfaces. This means that 221we can call mechanical behaviours generated by `MFront` through the 222`abaqus` interface quite easily. 223 224The `abaqus` interface is described [here](abaqus.html). 225 226### A first example, the Saint-Venant Kirchoff hyperelastic behaviour 227 228#### Generation of the shared library 229 230Consider the Saint-Venant Kirchoff hyperelastic behaviour as 231implemented 232[here](gallery/hyperelasticity/SaintVenantKirchhoffElasticity.mfront). 233 234The library is generated like this: 235 236~~~~~{.bash} 237$ mfront --obuild --interface=abaqus SaintVenantKirchhoffElasticity.mfront 238Treating target : all 239The following library has been built : 240- libABAQUSBEHAVIOUR.so : SAINTVENANTKIRCHHOFFELASTICITY_AXIS SAINTVENANTKIRCHHOFFELASTICITY_PSTRAIN SAINTVENANTKIRCHHOFFELASTICITY_3D 241~~~~~ 242 243This shows that the library `libABAQUSBEHAVIOUR.so` has been 244generated. Then, we have one implementation per modelling 245hypothesis. For a \(3D\) computation, one shall use the 246`SAINTVENANTKIRCHHOFFELASTICITY_3D` function. 247 248Thus, the material name to be used is: 249`@ABAQUSNL_ABAQUSBEHAVIOUR_SAINTVENANTKIRCHHOFFELASTICITY_3D`. 250 251> **Known issue with `CalculiX` 2.12** 252> 253> The source code generated by MFront contains a test that checks if 254> the behaviour is called in a finite strain resolution. This 255> information is not available in `CalculiX` 2.12, so the generation 256> of the library must be made as follows: 257> 258> 1) Generate the sources: 259> 260> ~~~~~{.bash} 261> $ mfront --interface=abaqus SaintVenantKirchhoffElasticity.mfront 262> ~~~~~ 263> 264> 2) Modify the sources: 265> 266> Comment all the blocks in the 267>`src/abaqusSaintVenantKirchhoffElasticity.cxx` file of the form: 268> 269> ~~~~~{.cpp} 270> if(KSTEP[2]!=1){ 271> std::cerr << "the SaintVenantKirchhoffElasticity behaviour is only valid in finite strain analysis\n"; 272> *PNEWDT=-1; 273> return; 274> } 275> ~~~~~ 276> 277> 3) Compile the library: 278> 279> ~~~~~{.bash} 280> $ mfront --obuild 281> ~~~~~ 282> 283 284> Another solution is to desactive checks (for `TFEL` greater than 285> 3.1) like this: 286> 287> ~~~~~{.bash} 288> $ mfront --obuild -D MFRONT_ABAQUS_NORUNTIMECHECKS --interface=abaqus SaintVenantKirchhoffElasticity.mfront 289> ~~~~~ 290 291#### A simple tensile test 292 293The description of a simple tensile test is as follows: 294 295~~~~~{.fortran} 296** 297** GEOMETRY 298** 299*Node 300 1, 0., 0., 1. 301 2, 0., 1., 1. 302 3, 0., 0., 0. 303 4, 0., 1., 0. 304 5, 1., 0., 1. 305 6, 1., 1., 1. 306 7, 1., 0., 0. 307 8, 1., 1., 0. 308*Element, type=C3D8, elset=cube 3091, 5, 6, 8, 7, 1, 2, 4, 3 310*Solid Section, elset=cube, material=@ABAQUSNL_ABAQUSBEHAVIOUR_SAINTVENANTKIRCHHOFFELASTICITY_3D 311, 312*Nset, nset=sx2, generate 313 5, 8, 1 314*Nset, nset=sx1, generate 315 1, 4, 1 316*Nset, nset=sy1 317 1, 3, 5, 7 318*Nset, nset=sy2 319 2, 4, 6, 8, 320*Nset, nset=sz1 321 3, 4, 7, 8 322*Nset, nset=sz2 323 1, 2, 5, 6, 324** 325** MATERIAL 326** 327*Material, name=@ABAQUSNL_AbaqusBehaviour_SaintVenantKirchhoffElasticity_3D 328*Depvar 329 0 330* User Material, constants=2 331 150e9, 0.34 332** 333** LOADING 334** 335*Step, nlgeom=YES 336*Static 3370.02, 1., 1e-05, 0.2 338*Boundary 339sx1, 1, 1 340*Boundary 341sy1, 2,2 342*Boundary 343sz1, 3,3 344*Boundary 345sx2, 1, 1, 0.2 346*EL PRINT, ELSET=cube 347E, S 348*End Step 349~~~~~~ 350 351> **Named state variables** 352> 353> `MFront` generates an example showing how to use the behaviour in 354> `Abaqus/Standard`. Such example names each state variables, which is 355> usefull for post-processing. However this feature is currently not 356> supported by `CalculiX`. 357 358# Known issues 359 360## `ABAQUS` and `ABAQUSNL` interfaces 361 362### Number of states variables and number of material properties 363 364In `CalculiX` 2.12, the value of the `NSTATV` argument passed to the 365`ABAQUS` and `ABAQUSNL` interfaces is the maximum number of state 366variables for all the materials. This is not what consistent with 367`Abaqus/Standard` which passes the number of state variables of the 368material. 369 370The same remarks applies to the number of the material properties 371(`NPROPS` argument). 372 373This issue can be circumvent by disabling checks in `MFront`: 374 375> ~~~~~{.bash} 376> $ mfront --obuild -D MFRONT_ABAQUS_NORUNTIMECHECKS --interface=abaqus SaintVenantKirchhoffElasticity.mfront 377> ~~~~~ 378 379### Behaviours at finite strain with `CalculiX` 2.12 380 381The source code generated by MFront contains a test that checks if the 382behaviour is called in a finite strain resolution. This information is 383not available in `CalculiX` 2.12. See the 384`SaintVenantKirchhoffElasticity` example for details of how to 385circumvent this issue. 386 387# Benchmarks 388 389## Small strain 390 391![](img/CalculiXBenchmarkSmallStrain.png "") 392 393This example describes an tensile test on an AE specimen using an 394[isotropic linear hardening plasticity behaviour](gallery/plasticity/IsotropicLinearKinematicHardeningPlasticity.mfront) 395depicted on the previous figure. 396 397CPU times between the native implementation and the MFront 398implementation (using the `CalculiX` interface) are reported in the 399following table: 400 401| | `CalculiX` | `MFront` | 402|-------|------------|-----------| 403|real | 7m43.588s | 8m6.849s | 404|user | 7m40.572s | 7m59.904s | 405|sys | 0m4.180s | 0m6.676s | 406 407Those figures shows that using the `MFront` implementation is 408\(4.9\%\) slower. Using the `callgrind` profiling tool of `valgrind` 409framework, one can see that more time is spend in looking for function 410`calculix_searchExternalBehaviours` than in the behaviour integration: 411\(2.65\%\) of the time vs \(1.66\%\) ! 412 413This is du to the mostly non intrusive way of introducing external 414behaviours in `CalculiX`. This additional cost could totally disapear 415with a more clever and intrusive development. 416 417If those 2.65% are removed from the total computational time, the 418`MFront` only causes to a \(2.3\%\) slow down, which is 419acceptable. 420 421This slow down could be du to the fact that the `MFront` behaviours 422update the elastic strain and recomputes the stress (it does not 423simply update it by adding an increment, as this is done in most 424implementation). Using the elastic strain is mandatory to handle 425properly material properties changing with temperature and thermal 426expansion. 427 428# References 429 430<!-- Local IspellDict: english --> 431