├── .gitignore ├── .travis.yml ├── LICENSE ├── README.md ├── bin └── build-fext ├── docs ├── .buildinfo ├── .gitignore ├── .nojekyll ├── _images │ ├── flow.png │ └── mmv.png ├── _sources │ ├── examples │ │ ├── ex1.rst.txt │ │ ├── ex2.rst.txt │ │ ├── ex3.rst.txt │ │ └── index.rst.txt │ ├── execution │ │ ├── cli.rst.txt │ │ ├── examples.rst.txt │ │ ├── index.rst.txt │ │ ├── mps.rst.txt │ │ ├── notebook.rst.txt │ │ ├── optimize.rst.txt │ │ ├── overview.rst.txt │ │ ├── permutate.rst.txt │ │ └── post.rst.txt │ ├── index.rst.txt │ ├── intro │ │ ├── about.rst.txt │ │ ├── conventions.rst.txt │ │ ├── environment.rst.txt │ │ ├── index.rst.txt │ │ ├── input.rst.txt │ │ ├── install.rst.txt │ │ ├── output.rst.txt │ │ └── solution.rst.txt │ ├── material │ │ ├── builtin.rst.txt │ │ ├── comm.rst.txt │ │ ├── elastic.rst.txt │ │ ├── expansion.rst.txt │ │ ├── fortran.rst.txt │ │ ├── index.rst.txt │ │ ├── mooney_rivlin.rst.txt │ │ ├── overview.rst.txt │ │ ├── plastic.rst.txt │ │ ├── python.rst.txt │ │ ├── sdvini.rst.txt │ │ ├── transverse_elastic.rst.txt │ │ ├── trs.rst.txt │ │ ├── uanisohyper_inv.rst.txt │ │ ├── uhyper.rst.txt │ │ ├── umat.rst.txt │ │ ├── user.rst.txt │ │ └── viscoelastic.rst.txt │ └── test │ │ ├── index.rst.txt │ │ ├── intro.rst.txt │ │ ├── standard.rst.txt │ │ ├── validation.rst.txt │ │ └── verification.rst.txt ├── _static │ ├── ajax-loader.gif │ ├── alabaster.css │ ├── basic.css │ ├── comment-bright.png │ ├── comment-close.png │ ├── comment.png │ ├── doctools.js │ ├── down-pressed.png │ ├── down.png │ ├── file.png │ ├── jquery-3.1.0.js │ ├── jquery.js │ ├── minus.png │ ├── plus.png │ ├── pygments.css │ ├── searchtools.js │ ├── underscore-1.3.1.js │ ├── underscore.js │ ├── up-pressed.png │ ├── up.png │ └── websupport.js ├── doctrees │ ├── environment.pickle │ ├── examples │ │ ├── ex1.doctree │ │ ├── ex2.doctree │ │ ├── ex3.doctree │ │ └── index.doctree │ ├── execution │ │ ├── cli.doctree │ │ ├── examples.doctree │ │ ├── index.doctree │ │ ├── mps.doctree │ │ ├── notebook.doctree │ │ ├── optimize.doctree │ │ ├── overview.doctree │ │ ├── permutate.doctree │ │ └── post.doctree │ ├── index.doctree │ ├── intro │ │ ├── about.doctree │ │ ├── conventions.doctree │ │ ├── environment.doctree │ │ ├── index.doctree │ │ ├── input.doctree │ │ ├── install.doctree │ │ ├── output.doctree │ │ └── solution.doctree │ ├── material │ │ ├── builtin.doctree │ │ ├── comm.doctree │ │ ├── elastic.doctree │ │ ├── expansion.doctree │ │ ├── fortran.doctree │ │ ├── index.doctree │ │ ├── mooney_rivlin.doctree │ │ ├── overview.doctree │ │ ├── plastic.doctree │ │ ├── python.doctree │ │ ├── sdvini.doctree │ │ ├── transverse_elastic.doctree │ │ ├── trs.doctree │ │ ├── uanisohyper_inv.doctree │ │ ├── uhyper.doctree │ │ ├── umat.doctree │ │ ├── user.doctree │ │ └── viscoelastic.doctree │ └── test │ │ ├── index.doctree │ │ ├── intro.doctree │ │ ├── standard.doctree │ │ ├── validation.doctree │ │ └── verification.doctree ├── examples │ ├── ex1.html │ ├── ex2.html │ ├── ex3.html │ └── index.html ├── execution │ ├── cli.html │ ├── examples.html │ ├── index.html │ ├── mps.html │ ├── notebook.html │ ├── optimize.html │ ├── overview.html │ ├── permutate.html │ └── post.html ├── genindex.html ├── index.html ├── intro │ ├── about.html │ ├── conventions.html │ ├── environment.html │ ├── index.html │ ├── input.html │ ├── install.html │ ├── output.html │ └── solution.html ├── material │ ├── builtin.html │ ├── comm.html │ ├── elastic.html │ ├── expansion.html │ ├── fortran.html │ ├── index.html │ ├── mooney_rivlin.html │ ├── overview.html │ ├── plastic.html │ ├── python.html │ ├── sdvini.html │ ├── transverse_elastic.html │ ├── trs.html │ ├── uanisohyper_inv.html │ ├── uhyper.html │ ├── umat.html │ ├── user.html │ └── viscoelastic.html ├── objects.inv ├── search.html ├── searchindex.js ├── source │ ├── Makefile │ ├── __init__.py │ ├── _static │ │ └── .dir │ ├── alabaster │ │ ├── __init__.py │ │ ├── _version.py │ │ ├── about.html │ │ ├── donate.html │ │ ├── layout.html │ │ ├── navigation.html │ │ ├── relations.html │ │ ├── static │ │ │ └── alabaster.css_t │ │ ├── support.py │ │ └── theme.conf │ ├── conf.py │ ├── examples │ │ ├── ex1.rst │ │ ├── ex2.rst │ │ ├── ex3.rst │ │ └── index.rst │ ├── execution │ │ ├── cli.rst │ │ ├── examples.rst │ │ ├── index.rst │ │ ├── mps.rst │ │ ├── notebook.rst │ │ ├── optimize.rst │ │ ├── overview.rst │ │ ├── permutate.rst │ │ └── post.rst │ ├── images │ │ ├── cfmt_desc.png │ │ ├── figs.key │ │ ├── flow.png │ │ ├── mmv.png │ │ ├── mmv_sig.png │ │ ├── path.png │ │ └── path_desc.png │ ├── index.rst │ ├── intro │ │ ├── about.rst │ │ ├── conventions.rst │ │ ├── environment.rst │ │ ├── index.rst │ │ ├── input.rst │ │ ├── install.rst │ │ ├── output.rst │ │ ├── quick.rstx │ │ └── solution.rst │ ├── material │ │ ├── builtin.rst │ │ ├── comm.rst │ │ ├── elastic.rst │ │ ├── expansion.rst │ │ ├── fortran.rst │ │ ├── index.rst │ │ ├── mooney_rivlin.rst │ │ ├── overview.rst │ │ ├── plastic.rst │ │ ├── python.rst │ │ ├── sdvini.rst │ │ ├── transverse_elastic.rst │ │ ├── trs.rst │ │ ├── uanisohyper_inv.rst │ │ ├── uhyper.rst │ │ ├── umat.rst │ │ ├── user.rst │ │ └── viscoelastic.rst │ └── test │ │ ├── index.rst │ │ ├── intro.rst │ │ ├── standard.rst │ │ ├── validation.rst │ │ └── verification.rst └── test │ ├── index.html │ ├── intro.html │ ├── standard.html │ ├── validation.html │ └── verification.html ├── matmodlab2 ├── .flake8 ├── __init__.py ├── core │ ├── __init__.py │ ├── database.py │ ├── deformation.py │ ├── environ.py │ ├── linalg.py │ ├── logio.py │ ├── material.py │ ├── matmodlab.py │ ├── misc.py │ ├── numerix.py │ ├── stress_control.py │ └── tensor.py ├── ext_helpers │ ├── __init__.py │ ├── blas_lapack-lite.f │ ├── build_ext.py │ ├── dgpadm.f │ ├── matrix_funcs.f90 │ ├── matrix_funcs.pyf │ └── mml_io.f90 ├── fitting │ ├── __init__.py │ ├── hyperfit.py │ ├── hyperopt.py │ └── mcgen.py ├── materials │ ├── __init__.py │ ├── addon.py │ ├── debugger.py │ ├── effective_stress.py │ ├── elastic.py │ ├── elastic2.py │ ├── elastic3.py │ ├── expansion.py │ ├── mooney_rivlin.py │ ├── neohooke.py │ ├── plastic.py │ ├── plastic2.py │ ├── plastic3.py │ ├── polyhyper.py │ ├── tresca.py │ ├── viscoelastic.py │ └── vonmises.py ├── optimize │ ├── __init__.py │ ├── numerix.py │ ├── optimizer.py │ └── tabular.py ├── umat │ ├── __init__.py │ ├── aba_param.inc │ ├── aba_sdvini.f90 │ ├── aba_utils.f90 │ ├── tensalg.f90 │ ├── uhyper.py │ ├── uhyper.pyf │ ├── uhyper_wrap.f90 │ ├── umat.py │ ├── umat.pyf │ ├── umats │ │ ├── __init__.py │ │ ├── uhyper_neohooke.f90 │ │ ├── umat_neohooke.f90 │ │ ├── umat_stub.f90 │ │ └── umat_thermoelastic.f90 │ ├── vumat.py │ └── vumat.pyf └── version.py ├── notebooks ├── .gitignore ├── Expressions.ipynb ├── GettingStarted.ipynb ├── HardeningJ2Plasticity.ipynb ├── Hyperfit.ipynb ├── Introduction.ipynb ├── LinearElastic.ipynb ├── MasterCurve.ipynb ├── MooneyRivlin.ipynb ├── NonhardeningJ2Plasticity.ipynb ├── PaperFigs.ipynb ├── ParameterOptimization.ipynb ├── PolynomialHyperelastic.ipynb ├── PoroplasticFitting.ipynb ├── Treloar_hyperelastic_data.xlsx ├── UserMaterials.ipynb ├── Writing Umats.ipynb ├── aldat.xls ├── mcgen.csv ├── plotting_helpers.py └── porodata.xlsx ├── requirements.txt ├── setup.py └── tests ├── .gitignore ├── data ├── j2_plast.base_dat ├── j2_plast_iso_hard.base_dat ├── j2_plast_kin_hard.base_dat ├── j2_plast_mix_hard.base_dat ├── lin_druck_prag_spher.base_dat └── mcgen.csv ├── fortran ├── conftest.py ├── test_core_matfuncs.py ├── test_ext_helpers_build_ext.py ├── test_materials_uhyper.py ├── test_materials_umat.py └── testing_utils.py ├── swan ├── test_correct_strain_evolution.py └── test_defgrad_basic.py ├── test_core_deformation.py ├── test_core_deformation_2.py ├── test_core_linalg.py ├── test_core_material_ufield.py ├── test_core_misc.py ├── test_core_mps_unit.py ├── test_core_stress_control.py ├── test_core_tensor.py ├── test_environment.py ├── test_fitting_hyperopt.py ├── test_fitting_mcgen.py ├── test_materials_brannon_leela.py ├── test_materials_elastic.py ├── test_materials_expansion.py ├── test_materials_j2plasticity.py ├── test_materials_linear_drucker_prager.py ├── test_materials_mooney_rivlin.py ├── test_materials_polyhyper.py ├── test_materials_tresca.py ├── test_materials_user_interface.py ├── test_materials_viscoelastic.py ├── test_optimize_optimizer.py └── testing_utils.py /.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | *.exo 3 | *.log 4 | *.eval 5 | *.npz 6 | *.so 7 | *.so.dSYM 8 | *.o 9 | *module.c 10 | foo.* 11 | foo 12 | .ipynb_checkpoints/* 13 | .ipynb_checkpoints 14 | *.eval/* 15 | __pycache__ 16 | __pycache__/* 17 | tests/.cache 18 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: python 2 | python: 3 | - "3.5" 4 | - "3.6" 5 | # command to install dependencies 6 | #install: "pip install -r requirements.txt" 7 | # command to run tests 8 | install: 9 | - pip install numpy scipy pandas 10 | - python setup.py install 11 | script: 12 | - py.test --ignore=./tests/fortran 13 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2017, Tim Fuller 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | * Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | * Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # The Material Model Laboratory 2 | 3 | ## What is it? 4 | 5 | The material model laboratory (*Matmodlab2*) is a material point simulator developed as a tool for developing and analyzing material models for use in larger finite element codes. 6 | 7 | ## System Requirements 8 | 9 | *Matmodlab2* has been built and tested extensively on several versions of linux 10 | and the Apple Mac OSX 10 operating systems. 11 | 12 | ### Required Software 13 | 14 | *Matmodlab2* requires the following software installed for your platform: 15 | 16 | - [Python (3.5 or newer)](http://www.python.org) or newer 17 | 18 | - [Numpy](http://www.numpy.org) 19 | 20 | - [Scipy](http://www.scipy.org) 21 | 22 | 23 | *Matmodlab2* is developed and tested using the [Anaconda](http://continuum.io) Python distributions. 24 | 25 | ### Optional Software 26 | 27 | - [Pandas](http://www.pandas.pydata.org) 28 | 29 | - [py.test](http://doc.pytest.org/en/latest) 30 | 31 | ## Installation 32 | 33 | The easiest way to get started with *Matmodlab2* is to 34 | clone or download *Matmodlab2* from the 35 | [repository](https://www.github.com/matmodlab/matmodlab2), navigate to the 36 | `matmodlab2` directory, and execute 37 | 38 | ``` 39 | python setup.py install 40 | ``` 41 | 42 | which will install *Matmodlab2* to your Python package's `site-packages` 43 | directory. Optionally, execute 44 | 45 | ``` 46 | python setup.py develop 47 | ``` 48 | 49 | and source files files are *linked* to the Python interpreter’s site-packages, 50 | rather than copied. This way, changes made to source files are applied 51 | immediately and do not require you to re-install *Matmodlab2*. 52 | 53 | Another method to "install" *Matmodlab2* is to simply set the `PYTHONPATH` 54 | environment variable to the `matmodlab2` directory. 55 | 56 | ## Documentation 57 | 58 | The documentation consists of Jupyter notebooks contained in the 59 | `matmodlab2/notebooks` directory and vieweable at [Introduction to 60 | Matmodlab](https://github.com/tjfulle/matmodlab2/blob/master/notebooks/Introduction.ipynb) 61 | 62 | ## Troubleshooting 63 | 64 | If you experience problems when building/installing/testing *Matmodlab2*, you 65 | can ask help from Tim Fuller 66 | -------------------------------------------------------------------------------- /bin/build-fext: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | from argparse import ArgumentParser 3 | from matmodlab2.ext_helpers.build_ext import main as ext_main 4 | 5 | def main(): 6 | ext_main() 7 | 8 | if __name__ == '__main__': 9 | main() 10 | -------------------------------------------------------------------------------- /docs/.buildinfo: -------------------------------------------------------------------------------- 1 | # Sphinx build info version 1 2 | # This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. 3 | config: 951f1c9b1848e93c989b5bdc43f9e8f2 4 | tags: 645f666f9bcd5a90fca523b33c5a78b7 5 | -------------------------------------------------------------------------------- /docs/.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | *.exo 3 | *.so 4 | *.con 5 | *.out 6 | *.perm 7 | *.eval 8 | *.opt 9 | *.log 10 | *.preprocessed 11 | *.o 12 | build/ 13 | *module.c 14 | *.bak 15 | *mod 16 | 17 | *-f2pywrappers2.f90 18 | 19 | docs/auto 20 | docs/*.aux 21 | docs/*.log 22 | docs/*.lof 23 | docs/*.lot 24 | docs/*.toc 25 | docs/*.bbl 26 | docs/*.blg 27 | docs/*.synctex.gz 28 | params.in 29 | lib/material_models.db 30 | lib/*.so 31 | 32 | TestResults.* 33 | .built 34 | 35 | _images/math/* 36 | -------------------------------------------------------------------------------- /docs/.nojekyll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matmodlab/matmodlab2/d2e6f5332d319752285c042e88e2baab506dc921/docs/.nojekyll -------------------------------------------------------------------------------- /docs/_images/flow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matmodlab/matmodlab2/d2e6f5332d319752285c042e88e2baab506dc921/docs/_images/flow.png -------------------------------------------------------------------------------- /docs/_images/mmv.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matmodlab/matmodlab2/d2e6f5332d319752285c042e88e2baab506dc921/docs/_images/mmv.png -------------------------------------------------------------------------------- /docs/_sources/examples/ex1.rst.txt: -------------------------------------------------------------------------------- 1 | 2 | Example 1: Uniaxial Strain 3 | ########################## 4 | 5 | This example demonstrates exercising the elastic material model through a path 6 | of uniaxial strain. The example input below is found in ``matmodlab/examples/uniaxial_strain.py`` 7 | 8 | The Example Script 9 | ================== 10 | 11 | :: 12 | 13 | from matmodlab import * 14 | 15 | # Create the material point simulator 16 | mps = MaterialPointSimulator('uniaxial_strain') 17 | 18 | # Define the material 19 | mps.Material('elastic', {'K': 1.35e11, 'G': 5.3e10}) 20 | 21 | # Define the strain step 22 | mps.StrainStep(components=(1, 0, 0), scale=.02) 23 | 24 | # Run the simulation 25 | mps.run() 26 | 27 | 28 | How Does the Script Work? 29 | ========================= 30 | 31 | This section describes each part of the example script. 32 | 33 | ``from matmodlab import *`` 34 | 35 | This statement makes the Matmodlab objects accessible to the script. 36 | 37 | ``mps = MaterialPointSimulator('uniaxial_strain')`` 38 | 39 | This statement creates a new material point simlator object named ``uniaxial_strain``. The variable ``mps`` is assigned to the simulator. 40 | 41 | ``mps.Material('elastic', {'K': 1.35e11, 'G': 5.3e10})`` 42 | 43 | This statement defines the material model to be the ``elastic`` material and 44 | defines the bulk modulus ``K`` and shear modulus ``G`` to ``1.35e11`` and 45 | ``5.3e10``, respectively. 46 | 47 | ``mps.StrainStep(components=(1, 0, 0), scale=.02)`` 48 | 49 | This statement defines an analysis step through which the material will be 50 | exercised. The step is defined by the tensor ``components`` :math:`(1, 0, 0)`, 51 | representing the ``xx``, ``yy``, and ``zz`` components of the strain tensor. A 52 | ``scale`` factor of ``.02`` is applied to each component. 53 | 54 | * The first 3 values of ``components`` represent the ``xx``, ``yy``, and 55 | ``zz`` components of the tensor describing the deformation path. The ``xy``, 56 | ``yz``, and ``xz`` components are implicitly ``0``. 57 | 58 | ``mps.run()`` 59 | 60 | This statement runs the material through the defined deformation path. 61 | -------------------------------------------------------------------------------- /docs/_sources/examples/ex2.rst.txt: -------------------------------------------------------------------------------- 1 | 2 | Example 2: Uniaxial Stress 3 | ########################## 4 | 5 | This example demonstrates exercising the elastic material model through a path 6 | of uniaxial stress. The example input below is found in ``matmodlab/examples/uniaxial_stress.py`` 7 | 8 | The Example Script 9 | .................. 10 | 11 | :: 12 | 13 | from matmodlab import * 14 | 15 | # Create the material point simulator 16 | mps = MaterialPointSimulator('uniaxial_stress') 17 | 18 | # Define the material 19 | mps.Material('elastic', {'K': 1.35e11, 'G': 5.3e10}) 20 | 21 | # Define the stress step 22 | mps.StressStep(components=(1, 0, 0), frames=25, scale=1e6) 23 | 24 | # Run the simulation 25 | mps.run() 26 | 27 | How Does the Script Work? 28 | ......................... 29 | 30 | This section describes each part of the example script 31 | 32 | ``from matmodlab import *`` 33 | 34 | This statement makes the Matmodlab objects accessible to the script. 35 | 36 | ``mps = MaterialPointSimulator('uniaxial_stress')`` 37 | 38 | This statement creates a new material point simlator object named ``uniaxial_stress``. The variable ``mps`` is assigned to the simulator. 39 | 40 | ``mps.Material('elastic', {'K': 1.35e11, 'G': 5.3e10})`` 41 | 42 | This statement defines the material model to be the ``elastic`` material and 43 | defines the bulk modulus ``K`` and shear modulus ``G`` to ``1.35e11`` and 44 | ``5.3e10``, respectively. 45 | 46 | ``mps.StressStep(components=(1, 0, 0), frames=25, scale=1e6)`` 47 | 48 | This statement defines an analysis step through which the material will be 49 | exercised. The step is defined by the tensor ``components`` :math:`(1, 0, 0)`, 50 | representing the ``xx``, ``yy``, and ``zz`` components of the stress tensor. A 51 | ``scale`` factor of ``1e6`` is applied to each component. 52 | 53 | * The first 3 values of ``components`` represent the ``xx``, ``yy``, and 54 | ``zz`` components of the tensor describing the deformation path. The ``xy``, 55 | ``yz``, and ``xz`` components are implicitly 0. 56 | 57 | ``mps.run()`` 58 | 59 | This statement runs the material through the defined deformation path. 60 | -------------------------------------------------------------------------------- /docs/_sources/examples/ex3.rst.txt: -------------------------------------------------------------------------------- 1 | 2 | Example 3: Uniaxial Stress, Mixed Mode 3 | ###################################### 4 | 5 | This example demonstrates exercising the elastic material model through a path 6 | of uniaxial stress, using a mixed mode step. The example input below is found in ``matmodlab/examples/uniaxial_stress.py`` 7 | 8 | The Example Script 9 | .................. 10 | 11 | :: 12 | 13 | from matmodlab import * 14 | 15 | # Create the material point simulator 16 | mps = MaterialPointSimulator('uniaxial_stress-1', output=EXO) 17 | 18 | # Define the material 19 | mps.Material('elastic', {'K': 1.35e11, 'G': 5.3e10}) 20 | 21 | # Define the mixed mode step 22 | mps.MixedStep(components=(1, 0, 0), descriptors='ESS', frames=25, scale=.02) 23 | 24 | # Run the simulation 25 | mps.run() 26 | 27 | # Launch the viewer 28 | mps.view() 29 | 30 | How Does the Script Work? 31 | ......................... 32 | 33 | This section describes each part of the example script. 34 | 35 | ``from matmodlab import *`` 36 | 37 | This statement makes the Matmodlab objects accessible to the script. 38 | 39 | ``mps = MaterialPointSimulator('uniaxial_stress-1', output=EXO)`` 40 | 41 | This statement creates a new material point simlator object named ``uniaxial_stress-1``. The variable ``mps`` is assigned to the simulator. The ``output`` format is ``EXO`` (ExodusII) instead of the default ``DBX``. 42 | 43 | ``mps.Material('elastic', {'K': 1.35e11, 'G': 5.3e10})`` 44 | 45 | This statement defines the material model to be the ``elastic`` material and 46 | defines the bulk modulus ``K`` and shear modulus ``G`` to ``1.35e11`` and 47 | ``5.3e10``, respectively. 48 | 49 | ``mps.MixedStep(components=(1, 0, 0), descriptors='ESS', frames=25, scale=.02)`` 50 | 51 | This statement defines an analysis step through which the material will be 52 | exercised. The step is defined by the tensor ``components`` :math:`(1, 0, 0)`, 53 | representing the ``xx`` component of the strain tensor and the ``yy``, and 54 | ``zz`` components of the stress tensor (as designated by the ``descriptors`` 55 | ``"ESS"``). The step is run in ``25`` ``frames`` (increments) and a ``scale`` of 56 | ``.02`` is applied to each component. Note the following: 57 | 58 | * The first 3 values of ``components`` represent the ``xx``, ``yy``, and 59 | ``zz`` components of the tensor describing the deformation path. The ``xy``, 60 | ``yz``, and ``xz`` components are implicitly ``0``. 61 | 62 | * The i\ :superscript:`th` ``descriptor`` designates the physical 63 | interpretation of the i\ :superscript:`th` ``component`` with ``E`` 64 | representing strain and ``S`` representing stress. 65 | 66 | ``mps.run()`` 67 | 68 | This statement runs the material through the defined deformation path. 69 | 70 | ``mps.view()`` 71 | 72 | This statement launches the Matmodlab viewer (the chaco and traitsui Python modules must be installed). 73 | -------------------------------------------------------------------------------- /docs/_sources/examples/index.rst.txt: -------------------------------------------------------------------------------- 1 | Examples 2 | ======== 3 | 4 | See the collection of `Jupyter notebooks `_ for examples of using *Matmodlab2*. 5 | -------------------------------------------------------------------------------- /docs/_sources/execution/cli.rst.txt: -------------------------------------------------------------------------------- 1 | 2 | .. _basic_cli: 3 | 4 | Execution Procedures 5 | #################### 6 | 7 | Overview 8 | ======== 9 | 10 | Matmodlab is executed by running the ``mml`` procedure. Several parameters can be set either on the command line or in an environment file (see :ref:`environment`). 11 | 12 | mml Summary 13 | =========== 14 | 15 | :: 16 | 17 | $ mml [-h|help] [] 18 | 19 | mml Commands 20 | ------------ 21 | 22 | (empty) 23 | ....... 24 | 25 | Launch the (empty) Matmodlab gui 26 | 27 | .. _cli_build: 28 | 29 | build 30 | ..... 31 | 32 | Build fortran libraries 33 | 34 | Optional build arguments 35 | ~~~~~~~~~~~~~~~~~~~~~~~~ 36 | 37 | :: 38 | 39 | -h, --help show this help message and exit 40 | -v V Verbosity 41 | -w Wipe before building 42 | -W Wipe and exit 43 | -m M [M ...] Materials to build 44 | -u Build auxiliary support files only 45 | 46 | clean 47 | ..... 48 | 49 | Remove files generated by Matmodlab (.pyc, .o, .so, .a, build, etc.) 50 | 51 | notebook 52 | ........ 53 | 54 | Launches an `IPython Notebook `_ in the Matmodlab environment. Requires the ``ipython`` and ``ipython-notebook`` modules. 55 | 56 | run 57 | ... 58 | 59 | Run a Matmodlab simulation script in the Matmodlab environment. 60 | 61 | Required run arguments 62 | ~~~~~~~~~~~~~~~~~~~~~~ 63 | 64 | :: 65 | 66 | source Python source file 67 | 68 | Optional run arguments 69 | ~~~~~~~~~~~~~~~~~~~~~~ 70 | 71 | :: 72 | 73 | -h, --help show this help message and exit 74 | -v V Verbosity 75 | --debug Debug mode 76 | --sqa SQA mode 77 | --switch MATX MATY Run with MATY instead of MATX, if present(not 78 | supported by all models) 79 | -B MATERIAL Wipe and rebuild MATERIAL before running 80 | -V Launch results viewer on completion 81 | -j NPROCS, --nprocs NPROCS 82 | Number of simultaneous jobs 83 | -W {std,all,error} Warning level 84 | -w Wipe and rebuild material in Material factory before 85 | running 86 | 87 | .. _cli_test: 88 | 89 | test 90 | .... 91 | 92 | ``mml test`` is merely a wrapper around ``py.test`` 93 | 94 | view 95 | .... 96 | 97 | Launch the Matmodlab viewer 98 | 99 | Required view arguments 100 | ~~~~~~~~~~~~~~~~~~~~~~~ 101 | 102 | :: 103 | 104 | sources Output database file[s] 105 | 106 | 107 | .. _exodiff: 108 | -------------------------------------------------------------------------------- /docs/_sources/execution/examples.rst.txt: -------------------------------------------------------------------------------- 1 | .. _examples: 2 | 3 | Annotated Examples 4 | ################## 5 | 6 | .. topic:: See Also 7 | 8 | * :ref:`intro_conventions` 9 | * :ref:`mps` 10 | 11 | Overview 12 | ======== 13 | 14 | In this section, several example input scripts are described. A Matmodlab 15 | input script consists of defining an instance of the 16 | ``MaterialPointSimulator`` class and defininig for it a ``material`` and 17 | ``steps``. The following examples provide illustration. 18 | 19 | Job Execution 20 | ============= 21 | 22 | Simulations are run by processing Matmodlab input scripts with the ``mml`` 23 | command line utility:: 24 | 25 | $ mml run filename.py 26 | 27 | where ``filename.py`` is the name of the input script. 28 | 29 | Examples 30 | ======== 31 | 32 | .. toctree:: 33 | :maxdepth: 1 34 | 35 | ../examples/ex1 36 | ../examples/ex2 37 | ../examples/ex3 38 | -------------------------------------------------------------------------------- /docs/_sources/execution/index.rst.txt: -------------------------------------------------------------------------------- 1 | 2 | .. _model_create_and_execute: 3 | 4 | Job Execution 5 | ############# 6 | 7 | .. toctree:: 8 | :maxdepth: 1 9 | 10 | overview 11 | cli 12 | mps 13 | post 14 | notebook 15 | permutate 16 | optimize 17 | examples 18 | -------------------------------------------------------------------------------- /docs/_sources/execution/notebook.rst.txt: -------------------------------------------------------------------------------- 1 | .. _notebook: 2 | 3 | Notebook 4 | ######## 5 | 6 | .. topic:: See Also 7 | 8 | * :ref:`basic_cli` 9 | * :ref:`intro_conventions` 10 | * :ref:`mps` 11 | * :ref:`viewer` 12 | 13 | Overview 14 | ======== 15 | 16 | The Matmodlab.Notebook 17 | 18 | * is an `IPython Notebook `_ environment; 19 | * requires the ``ipython`` and ``ipython-notebook`` modules; 20 | * requires the `matplotlib `_ and/or `Bokeh `_ modules for data visualization; and 21 | * allows interactive material model development. 22 | 23 | The full power of the Matmodlab.Notebook is realized by interactive data visualization using `Bokeh `_, which is a recommended install. 24 | 25 | The Matmodlab.Notebook Environment 26 | ================================== 27 | 28 | The Matmodlab.Notebook environment is invoked by launching the IPython Notebook through the ``mml`` procedure:: 29 | 30 | $ mml notebook 31 | 32 | After launching the notebook server and starting a new notebook, the following IPython magic should be executed in the notebook's first cell:: 33 | 34 | %matmodlab 35 | 36 | If Bokeh is installed, the :ref:`mps`\'s plotting methods use Bokeh for data visualization. Otherwise, matplotlib is used as the plotting backend. Matplotlib can be explicitly used as the plotting backend by specifying:: 37 | 38 | %matmodlab matplotlib 39 | 40 | 41 | .. todo:: 42 | 43 | Finish this section 44 | -------------------------------------------------------------------------------- /docs/_sources/execution/overview.rst.txt: -------------------------------------------------------------------------------- 1 | 2 | Job Execution: Overview 3 | ####################### 4 | 5 | .. topic:: See Also 6 | 7 | * :ref:`basic_cli` 8 | * :ref:`intro_conventions` 9 | * :ref:`mps` 10 | 11 | Overview 12 | ======== 13 | 14 | .. figure:: ../images/flow.png 15 | 16 | An analysis in Matmodlab is defined by an input script, which 17 | 18 | * is a Python script that imports the Matmodlab namespace; and 19 | * defines a ``MaterialPointSimulator`` object. 20 | 21 | Once defined, the input script is executed with the ``mml run`` procedure and results viewed with the ``mml view`` procedure. 22 | 23 | The Input Script 24 | ================ 25 | 26 | Most input scripts have the same basic layout: 27 | 28 | 1) Import the Matmodlab namespace:: 29 | 30 | from matmodlab import * 31 | 32 | 2) Instantiate the ``MaterialPointSimulator``:: 33 | 34 | mps = MaterialPointSimulator('jobname') 35 | 36 | 3) Define the simulation steps. For example, a single step of uniaxial strain:: 37 | 38 | mps.StrainStep(components=(1, 0, 0)) 39 | 40 | 4) Define the material model. For example, a linear elastic material:: 41 | 42 | mps.Material('elastic', {'K': 10, 'G': 8}) 43 | 44 | 5) Run the job:: 45 | 46 | mps.run() 47 | 48 | Executing the Input Script 49 | ========================== 50 | 51 | Once written, the input script is executed by the ``mml run`` procedure:: 52 | 53 | $ mml run 54 | 55 | Viewing the Results 56 | =================== 57 | 58 | Once executed, the model results are viewed with ``mml view`` procedure:: 59 | 60 | $ mml view 61 | -------------------------------------------------------------------------------- /docs/_sources/execution/post.rst.txt: -------------------------------------------------------------------------------- 1 | 2 | .. _viewer: 3 | 4 | Postprocessing Results 5 | ###################### 6 | 7 | .. topic:: See Also 8 | 9 | * :ref:`basic_cli` 10 | * :ref:`intro_conventions` 11 | * :ref:`mps` 12 | 13 | Overview 14 | ======== 15 | 16 | The Matmodlab.Viewer is an application that 17 | 18 | * is developed in `TraitsUI `_ and `Chaco `_; 19 | * reads output databases created by the :ref:`mps` and creates 2D plots of the simulation data; and 20 | * is invoked on the command line or as a method of the :ref:`mps`. 21 | 22 | Visualizing Results 23 | =================== 24 | 25 | After completion of a simulation, results can be viewed in one of two ways 26 | 27 | * ``MaterialPointSimulator.view()`` method call:: 28 | 29 | mps.run() 30 | mps.view() 31 | 32 | * The ``mml`` script:: 33 | 34 | $ mml view job.exo 35 | 36 | Whatever the method chosen, a `TraitsUI `_ window is opened... 37 | 38 | .. figure:: ../images/mmv.png 39 | :align: center 40 | :height: 3.5in 41 | 42 | .. todo:: 43 | 44 | Finish this section 45 | -------------------------------------------------------------------------------- /docs/_sources/index.rst.txt: -------------------------------------------------------------------------------- 1 | The Material Model Laboratory 2 | ############################# 3 | 4 | The Material Model Laboratory (*Matmodlab2*) is a single element material model 5 | driver aimed at developers of constitutive routines targeted for deployment in 6 | finite element codes. 7 | 8 | This guide is separated into four main parts: 9 | 10 | * Part 1: :ref:`intro_and_overview` 11 | * Part 2: :ref:`model_create_and_execute` 12 | * Part 3: :ref:`mat_index` 13 | * Part 4: :ref:`test_index` 14 | 15 | Additionally, a growing collection of `Jupyter Notebooks `_ demonstrate *Matmodlab2* usage. 16 | 17 | About This Guide 18 | ================ 19 | 20 | This guide is both a User's Guide and Application Programming Interface (API) 21 | guide to Matmodlab. The guide assumes a working knowledge of the computing 22 | languages Matmodlab is developed in, namely `Python `_ 23 | and `Fortran 24 | `_. No 25 | attempt to describe either is made. Online tutorials for each language are 26 | readily available. Likewise, the target audience is assumed to have a basic 27 | knowledge of continuum mechanics and familiarity with other finite element 28 | codes. These concepts are also not described in detail. 29 | 30 | Conventions Used in the Guide 31 | ----------------------------- 32 | 33 | * Python objects are typeset in ``fixed point font``. 34 | * ``$`` is used to denote a terminal prompt, e.g. ``$ cd`` is interpreted as executing the ``cd`` (change directory) command at a command prompt. 35 | 36 | License 37 | ======= 38 | 39 | *Matmodlab2* is an open source project licensed under the `MIT `_ license. 40 | 41 | Obtaining and Installing Matmodlab2 42 | =================================== 43 | 44 | *Matmodlab2* is maintained with git and can be obtained from ``_. To install *Matmodlab2*, obtain a copy (by cloning or downloading) of the source code and add the path to the ``matmodlab2`` root directory to your ``PYTHONPATH``. 45 | 46 | Acknowledgments 47 | =============== 48 | 49 | The inspiration for *Matmodlab2* came from Dr. `Rebecca Brannon's `_ *MED* material point driver and Tom Pucicks's *MMD* driver, developed at Sandia National Labs. 50 | 51 | The syntax and documentation have been greatly influenced by the authors' exposure and use of research codes at Sandia National Labs and other commercial finite element codes, notably `Abaqus `_. 52 | 53 | Obtaining Additional Help 54 | ========================= 55 | 56 | In addition to this guide, many examples can be found in 57 | ``matmodlab2/notebooks`` and ``matmodlab2/tests`` 58 | 59 | Indices and tables 60 | ================== 61 | 62 | * :ref:`genindex` 63 | 64 | * :ref:`search` 65 | 66 | .. toctree:: 67 | :maxdepth: 4 68 | :hidden: 69 | :numbered: 2 70 | 71 | intro/index 72 | execution/index 73 | material/index 74 | examples/index 75 | test/index 76 | -------------------------------------------------------------------------------- /docs/_sources/intro/about.rst.txt: -------------------------------------------------------------------------------- 1 | 2 | Introduction: Background 3 | ######################## 4 | 5 | Why a Single Element Driver? 6 | ============================ 7 | 8 | Single element drivers allow the constituive model developer to concentrate on 9 | model development and not the finite element response. Advantages of 10 | *Matmodlab2* (or, more generally, of any stand-alone constitutive model driver) 11 | are 12 | 13 | * *Matmodlab2* is a very small, special purpose, code. Thus, maintaining 14 | and adding new features to *Matmodlab2* is very easy; 15 | 16 | * simulations are not affected by irrelevant artifacts such as artificial 17 | viscosity or uncertainty in the handling of boundary conditions; 18 | 19 | * it is straightforward to produce supplemental output for deep analysis of 20 | the results that would otherwise constitute an unnecessary overhead in a 21 | finite element code; 22 | 23 | * specific material benchmarks may be developed and automatically run 24 | quickly any time the model is changed; and 25 | 26 | * specific features of a material model may be exercised easily by the model 27 | developer by prescribing strains, strain rates, stresses, stress rates, and 28 | deformation gradients as functions of time. 29 | 30 | Why Python? 31 | =========== 32 | 33 | Python is an interpreted, high level object oriented language. Programs can be 34 | written rapidly and, because it is an interpreted language, do not require a 35 | compiling step. While this might make programs written in python slower than 36 | those written in a compiled language, modern packages and computers make the 37 | speed up difference between python and a compiled language for single element 38 | problems almost insignificant. 39 | 40 | For numeric computations, the `NumPy `_ and `SciPy 41 | `_ modules allow programs written in Python to leverage 42 | a large set of numerical routines provided by lapack, blas, 43 | eigpack, etc. Python's APIs also allow for calling subroutines written in 44 | C or Fortran (in addition to a number of other languages), a prerequisite for 45 | model development as most legacy material models are written in Fortran. In 46 | fact, most modern material models are still written in Fortran to this day. 47 | 48 | Python's object oriented nature allows for rapid installation of new material 49 | models. 50 | -------------------------------------------------------------------------------- /docs/_sources/intro/conventions.rst.txt: -------------------------------------------------------------------------------- 1 | .. _intro_conventions: 2 | 3 | Conventions 4 | ########### 5 | 6 | Overview 7 | ======== 8 | 9 | Conventions used through out *Matmodlab2* are described. 10 | 11 | Dimension 12 | ========= 13 | 14 | Material models are always called with full 3D tensors. 15 | 16 | Vector Storage 17 | ============== 18 | 19 | Vector components are stored as 20 | 21 | .. math:: 22 | 23 | v_i = \{v_x, v_y, v_z\} 24 | 25 | Tensor Storage 26 | ============== 27 | 28 | Second-order symmetric tensors are stored as 6x1 arrays with the following 29 | component ordering 30 | 31 | .. math:: 32 | :label: order-symtens 33 | 34 | A_{ij} = \{A_{xx}, A_{yy}, A_{zz}, A_{xy}, A_{yz}, A_{xz}\} 35 | 36 | Nonsymmetric, second-order tensors are stored as 9x1 arrays in row major 37 | ordering, i.e., 38 | 39 | .. math:: 40 | 41 | B_{ij} = \{B_{xx}, B_{xy}, B_{xz}, 42 | B_{yx}, B_{yy}, B_{yz}, 43 | B_{zx}, B_{zy}, B_{zz}\} 44 | 45 | Engineering Strains 46 | ------------------- 47 | 48 | The shear components of strain-like tensors are sent to the material model as 49 | engineering strains, i.e. 50 | 51 | .. math:: 52 | 53 | \epsilon_{ij} = \{\epsilon_{xx}, \epsilon_{yy}, \epsilon_{zz}, 2\epsilon_{xy}, 2\epsilon_{yz}, 2\epsilon_{xz}\} 54 | = \{\epsilon_{xx}, \epsilon_{yy}, \epsilon_{zz}, \gamma_{xy}, \gamma_{yz}, \gamma_{xz}\} 55 | -------------------------------------------------------------------------------- /docs/_sources/intro/environment.rst.txt: -------------------------------------------------------------------------------- 1 | 2 | .. _environment: 3 | 4 | Environment Settings 5 | #################### 6 | 7 | Overview 8 | ======== 9 | 10 | *Matmodlab2* sets up and performs execution of input scripts in a customized 11 | environment (not to be confused with Python virtual environments). The 12 | environment can be modified by user environment files that are read at the 13 | beginning of each job. 14 | 15 | Environment File Locations 16 | ========================== 17 | 18 | *Matmodlab2* searches for the optional user environment file, 19 | ``mml_userenv.py``, in two locations, in the following order: 20 | 21 | 1) The location specified by the environment variable ``MML_USERENV`` 22 | 2) The current working directory. 23 | 24 | The value of a parameter is the last definition encountered, meaning that 25 | the order of precedence for user settings is the current working directory and 26 | ``MML_USERENV``. 27 | 28 | Environment files use Python syntax, meaning that entries will have the 29 | following form:: 30 | 31 | parameter = value 32 | 33 | All usual Python conventions apply. 34 | 35 | Recognized Environment Settings and Defaults 36 | ============================================ 37 | 38 | Below are the recognized environment settings and their defaults. Any of these 39 | settings can be changed by specifying a different value in a user environment 40 | file. 41 | 42 | .. note:: 43 | 44 | When specifying environment settings in a user environment file, the 45 | setting must have the same type as the default. If the default is a list, 46 | the user setting is inserted in to the default list. If the default is a 47 | dictionary, it is updated with the user setting. 48 | 49 | IO Settings 50 | ----------- 51 | 52 | verbosity 53 | 54 | *Matmodlab2* will print more, or less, information during job execution. Possible values are ``0``, ``1``, and ``2``. Set the value to ``0`` to suppress printing of information. Set the value to ``2``, or higher, to print increase the amount of information printed. The default value is ``1``. 55 | 56 | SQA 57 | 58 | *Matmodlab2* will run extra software quality checks. 59 | 60 | loglevel 61 | 62 | Set the `logging` module logger level. Value must be a valid `logging` level. 63 | 64 | prepend_to_sys_path 65 | 66 | If `True`, prepend the environment file's directory to the python search path. If a string (or list of strings), *Matmodlab2* will assume that the string (or list of strings) is a directory path and put it (or them) on the search path. 67 | -------------------------------------------------------------------------------- /docs/_sources/intro/index.rst.txt: -------------------------------------------------------------------------------- 1 | 2 | .. _intro_and_overview: 3 | 4 | Introduction and Overview 5 | ######################### 6 | 7 | .. toctree:: 8 | :maxdepth: 1 9 | 10 | about 11 | install 12 | input 13 | conventions 14 | environment 15 | solution 16 | output 17 | -------------------------------------------------------------------------------- /docs/_sources/intro/input.rst.txt: -------------------------------------------------------------------------------- 1 | Input Syntax Guidelines 2 | ####################### 3 | 4 | Overview 5 | ======== 6 | 7 | This section describes some conventions used in the *Matmodlab2* API and adopted 8 | in user input scripts. 9 | 10 | Matmodlab2 Namespace 11 | ==================== 12 | 13 | Input scripts to *Matmodlab2* should include:: 14 | 15 | from matmodlab2 import * 16 | 17 | to populate the script's namespace with *Matmodlab2* specific functions and 18 | classes. 19 | 20 | Primary Classes 21 | --------------- 22 | 23 | The primary classes exposed by importing ``matmodlab2`` are 24 | 25 | * ``MaterialPointSimulator``, the *Matmodlab2* material point simulator 26 | * ``Optimizer``, the *Matmodlab2* optimizer 27 | 28 | Each of these classes is described in more detail in the following sections. 29 | 30 | 31 | Naming Conventions 32 | ================== 33 | 34 | Throughout *Mamodlab2*, the following naming conventions are adopted (see the 35 | `PEP8 `_ guidelines for more 36 | guidance): 37 | 38 | * Class names use the ``CapWords`` convention. 39 | * Method names use ``lowercase`` with words separated by underscores as 40 | necessary to improve readability. 41 | * Variable names adopt the same rule as method names. 42 | -------------------------------------------------------------------------------- /docs/_sources/intro/install.rst.txt: -------------------------------------------------------------------------------- 1 | .. _intro_install: 2 | 3 | Installing Matmodlab2 4 | ##################### 5 | 6 | Overview 7 | ======== 8 | 9 | *Matmodlab2*'s code base is largely written in Python and requires no 10 | additional compiling. However, several (optional) linear algebra packages and 11 | material models are written in Fortran and require a separate compile step. 12 | 13 | System Requirements 14 | =================== 15 | 16 | *Matmodlab2* has been built and tested extensively on several versions of Linux 17 | and the Apple Mac OSX operating systems. 18 | 19 | Required Software 20 | ================= 21 | 22 | The basic functionality of *Matmodlab2* requires the following software 23 | installed for your platform: 24 | 25 | #) `Python 2.7 or 3.5 `_ 26 | 27 | #) `NumPy `_ 28 | 29 | #) `SciPy `_ 30 | 31 | *Matmodlab2* has further functionality that can be utilized if the appropriate 32 | packages are installed. 33 | 34 | #) `pytest `_ for running tests 35 | 36 | #) `pandas `_ for the ``DataFrame`` object. 37 | 38 | The required software may be obtained in several ways, though most development 39 | has been made using the `Anaconda `_ Python distribution. 40 | 41 | .. _installation: 42 | 43 | Installation 44 | ============ 45 | 46 | .. note:: 47 | 48 | Ensure that all *Matmodlab2* prerequisites are installed and working properly before proceeding. 49 | 50 | Obtain the source code from `github `_ 51 | and add the path to the ``matmodlab2`` directory to your ``PYTHONPATH`` environment 52 | variable:: 53 | 54 | $ git clone https://www.github.com/matmodlab/matmodlab2 55 | $ export MATMODLAB2_DIR=`pwd`/matmodlab 56 | $ export PYTHONPATH=${PYTHONPATH}:${MATMODLAB2_DIR} 57 | 58 | Build (Optional) 59 | ---------------- 60 | 61 | A library of Fortran linear algebra routines can also be built. Navigate to 62 | ``matmodlab2/matmodlab2/ext_helpers`` and execute the ``build_ext.py`` script:: 63 | 64 | $ cd ${MATMODLAB2_DIR}/matmodlab2/ext_helpers 65 | $ ./build_ext.py matfuncs 66 | 67 | Testing the Installation 68 | ======================== 69 | 70 | Testing requires that the `pytest `_ module be installed. Tests are run by executing:: 71 | 72 | $ cd ${MATMODLAB2_DIR}/tests 73 | $ py.test . 74 | 75 | Troubleshooting 76 | =============== 77 | 78 | If you run in to problems, open an issue at 79 | ``_. 80 | -------------------------------------------------------------------------------- /docs/_sources/intro/output.rst.txt: -------------------------------------------------------------------------------- 1 | .. _mml_out_dbs: 2 | 3 | Matmodlab File Formats 4 | ###################### 5 | 6 | Overview 7 | ======== 8 | 9 | *Matmodlab2* writes to one of two file formats. The format of output is determined by the *db_fmt* keyword to the ``MaterialPointSimulator``. The two formats are 10 | 11 | npz 12 | Compressed ``numpy`` array format. This is the default format and is chosen 13 | by letting ``db_fmt='npz'`` 14 | 15 | exo 16 | 17 | `ExodusII `_ output database 18 | format. Output is written to exo format if ``db_fmt=exo``. 19 | -------------------------------------------------------------------------------- /docs/_sources/material/builtin.rst.txt: -------------------------------------------------------------------------------- 1 | 2 | .. _mat_builtin: 3 | 4 | Material Library 5 | ################ 6 | 7 | .. topic:: See Also 8 | 9 | * :ref:`Role of Material Model` 10 | * :ref:`defining_a_material` 11 | * :ref:`intro_conventions` 12 | 13 | Overview 14 | ======== 15 | 16 | The library of available material models in Matmodlab is not intended to 17 | provide comprehensive coverage of material behaviors. Rather, it provides 18 | enough coverage to 19 | 20 | * test Matmodlab capabilities; and 21 | * demonstrate the material model interface to be adopted by user materials. 22 | 23 | Available Materials 24 | ------------------- 25 | 26 | .. toctree:: 27 | :maxdepth: 1 28 | :titlesonly: 29 | 30 | elastic 31 | plastic 32 | transverse_elastic 33 | mooney_rivlin 34 | -------------------------------------------------------------------------------- /docs/_sources/material/comm.rst.txt: -------------------------------------------------------------------------------- 1 | 2 | .. _comm_w_matmodlab: 3 | 4 | Writing Messages to the Console and/or Log File 5 | ############################################### 6 | 7 | Overview 8 | ======== 9 | 10 | Procedure *mml_comm* can be called from any user procedure to write messages 11 | to the console and log file. 12 | 13 | Interface 14 | ========= 15 | 16 | :: 17 | 18 | subroutine mml_comm(lop, string, intv, realv, charv) 19 | integer, intent(in) :: ierr 20 | character(120), intent(in) :: msg 21 | integer, intent(in) :: intv(*) 22 | real(8), intent(in) :: realv(*) 23 | character(8), intent(in) :: charv(*) 24 | 25 | ! coding 26 | 27 | end subroutine mml_comm 28 | 29 | Parameters 30 | ========== 31 | 32 | * *lop=1* writes an informational message to the log file 33 | 34 | *lop=-1* writes a warning message to the log file 35 | 36 | *lop=-2* writes an error message to the log file 37 | 38 | *lop=-3* writes an error message to the log file and stops the analysis 39 | 40 | * *string* is the informational string 41 | * *intv* 42 | * *realv* 43 | * *charv* 44 | 45 | 46 | .. topic:: Abaqus Users: 47 | 48 | Procedure *stdb_abqerr*, which has the same interface as *mml_comm*, is also 49 | compiled and linked to user defined materials. 50 | -------------------------------------------------------------------------------- /docs/_sources/material/elastic.rst.txt: -------------------------------------------------------------------------------- 1 | 2 | Linear Elastic Material 3 | ####################### 4 | 5 | .. topic:: See Also 6 | 7 | . 8 | 9 | Overview 10 | ======== 11 | 12 | Usage 13 | ===== 14 | 15 | Description 16 | =========== 17 | -------------------------------------------------------------------------------- /docs/_sources/material/expansion.rst.txt: -------------------------------------------------------------------------------- 1 | .. _expansion: 2 | 3 | Thermal Expansion 4 | ################# 5 | -------------------------------------------------------------------------------- /docs/_sources/material/fortran.rst.txt: -------------------------------------------------------------------------------- 1 | 2 | .. _fortran_models: 3 | 4 | Fortran User Material Interface 5 | ############################### 6 | 7 | .. topic:: See Also 8 | 9 | * :ref:`Role of Material Model` 10 | * :ref:`defining_a_material` 11 | * :ref:`intro_conventions` 12 | * :ref:`comm_w_matmodlab` 13 | * :ref:`sdvini` 14 | 15 | Overview 16 | ======== 17 | 18 | Procedures ``UMAT``, ``UHYPER``, and ``UANISOHYPER_INV`` are called for user defined materials defining the mechanical, hyperelastic, or anisotropic hyperelastic material responses, respectively. Regardles of the interface procedure used, a fortran compiler must be available for Matmodlab to compile and link user procedures. 19 | 20 | .. _invoke_user_f: 21 | 22 | Invoking User Materials 23 | ======================= 24 | 25 | User defined materials are invoked using the same 26 | ``MaterialPointSimulator.Material`` factory method as other materials, but 27 | with additional required and optional arguments. 28 | 29 | Required MaterialPointSimulator.Material Agruments 30 | -------------------------------------------------- 31 | 32 | * The *model* argument must be set to one of ``USER``, ``UMAT``, ``UHYPER``, or ``UANISOHYPER_INV``. 33 | * The *parameters* must be a ndarray of model constants (specified in the 34 | order expected by the model). 35 | * *source_files*, a list of model source files. The source files must exist 36 | and be readable on the file system. 37 | 38 | Optional MaterialPointSimulator.Material Arguments 39 | -------------------------------------------------- 40 | 41 | * *param_names*, is a list of parameter names in the order expected by the model. 42 | If given, *parameters* must be given as dict of ``name:value`` pairs as for 43 | builtin models. 44 | * *depvar*, is the number of state dependent variables required 45 | for the model. Can also be specified as a list of state dependent variable 46 | names, specified in the order expected by the model. If given as a list, the 47 | number of state variables allocated is inferred from its length. Matmodlab 48 | allocates storage for the *depvar* state dependent variables and 49 | initializes their values to 0. 50 | * *response*, is a string specifying the type of model. Must be one of ``MECHANICAL`` (default), ``HYPERELASTIC``, or ``ANISOHYPER``. 51 | * *cmname*, is a string giving is the constitutive model name. 52 | * *ordering*, is a list of symbolic constants specifying the ordering of 53 | second-order symmetric tensors. The default ordering of symmetric 54 | second-order tensor components is ``[XX, YY, ZZ, XY, YZ, XZ]``. The *ordering* 55 | argument can be used to change the ordering to be consistent with the 56 | assumptions of the material model. 57 | 58 | Example 59 | ------- 60 | 61 | :: 62 | 63 | mps = MaterialPointSimulator('user_material') 64 | parameters = np.array([135e9, 53e9, 200e6]) 65 | mps.Material(USER, parameters) 66 | 67 | 68 | .. topic:: Abaqus Users: 69 | 70 | Setting the *model* name to one of ``UMAT``, ``UHYPER``, or 71 | ``UANISOHYPER_INV`` is equivalient to *model=*\ ``USER``, with 72 | *response=*\ ``MECHANICAL``, *response=*\ ``HYPERELASTIC``, or 73 | *response=*\ ``ANISOHYPER``, respectively, and *ordering=*\ ``[XX, YY, 74 | ZZ, XY, XZ, YZ]``. 75 | 76 | Compiling Fortran Sources 77 | ========================= 78 | 79 | Matmodlab compiles and links material model sources using ``f2py``. 80 | 81 | User Subroutine Interfaces 82 | ========================== 83 | 84 | .. toctree:: 85 | :maxdepth: 1 86 | 87 | umat 88 | uhyper 89 | uanisohyper_inv 90 | -------------------------------------------------------------------------------- /docs/_sources/material/index.rst.txt: -------------------------------------------------------------------------------- 1 | .. _mat_index: 2 | 3 | Materials 4 | ######### 5 | 6 | .. toctree:: 7 | :maxdepth: 1 8 | :titlesonly: 9 | 10 | overview 11 | builtin 12 | user 13 | -------------------------------------------------------------------------------- /docs/_sources/material/mooney_rivlin.rst.txt: -------------------------------------------------------------------------------- 1 | Mooney-Rivlin Hyperelastic Material 2 | ################################### 3 | 4 | .. topic:: See Also 5 | 6 | . 7 | 8 | 9 | Overview 10 | ======== 11 | 12 | Usage 13 | ===== 14 | 15 | Description 16 | =========== 17 | -------------------------------------------------------------------------------- /docs/_sources/material/overview.rst.txt: -------------------------------------------------------------------------------- 1 | .. _mat_overview: 2 | 3 | Materials: Introduction 4 | ####################### 5 | 6 | .. topic:: See Also 7 | 8 | * :ref:`Role of Material Model` 9 | * :ref:`defining_a_material` 10 | * :ref:`intro_conventions` 11 | 12 | Overview 13 | ======== 14 | 15 | Material constitutive models provide the material's complete mechanical response. In other words, given the current mechanical state and an increment in deformation, the material model returns 16 | 17 | * the updated stress, 18 | * the material stiffness, and 19 | * the updated state dependent variable, if applicable. 20 | 21 | Matmodlab Material Library 22 | ========================== 23 | 24 | Matmodlab has a limited :ref:`library of material models `. 25 | 26 | User Developed Materials 27 | ======================== 28 | 29 | Matmodlab provides an API for :ref:`user developed materials `. 30 | 31 | 32 | Combining Material Responses 33 | ============================ 34 | 35 | Generally, constitutive models are treated as defining the entire mechanical 36 | response of a material and cannot be combined with other models. However, 37 | material models can be combined with the following behaviors: 38 | 39 | .. toctree:: 40 | :maxdepth: 1 41 | :titlesonly: 42 | 43 | expansion 44 | trs 45 | viscoelastic 46 | -------------------------------------------------------------------------------- /docs/_sources/material/plastic.rst.txt: -------------------------------------------------------------------------------- 1 | 2 | Perfectly Plastic Material 3 | ########################## 4 | 5 | .. topic:: See Also 6 | 7 | . 8 | 9 | Overview 10 | ======== 11 | 12 | Usage 13 | ===== 14 | 15 | Description 16 | =========== 17 | -------------------------------------------------------------------------------- /docs/_sources/material/sdvini.rst.txt: -------------------------------------------------------------------------------- 1 | 2 | .. _sdvini: 3 | 4 | User Defined Initial Conditions 5 | ############################### 6 | 7 | .. topic:: See Also 8 | 9 | * :ref:`mat_overview` 10 | 11 | Overview 12 | ======== 13 | 14 | Subroutine ``SDVINI`` allows users to set initial values to state dependent variables. If not provided by the user, Matmodlab will set state dependent to ``0``. 15 | 16 | Interface 17 | ========= 18 | 19 | .. code:: fortran 20 | 21 | subroutine sdvini(statev,coords,nstatv,ncrds,noel,npt,layer,kspt) 22 | integer, intent(in) :: nstatv, ncrds, noel, npt, layer, kspt 23 | real(kind=8), dimension(nstatv), intent(inout) :: statev 24 | real(kind=8), dimension(ncrds), intent(in) :: coords 25 | 26 | ! user code 27 | 28 | end subroutine sdvini 29 | -------------------------------------------------------------------------------- /docs/_sources/material/transverse_elastic.rst.txt: -------------------------------------------------------------------------------- 1 | Transversely Isotropic Elastic Material 2 | ####################################### 3 | 4 | .. topic:: See Also 5 | 6 | . 7 | 8 | 9 | Overview 10 | ======== 11 | 12 | Usage 13 | ===== 14 | 15 | Description 16 | =========== 17 | -------------------------------------------------------------------------------- /docs/_sources/material/trs.rst.txt: -------------------------------------------------------------------------------- 1 | .. _trs: 2 | 3 | Time Temperature Shift 4 | ###################### 5 | -------------------------------------------------------------------------------- /docs/_sources/material/uanisohyper_inv.rst.txt: -------------------------------------------------------------------------------- 1 | User Model to Define a Material's Anisotropic Hyperelastic Response 2 | ################################################################### 3 | 4 | Overview 5 | ======== 6 | 7 | *uanisohyper_inv* is a material model for anisotropic hyperelastic materials. 8 | 9 | Interface 10 | ========= 11 | 12 | .. code:: fortran 13 | 14 | subroutine uanisohyper_inv(ainv, u, zeta, nfibers, ninv, & 15 | ui1, ui2, ui3, temp, noel, cmname, incmpflag, ihybflag, & 16 | nstatev, statev, nfieldv, fieldv, fieldvinc, & 17 | nprops, props) 18 | implicit none 19 | integer, parameter :: dp=selected_real_kind(14) 20 | real(kind=dp), parameter :: zero=0._dp, one=1._dp, two=2._dp, three=3._dp 21 | character*8, intent(in) :: cmname 22 | integer, intent(in) :: nprops, noel, nstatev, incmpflag, nfieldv 23 | real(kind=dp), intent(in) :: ainv(ninv), props(nprops), temp 24 | real(kind=dp), intent(inout) ui1(ninv) 25 | real(kind=dp), intent(inout) :: ui2(ninv*(ninv+1)/2), ui3(ninv*(ninv+1)/2), 26 | real(kind=dp), intent(inout) :: statev(nstatev) 27 | real(kind=dp), intent(inout) :: fieldv(nfieldv), fieldvinc(nfieldv) 28 | 29 | ! User coding 30 | 31 | end subroutine uanisohyper_inv 32 | -------------------------------------------------------------------------------- /docs/_sources/material/uhyper.rst.txt: -------------------------------------------------------------------------------- 1 | User Model to Define a Material's Hyperelastic Response 2 | ####################################################### 3 | 4 | Overview 5 | ======== 6 | 7 | *uhyper* is a material model for hyperelastic materials. 8 | 9 | Interface 10 | ========= 11 | 12 | .. code:: fortran 13 | 14 | subroutine uhyper(i1b, i2b, jac, u, du, d2u, d3u, temp, noel, cmname, & 15 | incmpflag, nstatev, statev, nfieldv, fieldv, fieldvinc, & 16 | nprops, props) 17 | implicit none 18 | integer, parameter :: dp=selected_real_kind(14) 19 | real(kind=dp), parameter :: zero=0._dp, one=1._dp, two=2._dp, three=3._dp 20 | character*8, intent(in) :: cmname 21 | integer, intent(in) :: nprops, noel, nstatev, incmpflag, nfieldv 22 | real(kind=dp), intent(in) :: i1b, i2b, jac, props(nprops), temp 23 | real(kind=dp), intent(inout) :: u(2), du(3), d2u(6), d3u(6), statev(nstatev) 24 | real(kind=dp), intent(inout) :: fieldv(nfieldv), fieldvinc(nfieldv) 25 | 26 | ! User coding 27 | 28 | end subroutine uhyper 29 | -------------------------------------------------------------------------------- /docs/_sources/material/user.rst.txt: -------------------------------------------------------------------------------- 1 | .. _user_mats: 2 | 3 | User Defined Materials 4 | ###################### 5 | 6 | .. topic:: See Also 7 | 8 | * :ref:`Role of Material Model` 9 | * :ref:`defining_a_material` 10 | * :ref:`intro_conventions` 11 | 12 | Overview 13 | ======== 14 | 15 | Matmodlab calls user defined materials at each deformation increment through all analysis steps. User defined materials are 16 | 17 | * written in fortran or python 18 | * called from python 19 | 20 | Material Model API 21 | ================== 22 | 23 | Two API's are provided for interfacing user developed materials with Matmodlab: 24 | 25 | * :ref:`Python API `. Material models are implemented as subclasses of MaterialModel, 26 | * :ref:`Fortran API `. Similar to commercial finite element codes, material models are implemented in Fortran subroutines that are compiled, linked, and called by Matmodlab. 27 | 28 | Auxiliary Subroutines 29 | ===================== 30 | 31 | Fortran subroutines can set initial conditions and interact with Matmodlab as described in the following sections: 32 | 33 | * :ref:`sdvini` 34 | * :ref:`comm_w_matmodlab` 35 | 36 | .. toctree:: 37 | :hidden: 38 | 39 | python 40 | fortran 41 | comm 42 | sdvini 43 | -------------------------------------------------------------------------------- /docs/_sources/material/viscoelastic.rst.txt: -------------------------------------------------------------------------------- 1 | .. _viscoelastic: 2 | 3 | Viscoelasticity 4 | ############### 5 | -------------------------------------------------------------------------------- /docs/_sources/test/index.rst.txt: -------------------------------------------------------------------------------- 1 | 2 | .. _test_index: 3 | 4 | Material Model Testing 5 | ###################### 6 | 7 | .. toctree:: 8 | :maxdepth: 1 9 | 10 | intro 11 | verification 12 | validation 13 | standard 14 | -------------------------------------------------------------------------------- /docs/_sources/test/intro.rst.txt: -------------------------------------------------------------------------------- 1 | 2 | Material Model Testing: Introduction 3 | #################################### 4 | 5 | .. topic:: See Also 6 | 7 | * `http://pytest.org/latest/ `_ 8 | 9 | Overview 10 | ======== 11 | 12 | Regression testing is critical to the model development process. Only through thoroughly testing a model can confidence in model results be obtained. Testing of material models involves: 13 | 14 | * tests of individual program units (unit testing), 15 | * verfication of model response to controlled inputs, 16 | * validation of model response against data, and 17 | * regression testing when changes to the model are made. 18 | 19 | Regression tests in Matmodlab are special purpose problems that have a twofold purpose: 20 | 21 | * test the individual components and core capabilities of Matmodlab itself; 22 | * verification and validation (V&V) of material models. 23 | 24 | In the first role, problems are fast running and exercise specific features of 25 | Matmodlab in a unit-test type fashion. In the second, material models are 26 | exercised through specific paths with known, or expected outcomes. 27 | -------------------------------------------------------------------------------- /docs/_sources/test/validation.rst.txt: -------------------------------------------------------------------------------- 1 | 2 | Validation 3 | ########## 4 | 5 | .. topic:: See Also 6 | 7 | . 8 | 9 | Overview 10 | ======== 11 | -------------------------------------------------------------------------------- /docs/_sources/test/verification.rst.txt: -------------------------------------------------------------------------------- 1 | 2 | Verification 3 | ############ 4 | 5 | .. topic:: See Also 6 | 7 | . 8 | 9 | Overview 10 | ======== 11 | -------------------------------------------------------------------------------- /docs/_static/ajax-loader.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matmodlab/matmodlab2/d2e6f5332d319752285c042e88e2baab506dc921/docs/_static/ajax-loader.gif -------------------------------------------------------------------------------- /docs/_static/comment-bright.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matmodlab/matmodlab2/d2e6f5332d319752285c042e88e2baab506dc921/docs/_static/comment-bright.png -------------------------------------------------------------------------------- /docs/_static/comment-close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matmodlab/matmodlab2/d2e6f5332d319752285c042e88e2baab506dc921/docs/_static/comment-close.png -------------------------------------------------------------------------------- /docs/_static/comment.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matmodlab/matmodlab2/d2e6f5332d319752285c042e88e2baab506dc921/docs/_static/comment.png -------------------------------------------------------------------------------- /docs/_static/down-pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matmodlab/matmodlab2/d2e6f5332d319752285c042e88e2baab506dc921/docs/_static/down-pressed.png -------------------------------------------------------------------------------- /docs/_static/down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matmodlab/matmodlab2/d2e6f5332d319752285c042e88e2baab506dc921/docs/_static/down.png -------------------------------------------------------------------------------- /docs/_static/file.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matmodlab/matmodlab2/d2e6f5332d319752285c042e88e2baab506dc921/docs/_static/file.png -------------------------------------------------------------------------------- /docs/_static/minus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matmodlab/matmodlab2/d2e6f5332d319752285c042e88e2baab506dc921/docs/_static/minus.png -------------------------------------------------------------------------------- /docs/_static/plus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matmodlab/matmodlab2/d2e6f5332d319752285c042e88e2baab506dc921/docs/_static/plus.png -------------------------------------------------------------------------------- /docs/_static/up-pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matmodlab/matmodlab2/d2e6f5332d319752285c042e88e2baab506dc921/docs/_static/up-pressed.png -------------------------------------------------------------------------------- /docs/_static/up.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matmodlab/matmodlab2/d2e6f5332d319752285c042e88e2baab506dc921/docs/_static/up.png -------------------------------------------------------------------------------- /docs/doctrees/environment.pickle: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matmodlab/matmodlab2/d2e6f5332d319752285c042e88e2baab506dc921/docs/doctrees/environment.pickle -------------------------------------------------------------------------------- /docs/doctrees/examples/ex1.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matmodlab/matmodlab2/d2e6f5332d319752285c042e88e2baab506dc921/docs/doctrees/examples/ex1.doctree -------------------------------------------------------------------------------- /docs/doctrees/examples/ex2.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matmodlab/matmodlab2/d2e6f5332d319752285c042e88e2baab506dc921/docs/doctrees/examples/ex2.doctree -------------------------------------------------------------------------------- /docs/doctrees/examples/ex3.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matmodlab/matmodlab2/d2e6f5332d319752285c042e88e2baab506dc921/docs/doctrees/examples/ex3.doctree -------------------------------------------------------------------------------- /docs/doctrees/examples/index.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matmodlab/matmodlab2/d2e6f5332d319752285c042e88e2baab506dc921/docs/doctrees/examples/index.doctree -------------------------------------------------------------------------------- /docs/doctrees/execution/cli.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matmodlab/matmodlab2/d2e6f5332d319752285c042e88e2baab506dc921/docs/doctrees/execution/cli.doctree -------------------------------------------------------------------------------- /docs/doctrees/execution/examples.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matmodlab/matmodlab2/d2e6f5332d319752285c042e88e2baab506dc921/docs/doctrees/execution/examples.doctree -------------------------------------------------------------------------------- /docs/doctrees/execution/index.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matmodlab/matmodlab2/d2e6f5332d319752285c042e88e2baab506dc921/docs/doctrees/execution/index.doctree -------------------------------------------------------------------------------- /docs/doctrees/execution/mps.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matmodlab/matmodlab2/d2e6f5332d319752285c042e88e2baab506dc921/docs/doctrees/execution/mps.doctree -------------------------------------------------------------------------------- /docs/doctrees/execution/notebook.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matmodlab/matmodlab2/d2e6f5332d319752285c042e88e2baab506dc921/docs/doctrees/execution/notebook.doctree -------------------------------------------------------------------------------- /docs/doctrees/execution/optimize.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matmodlab/matmodlab2/d2e6f5332d319752285c042e88e2baab506dc921/docs/doctrees/execution/optimize.doctree -------------------------------------------------------------------------------- /docs/doctrees/execution/overview.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matmodlab/matmodlab2/d2e6f5332d319752285c042e88e2baab506dc921/docs/doctrees/execution/overview.doctree -------------------------------------------------------------------------------- /docs/doctrees/execution/permutate.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matmodlab/matmodlab2/d2e6f5332d319752285c042e88e2baab506dc921/docs/doctrees/execution/permutate.doctree -------------------------------------------------------------------------------- /docs/doctrees/execution/post.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matmodlab/matmodlab2/d2e6f5332d319752285c042e88e2baab506dc921/docs/doctrees/execution/post.doctree -------------------------------------------------------------------------------- /docs/doctrees/index.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matmodlab/matmodlab2/d2e6f5332d319752285c042e88e2baab506dc921/docs/doctrees/index.doctree -------------------------------------------------------------------------------- /docs/doctrees/intro/about.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matmodlab/matmodlab2/d2e6f5332d319752285c042e88e2baab506dc921/docs/doctrees/intro/about.doctree -------------------------------------------------------------------------------- /docs/doctrees/intro/conventions.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matmodlab/matmodlab2/d2e6f5332d319752285c042e88e2baab506dc921/docs/doctrees/intro/conventions.doctree -------------------------------------------------------------------------------- /docs/doctrees/intro/environment.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matmodlab/matmodlab2/d2e6f5332d319752285c042e88e2baab506dc921/docs/doctrees/intro/environment.doctree -------------------------------------------------------------------------------- /docs/doctrees/intro/index.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matmodlab/matmodlab2/d2e6f5332d319752285c042e88e2baab506dc921/docs/doctrees/intro/index.doctree -------------------------------------------------------------------------------- /docs/doctrees/intro/input.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matmodlab/matmodlab2/d2e6f5332d319752285c042e88e2baab506dc921/docs/doctrees/intro/input.doctree -------------------------------------------------------------------------------- /docs/doctrees/intro/install.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matmodlab/matmodlab2/d2e6f5332d319752285c042e88e2baab506dc921/docs/doctrees/intro/install.doctree -------------------------------------------------------------------------------- /docs/doctrees/intro/output.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matmodlab/matmodlab2/d2e6f5332d319752285c042e88e2baab506dc921/docs/doctrees/intro/output.doctree -------------------------------------------------------------------------------- /docs/doctrees/intro/solution.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matmodlab/matmodlab2/d2e6f5332d319752285c042e88e2baab506dc921/docs/doctrees/intro/solution.doctree -------------------------------------------------------------------------------- /docs/doctrees/material/builtin.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matmodlab/matmodlab2/d2e6f5332d319752285c042e88e2baab506dc921/docs/doctrees/material/builtin.doctree -------------------------------------------------------------------------------- /docs/doctrees/material/comm.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matmodlab/matmodlab2/d2e6f5332d319752285c042e88e2baab506dc921/docs/doctrees/material/comm.doctree -------------------------------------------------------------------------------- /docs/doctrees/material/elastic.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matmodlab/matmodlab2/d2e6f5332d319752285c042e88e2baab506dc921/docs/doctrees/material/elastic.doctree -------------------------------------------------------------------------------- /docs/doctrees/material/expansion.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matmodlab/matmodlab2/d2e6f5332d319752285c042e88e2baab506dc921/docs/doctrees/material/expansion.doctree -------------------------------------------------------------------------------- /docs/doctrees/material/fortran.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matmodlab/matmodlab2/d2e6f5332d319752285c042e88e2baab506dc921/docs/doctrees/material/fortran.doctree -------------------------------------------------------------------------------- /docs/doctrees/material/index.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matmodlab/matmodlab2/d2e6f5332d319752285c042e88e2baab506dc921/docs/doctrees/material/index.doctree -------------------------------------------------------------------------------- /docs/doctrees/material/mooney_rivlin.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matmodlab/matmodlab2/d2e6f5332d319752285c042e88e2baab506dc921/docs/doctrees/material/mooney_rivlin.doctree -------------------------------------------------------------------------------- /docs/doctrees/material/overview.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matmodlab/matmodlab2/d2e6f5332d319752285c042e88e2baab506dc921/docs/doctrees/material/overview.doctree -------------------------------------------------------------------------------- /docs/doctrees/material/plastic.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matmodlab/matmodlab2/d2e6f5332d319752285c042e88e2baab506dc921/docs/doctrees/material/plastic.doctree -------------------------------------------------------------------------------- /docs/doctrees/material/python.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matmodlab/matmodlab2/d2e6f5332d319752285c042e88e2baab506dc921/docs/doctrees/material/python.doctree -------------------------------------------------------------------------------- /docs/doctrees/material/sdvini.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matmodlab/matmodlab2/d2e6f5332d319752285c042e88e2baab506dc921/docs/doctrees/material/sdvini.doctree -------------------------------------------------------------------------------- /docs/doctrees/material/transverse_elastic.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matmodlab/matmodlab2/d2e6f5332d319752285c042e88e2baab506dc921/docs/doctrees/material/transverse_elastic.doctree -------------------------------------------------------------------------------- /docs/doctrees/material/trs.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matmodlab/matmodlab2/d2e6f5332d319752285c042e88e2baab506dc921/docs/doctrees/material/trs.doctree -------------------------------------------------------------------------------- /docs/doctrees/material/uanisohyper_inv.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matmodlab/matmodlab2/d2e6f5332d319752285c042e88e2baab506dc921/docs/doctrees/material/uanisohyper_inv.doctree -------------------------------------------------------------------------------- /docs/doctrees/material/uhyper.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matmodlab/matmodlab2/d2e6f5332d319752285c042e88e2baab506dc921/docs/doctrees/material/uhyper.doctree -------------------------------------------------------------------------------- /docs/doctrees/material/umat.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matmodlab/matmodlab2/d2e6f5332d319752285c042e88e2baab506dc921/docs/doctrees/material/umat.doctree -------------------------------------------------------------------------------- /docs/doctrees/material/user.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matmodlab/matmodlab2/d2e6f5332d319752285c042e88e2baab506dc921/docs/doctrees/material/user.doctree -------------------------------------------------------------------------------- /docs/doctrees/material/viscoelastic.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matmodlab/matmodlab2/d2e6f5332d319752285c042e88e2baab506dc921/docs/doctrees/material/viscoelastic.doctree -------------------------------------------------------------------------------- /docs/doctrees/test/index.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matmodlab/matmodlab2/d2e6f5332d319752285c042e88e2baab506dc921/docs/doctrees/test/index.doctree -------------------------------------------------------------------------------- /docs/doctrees/test/intro.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matmodlab/matmodlab2/d2e6f5332d319752285c042e88e2baab506dc921/docs/doctrees/test/intro.doctree -------------------------------------------------------------------------------- /docs/doctrees/test/standard.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matmodlab/matmodlab2/d2e6f5332d319752285c042e88e2baab506dc921/docs/doctrees/test/standard.doctree -------------------------------------------------------------------------------- /docs/doctrees/test/validation.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matmodlab/matmodlab2/d2e6f5332d319752285c042e88e2baab506dc921/docs/doctrees/test/validation.doctree -------------------------------------------------------------------------------- /docs/doctrees/test/verification.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matmodlab/matmodlab2/d2e6f5332d319752285c042e88e2baab506dc921/docs/doctrees/test/verification.doctree -------------------------------------------------------------------------------- /docs/objects.inv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matmodlab/matmodlab2/d2e6f5332d319752285c042e88e2baab506dc921/docs/objects.inv -------------------------------------------------------------------------------- /docs/source/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matmodlab/matmodlab2/d2e6f5332d319752285c042e88e2baab506dc921/docs/source/__init__.py -------------------------------------------------------------------------------- /docs/source/_static/.dir: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matmodlab/matmodlab2/d2e6f5332d319752285c042e88e2baab506dc921/docs/source/_static/.dir -------------------------------------------------------------------------------- /docs/source/alabaster/__init__.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | from alabaster import _version as version 4 | 5 | 6 | def get_path(): 7 | """ 8 | Shortcut for users whose theme is next to their conf.py. 9 | """ 10 | # Theme directory is defined as our parent directory 11 | return os.path.abspath(os.path.dirname(os.path.dirname(__file__))) 12 | 13 | 14 | def update_context(app, pagename, templatename, context, doctree): 15 | context['alabaster_version'] = version.__version__ 16 | 17 | def setup(app): 18 | app.connect('html-page-context', update_context) 19 | return {'version': version.__version__, 20 | 'parallel_read_safe': True} 21 | -------------------------------------------------------------------------------- /docs/source/alabaster/_version.py: -------------------------------------------------------------------------------- 1 | __version_info__ = (0, 7, 4) 2 | __version__ = '.'.join(map(str, __version_info__)) 3 | -------------------------------------------------------------------------------- /docs/source/alabaster/about.html: -------------------------------------------------------------------------------- 1 | {% if theme_logo %} 2 |

{{ project }}

7 | {% endif %} 8 | 9 |

10 | {% else %} 11 |

{{ project }}

12 | {% endif %} 13 | 14 | {% if theme_description %} 15 |

{{ theme_description }}

16 | {% endif %} 17 | 18 | {% if theme_github_button|lower == 'true' %} 19 |

20 | 22 |

23 | {% endif %} 24 | 25 | {% if theme_travis_button|lower != 'false' %} 26 | {% if theme_travis_button|lower == 'true' %} 27 | {% set path = theme_github_user + '/' + theme_github_repo %} 28 | {% else %} 29 | {% set path = theme_travis_button %} 30 | {% endif %} 31 |

32 | 33 | https://secure.travis-ci.org/{{ path }}.png?branch=master 37 | 38 |

39 | {% endif %} 40 | -------------------------------------------------------------------------------- /docs/source/alabaster/donate.html: -------------------------------------------------------------------------------- 1 | {% if theme_gratipay_user or theme_gittip_user %} 2 |

Donate

3 |

4 | Consider supporting the authors on Gratipay: 5 | 8 |

9 | {% endif %} 10 | -------------------------------------------------------------------------------- /docs/source/alabaster/layout.html: -------------------------------------------------------------------------------- 1 | {%- extends "basic/layout.html" %} 2 | 3 | {%- block extrahead %} 4 | {{ super() }} 5 | {% if theme_touch_icon %} 6 | 7 | {% endif %} 8 | 9 | {% endblock %} 10 | 11 | {# Disable base theme's top+bottom related navs; we have our own in sidebar #} 12 | {%- block relbar1 %}{% endblock %} 13 | {%- block relbar2 %}{% endblock %} 14 | 15 | {%- block footer %} 16 | 29 | 30 | {% if theme_github_banner|lower != 'false' %} 31 | 32 | Fork me on GitHub 33 | 34 | {% endif %} 35 | 36 | {% if theme_analytics_id %} 37 | 52 | {% endif %} 53 | {%- endblock %} 54 | -------------------------------------------------------------------------------- /docs/source/alabaster/navigation.html: -------------------------------------------------------------------------------- 1 |

Navigation

2 | {{ toctree(includehidden=theme_sidebar_includehidden) }} 3 | {% if theme_extra_nav_links %} 4 |
5 |
    6 | {% for text, uri in theme_extra_nav_links.items() %} 7 |
  • {{ text }}
  • 8 | {% endfor %} 9 |
10 | {% endif %} 11 | -------------------------------------------------------------------------------- /docs/source/alabaster/relations.html: -------------------------------------------------------------------------------- 1 |
2 |

Related Topics

3 | 21 |
22 | -------------------------------------------------------------------------------- /docs/source/alabaster/theme.conf: -------------------------------------------------------------------------------- 1 | [theme] 2 | inherit = basic 3 | stylesheet = alabaster.css 4 | pygments_style = alabaster.support.Alabaster 5 | 6 | [options] 7 | logo = 8 | logo_name = false 9 | logo_text_align = left 10 | description = 11 | description_font_style = normal 12 | github_user = 13 | github_repo = 14 | github_button = true 15 | github_banner = false 16 | github_type = watch 17 | github_count = true 18 | travis_button = false 19 | gratipay_user = 20 | gittip_user = 21 | analytics_id = 22 | touch_icon = 23 | extra_nav_links = 24 | sidebar_includehidden = true 25 | show_powered_by = true 26 | show_related = false 27 | 28 | gray_1 = #444 29 | gray_2 = #EEE 30 | gray_3 = #AAA 31 | 32 | pink_1 = #FCC 33 | pink_2 = #FAA 34 | 35 | body_text = #3E4349 36 | footer_text = #888 37 | link = #004B6B 38 | link_hover = #6D4100 39 | sidebar_header = 40 | sidebar_text = #555 41 | sidebar_link = 42 | sidebar_link_underscore = #999 43 | sidebar_search_button = #CCC 44 | sidebar_list = #000 45 | sidebar_hr = 46 | anchor = #DDD 47 | anchor_hover_fg = 48 | anchor_hover_bg = #EAEAEA 49 | note_bg = 50 | note_border = #CCC 51 | seealso_bg = 52 | seealso_border = #CCC 53 | warn_bg = 54 | warn_border = 55 | footnote_bg = #FDFDFD 56 | footnote_border = 57 | pre_bg = 58 | narrow_sidebar_bg = #333 59 | narrow_sidebar_fg = #FFF 60 | narrow_sidebar_link = 61 | code_font_size = 0.9em 62 | code_font_family = 'Consolas', 'Menlo', 'Deja Vu Sans Mono', 'Bitstream Vera Sans Mono', monospace 63 | font_family = 'goudy old style', 'minion pro', 'bell mt', Georgia, 'Hiragino Mincho Pro', serif 64 | head_font_family = 'Garamond', 'Georgia', serif 65 | code_highlight = #FFC 66 | -------------------------------------------------------------------------------- /docs/source/examples/ex1.rst: -------------------------------------------------------------------------------- 1 | 2 | Example 1: Uniaxial Strain 3 | ########################## 4 | 5 | This example demonstrates exercising the elastic material model through a path 6 | of uniaxial strain. The example input below is found in ``matmodlab/examples/uniaxial_strain.py`` 7 | 8 | The Example Script 9 | ================== 10 | 11 | :: 12 | 13 | from matmodlab import * 14 | 15 | # Create the material point simulator 16 | mps = MaterialPointSimulator('uniaxial_strain') 17 | 18 | # Define the material 19 | mps.Material('elastic', {'K': 1.35e11, 'G': 5.3e10}) 20 | 21 | # Define the strain step 22 | mps.StrainStep(components=(1, 0, 0), scale=.02) 23 | 24 | # Run the simulation 25 | mps.run() 26 | 27 | 28 | How Does the Script Work? 29 | ========================= 30 | 31 | This section describes each part of the example script. 32 | 33 | ``from matmodlab import *`` 34 | 35 | This statement makes the Matmodlab objects accessible to the script. 36 | 37 | ``mps = MaterialPointSimulator('uniaxial_strain')`` 38 | 39 | This statement creates a new material point simlator object named ``uniaxial_strain``. The variable ``mps`` is assigned to the simulator. 40 | 41 | ``mps.Material('elastic', {'K': 1.35e11, 'G': 5.3e10})`` 42 | 43 | This statement defines the material model to be the ``elastic`` material and 44 | defines the bulk modulus ``K`` and shear modulus ``G`` to ``1.35e11`` and 45 | ``5.3e10``, respectively. 46 | 47 | ``mps.StrainStep(components=(1, 0, 0), scale=.02)`` 48 | 49 | This statement defines an analysis step through which the material will be 50 | exercised. The step is defined by the tensor ``components`` :math:`(1, 0, 0)`, 51 | representing the ``xx``, ``yy``, and ``zz`` components of the strain tensor. A 52 | ``scale`` factor of ``.02`` is applied to each component. 53 | 54 | * The first 3 values of ``components`` represent the ``xx``, ``yy``, and 55 | ``zz`` components of the tensor describing the deformation path. The ``xy``, 56 | ``yz``, and ``xz`` components are implicitly ``0``. 57 | 58 | ``mps.run()`` 59 | 60 | This statement runs the material through the defined deformation path. 61 | -------------------------------------------------------------------------------- /docs/source/examples/ex2.rst: -------------------------------------------------------------------------------- 1 | 2 | Example 2: Uniaxial Stress 3 | ########################## 4 | 5 | This example demonstrates exercising the elastic material model through a path 6 | of uniaxial stress. The example input below is found in ``matmodlab/examples/uniaxial_stress.py`` 7 | 8 | The Example Script 9 | .................. 10 | 11 | :: 12 | 13 | from matmodlab import * 14 | 15 | # Create the material point simulator 16 | mps = MaterialPointSimulator('uniaxial_stress') 17 | 18 | # Define the material 19 | mps.Material('elastic', {'K': 1.35e11, 'G': 5.3e10}) 20 | 21 | # Define the stress step 22 | mps.StressStep(components=(1, 0, 0), frames=25, scale=1e6) 23 | 24 | # Run the simulation 25 | mps.run() 26 | 27 | How Does the Script Work? 28 | ......................... 29 | 30 | This section describes each part of the example script 31 | 32 | ``from matmodlab import *`` 33 | 34 | This statement makes the Matmodlab objects accessible to the script. 35 | 36 | ``mps = MaterialPointSimulator('uniaxial_stress')`` 37 | 38 | This statement creates a new material point simlator object named ``uniaxial_stress``. The variable ``mps`` is assigned to the simulator. 39 | 40 | ``mps.Material('elastic', {'K': 1.35e11, 'G': 5.3e10})`` 41 | 42 | This statement defines the material model to be the ``elastic`` material and 43 | defines the bulk modulus ``K`` and shear modulus ``G`` to ``1.35e11`` and 44 | ``5.3e10``, respectively. 45 | 46 | ``mps.StressStep(components=(1, 0, 0), frames=25, scale=1e6)`` 47 | 48 | This statement defines an analysis step through which the material will be 49 | exercised. The step is defined by the tensor ``components`` :math:`(1, 0, 0)`, 50 | representing the ``xx``, ``yy``, and ``zz`` components of the stress tensor. A 51 | ``scale`` factor of ``1e6`` is applied to each component. 52 | 53 | * The first 3 values of ``components`` represent the ``xx``, ``yy``, and 54 | ``zz`` components of the tensor describing the deformation path. The ``xy``, 55 | ``yz``, and ``xz`` components are implicitly 0. 56 | 57 | ``mps.run()`` 58 | 59 | This statement runs the material through the defined deformation path. 60 | -------------------------------------------------------------------------------- /docs/source/examples/ex3.rst: -------------------------------------------------------------------------------- 1 | 2 | Example 3: Uniaxial Stress, Mixed Mode 3 | ###################################### 4 | 5 | This example demonstrates exercising the elastic material model through a path 6 | of uniaxial stress, using a mixed mode step. The example input below is found in ``matmodlab/examples/uniaxial_stress.py`` 7 | 8 | The Example Script 9 | .................. 10 | 11 | :: 12 | 13 | from matmodlab import * 14 | 15 | # Create the material point simulator 16 | mps = MaterialPointSimulator('uniaxial_stress-1', output=EXO) 17 | 18 | # Define the material 19 | mps.Material('elastic', {'K': 1.35e11, 'G': 5.3e10}) 20 | 21 | # Define the mixed mode step 22 | mps.MixedStep(components=(1, 0, 0), descriptors='ESS', frames=25, scale=.02) 23 | 24 | # Run the simulation 25 | mps.run() 26 | 27 | # Launch the viewer 28 | mps.view() 29 | 30 | How Does the Script Work? 31 | ......................... 32 | 33 | This section describes each part of the example script. 34 | 35 | ``from matmodlab import *`` 36 | 37 | This statement makes the Matmodlab objects accessible to the script. 38 | 39 | ``mps = MaterialPointSimulator('uniaxial_stress-1', output=EXO)`` 40 | 41 | This statement creates a new material point simlator object named ``uniaxial_stress-1``. The variable ``mps`` is assigned to the simulator. The ``output`` format is ``EXO`` (ExodusII) instead of the default ``DBX``. 42 | 43 | ``mps.Material('elastic', {'K': 1.35e11, 'G': 5.3e10})`` 44 | 45 | This statement defines the material model to be the ``elastic`` material and 46 | defines the bulk modulus ``K`` and shear modulus ``G`` to ``1.35e11`` and 47 | ``5.3e10``, respectively. 48 | 49 | ``mps.MixedStep(components=(1, 0, 0), descriptors='ESS', frames=25, scale=.02)`` 50 | 51 | This statement defines an analysis step through which the material will be 52 | exercised. The step is defined by the tensor ``components`` :math:`(1, 0, 0)`, 53 | representing the ``xx`` component of the strain tensor and the ``yy``, and 54 | ``zz`` components of the stress tensor (as designated by the ``descriptors`` 55 | ``"ESS"``). The step is run in ``25`` ``frames`` (increments) and a ``scale`` of 56 | ``.02`` is applied to each component. Note the following: 57 | 58 | * The first 3 values of ``components`` represent the ``xx``, ``yy``, and 59 | ``zz`` components of the tensor describing the deformation path. The ``xy``, 60 | ``yz``, and ``xz`` components are implicitly ``0``. 61 | 62 | * The i\ :superscript:`th` ``descriptor`` designates the physical 63 | interpretation of the i\ :superscript:`th` ``component`` with ``E`` 64 | representing strain and ``S`` representing stress. 65 | 66 | ``mps.run()`` 67 | 68 | This statement runs the material through the defined deformation path. 69 | 70 | ``mps.view()`` 71 | 72 | This statement launches the Matmodlab viewer (the chaco and traitsui Python modules must be installed). 73 | -------------------------------------------------------------------------------- /docs/source/examples/index.rst: -------------------------------------------------------------------------------- 1 | Examples 2 | ======== 3 | 4 | See the collection of `Jupyter notebooks `_ for examples of using *Matmodlab2*. 5 | -------------------------------------------------------------------------------- /docs/source/execution/cli.rst: -------------------------------------------------------------------------------- 1 | 2 | .. _basic_cli: 3 | 4 | Execution Procedures 5 | #################### 6 | 7 | Overview 8 | ======== 9 | 10 | Matmodlab is executed by running the ``mml`` procedure. Several parameters can be set either on the command line or in an environment file (see :ref:`environment`). 11 | 12 | mml Summary 13 | =========== 14 | 15 | :: 16 | 17 | $ mml [-h|help] [] 18 | 19 | mml Commands 20 | ------------ 21 | 22 | (empty) 23 | ....... 24 | 25 | Launch the (empty) Matmodlab gui 26 | 27 | .. _cli_build: 28 | 29 | build 30 | ..... 31 | 32 | Build fortran libraries 33 | 34 | Optional build arguments 35 | ~~~~~~~~~~~~~~~~~~~~~~~~ 36 | 37 | :: 38 | 39 | -h, --help show this help message and exit 40 | -v V Verbosity 41 | -w Wipe before building 42 | -W Wipe and exit 43 | -m M [M ...] Materials to build 44 | -u Build auxiliary support files only 45 | 46 | clean 47 | ..... 48 | 49 | Remove files generated by Matmodlab (.pyc, .o, .so, .a, build, etc.) 50 | 51 | notebook 52 | ........ 53 | 54 | Launches an `IPython Notebook `_ in the Matmodlab environment. Requires the ``ipython`` and ``ipython-notebook`` modules. 55 | 56 | run 57 | ... 58 | 59 | Run a Matmodlab simulation script in the Matmodlab environment. 60 | 61 | Required run arguments 62 | ~~~~~~~~~~~~~~~~~~~~~~ 63 | 64 | :: 65 | 66 | source Python source file 67 | 68 | Optional run arguments 69 | ~~~~~~~~~~~~~~~~~~~~~~ 70 | 71 | :: 72 | 73 | -h, --help show this help message and exit 74 | -v V Verbosity 75 | --debug Debug mode 76 | --sqa SQA mode 77 | --switch MATX MATY Run with MATY instead of MATX, if present(not 78 | supported by all models) 79 | -B MATERIAL Wipe and rebuild MATERIAL before running 80 | -V Launch results viewer on completion 81 | -j NPROCS, --nprocs NPROCS 82 | Number of simultaneous jobs 83 | -W {std,all,error} Warning level 84 | -w Wipe and rebuild material in Material factory before 85 | running 86 | 87 | .. _cli_test: 88 | 89 | test 90 | .... 91 | 92 | ``mml test`` is merely a wrapper around ``py.test`` 93 | 94 | view 95 | .... 96 | 97 | Launch the Matmodlab viewer 98 | 99 | Required view arguments 100 | ~~~~~~~~~~~~~~~~~~~~~~~ 101 | 102 | :: 103 | 104 | sources Output database file[s] 105 | 106 | 107 | .. _exodiff: 108 | -------------------------------------------------------------------------------- /docs/source/execution/examples.rst: -------------------------------------------------------------------------------- 1 | .. _examples: 2 | 3 | Annotated Examples 4 | ################## 5 | 6 | .. topic:: See Also 7 | 8 | * :ref:`intro_conventions` 9 | * :ref:`mps` 10 | 11 | Overview 12 | ======== 13 | 14 | In this section, several example input scripts are described. A Matmodlab 15 | input script consists of defining an instance of the 16 | ``MaterialPointSimulator`` class and defininig for it a ``material`` and 17 | ``steps``. The following examples provide illustration. 18 | 19 | Job Execution 20 | ============= 21 | 22 | Simulations are run by processing Matmodlab input scripts with the ``mml`` 23 | command line utility:: 24 | 25 | $ mml run filename.py 26 | 27 | where ``filename.py`` is the name of the input script. 28 | 29 | Examples 30 | ======== 31 | 32 | .. toctree:: 33 | :maxdepth: 1 34 | 35 | ../examples/ex1 36 | ../examples/ex2 37 | ../examples/ex3 38 | -------------------------------------------------------------------------------- /docs/source/execution/index.rst: -------------------------------------------------------------------------------- 1 | 2 | .. _model_create_and_execute: 3 | 4 | Job Execution 5 | ############# 6 | 7 | .. toctree:: 8 | :maxdepth: 1 9 | 10 | overview 11 | cli 12 | mps 13 | post 14 | notebook 15 | permutate 16 | optimize 17 | examples 18 | -------------------------------------------------------------------------------- /docs/source/execution/notebook.rst: -------------------------------------------------------------------------------- 1 | .. _notebook: 2 | 3 | Notebook 4 | ######## 5 | 6 | .. topic:: See Also 7 | 8 | * :ref:`basic_cli` 9 | * :ref:`intro_conventions` 10 | * :ref:`mps` 11 | * :ref:`viewer` 12 | 13 | Overview 14 | ======== 15 | 16 | The Matmodlab.Notebook 17 | 18 | * is an `IPython Notebook `_ environment; 19 | * requires the ``ipython`` and ``ipython-notebook`` modules; 20 | * requires the `matplotlib `_ and/or `Bokeh `_ modules for data visualization; and 21 | * allows interactive material model development. 22 | 23 | The full power of the Matmodlab.Notebook is realized by interactive data visualization using `Bokeh `_, which is a recommended install. 24 | 25 | The Matmodlab.Notebook Environment 26 | ================================== 27 | 28 | The Matmodlab.Notebook environment is invoked by launching the IPython Notebook through the ``mml`` procedure:: 29 | 30 | $ mml notebook 31 | 32 | After launching the notebook server and starting a new notebook, the following IPython magic should be executed in the notebook's first cell:: 33 | 34 | %matmodlab 35 | 36 | If Bokeh is installed, the :ref:`mps`\'s plotting methods use Bokeh for data visualization. Otherwise, matplotlib is used as the plotting backend. Matplotlib can be explicitly used as the plotting backend by specifying:: 37 | 38 | %matmodlab matplotlib 39 | 40 | 41 | .. todo:: 42 | 43 | Finish this section 44 | -------------------------------------------------------------------------------- /docs/source/execution/overview.rst: -------------------------------------------------------------------------------- 1 | 2 | Job Execution: Overview 3 | ####################### 4 | 5 | .. topic:: See Also 6 | 7 | * :ref:`basic_cli` 8 | * :ref:`intro_conventions` 9 | * :ref:`mps` 10 | 11 | Overview 12 | ======== 13 | 14 | .. figure:: ../images/flow.png 15 | 16 | An analysis in Matmodlab is defined by an input script, which 17 | 18 | * is a Python script that imports the Matmodlab namespace; and 19 | * defines a ``MaterialPointSimulator`` object. 20 | 21 | Once defined, the input script is executed with the ``mml run`` procedure and results viewed with the ``mml view`` procedure. 22 | 23 | The Input Script 24 | ================ 25 | 26 | Most input scripts have the same basic layout: 27 | 28 | 1) Import the Matmodlab namespace:: 29 | 30 | from matmodlab import * 31 | 32 | 2) Instantiate the ``MaterialPointSimulator``:: 33 | 34 | mps = MaterialPointSimulator('jobname') 35 | 36 | 3) Define the simulation steps. For example, a single step of uniaxial strain:: 37 | 38 | mps.StrainStep(components=(1, 0, 0)) 39 | 40 | 4) Define the material model. For example, a linear elastic material:: 41 | 42 | mps.Material('elastic', {'K': 10, 'G': 8}) 43 | 44 | 5) Run the job:: 45 | 46 | mps.run() 47 | 48 | Executing the Input Script 49 | ========================== 50 | 51 | Once written, the input script is executed by the ``mml run`` procedure:: 52 | 53 | $ mml run 54 | 55 | Viewing the Results 56 | =================== 57 | 58 | Once executed, the model results are viewed with ``mml view`` procedure:: 59 | 60 | $ mml view 61 | -------------------------------------------------------------------------------- /docs/source/execution/post.rst: -------------------------------------------------------------------------------- 1 | 2 | .. _viewer: 3 | 4 | Postprocessing Results 5 | ###################### 6 | 7 | .. topic:: See Also 8 | 9 | * :ref:`basic_cli` 10 | * :ref:`intro_conventions` 11 | * :ref:`mps` 12 | 13 | Overview 14 | ======== 15 | 16 | The Matmodlab.Viewer is an application that 17 | 18 | * is developed in `TraitsUI `_ and `Chaco `_; 19 | * reads output databases created by the :ref:`mps` and creates 2D plots of the simulation data; and 20 | * is invoked on the command line or as a method of the :ref:`mps`. 21 | 22 | Visualizing Results 23 | =================== 24 | 25 | After completion of a simulation, results can be viewed in one of two ways 26 | 27 | * ``MaterialPointSimulator.view()`` method call:: 28 | 29 | mps.run() 30 | mps.view() 31 | 32 | * The ``mml`` script:: 33 | 34 | $ mml view job.exo 35 | 36 | Whatever the method chosen, a `TraitsUI `_ window is opened... 37 | 38 | .. figure:: ../images/mmv.png 39 | :align: center 40 | :height: 3.5in 41 | 42 | .. todo:: 43 | 44 | Finish this section 45 | -------------------------------------------------------------------------------- /docs/source/images/cfmt_desc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matmodlab/matmodlab2/d2e6f5332d319752285c042e88e2baab506dc921/docs/source/images/cfmt_desc.png -------------------------------------------------------------------------------- /docs/source/images/figs.key: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matmodlab/matmodlab2/d2e6f5332d319752285c042e88e2baab506dc921/docs/source/images/figs.key -------------------------------------------------------------------------------- /docs/source/images/flow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matmodlab/matmodlab2/d2e6f5332d319752285c042e88e2baab506dc921/docs/source/images/flow.png -------------------------------------------------------------------------------- /docs/source/images/mmv.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matmodlab/matmodlab2/d2e6f5332d319752285c042e88e2baab506dc921/docs/source/images/mmv.png -------------------------------------------------------------------------------- /docs/source/images/mmv_sig.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matmodlab/matmodlab2/d2e6f5332d319752285c042e88e2baab506dc921/docs/source/images/mmv_sig.png -------------------------------------------------------------------------------- /docs/source/images/path.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matmodlab/matmodlab2/d2e6f5332d319752285c042e88e2baab506dc921/docs/source/images/path.png -------------------------------------------------------------------------------- /docs/source/images/path_desc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matmodlab/matmodlab2/d2e6f5332d319752285c042e88e2baab506dc921/docs/source/images/path_desc.png -------------------------------------------------------------------------------- /docs/source/index.rst: -------------------------------------------------------------------------------- 1 | The Material Model Laboratory 2 | ############################# 3 | 4 | The Material Model Laboratory (*Matmodlab2*) is a single element material model 5 | driver aimed at developers of constitutive routines targeted for deployment in 6 | finite element codes. 7 | 8 | This guide is separated into four main parts: 9 | 10 | * Part 1: :ref:`intro_and_overview` 11 | * Part 2: :ref:`model_create_and_execute` 12 | * Part 3: :ref:`mat_index` 13 | * Part 4: :ref:`test_index` 14 | 15 | Additionally, a growing collection of `Jupyter Notebooks `_ demonstrate *Matmodlab2* usage. 16 | 17 | About This Guide 18 | ================ 19 | 20 | This guide is both a User's Guide and Application Programming Interface (API) 21 | guide to Matmodlab. The guide assumes a working knowledge of the computing 22 | languages Matmodlab is developed in, namely `Python `_ 23 | and `Fortran 24 | `_. No 25 | attempt to describe either is made. Online tutorials for each language are 26 | readily available. Likewise, the target audience is assumed to have a basic 27 | knowledge of continuum mechanics and familiarity with other finite element 28 | codes. These concepts are also not described in detail. 29 | 30 | Conventions Used in the Guide 31 | ----------------------------- 32 | 33 | * Python objects are typeset in ``fixed point font``. 34 | * ``$`` is used to denote a terminal prompt, e.g. ``$ cd`` is interpreted as executing the ``cd`` (change directory) command at a command prompt. 35 | 36 | License 37 | ======= 38 | 39 | *Matmodlab2* is an open source project licensed under the `MIT `_ license. 40 | 41 | Obtaining and Installing Matmodlab2 42 | =================================== 43 | 44 | *Matmodlab2* is maintained with git and can be obtained from ``_. To install *Matmodlab2*, obtain a copy (by cloning or downloading) of the source code and add the path to the ``matmodlab2`` root directory to your ``PYTHONPATH``. 45 | 46 | Acknowledgments 47 | =============== 48 | 49 | The inspiration for *Matmodlab2* came from Dr. `Rebecca Brannon's `_ *MED* material point driver and Tom Pucicks's *MMD* driver, developed at Sandia National Labs. 50 | 51 | The syntax and documentation have been greatly influenced by the authors' exposure and use of research codes at Sandia National Labs and other commercial finite element codes, notably `Abaqus `_. 52 | 53 | Obtaining Additional Help 54 | ========================= 55 | 56 | In addition to this guide, many examples can be found in 57 | ``matmodlab2/notebooks`` and ``matmodlab2/tests`` 58 | 59 | Indices and tables 60 | ================== 61 | 62 | * :ref:`genindex` 63 | 64 | * :ref:`search` 65 | 66 | .. toctree:: 67 | :maxdepth: 4 68 | :hidden: 69 | :numbered: 2 70 | 71 | intro/index 72 | execution/index 73 | material/index 74 | examples/index 75 | test/index 76 | -------------------------------------------------------------------------------- /docs/source/intro/about.rst: -------------------------------------------------------------------------------- 1 | 2 | Introduction: Background 3 | ######################## 4 | 5 | Why a Single Element Driver? 6 | ============================ 7 | 8 | Single element drivers allow the constituive model developer to concentrate on 9 | model development and not the finite element response. Advantages of 10 | *Matmodlab2* (or, more generally, of any stand-alone constitutive model driver) 11 | are 12 | 13 | * *Matmodlab2* is a very small, special purpose, code. Thus, maintaining 14 | and adding new features to *Matmodlab2* is very easy; 15 | 16 | * simulations are not affected by irrelevant artifacts such as artificial 17 | viscosity or uncertainty in the handling of boundary conditions; 18 | 19 | * it is straightforward to produce supplemental output for deep analysis of 20 | the results that would otherwise constitute an unnecessary overhead in a 21 | finite element code; 22 | 23 | * specific material benchmarks may be developed and automatically run 24 | quickly any time the model is changed; and 25 | 26 | * specific features of a material model may be exercised easily by the model 27 | developer by prescribing strains, strain rates, stresses, stress rates, and 28 | deformation gradients as functions of time. 29 | 30 | Why Python? 31 | =========== 32 | 33 | Python is an interpreted, high level object oriented language. Programs can be 34 | written rapidly and, because it is an interpreted language, do not require a 35 | compiling step. While this might make programs written in python slower than 36 | those written in a compiled language, modern packages and computers make the 37 | speed up difference between python and a compiled language for single element 38 | problems almost insignificant. 39 | 40 | For numeric computations, the `NumPy `_ and `SciPy 41 | `_ modules allow programs written in Python to leverage 42 | a large set of numerical routines provided by lapack, blas, 43 | eigpack, etc. Python's APIs also allow for calling subroutines written in 44 | C or Fortran (in addition to a number of other languages), a prerequisite for 45 | model development as most legacy material models are written in Fortran. In 46 | fact, most modern material models are still written in Fortran to this day. 47 | 48 | Python's object oriented nature allows for rapid installation of new material 49 | models. 50 | -------------------------------------------------------------------------------- /docs/source/intro/conventions.rst: -------------------------------------------------------------------------------- 1 | .. _intro_conventions: 2 | 3 | Conventions 4 | ########### 5 | 6 | Overview 7 | ======== 8 | 9 | Conventions used through out *Matmodlab2* are described. 10 | 11 | Dimension 12 | ========= 13 | 14 | Material models are always called with full 3D tensors. 15 | 16 | Vector Storage 17 | ============== 18 | 19 | Vector components are stored as 20 | 21 | .. math:: 22 | 23 | v_i = \{v_x, v_y, v_z\} 24 | 25 | Tensor Storage 26 | ============== 27 | 28 | Second-order symmetric tensors are stored as 6x1 arrays with the following 29 | component ordering 30 | 31 | .. math:: 32 | :label: order-symtens 33 | 34 | A_{ij} = \{A_{xx}, A_{yy}, A_{zz}, A_{xy}, A_{yz}, A_{xz}\} 35 | 36 | Nonsymmetric, second-order tensors are stored as 9x1 arrays in row major 37 | ordering, i.e., 38 | 39 | .. math:: 40 | 41 | B_{ij} = \{B_{xx}, B_{xy}, B_{xz}, 42 | B_{yx}, B_{yy}, B_{yz}, 43 | B_{zx}, B_{zy}, B_{zz}\} 44 | 45 | Engineering Strains 46 | ------------------- 47 | 48 | The shear components of strain-like tensors are sent to the material model as 49 | engineering strains, i.e. 50 | 51 | .. math:: 52 | 53 | \epsilon_{ij} = \{\epsilon_{xx}, \epsilon_{yy}, \epsilon_{zz}, 2\epsilon_{xy}, 2\epsilon_{yz}, 2\epsilon_{xz}\} 54 | = \{\epsilon_{xx}, \epsilon_{yy}, \epsilon_{zz}, \gamma_{xy}, \gamma_{yz}, \gamma_{xz}\} 55 | -------------------------------------------------------------------------------- /docs/source/intro/environment.rst: -------------------------------------------------------------------------------- 1 | 2 | .. _environment: 3 | 4 | Environment Settings 5 | #################### 6 | 7 | Overview 8 | ======== 9 | 10 | *Matmodlab2* sets up and performs execution of input scripts in a customized 11 | environment (not to be confused with Python virtual environments). The 12 | environment can be modified by user environment files that are read at the 13 | beginning of each job. 14 | 15 | Environment File Locations 16 | ========================== 17 | 18 | *Matmodlab2* searches for the optional user environment file, 19 | ``mml_userenv.py``, in two locations, in the following order: 20 | 21 | 1) The location specified by the environment variable ``MML_USERENV`` 22 | 2) The current working directory. 23 | 24 | The value of a parameter is the last definition encountered, meaning that 25 | the order of precedence for user settings is the current working directory and 26 | ``MML_USERENV``. 27 | 28 | Environment files use Python syntax, meaning that entries will have the 29 | following form:: 30 | 31 | parameter = value 32 | 33 | All usual Python conventions apply. 34 | 35 | Recognized Environment Settings and Defaults 36 | ============================================ 37 | 38 | Below are the recognized environment settings and their defaults. Any of these 39 | settings can be changed by specifying a different value in a user environment 40 | file. 41 | 42 | .. note:: 43 | 44 | When specifying environment settings in a user environment file, the 45 | setting must have the same type as the default. If the default is a list, 46 | the user setting is inserted in to the default list. If the default is a 47 | dictionary, it is updated with the user setting. 48 | 49 | IO Settings 50 | ----------- 51 | 52 | verbosity 53 | 54 | *Matmodlab2* will print more, or less, information during job execution. Possible values are ``0``, ``1``, and ``2``. Set the value to ``0`` to suppress printing of information. Set the value to ``2``, or higher, to print increase the amount of information printed. The default value is ``1``. 55 | 56 | SQA 57 | 58 | *Matmodlab2* will run extra software quality checks. 59 | 60 | loglevel 61 | 62 | Set the `logging` module logger level. Value must be a valid `logging` level. 63 | 64 | prepend_to_sys_path 65 | 66 | If `True`, prepend the environment file's directory to the python search path. If a string (or list of strings), *Matmodlab2* will assume that the string (or list of strings) is a directory path and put it (or them) on the search path. 67 | -------------------------------------------------------------------------------- /docs/source/intro/index.rst: -------------------------------------------------------------------------------- 1 | 2 | .. _intro_and_overview: 3 | 4 | Introduction and Overview 5 | ######################### 6 | 7 | .. toctree:: 8 | :maxdepth: 1 9 | 10 | about 11 | install 12 | input 13 | conventions 14 | environment 15 | solution 16 | output 17 | -------------------------------------------------------------------------------- /docs/source/intro/input.rst: -------------------------------------------------------------------------------- 1 | Input Syntax Guidelines 2 | ####################### 3 | 4 | Overview 5 | ======== 6 | 7 | This section describes some conventions used in the *Matmodlab2* API and adopted 8 | in user input scripts. 9 | 10 | Matmodlab2 Namespace 11 | ==================== 12 | 13 | Input scripts to *Matmodlab2* should include:: 14 | 15 | from matmodlab2 import * 16 | 17 | to populate the script's namespace with *Matmodlab2* specific functions and 18 | classes. 19 | 20 | Primary Classes 21 | --------------- 22 | 23 | The primary classes exposed by importing ``matmodlab2`` are 24 | 25 | * ``MaterialPointSimulator``, the *Matmodlab2* material point simulator 26 | * ``Optimizer``, the *Matmodlab2* optimizer 27 | 28 | Each of these classes is described in more detail in the following sections. 29 | 30 | 31 | Naming Conventions 32 | ================== 33 | 34 | Throughout *Mamodlab2*, the following naming conventions are adopted (see the 35 | `PEP8 `_ guidelines for more 36 | guidance): 37 | 38 | * Class names use the ``CapWords`` convention. 39 | * Method names use ``lowercase`` with words separated by underscores as 40 | necessary to improve readability. 41 | * Variable names adopt the same rule as method names. 42 | -------------------------------------------------------------------------------- /docs/source/intro/install.rst: -------------------------------------------------------------------------------- 1 | .. _intro_install: 2 | 3 | Installing Matmodlab2 4 | ##################### 5 | 6 | Overview 7 | ======== 8 | 9 | *Matmodlab2*'s code base is largely written in Python and requires no 10 | additional compiling. However, several (optional) linear algebra packages and 11 | material models are written in Fortran and require a separate compile step. 12 | 13 | System Requirements 14 | =================== 15 | 16 | *Matmodlab2* has been built and tested extensively on several versions of Linux 17 | and the Apple Mac OSX operating systems. 18 | 19 | Required Software 20 | ================= 21 | 22 | The basic functionality of *Matmodlab2* requires the following software 23 | installed for your platform: 24 | 25 | #) `Python 2.7 or 3.5 `_ 26 | 27 | #) `NumPy `_ 28 | 29 | #) `SciPy `_ 30 | 31 | *Matmodlab2* has further functionality that can be utilized if the appropriate 32 | packages are installed. 33 | 34 | #) `pytest `_ for running tests 35 | 36 | #) `pandas `_ for the ``DataFrame`` object. 37 | 38 | The required software may be obtained in several ways, though most development 39 | has been made using the `Anaconda `_ Python distribution. 40 | 41 | .. _installation: 42 | 43 | Installation 44 | ============ 45 | 46 | .. note:: 47 | 48 | Ensure that all *Matmodlab2* prerequisites are installed and working properly before proceeding. 49 | 50 | Obtain the source code from `github `_ 51 | and add the path to the ``matmodlab2`` directory to your ``PYTHONPATH`` environment 52 | variable:: 53 | 54 | $ git clone https://www.github.com/matmodlab/matmodlab2 55 | $ export MATMODLAB2_DIR=`pwd`/matmodlab 56 | $ export PYTHONPATH=${PYTHONPATH}:${MATMODLAB2_DIR} 57 | 58 | Build (Optional) 59 | ---------------- 60 | 61 | A library of Fortran linear algebra routines can also be built. Navigate to 62 | ``matmodlab2/matmodlab2/ext_helpers`` and execute the ``build_ext.py`` script:: 63 | 64 | $ cd ${MATMODLAB2_DIR}/matmodlab2/ext_helpers 65 | $ ./build_ext.py matfuncs 66 | 67 | Testing the Installation 68 | ======================== 69 | 70 | Testing requires that the `pytest `_ module be installed. Tests are run by executing:: 71 | 72 | $ cd ${MATMODLAB2_DIR}/tests 73 | $ py.test . 74 | 75 | Troubleshooting 76 | =============== 77 | 78 | If you run in to problems, open an issue at 79 | ``_. 80 | -------------------------------------------------------------------------------- /docs/source/intro/output.rst: -------------------------------------------------------------------------------- 1 | .. _mml_out_dbs: 2 | 3 | Matmodlab File Formats 4 | ###################### 5 | 6 | Overview 7 | ======== 8 | 9 | *Matmodlab2* writes to one of two file formats. The format of output is determined by the *db_fmt* keyword to the ``MaterialPointSimulator``. The two formats are 10 | 11 | npz 12 | Compressed ``numpy`` array format. This is the default format and is chosen 13 | by letting ``db_fmt='npz'`` 14 | 15 | exo 16 | 17 | `ExodusII `_ output database 18 | format. Output is written to exo format if ``db_fmt=exo``. 19 | -------------------------------------------------------------------------------- /docs/source/intro/quick.rstx: -------------------------------------------------------------------------------- 1 | 2 | Matmodlab Quickstart 3 | #################### 4 | 5 | Overview 6 | ======== 7 | 8 | An overview of the process of installing and running Matmodlab is provided. 9 | 10 | .. note:: 11 | 12 | The following commands are to be executed from a command prompt 13 | 14 | Setup and Build 15 | =============== 16 | 17 | Users 18 | ----- 19 | 20 | Simply execute 21 | 22 | :: 23 | 24 | pip install matmodlab 25 | 26 | or 27 | 28 | :: 29 | 30 | easy_install matmodlab 31 | 32 | 33 | Matmodlab Developers 34 | ---------------------- 35 | 36 | See :ref:`Installing` for more details. 37 | 38 | * Clone Matmodlab from ``_:: 39 | 40 | git clone https://github.com/tjfulle/matmodlab.git 41 | 42 | * Navigate to the ``matmodlab`` directory and execute:: 43 | 44 | python setup.py develop 45 | 46 | All components of Matmodlab will be built and installed. 47 | 48 | .. _prepare_input: 49 | 50 | Prepare Input 51 | ============= 52 | 53 | Input files are Python scripts. See :ref:`examples` and :ref:`Methods for Creating Simulations` for more details. 54 | 55 | * Instantiate a ``MaterialPointSimulator`` object. 56 | * Define the material model 57 | * Define the deformation path 58 | 59 | .. _run_the_input: 60 | 61 | Run the Simulation 62 | ================== 63 | 64 | Run the input script with ``mml``. See :ref:`examples` for more 65 | details:: 66 | 67 | mml run [options] filename.py 68 | 69 | ``mml`` will create the following files:: 70 | 71 | ls filename.* 72 | filename.dbx filename.log filename.py 73 | 74 | ``filename.dbx`` is the dbx output database and ``filename.log`` the simulation 75 | log file. See ``mml help run`` for a complete list of options 76 | 77 | .. _post_proc_results: 78 | 79 | Postprocess 80 | =========== 81 | 82 | View results in Matmodlab viewer. See :ref:`Postprocessing` for more details:: 83 | 84 | mml view filename.dbx 85 | -------------------------------------------------------------------------------- /docs/source/material/builtin.rst: -------------------------------------------------------------------------------- 1 | 2 | .. _mat_builtin: 3 | 4 | Material Library 5 | ################ 6 | 7 | .. topic:: See Also 8 | 9 | * :ref:`Role of Material Model` 10 | * :ref:`defining_a_material` 11 | * :ref:`intro_conventions` 12 | 13 | Overview 14 | ======== 15 | 16 | The library of available material models in Matmodlab is not intended to 17 | provide comprehensive coverage of material behaviors. Rather, it provides 18 | enough coverage to 19 | 20 | * test Matmodlab capabilities; and 21 | * demonstrate the material model interface to be adopted by user materials. 22 | 23 | Available Materials 24 | ------------------- 25 | 26 | .. toctree:: 27 | :maxdepth: 1 28 | :titlesonly: 29 | 30 | elastic 31 | plastic 32 | transverse_elastic 33 | mooney_rivlin 34 | -------------------------------------------------------------------------------- /docs/source/material/comm.rst: -------------------------------------------------------------------------------- 1 | 2 | .. _comm_w_matmodlab: 3 | 4 | Writing Messages to the Console and/or Log File 5 | ############################################### 6 | 7 | Overview 8 | ======== 9 | 10 | Procedure *mml_comm* can be called from any user procedure to write messages 11 | to the console and log file. 12 | 13 | Interface 14 | ========= 15 | 16 | :: 17 | 18 | subroutine mml_comm(lop, string, intv, realv, charv) 19 | integer, intent(in) :: ierr 20 | character(120), intent(in) :: msg 21 | integer, intent(in) :: intv(*) 22 | real(8), intent(in) :: realv(*) 23 | character(8), intent(in) :: charv(*) 24 | 25 | ! coding 26 | 27 | end subroutine mml_comm 28 | 29 | Parameters 30 | ========== 31 | 32 | * *lop=1* writes an informational message to the log file 33 | 34 | *lop=-1* writes a warning message to the log file 35 | 36 | *lop=-2* writes an error message to the log file 37 | 38 | *lop=-3* writes an error message to the log file and stops the analysis 39 | 40 | * *string* is the informational string 41 | * *intv* 42 | * *realv* 43 | * *charv* 44 | 45 | 46 | .. topic:: Abaqus Users: 47 | 48 | Procedure *stdb_abqerr*, which has the same interface as *mml_comm*, is also 49 | compiled and linked to user defined materials. 50 | -------------------------------------------------------------------------------- /docs/source/material/elastic.rst: -------------------------------------------------------------------------------- 1 | 2 | Linear Elastic Material 3 | ####################### 4 | 5 | .. topic:: See Also 6 | 7 | . 8 | 9 | Overview 10 | ======== 11 | 12 | Usage 13 | ===== 14 | 15 | Description 16 | =========== 17 | -------------------------------------------------------------------------------- /docs/source/material/expansion.rst: -------------------------------------------------------------------------------- 1 | .. _expansion: 2 | 3 | Thermal Expansion 4 | ################# 5 | -------------------------------------------------------------------------------- /docs/source/material/fortran.rst: -------------------------------------------------------------------------------- 1 | 2 | .. _fortran_models: 3 | 4 | Fortran User Material Interface 5 | ############################### 6 | 7 | .. topic:: See Also 8 | 9 | * :ref:`Role of Material Model` 10 | * :ref:`defining_a_material` 11 | * :ref:`intro_conventions` 12 | * :ref:`comm_w_matmodlab` 13 | * :ref:`sdvini` 14 | 15 | Overview 16 | ======== 17 | 18 | Procedures ``UMAT``, ``UHYPER``, and ``UANISOHYPER_INV`` are called for user defined materials defining the mechanical, hyperelastic, or anisotropic hyperelastic material responses, respectively. Regardles of the interface procedure used, a fortran compiler must be available for Matmodlab to compile and link user procedures. 19 | 20 | .. _invoke_user_f: 21 | 22 | Invoking User Materials 23 | ======================= 24 | 25 | User defined materials are invoked using the same 26 | ``MaterialPointSimulator.Material`` factory method as other materials, but 27 | with additional required and optional arguments. 28 | 29 | Required MaterialPointSimulator.Material Agruments 30 | -------------------------------------------------- 31 | 32 | * The *model* argument must be set to one of ``USER``, ``UMAT``, ``UHYPER``, or ``UANISOHYPER_INV``. 33 | * The *parameters* must be a ndarray of model constants (specified in the 34 | order expected by the model). 35 | * *source_files*, a list of model source files. The source files must exist 36 | and be readable on the file system. 37 | 38 | Optional MaterialPointSimulator.Material Arguments 39 | -------------------------------------------------- 40 | 41 | * *param_names*, is a list of parameter names in the order expected by the model. 42 | If given, *parameters* must be given as dict of ``name:value`` pairs as for 43 | builtin models. 44 | * *depvar*, is the number of state dependent variables required 45 | for the model. Can also be specified as a list of state dependent variable 46 | names, specified in the order expected by the model. If given as a list, the 47 | number of state variables allocated is inferred from its length. Matmodlab 48 | allocates storage for the *depvar* state dependent variables and 49 | initializes their values to 0. 50 | * *response*, is a string specifying the type of model. Must be one of ``MECHANICAL`` (default), ``HYPERELASTIC``, or ``ANISOHYPER``. 51 | * *cmname*, is a string giving is the constitutive model name. 52 | * *ordering*, is a list of symbolic constants specifying the ordering of 53 | second-order symmetric tensors. The default ordering of symmetric 54 | second-order tensor components is ``[XX, YY, ZZ, XY, YZ, XZ]``. The *ordering* 55 | argument can be used to change the ordering to be consistent with the 56 | assumptions of the material model. 57 | 58 | Example 59 | ------- 60 | 61 | :: 62 | 63 | mps = MaterialPointSimulator('user_material') 64 | parameters = np.array([135e9, 53e9, 200e6]) 65 | mps.Material(USER, parameters) 66 | 67 | 68 | .. topic:: Abaqus Users: 69 | 70 | Setting the *model* name to one of ``UMAT``, ``UHYPER``, or 71 | ``UANISOHYPER_INV`` is equivalient to *model=*\ ``USER``, with 72 | *response=*\ ``MECHANICAL``, *response=*\ ``HYPERELASTIC``, or 73 | *response=*\ ``ANISOHYPER``, respectively, and *ordering=*\ ``[XX, YY, 74 | ZZ, XY, XZ, YZ]``. 75 | 76 | Compiling Fortran Sources 77 | ========================= 78 | 79 | Matmodlab compiles and links material model sources using ``f2py``. 80 | 81 | User Subroutine Interfaces 82 | ========================== 83 | 84 | .. toctree:: 85 | :maxdepth: 1 86 | 87 | umat 88 | uhyper 89 | uanisohyper_inv 90 | -------------------------------------------------------------------------------- /docs/source/material/index.rst: -------------------------------------------------------------------------------- 1 | .. _mat_index: 2 | 3 | Materials 4 | ######### 5 | 6 | .. toctree:: 7 | :maxdepth: 1 8 | :titlesonly: 9 | 10 | overview 11 | builtin 12 | user 13 | -------------------------------------------------------------------------------- /docs/source/material/mooney_rivlin.rst: -------------------------------------------------------------------------------- 1 | Mooney-Rivlin Hyperelastic Material 2 | ################################### 3 | 4 | .. topic:: See Also 5 | 6 | . 7 | 8 | 9 | Overview 10 | ======== 11 | 12 | Usage 13 | ===== 14 | 15 | Description 16 | =========== 17 | -------------------------------------------------------------------------------- /docs/source/material/overview.rst: -------------------------------------------------------------------------------- 1 | .. _mat_overview: 2 | 3 | Materials: Introduction 4 | ####################### 5 | 6 | .. topic:: See Also 7 | 8 | * :ref:`Role of Material Model` 9 | * :ref:`defining_a_material` 10 | * :ref:`intro_conventions` 11 | 12 | Overview 13 | ======== 14 | 15 | Material constitutive models provide the material's complete mechanical response. In other words, given the current mechanical state and an increment in deformation, the material model returns 16 | 17 | * the updated stress, 18 | * the material stiffness, and 19 | * the updated state dependent variable, if applicable. 20 | 21 | Matmodlab Material Library 22 | ========================== 23 | 24 | Matmodlab has a limited :ref:`library of material models `. 25 | 26 | User Developed Materials 27 | ======================== 28 | 29 | Matmodlab provides an API for :ref:`user developed materials `. 30 | 31 | 32 | Combining Material Responses 33 | ============================ 34 | 35 | Generally, constitutive models are treated as defining the entire mechanical 36 | response of a material and cannot be combined with other models. However, 37 | material models can be combined with the following behaviors: 38 | 39 | .. toctree:: 40 | :maxdepth: 1 41 | :titlesonly: 42 | 43 | expansion 44 | trs 45 | viscoelastic 46 | -------------------------------------------------------------------------------- /docs/source/material/plastic.rst: -------------------------------------------------------------------------------- 1 | 2 | Perfectly Plastic Material 3 | ########################## 4 | 5 | .. topic:: See Also 6 | 7 | . 8 | 9 | Overview 10 | ======== 11 | 12 | Usage 13 | ===== 14 | 15 | Description 16 | =========== 17 | -------------------------------------------------------------------------------- /docs/source/material/sdvini.rst: -------------------------------------------------------------------------------- 1 | 2 | .. _sdvini: 3 | 4 | User Defined Initial Conditions 5 | ############################### 6 | 7 | .. topic:: See Also 8 | 9 | * :ref:`mat_overview` 10 | 11 | Overview 12 | ======== 13 | 14 | Subroutine ``SDVINI`` allows users to set initial values to state dependent variables. If not provided by the user, Matmodlab will set state dependent to ``0``. 15 | 16 | Interface 17 | ========= 18 | 19 | .. code:: fortran 20 | 21 | subroutine sdvini(statev,coords,nstatv,ncrds,noel,npt,layer,kspt) 22 | integer, intent(in) :: nstatv, ncrds, noel, npt, layer, kspt 23 | real(kind=8), dimension(nstatv), intent(inout) :: statev 24 | real(kind=8), dimension(ncrds), intent(in) :: coords 25 | 26 | ! user code 27 | 28 | end subroutine sdvini 29 | -------------------------------------------------------------------------------- /docs/source/material/transverse_elastic.rst: -------------------------------------------------------------------------------- 1 | Transversely Isotropic Elastic Material 2 | ####################################### 3 | 4 | .. topic:: See Also 5 | 6 | . 7 | 8 | 9 | Overview 10 | ======== 11 | 12 | Usage 13 | ===== 14 | 15 | Description 16 | =========== 17 | -------------------------------------------------------------------------------- /docs/source/material/trs.rst: -------------------------------------------------------------------------------- 1 | .. _trs: 2 | 3 | Time Temperature Shift 4 | ###################### 5 | -------------------------------------------------------------------------------- /docs/source/material/uanisohyper_inv.rst: -------------------------------------------------------------------------------- 1 | User Model to Define a Material's Anisotropic Hyperelastic Response 2 | ################################################################### 3 | 4 | Overview 5 | ======== 6 | 7 | *uanisohyper_inv* is a material model for anisotropic hyperelastic materials. 8 | 9 | Interface 10 | ========= 11 | 12 | .. code:: fortran 13 | 14 | subroutine uanisohyper_inv(ainv, u, zeta, nfibers, ninv, & 15 | ui1, ui2, ui3, temp, noel, cmname, incmpflag, ihybflag, & 16 | nstatev, statev, nfieldv, fieldv, fieldvinc, & 17 | nprops, props) 18 | implicit none 19 | integer, parameter :: dp=selected_real_kind(14) 20 | real(kind=dp), parameter :: zero=0._dp, one=1._dp, two=2._dp, three=3._dp 21 | character*8, intent(in) :: cmname 22 | integer, intent(in) :: nprops, noel, nstatev, incmpflag, nfieldv 23 | real(kind=dp), intent(in) :: ainv(ninv), props(nprops), temp 24 | real(kind=dp), intent(inout) ui1(ninv) 25 | real(kind=dp), intent(inout) :: ui2(ninv*(ninv+1)/2), ui3(ninv*(ninv+1)/2), 26 | real(kind=dp), intent(inout) :: statev(nstatev) 27 | real(kind=dp), intent(inout) :: fieldv(nfieldv), fieldvinc(nfieldv) 28 | 29 | ! User coding 30 | 31 | end subroutine uanisohyper_inv 32 | -------------------------------------------------------------------------------- /docs/source/material/uhyper.rst: -------------------------------------------------------------------------------- 1 | User Model to Define a Material's Hyperelastic Response 2 | ####################################################### 3 | 4 | Overview 5 | ======== 6 | 7 | *uhyper* is a material model for hyperelastic materials. 8 | 9 | Interface 10 | ========= 11 | 12 | .. code:: fortran 13 | 14 | subroutine uhyper(i1b, i2b, jac, u, du, d2u, d3u, temp, noel, cmname, & 15 | incmpflag, nstatev, statev, nfieldv, fieldv, fieldvinc, & 16 | nprops, props) 17 | implicit none 18 | integer, parameter :: dp=selected_real_kind(14) 19 | real(kind=dp), parameter :: zero=0._dp, one=1._dp, two=2._dp, three=3._dp 20 | character*8, intent(in) :: cmname 21 | integer, intent(in) :: nprops, noel, nstatev, incmpflag, nfieldv 22 | real(kind=dp), intent(in) :: i1b, i2b, jac, props(nprops), temp 23 | real(kind=dp), intent(inout) :: u(2), du(3), d2u(6), d3u(6), statev(nstatev) 24 | real(kind=dp), intent(inout) :: fieldv(nfieldv), fieldvinc(nfieldv) 25 | 26 | ! User coding 27 | 28 | end subroutine uhyper 29 | -------------------------------------------------------------------------------- /docs/source/material/user.rst: -------------------------------------------------------------------------------- 1 | .. _user_mats: 2 | 3 | User Defined Materials 4 | ###################### 5 | 6 | .. topic:: See Also 7 | 8 | * :ref:`Role of Material Model` 9 | * :ref:`defining_a_material` 10 | * :ref:`intro_conventions` 11 | 12 | Overview 13 | ======== 14 | 15 | Matmodlab calls user defined materials at each deformation increment through all analysis steps. User defined materials are 16 | 17 | * written in fortran or python 18 | * called from python 19 | 20 | Material Model API 21 | ================== 22 | 23 | Two API's are provided for interfacing user developed materials with Matmodlab: 24 | 25 | * :ref:`Python API `. Material models are implemented as subclasses of MaterialModel, 26 | * :ref:`Fortran API `. Similar to commercial finite element codes, material models are implemented in Fortran subroutines that are compiled, linked, and called by Matmodlab. 27 | 28 | Auxiliary Subroutines 29 | ===================== 30 | 31 | Fortran subroutines can set initial conditions and interact with Matmodlab as described in the following sections: 32 | 33 | * :ref:`sdvini` 34 | * :ref:`comm_w_matmodlab` 35 | 36 | .. toctree:: 37 | :hidden: 38 | 39 | python 40 | fortran 41 | comm 42 | sdvini 43 | -------------------------------------------------------------------------------- /docs/source/material/viscoelastic.rst: -------------------------------------------------------------------------------- 1 | .. _viscoelastic: 2 | 3 | Viscoelasticity 4 | ############### 5 | -------------------------------------------------------------------------------- /docs/source/test/index.rst: -------------------------------------------------------------------------------- 1 | 2 | .. _test_index: 3 | 4 | Material Model Testing 5 | ###################### 6 | 7 | .. toctree:: 8 | :maxdepth: 1 9 | 10 | intro 11 | verification 12 | validation 13 | standard 14 | -------------------------------------------------------------------------------- /docs/source/test/intro.rst: -------------------------------------------------------------------------------- 1 | 2 | Material Model Testing: Introduction 3 | #################################### 4 | 5 | .. topic:: See Also 6 | 7 | * `http://pytest.org/latest/ `_ 8 | 9 | Overview 10 | ======== 11 | 12 | Regression testing is critical to the model development process. Only through thoroughly testing a model can confidence in model results be obtained. Testing of material models involves: 13 | 14 | * tests of individual program units (unit testing), 15 | * verfication of model response to controlled inputs, 16 | * validation of model response against data, and 17 | * regression testing when changes to the model are made. 18 | 19 | Regression tests in Matmodlab are special purpose problems that have a twofold purpose: 20 | 21 | * test the individual components and core capabilities of Matmodlab itself; 22 | * verification and validation (V&V) of material models. 23 | 24 | In the first role, problems are fast running and exercise specific features of 25 | Matmodlab in a unit-test type fashion. In the second, material models are 26 | exercised through specific paths with known, or expected outcomes. 27 | -------------------------------------------------------------------------------- /docs/source/test/validation.rst: -------------------------------------------------------------------------------- 1 | 2 | Validation 3 | ########## 4 | 5 | .. topic:: See Also 6 | 7 | . 8 | 9 | Overview 10 | ======== 11 | -------------------------------------------------------------------------------- /docs/source/test/verification.rst: -------------------------------------------------------------------------------- 1 | 2 | Verification 3 | ############ 4 | 5 | .. topic:: See Also 6 | 7 | . 8 | 9 | Overview 10 | ======== 11 | -------------------------------------------------------------------------------- /matmodlab2/.flake8: -------------------------------------------------------------------------------- 1 | # -*- conf -*- 2 | # flake8 settings for Nevada core files. 3 | # 4 | # E1: Indentation 5 | # - E129: visually indented line with same indent as next logical line 6 | # 7 | # E2: Whitespace 8 | # - E203: space before : 9 | # - E221: multiple spaces before operator 10 | # - E241: multiple spaces after ',' 11 | # - E272: multiple spaces before keyword 12 | # 13 | # E7: Statement 14 | # - E731: do not assign a lambda expression, use a def 15 | # 16 | # W5: Line break warning 17 | # - W503: line break before binary operator 18 | # - W504: line break after binary operator 19 | # 20 | # These are required to get the package.py files to test clean: 21 | # - F999: syntax error in doctest 22 | # 23 | # N8: PEP8-naming 24 | # - N801: class names should use CapWords convention 25 | # - N813: camelcase imported as lowercase 26 | # - N814: camelcase imported as constant 27 | # 28 | [flake8] 29 | ignore = E129,E221,E241,E272,E731,W503,W504,F999,N801,N813,N814,E203,W605,E741 30 | max-line-length = 88 31 | exclude = test,__init__.py,.cache,.git 32 | -------------------------------------------------------------------------------- /matmodlab2/__init__.py: -------------------------------------------------------------------------------- 1 | from .core.environ import environ 2 | from .core.material import Material 3 | from .core.database import read_exodb, read_npzdb, read_db 4 | from .core.matmodlab import MaterialPointSimulator 5 | from .materials import * 6 | from .umat import UMat, UHyper, VUMat 7 | from .core.logio import logger 8 | 9 | __all__ = [ 10 | "MaterialPointSimulator", 11 | "Material", 12 | "ElasticMaterial", 13 | "AnisotropicElasticMaterial", 14 | "DebuggerMaterial", 15 | "ElasticMaterialTotal", 16 | "PlasticMaterial", 17 | "VonMisesMaterial", 18 | "NonhardeningPlasticMaterial", 19 | "HardeningPlasticMaterial", 20 | "PolynomialHyperelasticMaterial", 21 | "MooneyRivlinMaterial", 22 | "NeoHookeMaterial", 23 | "TrescaMaterial", 24 | "UMat", 25 | "UHyper", 26 | "read_db", 27 | "read_exodb", 28 | "read_npzdb", 29 | "environ", 30 | "logger", 31 | ] 32 | -------------------------------------------------------------------------------- /matmodlab2/core/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matmodlab/matmodlab2/d2e6f5332d319752285c042e88e2baab506dc921/matmodlab2/core/__init__.py -------------------------------------------------------------------------------- /matmodlab2/core/environ.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | import logging 4 | import warnings 5 | from argparse import ArgumentParser 6 | 7 | __all__ = ["environ"] 8 | try: 9 | unicode = unicode 10 | except NameError: 11 | # 'unicode' is undefined, must be Python 3 12 | basestring = (str, bytes) 13 | 14 | 15 | def prepend_sys_path(dirname): 16 | if os.path.isdir(dirname): 17 | sys.path.insert(0, dirname) 18 | 19 | 20 | class SimulationEnvironment: 21 | def __init__(self): 22 | self.SQA = False 23 | self.verbosity = 1 24 | self.notebook = False 25 | self.parent_process = False 26 | self.loglevel = logging.WARNING 27 | self.use_python_linalg = False 28 | 29 | 30 | environ = SimulationEnvironment() 31 | 32 | 33 | def load_user_env(): 34 | user_env = {} 35 | filename = "mml_userenv.py" 36 | candidate_files = [] 37 | if os.getenv("MML_USERENV"): 38 | for item in os.getenv("MML_USERENV").split(os.pathsep): 39 | if os.path.isfile(item): 40 | candidate_files.append(item) 41 | elif os.path.isdir(item): 42 | if os.path.isfile(os.path.join(item, filename)): 43 | candidate_files.append(os.path.join(item, filename)) 44 | if os.path.isfile(os.path.join(os.getcwd(), filename)): 45 | candidate_files.append(os.path.join(os.getcwd(), filename)) 46 | 47 | for user_env_file in candidate_files: 48 | # User environment file found - load it! 49 | with open(user_env_file) as fh: 50 | code = compile(fh.read(), user_env_file, "exec") 51 | file_env = {} 52 | ns = { 53 | "my_filename": user_env_file, 54 | "os": os, 55 | "sys": sys, 56 | } 57 | exec(code, ns, file_env) 58 | for (key, val) in file_env.items(): 59 | if key.startswith("_"): 60 | continue 61 | if key == "prepend_to_sys_path": 62 | if isinstance(val, bool) and val: 63 | val = os.path.dirname(user_env_file) 64 | if isinstance(val, (str, basestring)): 65 | val = [val] 66 | for d in val: 67 | if os.path.isdir(d): 68 | sys.path.insert(0, d) 69 | else: 70 | msg = "prepend_to_sys_path variable " 71 | msg += "{0!r} is not a directory" 72 | warnings.warn(msg.format(d)) 73 | continue 74 | if key not in environ.__dict__: 75 | raise ValueError("Unknown user environment: {0}".format(key)) 76 | user_env[key] = val 77 | return user_env 78 | 79 | 80 | # Look for options in the user's environment file 81 | for (key, val) in load_user_env().items(): 82 | setattr(environ, key, val) 83 | 84 | try: 85 | # Check to see if we are running in a Jupyter notebook 86 | get_ipython() 87 | print("Setting up the Matmodlab notebook environment") 88 | environ.notebook = True 89 | except NameError: 90 | pass 91 | 92 | # Get some commands that can change the environment 93 | p = ArgumentParser(add_help=False) 94 | p.add_argument("--verbosity", default=None, type=int) 95 | args, extra = p.parse_known_args() 96 | if args.verbosity is not None: 97 | v = min(max(args.verbosity, 0), 3) 98 | level = {0: logging.ERROR, 1: logging.WARNING, 2: logging.INFO, 3: logging.DEBUG}[v] 99 | environ.loglevel = level 100 | sys.argv[:] = [sys.argv[0]] + extra 101 | -------------------------------------------------------------------------------- /matmodlab2/core/logio.py: -------------------------------------------------------------------------------- 1 | import logging 2 | from ..version import VERSION 3 | from .environ import environ 4 | 5 | SPLASH = r""" 6 | _____ ______ _____ ______ ___ _______ 7 | |\ _ \ _ \|\ _ \ _ \|\ \ / ___ \ 8 | \ \ \\\__\ \ \ \ \\\__\ \ \ \ \ /__/|_/ /| 9 | \ \ \\|__| \ \ \ \\|__| \ \ \ \ |__|// / / 10 | \ \ \ \ \ \ \ \ \ \ \ \ \____ / /_/__ 11 | \ \__\ \ \__\ \__\ \ \__\ \_______\\________\ 12 | \|__| \|__|\|__| \|__|\|_______|\|_______| 13 | Material Model Laboratory2 v {0} 14 | 15 | """.format( 16 | ".".join("{0}".format(i) for i in VERSION) 17 | ) 18 | 19 | # Monkey path the logging stream handler emit function 20 | logging.basicConfig(format="%(message)s") 21 | 22 | 23 | def emit(self, record): 24 | """Monkey-patch the logging StreamHandler emit function. Allows omiting 25 | trailing newline when not wanted""" 26 | if hasattr(self, "baseFilename"): 27 | fs = "%s\n" 28 | else: 29 | fs = "%s" if getattr(record, "continued", False) else "%s\n" 30 | self.stream.write(fs % self.format(record)) 31 | self.flush() 32 | 33 | 34 | logging.StreamHandler.emit = emit 35 | 36 | 37 | def get_logger(name, verbosity=None): 38 | """Set up the logger""" 39 | 40 | if environ.notebook: 41 | level = logging.WARNING 42 | 43 | elif environ.parent_process: 44 | level = logging.CRITICAL 45 | 46 | elif verbosity is not None: 47 | environ.verbosity = verbosity 48 | level = environ.loglevel 49 | else: 50 | level = environ.loglevel 51 | 52 | logger = logging.getLogger(name) 53 | logger.propagate = False 54 | for handler in logger.handlers: 55 | logger.removeHandler(handler) 56 | logger.setLevel(logging.NOTSET) 57 | 58 | ch = logging.StreamHandler() 59 | ch.setLevel(level) 60 | logger.addHandler(ch) 61 | 62 | return logger 63 | 64 | 65 | def add_filehandler(logger, filename): 66 | for handler in logger.handlers: 67 | if hasattr(handler, "baseFilename"): 68 | logger.removeHandler(handler) 69 | fh = logging.FileHandler(filename, mode="w") 70 | fh.setLevel(logging.DEBUG) 71 | logger.addHandler(fh) 72 | 73 | 74 | def splash(logger): 75 | splashed = getattr(logger, "splashed", False) 76 | if not splashed: 77 | logger.info(SPLASH) 78 | logger.splashed = True 79 | 80 | 81 | class FortranError(Exception): 82 | pass 83 | 84 | 85 | def StopFortran(message): 86 | raise FortranError(message) 87 | 88 | 89 | logger = get_logger("matmodlab") 90 | -------------------------------------------------------------------------------- /matmodlab2/core/misc.py: -------------------------------------------------------------------------------- 1 | """Misc. functions""" 2 | import os 3 | from contextlib import contextmanager 4 | 5 | 6 | def is_listlike(item): 7 | """Is item list like?""" 8 | try: 9 | [x for x in item] 10 | return not is_stringlike(item) 11 | except TypeError: 12 | return False 13 | 14 | 15 | def is_stringlike(item): 16 | """Is item string like?""" 17 | try: 18 | item + "string" 19 | return True 20 | except TypeError: 21 | return False 22 | 23 | 24 | def is_scalarlike(item): 25 | """Is item scalar like?""" 26 | try: 27 | float(item) 28 | return True 29 | except TypeError: 30 | return False 31 | 32 | 33 | # Copied from six.py: https://github.com/benjaminp/six 34 | def add_metaclass(metaclass): 35 | """Class decorator for creating a class with a metaclass.""" 36 | 37 | def wrapper(cls): 38 | orig_vars = cls.__dict__.copy() 39 | slots = orig_vars.get("__slots__") 40 | if slots is not None: 41 | if isinstance(slots, str): 42 | slots = [slots] 43 | for slots_var in slots: 44 | orig_vars.pop(slots_var) 45 | orig_vars.pop("__dict__", None) 46 | orig_vars.pop("__weakref__", None) 47 | return metaclass(cls.__name__, cls.__bases__, orig_vars) 48 | 49 | return wrapper 50 | 51 | 52 | @contextmanager 53 | def working_dir(dirname): 54 | cwd = os.getcwd() 55 | os.chdir(dirname) 56 | yield dirname 57 | os.chdir(cwd) 58 | -------------------------------------------------------------------------------- /matmodlab2/ext_helpers/__init__.py: -------------------------------------------------------------------------------- 1 | from .build_ext import build_extension_module, build_mml_matrix_functions 2 | from .build_ext import build_umat, build_vumat, build_uhyper 3 | -------------------------------------------------------------------------------- /matmodlab2/ext_helpers/matrix_funcs.pyf: -------------------------------------------------------------------------------- 1 | ! -*- f90 -*- 2 | ! Note: the context of this file is case sensitive. 3 | 4 | python module _matfuncs_sq3 ! in 5 | interface ! in :_matfuncs_sq3 6 | module linalg ! in :_matfuncs_sq3:matrix_funcs.f90 7 | function expm(a) ! in :_matfuncs_sq3:matrix_funcs.f90:linalg 8 | real(kind=8) dimension(3,3),intent(in) :: a 9 | real(kind=8) dimension(3,3) :: expm 10 | end function expm 11 | function powm(a,m) ! in :_matfuncs_sq3:matrix_funcs.f90:linalg 12 | real(kind=8) dimension(3,3),intent(in) :: a 13 | real(kind=8) intent(in) :: m 14 | real(kind=8) dimension(3,3) :: powm 15 | end function powm 16 | function sqrtm(a) ! in :_matfuncs_sq3:matrix_funcs.f90:linalg 17 | real(kind=8) dimension(3,3),intent(in) :: a 18 | real(kind=8) dimension(3,3) :: sqrtm 19 | end function sqrtm 20 | function logm(a) ! in :_matfuncs_sq3:matrix_funcs.f90:linalg 21 | real(kind=8) dimension(3,3),intent(in) :: a 22 | real(kind=8) dimension(3,3) :: logm 23 | end function logm 24 | function isdiag(a) ! in :_matfuncs_sq3:matrix_funcs.f90:linalg 25 | real(kind=8) dimension(3,3),intent(in) :: a 26 | logical :: isdiag 27 | end function isdiag 28 | function eye(n) ! in :_matfuncs_sq3:matrix_funcs.f90:linalg 29 | integer intent(in) :: n 30 | real(kind=8) dimension(n,n) :: eye 31 | end function eye 32 | function det(a) ! in :_matfuncs_sq3:matrix_funcs.f90:linalg 33 | real(kind=8) dimension(3,3),intent(in) :: a 34 | real(kind=8) :: det 35 | end function det 36 | function inv(a) ! in :_matfuncs_sq3:matrix_funcs.f90:linalg 37 | real(kind=8) dimension(3,3),intent(in) :: a 38 | real(kind=8) dimension(3,3) :: inv 39 | end function inv 40 | subroutine polar_decomp(f,r,u,i) ! in :_matfuncs_sq3:matrix_funcs.f90:linalg 41 | real(kind=8) dimension(3,3),intent(in) :: f 42 | real(kind=8) dimension(3,3),intent(out) :: r 43 | real(kind=8) dimension(3,3),intent(out) :: u 44 | integer intent(out) :: i 45 | end subroutine polar_decomp 46 | end module linalg 47 | end interface 48 | end python module _matfuncs_sq3 49 | 50 | ! This file was auto-generated with f2py (version:2). 51 | ! See http://cens.ioc.ee/projects/f2py2e/ 52 | -------------------------------------------------------------------------------- /matmodlab2/fitting/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matmodlab/matmodlab2/d2e6f5332d319752285c042e88e2baab506dc921/matmodlab2/fitting/__init__.py -------------------------------------------------------------------------------- /matmodlab2/materials/__init__.py: -------------------------------------------------------------------------------- 1 | from .debugger import DebuggerMaterial 2 | from .elastic import ElasticMaterial 3 | from .elastic2 import AnisotropicElasticMaterial 4 | from .elastic3 import ElasticMaterialTotal 5 | from .plastic import PlasticMaterial 6 | from .plastic2 import NonhardeningPlasticMaterial 7 | from .plastic3 import HardeningPlasticMaterial 8 | from .vonmises import VonMisesMaterial 9 | from .polyhyper import PolynomialHyperelasticMaterial 10 | from .mooney_rivlin import MooneyRivlinMaterial 11 | from .tresca import TrescaMaterial 12 | from .neohooke import NeoHookeMaterial 13 | 14 | 15 | __all__ = [ 16 | "DebuggerMaterial", 17 | "ElasticMaterial", 18 | "AnisotropicElasticMaterial", 19 | "ElasticMaterialTotal", 20 | "PlasticMaterial", 21 | "NonhardeningPlasticMaterial", 22 | "HardeningPlasticMaterial", 23 | "VonMisesMaterial", 24 | "PolynomialHyperelasticMaterial", 25 | "MooneyRivlinMaterial", 26 | "NeoHookeMaterial", 27 | "TrescaMaterial", 28 | ] 29 | -------------------------------------------------------------------------------- /matmodlab2/materials/addon.py: -------------------------------------------------------------------------------- 1 | class AddonModel(object): 2 | def sdvini(self, statev): 3 | return statev 4 | 5 | def eval( 6 | self, 7 | kappa, 8 | time, 9 | dtime, 10 | temp, 11 | dtemp, 12 | F0, 13 | F, 14 | strain, 15 | d, 16 | stress, 17 | statev, 18 | initial_temp=0.0, 19 | **kwds 20 | ): 21 | # All arrays must be modified in place 22 | return None 23 | 24 | def posteval( 25 | self, 26 | kappa, 27 | time, 28 | dtime, 29 | temp, 30 | dtemp, 31 | F0, 32 | F, 33 | strain, 34 | d, 35 | stress, 36 | statev, 37 | initial_temp=0.0, 38 | **kwds 39 | ): 40 | # All arrays must be modified in place 41 | return None 42 | -------------------------------------------------------------------------------- /matmodlab2/materials/debugger.py: -------------------------------------------------------------------------------- 1 | from ..core.material import Material 2 | 3 | 4 | class DebuggerMaterial(Material): 5 | """A dummy material that saves all standard inputs as state variables 6 | 7 | Parameters 8 | ---------- 9 | 10 | *** takes no paramters *** 11 | 12 | """ 13 | 14 | name = "debugger" 15 | 16 | def __init__(self, **parameters): 17 | def symm_names(base): 18 | return [base + "." + _ for _ in "XX YY ZZ XY XZ YZ".split()] 19 | 20 | def full_names(base): 21 | return [base + "." + _ for _ in "XX XY XZ YX YY YZ ZX ZY ZZ".split()] 22 | 23 | self.sdv_names = ( 24 | ["TIME", "DTIME", "TEMP", "DTEMP"] 25 | + full_names("F0") 26 | + full_names("F1") 27 | + symm_names("STRAIN") 28 | + symm_names("D") 29 | + symm_names("STRESS") 30 | ) 31 | self.sdv_names = ["SDV_" + _ for _ in self.sdv_names] 32 | self.num_sdv = len(self.sdv_names) 33 | 34 | def eval(self, time, dtime, temp, dtemp, F0, F1, strain, d, stress, statev, **kwds): 35 | def stick_it(what, where, expected_length): 36 | if len(what) != expected_length: 37 | raise Exception( 38 | "Unexpected length: {0} {1}".format(len(what), expected_length) 39 | ) 40 | statev[where : where + len(what)] = what 41 | 42 | statev[self.sdv_names.index("SDV_TIME")] = time 43 | statev[self.sdv_names.index("SDV_DTIME")] = dtime 44 | statev[self.sdv_names.index("SDV_TEMP")] = temp 45 | statev[self.sdv_names.index("SDV_DTEMP")] = dtemp 46 | statev[self.sdv_names.index("SDV_DTEMP")] = dtemp 47 | stick_it(F0.flatten(), self.sdv_names.index("SDV_F0.XX"), 9) 48 | stick_it(F1.flatten(), self.sdv_names.index("SDV_F1.XX"), 9) 49 | stick_it(strain, self.sdv_names.index("SDV_STRAIN.XX"), 6) 50 | stick_it(d, self.sdv_names.index("SDV_D.XX"), 6) 51 | stick_it(stress, self.sdv_names.index("SDV_STRESS.XX"), 6) 52 | 53 | return stress, statev, None 54 | -------------------------------------------------------------------------------- /matmodlab2/materials/effective_stress.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | from .addon import AddonModel 4 | 5 | 6 | class EffectiveStressModel(AddonModel): 7 | """Effective stress model""" 8 | 9 | name = "__effstress__" 10 | 11 | def __init__(self, porepres): 12 | self.num_sdv = 1 13 | self.sdv_names = ["POREPRES"] 14 | self.porepres = np.asarray(porepres) 15 | if len(self.porepres.shape) != 2: 16 | raise ValueError( 17 | "pore_pres must be a 2 dimensional array with " 18 | "the first column being time and the second the " 19 | "associated pore pressure." 20 | ) 21 | 22 | def get_porepres_at_time(self, time): 23 | return np.interp( 24 | 1, 25 | self.porepres[0, :], 26 | self.porepres[1, :], 27 | left=self.porepres[1, 0], 28 | right=self.porepres[1, -1], 29 | ) 30 | 31 | def sdvini(self, statev): 32 | statev = np.array([self.get_porepres_at_time(0.0)]) 33 | return statev 34 | 35 | def eval( 36 | self, kappa, time, dtime, temp, dtemp, F0, F, strain, d, stress, statev, **kwds 37 | ): 38 | """Evaluate the effective stress model""" 39 | porepres = self.get_porepres_at_time(time + dtime / 2.0) 40 | stress[[0, 1, 2]] -= porepres 41 | statev[0] = porepres 42 | return None 43 | 44 | def posteval( 45 | self, kappa, time, dtime, temp, dtemp, F0, F, strain, d, stress, statev, **kwds 46 | ): 47 | porepres = self.get_porepres_at_time(time + dtime / 2.0) 48 | stress[[0, 1, 2]] += porepres 49 | statev[0] = porepres 50 | return None 51 | -------------------------------------------------------------------------------- /matmodlab2/materials/elastic.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | from ..core.material import Material 4 | 5 | 6 | class ElasticMaterial(Material): 7 | """Implements linear elasticity 8 | 9 | Parameters 10 | ---------- 11 | **kwds : dict 12 | Material parameters. Recognized parameters are the Young's 13 | modules `E` and Poisson's ratio `Nu` 14 | 15 | """ 16 | 17 | name = "pyelastic" 18 | 19 | def __init__(self, **parameters): 20 | E = parameters["E"] 21 | assert E > 0.0 22 | Nu = parameters["Nu"] 23 | assert -1.0 < Nu < 0.5 24 | self.G = E / 2.0 / (1.0 + Nu) 25 | self.K = E / 3.0 / (1.0 - 2.0 * Nu) 26 | 27 | def eval(self, time, dtime, temp, dtemp, F0, F, strain, d, stress, statev, **kwds): 28 | K3 = 3.0 * self.K 29 | G2 = 2.0 * self.G 30 | Lam = (K3 - G2) / 3.0 31 | # elastic stiffness 32 | ddsdde = np.zeros((6, 6)) 33 | ddsdde[np.ix_(range(3), range(3))] = Lam 34 | ddsdde[range(3), range(3)] += G2 35 | ddsdde[range(3, 6), range(3, 6)] = self.G 36 | # stress update 37 | stress = stress + np.dot(ddsdde, d * dtime) 38 | return stress, statev, ddsdde 39 | -------------------------------------------------------------------------------- /matmodlab2/materials/elastic2.py: -------------------------------------------------------------------------------- 1 | from numpy import dot, zeros, triu 2 | from numpy.linalg import cholesky, LinAlgError 3 | from ..core.logio import logger 4 | from ..core.material import Material 5 | 6 | 7 | class AnisotropicElasticMaterial(Material): 8 | name = "elastic2" 9 | 10 | def __init__(self, **parameters): 11 | """Set up the Elastic material""" 12 | # Define mapping from 21 elastic parameters to location 13 | # in parameter array 14 | param_names = [ 15 | "C{0}{1}".format(i + 1, j + 1) for i in range(6) for j in range(i, 6) 16 | ] 17 | 18 | # Create the parameter array and check inputs 19 | self.params = zeros(len(param_names)) 20 | for (i, name) in enumerate(param_names): 21 | self.params[i] = parameters.pop(name, 0.0) 22 | if parameters: 23 | unused = ", ".join(list(parameters.keys())) 24 | logger.warning("The following parameters were " "unused {0}".format(unused)) 25 | 26 | # check if C is positive definite 27 | C = self.form_stiff(self.params) 28 | try: 29 | cholesky(C) 30 | except LinAlgError: 31 | raise ValueError("elastic stiffness not positive definite") 32 | 33 | @staticmethod 34 | def form_stiff(cij): 35 | C = zeros((6, 6)) 36 | i = 0 37 | for k in range(6): 38 | j = 6 - k 39 | C[k, k:] = cij[i : i + j] 40 | i += j 41 | return C + triu(C, k=1).T 42 | 43 | def eval(self, time, dtime, temp, dtemp, F0, F, stran, d, stress, statev, **kwargs): 44 | """Compute updated stress given strain increment""" 45 | 46 | # elastic stiffness 47 | ddsdde = self.form_stiff(self.params) 48 | 49 | # stress update 50 | stress = dot(ddsdde, stran) 51 | 52 | return stress, statev, ddsdde 53 | -------------------------------------------------------------------------------- /matmodlab2/materials/elastic3.py: -------------------------------------------------------------------------------- 1 | from numpy import zeros, ix_ 2 | from ..core.logio import logger 3 | from ..core.material import Material 4 | from ..core.deformation import strain_from_stretch 5 | from ..core.tensor import polar_decomp, isotropic_part, deviatoric_part, array_rep 6 | 7 | 8 | class ElasticMaterialTotal(Material): 9 | name = "elastic3" 10 | 11 | def __init__(self, **parameters): 12 | """Set up the Elastic material""" 13 | 14 | # Check inputs 15 | E = parameters.get("E", 0.0) 16 | Nu = parameters.get("Nu", 0.0) 17 | k = parameters.get("k", 0.0) 18 | 19 | errors = 0 20 | if E <= 0.0: 21 | errors += 1 22 | logger.error("Young's modulus E must be positive") 23 | if Nu > 0.5: 24 | errors += 1 25 | logger.error("Poisson's ratio > .5") 26 | if Nu < -1.0: 27 | errors += 1 28 | logger.error("Poisson's ratio < -1.") 29 | if Nu < 0.0: 30 | logger.warning("#---- WARNING: negative Poisson's ratio") 31 | if errors: 32 | raise ValueError("stopping due to previous errors") 33 | self.params = {"E": E, "Nu": Nu, "k": k} 34 | 35 | def eval(self, time, dtime, temp, dtemp, F0, F, stran, d, stress, statev, **kwargs): 36 | """Compute updated stress given strain increment""" 37 | 38 | # elastic properties 39 | k = self.params["k"] 40 | E = self.params["E"] 41 | Nu = self.params["Nu"] 42 | 43 | # Get the bulk, shear, and Lame constants 44 | K = E / 3.0 / (1.0 - 2.0 * Nu) 45 | G = E / 2.0 / (1.0 + Nu) 46 | 47 | K3 = 3.0 * K 48 | G2 = 2.0 * G 49 | Lam = (K3 - G2) / 3.0 50 | 51 | # elastic stiffness 52 | ddsdde = zeros((6, 6)) 53 | ddsdde[ix_(range(3), range(3))] = Lam 54 | ddsdde[range(3), range(3)] += G2 55 | ddsdde[range(3, 6), range(3, 6)] = G 56 | 57 | R, U = polar_decomp(F.reshape(3, 3)) 58 | e = strain_from_stretch(array_rep(U, (6,)), k) 59 | 60 | # stress update 61 | stress = K3 * isotropic_part(e) + G2 * deviatoric_part(e) 62 | 63 | return stress, statev, ddsdde 64 | -------------------------------------------------------------------------------- /matmodlab2/materials/expansion.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | from ..core.misc import is_scalarlike, is_listlike 4 | from ..core.deformation import defgrad_from_strain 5 | from ..core.database import COMPONENT_SEP 6 | from ..core.tensor import SYMMETRIC_COMPONENTS, TENSOR_COMPONENTS 7 | from .addon import AddonModel 8 | 9 | 10 | class ExpansionModel(AddonModel): 11 | """Thermal expansion model""" 12 | 13 | name = "__expansion__" 14 | 15 | def __init__(self, expansion): 16 | """Format the thermal expansion term""" 17 | self.num_sdv = 15 18 | self.sdv_names = ["EM" + COMPONENT_SEP + x for x in SYMMETRIC_COMPONENTS] 19 | self.sdv_names.extend(["FM" + COMPONENT_SEP + x for x in TENSOR_COMPONENTS]) 20 | if is_scalarlike(expansion): 21 | expansion = [expansion] * 3 22 | if not is_listlike(expansion): 23 | raise ValueError("Expected expansion to be array_like") 24 | if len(expansion) == 3: 25 | expansion = [x for x in expansion] + [0, 0, 0] 26 | if len(expansion) != 6: 27 | raise ValueError("Expected len(expansion) to be 3 or 6") 28 | self.data = np.array([float(x) for x in expansion]) 29 | 30 | def sdvini(self, statev): 31 | statev = np.append( 32 | np.zeros(6), np.array([1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0]) 33 | ) 34 | return statev 35 | 36 | def eval( 37 | self, 38 | kappa, 39 | time, 40 | dtime, 41 | temp, 42 | dtemp, 43 | F0, 44 | F, 45 | strain, 46 | d, 47 | stress, 48 | statev, 49 | initial_temp=0.0, 50 | **kwds 51 | ): 52 | """Evaluate the thermal expansion model 53 | 54 | F0, F, strain, d are updated in place 55 | """ 56 | assert len(statev) == 15 57 | 58 | # Determine mechanical strain 59 | thermal_strain = (temp + dtemp - initial_temp) * self.data 60 | strain -= thermal_strain 61 | 62 | # Updated deformation gradient 63 | F0[:9] = np.array(statev[6:15]) 64 | F[:9] = defgrad_from_strain(strain, kappa, flatten=1) 65 | 66 | thermal_d = self.data * dtemp / dtime 67 | d -= thermal_d 68 | 69 | # Save the mechanical state to the statev 70 | statev[: self.num_sdv] = np.append(strain, F) 71 | 72 | return None 73 | 74 | 75 | class EffectiveStressModel(AddonModel): 76 | """Effective stress model""" 77 | 78 | def __init__(self, porepres): 79 | """Format the thermal expansion term""" 80 | self.num_sdv = 1 81 | self.sdv_names = ["POREPRES"] 82 | self.porepres = np.asarray(porepres) 83 | if len(self.porepres.shape) != 2: 84 | raise ValueError( 85 | "pore_pres must be a 2 dimensional array with " 86 | "the first column being time and the second the " 87 | "associated pore pressure." 88 | ) 89 | 90 | def get_porepres_at_time(self, time): 91 | return np.interp( 92 | 1, 93 | self.porepres[0, :], 94 | self.porepres[1, :], 95 | left=self.porepres[1, 0], 96 | right=self.porepres[1, -1], 97 | ) 98 | 99 | def sdvini(self, statev): 100 | statev = np.array([self.get_porepres_at_time(0.0)]) 101 | return statev 102 | 103 | def eval( 104 | self, kappa, time, dtime, temp, dtemp, F0, F, strain, d, stress, statev, **kwds 105 | ): 106 | """Evaluate the effective stress model""" 107 | porepres = self.get_porepres_at_time(time + dtime / 2.0) 108 | stress[[0, 1, 2]] -= porepres 109 | statev[0] = porepres 110 | return None 111 | 112 | def posteval( 113 | self, kappa, time, dtime, temp, dtemp, F0, F, strain, d, stress, statev, **kwds 114 | ): 115 | porepres = self.get_porepres_at_time(time + dtime / 2.0) 116 | stress[[0, 1, 2]] += porepres 117 | statev[0] = porepres 118 | return None 119 | -------------------------------------------------------------------------------- /matmodlab2/materials/mooney_rivlin.py: -------------------------------------------------------------------------------- 1 | from numpy import dot, trace 2 | 3 | from ..core.logio import logger 4 | from ..core.material import Material 5 | from ..core.tensor import array_rep, det, I6 6 | 7 | 8 | class MooneyRivlinMaterial(Material): 9 | name = "mooney-rivlin" 10 | 11 | def __init__(self, **parameters): 12 | """Set up the Mooney Rivlin material""" 13 | param_names = ["C10", "C01", "D1"] 14 | self.params = {} 15 | for param_name in param_names: 16 | value = parameters.pop(param_name, 0.0) 17 | self.params[param_name] = value 18 | if parameters: 19 | unused = ", ".join(parameters.keys()) 20 | logger.warning("Unused parameters: {0}".format(unused)) 21 | 22 | # Check inputs 23 | C10 = self.params["C10"] 24 | C01 = self.params["C01"] 25 | D1 = self.params["D1"] 26 | 27 | errors = 0 28 | if D1 <= 0.0: 29 | errors += 1 30 | logger.error("D1 must be > 0") 31 | 32 | G = 2.0 * (C10 + C01) 33 | if G <= 0: 34 | errors += 1 35 | logger.error("2 (C10 + C01) > 0") 36 | 37 | if errors: 38 | raise ValueError("stopping due to previous errors") 39 | 40 | def eval(self, time, dtime, temp, dtemp, F0, F, stran, d, stress, statev, **kwargs): 41 | """Compute updated stress given the updated deformation""" 42 | 43 | # elastic properties 44 | C10 = self.params["C10"] 45 | C01 = self.params["C01"] 46 | D1 = self.params["D1"] 47 | 48 | # elastic stiffness 49 | ddsdde = None 50 | 51 | # Reshape the deformation gradient 52 | F = F.reshape(3, 3) 53 | Jac = det(F) 54 | 55 | # left Cauchy deformation 56 | B = dot(F, F.T) 57 | Bsq = dot(B, B) 58 | 59 | incompressible = D1 > 1e4 * (C10 + C01) 60 | if incompressible: 61 | # enforce incompressibility 62 | Jac = 1 63 | 64 | # Invariants of B 65 | I1 = trace(B) 66 | I2 = 0.5 * (I1**2 - trace(Bsq)) 67 | 68 | # Invariants of Cbar 69 | scale = sign(abs(Jac) ** (1.0 / 3.0), Jac) 70 | I1B = I1 / (scale**2) 71 | I2B = I2 / (scale**4) 72 | 73 | # convert symmetric tensors to arrays 74 | BBsq = array_rep(Bsq, (6,)) / scale**4 75 | BB = array_rep(B, (6,)) / scale**2 76 | 77 | if not incompressible: 78 | p = -2.0 / D1 * (Jac - 1.0) 79 | else: 80 | p = 0.0 81 | pb = p + 2.0 / 3.0 / Jac * (C10 * I1B + 2.0 * C01 * I2B) 82 | stress = 2.0 / Jac * ((C10 + C01 * I1B) * BB - C01 * BBsq) - pb * I6 83 | 84 | return stress, statev, ddsdde 85 | 86 | 87 | def sign(x, y): 88 | return x if y > 0.0 else -x 89 | -------------------------------------------------------------------------------- /matmodlab2/materials/neohooke.py: -------------------------------------------------------------------------------- 1 | from numpy import zeros, sum 2 | 3 | from ..core.logio import logger 4 | from ..core.material import Material 5 | from ..core.tensor import det, I6 6 | 7 | 8 | class NeoHookeMaterial(Material): 9 | name = "neo-hooke" 10 | 11 | def __init__(self, **parameters): 12 | """Set up the Neo Hooke material""" 13 | 14 | E = parameters.pop("E", 0.0) 15 | assert E > 0 16 | Nu = parameters.pop("Nu", 0.0) 17 | 18 | C10 = E / (4.0 * (1.0 + Nu)) 19 | D1 = 6.0 * (1.0 - 2.0 * Nu) / E 20 | self.params = {"C10": C10, "D1": D1} 21 | 22 | errors = 0 23 | if D1 <= 0.0: 24 | errors += 1 25 | logger.error("D1 must be > 0") 26 | 27 | G = 2.0 * C10 28 | if G <= 0: 29 | errors += 1 30 | logger.error("2 C10 > 0") 31 | 32 | if errors: 33 | raise ValueError("stopping due to previous errors") 34 | 35 | def eval(self, time, dtime, temp, dtemp, F0, F, stran, d, stress, statev, **kwargs): 36 | """Compute updated stress given the updated deformation""" 37 | 38 | # elastic properties 39 | C10 = self.params["C10"] 40 | D1 = self.params["D1"] 41 | 42 | # elastic stiffness 43 | ddsdde = zeros((6, 6)) 44 | 45 | # Reshape the deformation gradient 46 | F = F.reshape(3, 3) 47 | Jac = det(F) 48 | 49 | scale = Jac ** (-1.0 / 3.0) 50 | fb = scale * F 51 | 52 | # deviatoric left Cauchy-Green deformation tensor 53 | bb = zeros(6) 54 | bb[0] = fb[0, 0] * fb[0, 0] + fb[0, 1] * fb[0, 1] + fb[0, 2] * fb[0, 2] 55 | bb[1] = fb[1, 0] * fb[1, 0] + fb[1, 1] * fb[1, 1] + fb[1, 2] * fb[1, 2] 56 | bb[2] = fb[2, 0] * fb[2, 0] + fb[2, 1] * fb[2, 1] + fb[2, 2] * fb[2, 2] 57 | bb[3] = fb[1, 0] * fb[0, 0] + fb[1, 1] * fb[0, 1] + fb[1, 2] * fb[0, 2] 58 | bb[4] = fb[2, 0] * fb[1, 0] + fb[2, 1] * fb[1, 1] + fb[2, 2] * fb[1, 2] 59 | bb[5] = fb[2, 0] * fb[0, 0] + fb[2, 1] * fb[0, 1] + fb[2, 2] * fb[0, 2] 60 | 61 | trbbar = sum(bb[:3]) / 3.0 62 | eg = 2.0 * C10 / Jac 63 | ek = 2.0 / D1 * (2.0 * Jac - 1.0) 64 | pr = 2.0 / D1 * (Jac - 1.0) 65 | 66 | # cauchy stress 67 | stress = eg * (bb - trbbar * I6) + pr * I6 68 | 69 | # spatial stiffness 70 | eg23 = eg * 2.0 / 3.0 71 | ddsdde[0, 0] = eg23 * (bb[0] + trbbar) + ek 72 | ddsdde[0, 1] = -eg23 * (bb[0] + bb[1] - trbbar) + ek 73 | ddsdde[0, 2] = -eg23 * (bb[0] + bb[2] - trbbar) + ek 74 | ddsdde[0, 3] = eg23 * bb[3] / 2.0 75 | ddsdde[0, 4] = -eg23 * bb[4] 76 | ddsdde[0, 5] = eg23 * bb[5] / 2.0 77 | 78 | ddsdde[1, 1] = eg23 * (bb[1] + trbbar) + ek 79 | ddsdde[1, 2] = -eg23 * (bb[1] + bb[2] - trbbar) + ek 80 | ddsdde[1, 3] = eg23 * bb[3] / 2.0 81 | ddsdde[1, 4] = eg23 * bb[4] / 2.0 82 | ddsdde[1, 5] = -eg23 * bb[5] 83 | 84 | ddsdde[2, 2] = eg23 * (bb[2] + trbbar) + ek 85 | ddsdde[2, 3] = -eg23 * bb[3] 86 | ddsdde[2, 4] = eg23 * bb[4] / 2.0 87 | ddsdde[2, 5] = eg23 * bb[5] / 2.0 88 | 89 | ddsdde[3, 3] = eg * (bb[0] + bb[1]) / 2.0 90 | ddsdde[3, 4] = eg * bb[5] / 2.0 91 | ddsdde[3, 5] = eg * bb[4] / 2.0 92 | 93 | ddsdde[4, 4] = eg * (bb[0] + bb[2]) / 2.0 94 | ddsdde[4, 5] = eg * bb[3] / 2.0 95 | 96 | ddsdde[5, 5] = eg * (bb[1] + bb[2]) / 2.0 97 | 98 | for i in range(6): 99 | for j in range(i + 1, 6): 100 | ddsdde[i, j] = ddsdde[j, i] 101 | 102 | return stress, statev, ddsdde 103 | -------------------------------------------------------------------------------- /matmodlab2/optimize/__init__.py: -------------------------------------------------------------------------------- 1 | from .optimizer import Optimizer, OptimizeVariable 2 | -------------------------------------------------------------------------------- /matmodlab2/optimize/numerix.py: -------------------------------------------------------------------------------- 1 | from ..core.numerix import * # noqa 2 | -------------------------------------------------------------------------------- /matmodlab2/umat/__init__.py: -------------------------------------------------------------------------------- 1 | from .umat import UMat 2 | from .vumat import VUMat 3 | from .uhyper import UHyper 4 | -------------------------------------------------------------------------------- /matmodlab2/umat/aba_param.inc: -------------------------------------------------------------------------------- 1 | C -*- fortran -*- 2 | implicit real*8(a-h,o-z) 3 | parameter (nprecd=2) 4 | -------------------------------------------------------------------------------- /matmodlab2/umat/aba_sdvini.f90: -------------------------------------------------------------------------------- 1 | subroutine sdvini(statev,coords,nstatv,ncrds,noel,npt,layer,kspt) 2 | integer, intent(in) :: nstatv, ncrds, noel, npt, layer, kspt 3 | real(kind=8), dimension(nstatv), intent(inout) :: statev 4 | real(kind=8), dimension(ncrds), intent(in) :: coords 5 | integer :: n 6 | real(kind=8) :: a 7 | n=nstatv; n=ncrds; n=noel; n=npt; n=layer; n=kspt 8 | a = coords(1) 9 | statev(:) = 0.e+00_8 10 | end subroutine sdvini 11 | -------------------------------------------------------------------------------- /matmodlab2/umat/aba_utils.f90: -------------------------------------------------------------------------------- 1 | subroutine rotsig(S, R, Sprime, lstr, ndi, nshr) 2 | implicit none 3 | integer, intent(in) :: lstr, ndi, nshr 4 | real(8), intent(in) :: S(6), R(3,3) 5 | real(8), intent(out) :: Sprime(6) 6 | real(8) :: work(2,3,3), c 7 | 8 | ! NOTE: this subroutine is set up to work only with 3D rotations 9 | if (ndi /= 3 .or. nshr /= 3) then 10 | print*, 'rotsig incompatible with tensors' 11 | call xit 12 | end if 13 | 14 | c = 1. 15 | if (lstr == 2) c = 2. 16 | 17 | ! convert to matrix 18 | call to_matrix_3d(S, work(1,:,:), 1./c) 19 | 20 | ! perform the rotation 21 | work(2,:,:) = matmul(R, matmul(work(1,:,:), transpose(R))) 22 | 23 | ! convert to tensor 24 | call to_tensor_3d(work(2,:,:), Sprime, c) 25 | 26 | return 27 | 28 | end subroutine rotsig 29 | 30 | subroutine to_tensor_3d(x, t, c) 31 | implicit none 32 | real(8), intent(in) :: x(3,3) 33 | real(8), intent(out) :: t(6) 34 | real(8), intent(in) :: c 35 | t(1) = x(1,1); t(4) = x(1,2)*c; t(5) = x(1,3)*c 36 | t(2) = x(2,2); t(6) = x(2,3)*c 37 | t(3) = x(3,3) 38 | return 39 | end subroutine to_tensor_3d 40 | 41 | subroutine to_matrix_3d(x, m, c) 42 | implicit none 43 | real(8), intent(in) :: x(6) 44 | real(8), intent(out) :: m(3,3) 45 | real(8), intent(in) :: c 46 | m(1,1) = x(1); m(1,2) = x(4)*c; m(1,3) = x(5)*c 47 | m(2,2) = x(2); m(2,3) = x(6)*c 48 | m(3,3) = x(3) 49 | m(2,1) = m(1,2) 50 | m(3,1) = m(1,3) 51 | m(3,2) = m(2,3) 52 | return 53 | end subroutine to_matrix_3d 54 | 55 | subroutine stdb_abqerr(ierr, msg, intv, realv, charv) 56 | implicit none 57 | integer, intent(in) :: ierr 58 | character(120), intent(in) :: msg 59 | integer, intent(in) :: intv(*) 60 | real(8), intent(in) :: realv(*) 61 | character(8), intent(in) :: charv(*) 62 | call mml_comm(ierr, msg, intv, realv, charv) 63 | end subroutine stdb_abqerr 64 | 65 | 66 | subroutine xplb_abqerr(ierr, msg, intv, realv, charv) 67 | implicit none 68 | integer, intent(in) :: ierr 69 | character(120), intent(in) :: msg 70 | integer, intent(in) :: intv(*) 71 | real(8), intent(in) :: realv(*) 72 | character(8), intent(in) :: charv(*) 73 | call mml_comm(ierr, msg, intv, realv, charv) 74 | end subroutine xplb_abqerr 75 | 76 | 77 | subroutine xit 78 | implicit none 79 | character*120 :: msg 80 | external log_error 81 | msg = 'STOPPING DUE TO FORTRAN PROCEDURE ERROR' 82 | call log_error(msg) 83 | end subroutine xit 84 | 85 | subroutine sprind(S, PS, AN, LSTR, NDI, NSHR) 86 | implicit none 87 | real(8), intent(in) :: S(6) 88 | real(8), intent(out) :: PS(3), AN(3,3) 89 | integer, intent(in) :: LSTR, NDI, NSHR 90 | integer, parameter :: N=3, LWORK=3*N-1 91 | real(8) :: WORK(LWORK), C 92 | integer :: INFO 93 | ! NOTE: this subroutine is set up to work only with 3D tensors 94 | if (NDI /= 3 .or. NSHR /= 3) then 95 | print *, 'wrong number of direct and/or shear components to sprind' 96 | call xit 97 | end if 98 | ! convert to matrix 99 | C = 1. 100 | if (LSTR == 2) C = 2. 101 | call to_matrix_3d(S, AN, 1./C) 102 | ! eigenvalues/vectors of S 103 | call DSYEV("V", "L", 3, AN, 3, PS, WORK, LWORK, INFO) 104 | end subroutine sprind 105 | 106 | subroutine sprinc(S, PS, LSTR, NDI, NSHR) 107 | implicit none 108 | real(8), intent(in) :: S(6) 109 | real(8), intent(out) :: PS(3) 110 | integer, intent(in) :: LSTR, NDI, NSHR 111 | real(8) :: AN(3,3) 112 | call sprind(S, PS, AN, LSTR, NDI, NSHR) 113 | end subroutine sprinc 114 | -------------------------------------------------------------------------------- /matmodlab2/umat/umats/__init__.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | dir = os.path.dirname(os.path.realpath(__file__)) 4 | neohooke_umat = os.path.join(dir, "umat_neohooke.f90") 5 | neohooke_uhyper = os.path.join(dir, "uhyper_neohooke.f90") 6 | thermoelastic_umat = os.path.join(dir, "umat_thermoelastic.f90") 7 | -------------------------------------------------------------------------------- /matmodlab2/umat/umats/uhyper_neohooke.f90: -------------------------------------------------------------------------------- 1 | SUBROUTINE UHYPER(I1B, I2B, JAC, U, DU, D2U, D3U, TEMP, NOEL, CMNAME, & 2 | INCMPFLAG, NSTATEV, STATEV, NFIELDV, FIELDV, FIELDVINC, & 3 | NPROPS, PROPS) 4 | ! ----------------------------------------------------------------------- ! 5 | ! HYPERELASTIC COMPRESSIBLE NEO-HOOKEAN MATERIAL 6 | ! ----------------------------------------------------------------------- ! 7 | ! CANNOT BE USED FOR PLANE STRESS 8 | ! PROPS(1) - C10 9 | ! PROPS(2) - D1 10 | ! ----------------------------------------------------------------------- ! 11 | IMPLICIT NONE 12 | INTEGER, PARAMETER :: DP=SELECTED_REAL_KIND(14) 13 | REAL(KIND=DP), PARAMETER :: ZERO=0._DP, ONE=1._DP, TWO=2._DP, THREE=3._DP 14 | CHARACTER*8, INTENT(IN) :: CMNAME 15 | INTEGER, INTENT(IN) :: NPROPS, NOEL, NSTATEV, INCMPFLAG, NFIELDV 16 | REAL(KIND=DP), INTENT(IN) :: I1B, I2B, JAC, PROPS(NPROPS), TEMP 17 | REAL(KIND=DP), INTENT(INOUT) :: U(2), DU(3), D2U(6), D3U(6), STATEV(NSTATEV) 18 | REAL(KIND=DP), INTENT(INOUT) :: FIELDV(NFIELDV), FIELDVINC(NFIELDV) 19 | REAL(KIND=DP) :: C10, D1, U_VOL, U_DEV 20 | ! -------------------------------------------------------------- UHYPER --- ! 21 | 22 | C10 = PROPS(1) 23 | D1 = PROPS(2) 24 | 25 | ! ENERGY: U 26 | U_VOL = ONE / D1 * (JAC - ONE) ** 2 27 | U_DEV = C10 * (I1B - THREE) 28 | U(1) = U_VOL + U_DEV 29 | U(2) = U_DEV 30 | 31 | ! FIRST DERIVATIVE OF ENERGY: DU 32 | DU(1) = C10 ! DU/DI1B 33 | DU(2) = ZERO ! DU/DI2B 34 | DU(3) = TWO / D1 * (JAC - ONE) ! DU/DJ 35 | 36 | ! SECOND DERIVATIVE OF ENERGY: D2U 37 | D2U(1) = ZERO ! D(DU/DI1B)/DI1B 38 | D2U(2) = ZERO ! D(DU/DI2B)/DI2B 39 | D2U(3) = TWO / D1 ! D(DU/DJ)/DJ 40 | D2U(4) = ZERO ! D(DU/DI1B)/DI2B 41 | D2U(5) = ZERO ! D(DU/DI1B)/DJ 42 | D2U(6) = ZERO ! D(DU/DI2B)/DJ 43 | 44 | ! THIRD DERIVATIVE OF ENERGY: D3U 45 | D3U(1) = ZERO ! D(D(DU/DI1B)/DI1B)/DJ 46 | D3U(2) = ZERO ! D(D(DU/DI2B)/DI2B)/DJ 47 | D3U(3) = ZERO ! D(D(DU/DI1B)/DI2B)/DJ 48 | D3U(4) = ZERO ! D(D(DU/DI1B)/DJ)/DJ 49 | D3U(5) = ZERO ! D(D(DU/DI1B)/DJ)/DJ 50 | D3U(6) = ZERO ! D(D(DU/DJ)/DJ)/DJ 51 | RETURN 52 | END SUBROUTINE UHYPER 53 | -------------------------------------------------------------------------------- /matmodlab2/umat/umats/umat_stub.f90: -------------------------------------------------------------------------------- 1 | SUBROUTINE UMAT(STRESS, STATEV, DDSDDE, SSE, SPD, SCD, RPL, & 2 | DDSDDT, DRPLDE, DRPLDT, STRAN, DSTRAN, TIME, DTIME, TEMP, DTEMP, & 3 | PREDEF, DPRED, CMNAME, NDI, NSHR, NTENS, NSTATV, PROPS, NPROPS, & 4 | COORDS, DROT, PNEWDT, CELENT, DFGRD0, DFGRD1, NOEL, NPT, LAYER, & 5 | KSPT, KSTEP, KINC) 6 | 7 | IMPLICIT NONE 8 | REAL(8), PARAMETER :: ZERO=0.E+00_8, ONE=1.E+00_8, TWO=2.E+00_8 9 | REAL(8), PARAMETER :: THREE=3.E+00_8, SIX=6.E+00_8 10 | CHARACTER*8, INTENT(IN) :: CMNAME 11 | INTEGER, INTENT(IN) :: NDI, NSHR, NTENS, NSTATV, NPROPS 12 | INTEGER, INTENT(IN) :: NOEL, NPT, LAYER, KSPT, KSTEP, KINC 13 | REAL(8), INTENT(IN) :: SSE, SPD, SCD, RPL, DRPLDT, TIME, DTIME, TEMP, DTEMP 14 | REAL(8), INTENT(IN) :: PNEWDT, CELENT 15 | REAL(8), INTENT(INOUT) :: STRESS(NTENS), STATEV(NSTATV), DDSDDE(NTENS, NTENS) 16 | REAL(8), INTENT(INOUT) :: DDSDDT(NTENS), DRPLDE(NTENS) 17 | REAL(8), INTENT(IN) :: STRAN(NTENS), DSTRAN(NTENS) 18 | REAL(8), INTENT(IN) :: PREDEF(1), DPRED(1), PROPS(NPROPS), COORDS(3) 19 | REAL(8), INTENT(IN) :: DROT(3, 3), DFGRD0(3, 3), DFGRD1(3, 3) 20 | 21 | RETURN 22 | END SUBROUTINE UMAT 23 | -------------------------------------------------------------------------------- /matmodlab2/umat/vumat.pyf: -------------------------------------------------------------------------------- 1 | ! -*- f90 -*- 2 | ! Note: the context of this file is case sensitive. 3 | python module mml__user__routines 4 | interface mml_user_interface 5 | subroutine log_message(message) 6 | intent(callback) log_message 7 | character*(*) :: message 8 | end subroutine log_message 9 | subroutine log_warning(message) 10 | intent(callback) log_warning 11 | character*(*) :: message 12 | end subroutine log_warning 13 | subroutine log_error(message) 14 | intent(callback) log_error 15 | character*(*) :: message 16 | end subroutine log_error 17 | end interface mml_user_interface 18 | end python module mml__user__routines 19 | 20 | python module _vumat ! in 21 | interface ! in : 22 | subroutine vumat(nblock,ndir,nshr,nstatev,nfieldv,nprops,lanneal,stepTime,totalTime,dt,cmname,coordMp,charLength,props,density,strainInc,relSpinInc,tempOld,stretchOld,defgradOld,fieldOld,stressOld,stateOld,enerInternOld,enerInelasOld,tempNew,stretchNew,defgradNew,fieldNew,stressNew,stateNew,enerInternNew,enerInelasNew) 23 | use mml__user__routines 24 | intent(callback) log_message 25 | external log_message 26 | intent(callback) log_warning 27 | external log_warning 28 | intent(callback) log_error 29 | external log_error 30 | integer intent(in) :: nblock 31 | integer intent(in) :: ndir 32 | integer intent(in) :: nshr 33 | integer intent(in) :: nstatev 34 | integer intent(in) :: nfieldv 35 | integer intent(in) :: nprops 36 | integer intent(in) :: lanneal 37 | real(kind=8) intent(in) :: stepTime 38 | real(kind=8) intent(in) :: totalTime 39 | real(kind=8) intent(in) :: dt 40 | character*8 intent(in) :: cmname 41 | real(kind=8) dimension(nblock,3),intent(in) :: coordMp 42 | real(kind=8) dimension(nblock),intent(in) :: charLength 43 | real(kind=8) dimension(nprops),intent(in) :: props 44 | real(kind=8) dimension(nblock),intent(in) :: density 45 | real(kind=8) dimension(nblock,ndir+nshr),intent(in) :: strainInc 46 | real(kind=8) dimension(nblock,nshr),intent(in) :: relSpinInc, 47 | real(kind=8) dimension(nblock),intent(in) :: tempOld 48 | real(kind=8) dimension(nblock,ndir+nshr),intent(in) :: stretchOld 49 | real(kind=8) dimension(nblock,ndir+nshr+nshr),intent(in) :: defgradOld 50 | real(kind=8) dimension(nblock,nfieldv),intent(in) :: fieldOld 51 | real(kind=8) dimension(nblock,ndir+nshr),intent(in) :: stressOld 52 | real(kind=8) dimension(nblock,nstatev),intent(in) :: stateOld 53 | real(kind=8) dimension(nblock),intent(in) :: enerInternOld 54 | real(kind=8) dimension(nblock),intent(in) :: enerInelasOld 55 | real(kind=8) dimension(nblock),intent(in) :: tempNew 56 | real(kind=8) dimension(nblock,ndir+nshr),intent(in) :: stretchNew 57 | real(kind=8) dimension(nblock,ndir+nshr+nshr),intent(in) :: defgradNew 58 | real(kind=8) dimension(nblock,nfieldv),intent(in) :: fieldNew 59 | real(kind=8) dimension(nblock,ndir+nshr),intent(out) :: stressNew 60 | real(kind=8) dimension(nblock,nstatev),intent(out) :: stateNew 61 | real(kind=8) dimension(nblock),intent(out) :: enerInternNew 62 | real(kind=8) dimension(nblock),intent(out) :: enerInelasNew 63 | end subroutine vumat 64 | end interface 65 | end python module _vumat 66 | 67 | ! This file was auto-generated with f2py (version:2). 68 | ! See http://cens.ioc.ee/projects/f2py2e/ 69 | -------------------------------------------------------------------------------- /matmodlab2/version.py: -------------------------------------------------------------------------------- 1 | VERSION = (1, 0, 0) 2 | -------------------------------------------------------------------------------- /notebooks/.gitignore: -------------------------------------------------------------------------------- 1 | umat_elastic.f90 -------------------------------------------------------------------------------- /notebooks/Introduction.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Introduction to Matmodlab\n", 8 | "\n", 9 | "The Material Model Laboratory (Matmodlab) is a suite of tools designed for the development of material models intended for deployment in finite element codes. Matmodlab can be thought of as a tool to drive a single material point of a finite element simulation through specific user defined deformation paths. This permits exercising material models in ways not possible in finite element calculations, desgning verification and validation tests of the material response, among others." 10 | ] 11 | }, 12 | { 13 | "cell_type": "markdown", 14 | "metadata": {}, 15 | "source": [ 16 | "\n", 17 | "## Contents\n", 18 | "\n", 19 | "### Introduction\n", 20 | "\n", 21 | "1. [Getting Started](GettingStarted.ipynb)\n", 22 | "2. [User Defined Material Models](UserMaterials.ipynb)\n", 23 | "\n", 24 | "### Material Models\n", 25 | "\n", 26 | "1. [Linear Elasticity](LinearElastic.ipynb)\n", 27 | "2. [Mooney Rivlin Hyperelasticity](MooneyRivlin.ipynb)\n", 28 | "3. [Polynomial Hyperelastic Model](PolynomialHyperelastic.ipynb)\n", 29 | "4. [Nonhardening $J_2$ Plasticity](NonhardeningJ2Plasticity.ipynb)\n", 30 | "5. [Hardening $J_2$ Plasticity](HardeningJ2Plasticity.ipynb)\n", 31 | "6. [Writing UMATs](Writing Umats.ipynb)\n", 32 | "\n", 33 | "### Parameter Fitting\n", 34 | "\n", 35 | "1. [Fitting Hyperelastic Models](Hyperfit.ipynb)\n", 36 | "2. [Parameter Fitting by Optimization](ParameterOptimization.ipynb)\n", 37 | "3. [Poroplastic Fitting](PoroplasticFitting.ipynb)\n", 38 | "4. [Master Curve Generation](MasterCurve.ipynb)" 39 | ] 40 | }, 41 | { 42 | "cell_type": "code", 43 | "execution_count": null, 44 | "metadata": { 45 | "collapsed": true 46 | }, 47 | "outputs": [], 48 | "source": [] 49 | } 50 | ], 51 | "metadata": { 52 | "anaconda-cloud": {}, 53 | "kernelspec": { 54 | "display_name": "Python 3", 55 | "language": "python", 56 | "name": "python3" 57 | }, 58 | "language_info": { 59 | "codemirror_mode": { 60 | "name": "ipython", 61 | "version": 3 62 | }, 63 | "file_extension": ".py", 64 | "mimetype": "text/x-python", 65 | "name": "python", 66 | "nbconvert_exporter": "python", 67 | "pygments_lexer": "ipython3", 68 | "version": "3.6.0" 69 | } 70 | }, 71 | "nbformat": 4, 72 | "nbformat_minor": 0 73 | } 74 | -------------------------------------------------------------------------------- /notebooks/Treloar_hyperelastic_data.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matmodlab/matmodlab2/d2e6f5332d319752285c042e88e2baab506dc921/notebooks/Treloar_hyperelastic_data.xlsx -------------------------------------------------------------------------------- /notebooks/aldat.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matmodlab/matmodlab2/d2e6f5332d319752285c042e88e2baab506dc921/notebooks/aldat.xls -------------------------------------------------------------------------------- /notebooks/mcgen.csv: -------------------------------------------------------------------------------- 1 | # Each line shall be as 2 | # Temperature, Time, Value 3 | 0.0000, 0.0100, 4857.0000 4 | 0.0000, 0.0316, 3444.0000 5 | 0.0000, 0.1000, 2489.0000 6 | 0.0000, 0.3162, 1815.0000 7 | 0.0000, 1.0000, 1375.0000 8 | 0.0000, 3.1623, 1067.0000 9 | 0.0000, 10.0000, 852.0000 10 | 0.0000, 16.5959, 774.0000 11 | 20.0000, 0.0100, 3292.0000 12 | 20.0000, 0.0316, 2353.0000 13 | 20.0000, 0.1000, 1730.0000 14 | 20.0000, 0.3162, 1284.0000 15 | 20.0000, 1.0000, 970.0000 16 | 20.0000, 3.1623, 746.0000 17 | 20.0000, 10.0000, 577.0000 18 | 20.0000, 16.5959, 505.0000 19 | 40.0000, 0.0100, 2159.0000 20 | 40.0000, 0.0316, 1592.0000 21 | 40.0000, 0.1000, 1179.0000 22 | 40.0000, 0.3162, 920.0000 23 | 40.0000, 1.0000, 733.0000 24 | 40.0000, 3.1623, 585.0000 25 | 40.0000, 10.0000, 484.0000 26 | 40.0000, 16.5959, 449.0000 27 | 75.0000, 0.0100, 1287.0000 28 | 75.0000, 0.0316, 985.0000 29 | 75.0000, 0.1000, 767.0000 30 | 75.0000, 0.3162, 616.0000 31 | 75.0000, 1.0000, 498.0000 32 | 75.0000, 3.1623, 410.0000 33 | 75.0000, 10.0000, 333.0000 34 | 75.0000, 16.5959, 311.0000 35 | 100.0000, 0.0100, 1123.0000 36 | 100.0000, 0.0316, 881.0000 37 | 100.0000, 0.1000, 708.0000 38 | 100.0000, 0.3162, 573.0000 39 | 100.0000, 1.0000, 471.0000 40 | 100.0000, 3.1623, 399.0000 41 | 100.0000, 10.0000, 341.0000 42 | 100.0000, 16.5959, 316.0000 43 | 130.0000, 0.0100, 810.0000 44 | 130.0000, 0.0316, 646.0000 45 | 130.0000, 0.1000, 523.0000 46 | 130.0000, 0.3162, 432.0000 47 | 130.0000, 1.0000, 364.0000 48 | 130.0000, 3.1623, 313.0000 49 | 130.0000, 10.0000, 271.0000 50 | 130.0000, 16.5959, 254.0000 51 | -------------------------------------------------------------------------------- /notebooks/plotting_helpers.py: -------------------------------------------------------------------------------- 1 | from matmodlab2.core.environ import environ 2 | 3 | def create_figure(**kwargs): 4 | bokeh = kwargs.pop('bokeh', False) 5 | if bokeh: 6 | from bokeh.plotting import figure 7 | TOOLS = ('resize,crosshair,pan,wheel_zoom,box_zoom,' 8 | 'reset,box_select,lasso_select') 9 | TOOLS = 'resize,pan,wheel_zoom,box_zoom,reset,save' 10 | return figure(tools=TOOLS, **kwargs) 11 | else: 12 | from matplotlib import pylab 13 | return pylab.subplot() 14 | -------------------------------------------------------------------------------- /notebooks/porodata.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matmodlab/matmodlab2/d2e6f5332d319752285c042e88e2baab506dc921/notebooks/porodata.xlsx -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | numpy 2 | scipy 3 | pytest 4 | pandas 5 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup 2 | 3 | setup(name='matmodlab2', 4 | version='1.0.0', 5 | description='A material point simulator for testing and evaluating material models', 6 | long_description=('The material model laboratory (Matmodlab2) ' 7 | 'is a material point simulator developed as ' 8 | 'a tool for developing and analyzing material ' 9 | 'models for use in larger finite element codes.'), 10 | classifiers=[ # Classifier list: https://pypi.python.org/pypi?:action=list_classifiers 11 | "Development Status :: 3 - Alpha", 12 | "Environment :: Console", 13 | "Intended Audience :: Developers", 14 | "Intended Audience :: Science/Research", 15 | "License :: OSI Approved :: BSD License", 16 | "Natural Language :: English", 17 | "Operating System :: OS Independent", 18 | "Programming Language :: Python :: 3", 19 | "Topic :: Scientific/Engineering", 20 | "Topic :: Scientific/Engineering :: Physics", 21 | "Topic :: Software Development :: Testing", 22 | ], 23 | url='https://github.com/matmodlab/matmodlab2', 24 | author='Tim Fuller and Scot Swan', 25 | author_email='timothy.fuller@utah.edu', 26 | license='BSD-3-Clause', 27 | packages=['matmodlab2', 28 | 'matmodlab2.core', 29 | 'matmodlab2.ext_helpers', 30 | 'matmodlab2.fitting', 31 | 'matmodlab2.materials', 32 | 'matmodlab2.optimize', 33 | 'matmodlab2.umat', 34 | ], 35 | package_dir={ 36 | 'matmodlab2':'matmodlab2', 37 | }, 38 | package_data={ 39 | 'matmodlab2':[ 40 | 'ext_helpers/*', 41 | 'umat/*', 42 | 'umat/umats/*', 43 | ], 44 | }, 45 | install_requires=['numpy', 'scipy'], 46 | zip_safe=False) 47 | -------------------------------------------------------------------------------- /tests/.gitignore: -------------------------------------------------------------------------------- 1 | data/supreme_linear_elastic.base_dat 2 | *.csv -------------------------------------------------------------------------------- /tests/data/mcgen.csv: -------------------------------------------------------------------------------- 1 | # Each line shall be as 2 | # Temperature, Time, Value 3 | 0.0000, 0.0100, 4857.0000 4 | 0.0000, 0.0316, 3444.0000 5 | 0.0000, 0.1000, 2489.0000 6 | 0.0000, 0.3162, 1815.0000 7 | 0.0000, 1.0000, 1375.0000 8 | 0.0000, 3.1623, 1067.0000 9 | 0.0000, 10.0000, 852.0000 10 | 0.0000, 16.5959, 774.0000 11 | 20.0000, 0.0100, 3292.0000 12 | 20.0000, 0.0316, 2353.0000 13 | 20.0000, 0.1000, 1730.0000 14 | 20.0000, 0.3162, 1284.0000 15 | 20.0000, 1.0000, 970.0000 16 | 20.0000, 3.1623, 746.0000 17 | 20.0000, 10.0000, 577.0000 18 | 20.0000, 16.5959, 505.0000 19 | 40.0000, 0.0100, 2159.0000 20 | 40.0000, 0.0316, 1592.0000 21 | 40.0000, 0.1000, 1179.0000 22 | 40.0000, 0.3162, 920.0000 23 | 40.0000, 1.0000, 733.0000 24 | 40.0000, 3.1623, 585.0000 25 | 40.0000, 10.0000, 484.0000 26 | 40.0000, 16.5959, 449.0000 27 | 75.0000, 0.0100, 1287.0000 28 | 75.0000, 0.0316, 985.0000 29 | 75.0000, 0.1000, 767.0000 30 | 75.0000, 0.3162, 616.0000 31 | 75.0000, 1.0000, 498.0000 32 | 75.0000, 3.1623, 410.0000 33 | 75.0000, 10.0000, 333.0000 34 | 75.0000, 16.5959, 311.0000 35 | 100.0000, 0.0100, 1123.0000 36 | 100.0000, 0.0316, 881.0000 37 | 100.0000, 0.1000, 708.0000 38 | 100.0000, 0.3162, 573.0000 39 | 100.0000, 1.0000, 471.0000 40 | 100.0000, 3.1623, 399.0000 41 | 100.0000, 10.0000, 341.0000 42 | 100.0000, 16.5959, 316.0000 43 | 130.0000, 0.0100, 810.0000 44 | 130.0000, 0.0316, 646.0000 45 | 130.0000, 0.1000, 523.0000 46 | 130.0000, 0.3162, 432.0000 47 | 130.0000, 1.0000, 364.0000 48 | 130.0000, 3.1623, 313.0000 49 | 130.0000, 10.0000, 271.0000 50 | 130.0000, 16.5959, 254.0000 -------------------------------------------------------------------------------- /tests/fortran/conftest.py: -------------------------------------------------------------------------------- 1 | import os 2 | import glob 3 | import pytest 4 | import matmodlab2 5 | from matmodlab2.ext_helpers import build_mml_matrix_functions 6 | 7 | 8 | def pytest_configure(): 9 | # Setup code, executed ahead of first test 10 | # Remove all fortran files 11 | matmodlab2_dir = os.path.dirname(matmodlab2.__file__) 12 | for d in ("core", "ext_helpers"): 13 | dirname = os.path.join(matmodlab2_dir, d) 14 | assert os.path.isdir(dirname) 15 | for filename in glob.glob(os.path.join(dirname, "*.o")): 16 | os.remove(filename) 17 | for filename in glob.glob(os.path.join(dirname, "*.so")): 18 | os.remove(filename) 19 | returncode = build_mml_matrix_functions() 20 | assert returncode == 0, "matfuncs not built" 21 | -------------------------------------------------------------------------------- /tests/fortran/test_core_matfuncs.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | This file contains tests for matfuncs.py 4 | """ 5 | import pytest 6 | import numpy as np 7 | from testing_utils import * 8 | 9 | try: 10 | import matmodlab2.core._matfuncs_sq3 11 | 12 | la = matmodlab2.core._matfuncs_sq3.linalg 13 | except ImportError: 14 | la = None 15 | pytestmark = pytest.mark.skipif(la is None, reason="Fortran linalg not imported") 16 | 17 | 18 | def test_inv(): 19 | """Inverse of A""" 20 | A = random_matrix() 21 | Ai = la.inv(A) 22 | assert np.allclose(np.dot(Ai, A), np.eye(3)) 23 | 24 | 25 | def test_expm(): 26 | """Compute the matrix exponential of a 3x3 matrix""" 27 | x, y, z = 1.0, 2.0, 3.0 28 | A = np.array([[x, 0, 0], [0, y, 0], [0, 0, z]]) 29 | exp_A = np.array([[np.exp(x), 0, 0], [0, np.exp(y), 0], [0, 0, np.exp(z)]]) 30 | assert np.allclose(la.expm(A), exp_A) 31 | 32 | 33 | def test_logm(): 34 | """Compute the matrix logarithm of a 3x3 matrix""" 35 | x, y, z = 1.0, 2.0, 3.0 36 | A = np.array([[x, 0, 0], [0, y, 0], [0, 0, z]]) 37 | log_A = np.array([[np.log(x), 0, 0], [0, np.log(y), 0], [0, 0, np.log(z)]]) 38 | assert np.allclose(log_A, la.logm(A)) 39 | 40 | 41 | def test_expm_logm_consistency(): 42 | A = random_symmetric_positive_definite_matrix() 43 | B = la.expm(A) 44 | assert np.allclose(la.logm(B), A) 45 | 46 | 47 | def test_logm_expm_consistency(): 48 | A = random_symmetric_positive_definite_matrix() 49 | A = A.reshape(3, 3) 50 | B = la.logm(A) 51 | assert np.allclose(la.expm(B), A) 52 | 53 | 54 | def test_powm(): 55 | """Compute the matrix power of a 3x3 matrix""" 56 | m = 1.2 57 | x, y, z = 1.0, 2.0, 3.0 58 | A = np.array([[x, 0, 0], [0, y, 0], [0, 0, z]]) 59 | pow_A = np.array([[x**m, 0, 0], [0, y**m, 0], [0, 0, z**m]]) 60 | assert np.allclose(la.powm(A, m), pow_A) 61 | A = random_symmetric_positive_definite_matrix() 62 | B = la.powm(A, 0.5) 63 | assert np.allclose(np.dot(B, B), A) 64 | A = random_symmetric_positive_definite_matrix() 65 | B = la.powm(A, 2) 66 | assert np.allclose(np.dot(A, A), B) 67 | 68 | 69 | def test_sqrtm(): 70 | """Compute the square root of a 3x3 matrix""" 71 | x, y, z = np.random.rand(3) 72 | A = np.array([[x, 0, 0], [0, y, 0], [0, 0, z]]) 73 | sqrt_A = np.array([[np.sqrt(x), 0, 0], [0, np.sqrt(y), 0], [0, 0, np.sqrt(z)]]) 74 | assert np.allclose(la.sqrtm(A), sqrt_A) 75 | A = random_symmetric_positive_definite_matrix() 76 | B = la.sqrtm(A) 77 | assert np.allclose(np.dot(B, B), A) 78 | 79 | 80 | if __name__ == "__main__": 81 | test_import() 82 | -------------------------------------------------------------------------------- /tests/fortran/test_ext_helpers_build_ext.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | import glob 4 | import pytest 5 | import testing_utils as tu 6 | from subprocess import Popen, STDOUT 7 | from matmodlab2.ext_helpers import build_umat 8 | from matmodlab2.umat.umats import neohooke_umat 9 | from matmodlab2.core.misc import working_dir 10 | 11 | # pytestmark = pytest.mark.skipif('linux' in sys.platform.lower(), 12 | # reason='Does not pass on linux') 13 | 14 | # matmodlab.ext_helpers.build_ext defines the actual function that builds the 15 | # extension modules. It adds some Matmodlab specific fortran I/O files (and 16 | # some Abaqus specific files for umats) to the list of source files and then 17 | # distutils to compile the thing. Instead of using this function directly, the 18 | # command line tool build-fext is used. This is done since distutils can only 19 | # be initialized once and we want to run several different tests, each building 20 | # a different library. 21 | 22 | try: 23 | fc = os.getenv("FC", "gfortran") 24 | with open(os.devnull, "a") as fh: 25 | p = Popen([fc, "-v"], stdout=fh, stderr=STDOUT) 26 | p.wait() 27 | has_fortran = p.returncode == 0 28 | except: 29 | has_fortran = False 30 | 31 | 32 | @pytest.mark.skipif(not has_fortran, reason="Fortran compiler not found") 33 | def test_build_umat_ext(tmpdir): 34 | """Test building a umat""" 35 | 36 | with working_dir(tmpdir): 37 | returncode = build_umat(neohooke_umat, cwd=".") 38 | if not len(glob.glob("_umat*.so")): 39 | assert 0, f"umat not found in {tmpdir}" 40 | if "_umat" in sys.modules: 41 | # Remove so it can be loaded below 42 | del sys.modules["_umat"] 43 | try: 44 | import _umat 45 | except ImportError: 46 | raise Exception("_umat not imported") 47 | assert hasattr(_umat, "sdvini") 48 | assert hasattr(_umat, "umat") 49 | -------------------------------------------------------------------------------- /tests/fortran/test_materials_uhyper.py: -------------------------------------------------------------------------------- 1 | """Test the Matmodlab2 umat interface. The interface to the fortran UMAT 2 | procedure is identical to the Abaqus interface (albeit, written in free-form 3 | fortran). 4 | """ 5 | import os 6 | import sys 7 | import glob 8 | import pytest 9 | import numpy as np 10 | import testing_utils as tu 11 | from subprocess import Popen, STDOUT 12 | from matmodlab2.ext_helpers import build_uhyper 13 | from matmodlab2.umat.umats import neohooke_uhyper 14 | from matmodlab2 import MaterialPointSimulator, UHyper 15 | from matmodlab2.core.misc import working_dir 16 | 17 | try: 18 | fc = os.getenv("FC", "gfortran") 19 | with open(os.devnull, "a") as fh: 20 | p = Popen([fc, "-v"], stdout=fh, stderr=STDOUT) 21 | p.wait() 22 | has_fortran = p.returncode == 0 23 | except: 24 | has_fortran = False 25 | 26 | 27 | @pytest.mark.skipif(not has_fortran, reason="Fortran compiler not found") 28 | def test_uhyper_neohooke(tmpdir): 29 | """Test building a umat""" 30 | with working_dir(tmpdir): 31 | build_uhyper(neohooke_uhyper, verbose=True, cwd=".") 32 | if not len(glob.glob("_uhyper*.so")): 33 | assert 0, f"uhyper not found in {tmpdir}" 34 | if "_uhyper" in sys.modules: 35 | # Remove so it can be loaded below 36 | del sys.modules["_uhyper"] 37 | try: 38 | import _uhyper 39 | except ImportError: 40 | raise Exception("_uhyper not imported") 41 | assert hasattr(_uhyper, "sdvini") 42 | assert hasattr(_uhyper, "umat") 43 | 44 | # Now do the actual material test 45 | E = 500 46 | Nu = 0.45 47 | C1 = E / (4.0 * (1.0 + Nu)) 48 | D1 = 1.0 / (6.0 * (1.0 - 2.0 * Nu) / E) 49 | 50 | X = 0.1 51 | mps = MaterialPointSimulator("UHyper") 52 | mps.material = UHyper([C1, 1.0 / D1]) 53 | mps.run_step("ESS", (1, 0, 0), frames=10, scale=X) 54 | mps.run_step("ESS", (0, 0, 0), frames=10) 55 | 56 | V0 = ("E.XX", "E.YY", "E.ZZ", "S.XX", "S.YY", "S.ZZ", "F.XX", "F.YY", "F.ZZ") 57 | a = mps.get2(*V0) 58 | 59 | # make sure the strain table was interpoloated correctly 60 | i = np.argmax(a[:, 0]) 61 | assert np.allclose(a[i, 0], X) 62 | 63 | # analytic solution for uniaxial stress 64 | 65 | J = np.prod(a[i, [6, 7, 8]]) 66 | L = np.exp(a[i, 0]) 67 | S = 2.0 * C1 / (J ** (5.0 / 3.0)) * (L**2 - J / L) 68 | assert np.allclose(a[i, 3], S) 69 | 70 | # analytic solution for J 71 | f = ( 72 | lambda j: D1 * j ** (8.0 / 3.0) 73 | - D1 * j ** (5.0 / 3.0) 74 | + C1 / (3.0 * L) * J 75 | - C1 * L**2.0 / 3.0 76 | ) 77 | df = ( 78 | lambda j: 8.0 / 3.0 * D1 * j ** (5.0 / 3.0) 79 | - 5.0 / 3.0 * D1 * j ** (2.0 / 3.0) 80 | + C1 / (3.0 * L) 81 | ) 82 | j = tu.newton(1.0, f, df) 83 | assert np.allclose(J, j) 84 | -------------------------------------------------------------------------------- /tests/fortran/test_materials_umat.py: -------------------------------------------------------------------------------- 1 | """Test the Matmodlab2 umat interface. The interface to the fortran UMAT 2 | procedure is identical to the Abaqus interface (albeit, written in free-form 3 | fortran). 4 | """ 5 | import os 6 | import sys 7 | import glob 8 | import pytest 9 | import numpy as np 10 | import testing_utils as tu 11 | from subprocess import Popen, STDOUT 12 | from matmodlab2.ext_helpers import build_umat 13 | from matmodlab2.umat.umats import neohooke_umat 14 | from matmodlab2 import MaterialPointSimulator, UMat 15 | from matmodlab2.core.misc import working_dir 16 | 17 | try: 18 | fc = os.getenv("FC", "gfortran") 19 | with open(os.devnull, "a") as fh: 20 | p = Popen([fc, "-v"], stdout=fh, stderr=STDOUT) 21 | p.wait() 22 | has_fortran = p.returncode == 0 23 | except: 24 | has_fortran = False 25 | 26 | 27 | @pytest.mark.skipif(not has_fortran, reason="Fortran compiler not found") 28 | def test_umat_neohooke(tmpdir): 29 | """Test building a umat""" 30 | with working_dir(tmpdir): 31 | returncode = build_umat(neohooke_umat, cwd=".") 32 | if not len(glob.glob("_umat*.so")): 33 | assert 0, f"umat not found in {tmpdir}" 34 | if "_umat" in sys.modules: 35 | # Remove so it can be loaded below 36 | del sys.modules["_umat"] 37 | try: 38 | import _umat 39 | except ImportError: 40 | raise Exception("_umat not imported") 41 | assert hasattr(_umat, "sdvini") 42 | assert hasattr(_umat, "umat") 43 | 44 | # Now do the actual material test 45 | E = 500 46 | Nu = 0.45 47 | C1 = E / (4.0 * (1.0 + Nu)) 48 | D1 = 1.0 / (6.0 * (1.0 - 2.0 * Nu) / E) 49 | 50 | X = 0.1 51 | mps = MaterialPointSimulator("Umat") 52 | mps.material = UMat([E, Nu]) 53 | mps.run_step("ESS", (1, 0, 0), frames=10, scale=X) 54 | mps.run_step("ESS", (0, 0, 0), frames=10) 55 | 56 | V0 = ("E.XX", "E.YY", "E.ZZ", "S.XX", "S.YY", "S.ZZ", "F.XX", "F.YY", "F.ZZ") 57 | a = mps.get2(*V0) 58 | 59 | # make sure the strain table was interpoloated correctly 60 | i = np.argmax(a[:, 0]) 61 | assert np.allclose(a[i, 0], X) 62 | 63 | # analytic solution for uniaxial stress 64 | 65 | J = np.prod(a[i, [6, 7, 8]]) 66 | L = np.exp(a[i, 0]) 67 | S = 2.0 * C1 / (J ** (5.0 / 3.0)) * (L**2 - J / L) 68 | assert np.allclose(a[i, 3], S) 69 | 70 | # analytic solution for J 71 | f = ( 72 | lambda j: D1 * j ** (8.0 / 3.0) 73 | - D1 * j ** (5.0 / 3.0) 74 | + C1 / (3.0 * L) * J 75 | - C1 * L**2.0 / 3.0 76 | ) 77 | df = ( 78 | lambda j: 8.0 / 3.0 * D1 * j ** (5.0 / 3.0) 79 | - 5.0 / 3.0 * D1 * j ** (2.0 / 3.0) 80 | + C1 / (3.0 * L) 81 | ) 82 | j = tu.newton(1.0, f, df) 83 | assert np.allclose(J, j) 84 | -------------------------------------------------------------------------------- /tests/swan/test_defgrad_basic.py: -------------------------------------------------------------------------------- 1 | from io import StringIO 2 | from collections import OrderedDict 3 | import numpy as np 4 | import scipy.linalg as sl 5 | import pandas as pd 6 | import pytest 7 | import matmodlab2 as mml 8 | 9 | 10 | runid = "simulation_output" 11 | 12 | 13 | def compare_dataframes(frame1, frame2, tol=1.0e-12): 14 | head1 = frame1.keys() 15 | head2 = frame2.keys() 16 | passed = True 17 | for key in set(list(head1)) & set(list(head2)): 18 | print(key) 19 | arr1 = frame1[key] 20 | arr2 = frame2[key] 21 | if not np.allclose(arr1, arr2, atol=tol, rtol=tol): 22 | passed = False 23 | print("Column {0} failed".format(key)) 24 | print(arr1 - arr2) 25 | print(sum(arr1 - arr2)) 26 | return passed 27 | 28 | 29 | @pytest.mark.skip() 30 | @pytest.mark.parametrize("stretch", [1.5, 1.001, 0.999, 0.5]) 31 | @pytest.mark.parametrize("kappa", [2.0, 1.0, 0.0, -1.0, 2.0]) 32 | def test_defgrad_basic(kappa, stretch): 33 | 34 | stretch1 = (stretch - 1.0) / 2.0 + 1.0 35 | stretch2 = stretch 36 | if kappa == 0.0: 37 | strain1 = np.log(stretch1) 38 | strain2 = np.log(stretch2) 39 | else: 40 | strain1 = (stretch1**kappa - 1.0) / kappa 41 | strain2 = (stretch2**kappa - 1.0) / kappa 42 | 43 | sol_io = StringIO( 44 | """Time,E.XX,E.YY,E.ZZ,F.XX,F.YY,F.ZZ 45 | 0.0,0.0,0.0,0.0,1.0,1.0,1.0 46 | 0.5,{0:.14e},0.0,0.0,{1:.14e},1.0,1.0 47 | 1.0,{2:.14e},0.0,0.0,{3:.14e},1.0,1.0""".format( 48 | strain1, stretch1, strain2, stretch2 49 | ) 50 | ) 51 | sol_df = pd.read_csv(sol_io) 52 | sol_df.to_csv("defgrad_basic_solution.csv") 53 | 54 | # Initialize the simulator 55 | mps = mml.MaterialPointSimulator(runid) 56 | 57 | # Initialize the material 58 | mat = mml.ElasticMaterial(E=8.0, Nu=1.0 / 3.0) 59 | mps.assign_material(mat) 60 | 61 | # Run the steps 62 | mps.run_step( 63 | "FFFFFFFFF", 64 | [stretch, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0], 65 | frames=20, 66 | increment=1.0, 67 | kappa=kappa, 68 | ) 69 | 70 | print(sol_df) 71 | mps.df.to_csv("defgrad_basic.csv", index=False) 72 | assert compare_dataframes(sol_df, mps.df) 73 | 74 | 75 | if __name__ == "__main__": 76 | test_defgrad_basic(0.0, 1.5) 77 | -------------------------------------------------------------------------------- /tests/test_core_linalg.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | This file contains tests for matfuncs.py 4 | """ 5 | import pytest 6 | import numpy as np 7 | from testing_utils import * 8 | 9 | import matmodlab2 10 | import matmodlab2.core.linalg as la 11 | 12 | la.set_linalg_library("scipy") 13 | 14 | # NOTE: In many of the tests to follow, only a trivial tensor is sent to test 15 | # the matrix function. This is by design. Since all of the matrix functions are 16 | # just wrappers to scipy functions, these tests just test the wrapper (the 17 | # ability to call the function with a 3x3 "matrix" or 6x1 array) 18 | 19 | 20 | def test_inv(): 21 | """Inverse of A""" 22 | A = random_matrix() 23 | Ai = la.inv(A) 24 | assert np.allclose(np.dot(Ai, A), np.eye(3)) 25 | 26 | 27 | def test_expm(): 28 | """Compute the matrix exponential of a 3x3 matrix""" 29 | x, y, z = 1.0, 2.0, 3.0 30 | A = np.array([[x, 0, 0], [0, y, 0], [0, 0, z]]) 31 | exp_A = np.array([[np.exp(x), 0, 0], [0, np.exp(y), 0], [0, 0, np.exp(z)]]) 32 | assert np.allclose(la.expm(A), exp_A) 33 | 34 | 35 | def test_logm(): 36 | """Compute the matrix logarithm of a 3x3 matrix""" 37 | x, y, z = 1.0, 2.0, 3.0 38 | A = np.array([[x, 0, 0], [0, y, 0], [0, 0, z]]) 39 | log_A = np.array([[np.log(x), 0, 0], [0, np.log(y), 0], [0, 0, np.log(z)]]) 40 | assert np.allclose(log_A, la.logm(A)) 41 | 42 | 43 | def test_expm_logm_consistency(): 44 | A = random_symmetric_positive_definite_matrix() 45 | B = la.expm(A) 46 | assert np.allclose(la.logm(B), A) 47 | 48 | 49 | def test_logm_expm_consistency(): 50 | A = random_symmetric_positive_definite_matrix() 51 | A = A.reshape(3, 3) 52 | B = la.logm(A) 53 | assert np.allclose(la.expm(B), A) 54 | 55 | 56 | def test_powm(): 57 | """Compute the matrix power of a 3x3 matrix""" 58 | m = 1.2 59 | x, y, z = 1.0, 2.0, 3.0 60 | A = np.array([[x, 0, 0], [0, y, 0], [0, 0, z]]) 61 | pow_A = np.array([[x**m, 0, 0], [0, y**m, 0], [0, 0, z**m]]) 62 | assert np.allclose(la.powm(A, m), pow_A) 63 | A = random_matrix() 64 | B = la.powm(A, 0.5) 65 | assert np.allclose(np.dot(B, B), A) 66 | A = random_matrix() 67 | B = la.powm(A, 2) 68 | assert np.allclose(np.dot(A, A), B) 69 | 70 | 71 | def test_sqrtm(): 72 | """Compute the square root of a 3x3 matrix""" 73 | x, y, z = np.random.rand(3) 74 | A = np.array([[x, 0, 0], [0, y, 0], [0, 0, z]]) 75 | sqrt_A = np.array([[np.sqrt(x), 0, 0], [0, np.sqrt(y), 0], [0, 0, np.sqrt(z)]]) 76 | assert np.allclose(la.sqrtm(A), sqrt_A) 77 | A = random_symmetric_positive_definite_matrix() 78 | B = la.sqrtm(A) 79 | assert np.allclose(np.dot(B, B), A) 80 | 81 | 82 | la.set_linalg_library("default") 83 | 84 | if __name__ == "__main__": 85 | test_import() 86 | -------------------------------------------------------------------------------- /tests/test_core_misc.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | This file contains tests for misc.py 4 | """ 5 | import sys 6 | import pytest 7 | import numpy as np 8 | 9 | import matmodlab2 10 | import matmodlab2.core.misc as misc 11 | 12 | 13 | def test_is_listlike(): 14 | """Is item list like?""" 15 | assert not misc.is_listlike("aaa") 16 | assert misc.is_listlike([0, 1, 2]) 17 | assert misc.is_listlike((0, 1, 2)) 18 | assert not misc.is_listlike(None) 19 | 20 | 21 | def test_is_stringlike(): 22 | """Is item string like?""" 23 | assert misc.is_stringlike("aaa") 24 | assert not misc.is_stringlike([0, 1, 2]) 25 | assert not misc.is_stringlike((0, 1, 2)) 26 | 27 | 28 | def test_is_scalarlike(): 29 | """Is item scalar like?""" 30 | assert misc.is_scalarlike(5) 31 | assert misc.is_scalarlike(5.0) 32 | assert misc.is_scalarlike(np.array(5.0)) 33 | assert misc.is_scalarlike(np.array(5)) 34 | assert not misc.is_scalarlike([1, 2]) 35 | assert not misc.is_scalarlike(np.array([1, 2])) 36 | 37 | 38 | if __name__ == "__main__": 39 | test_import() 40 | -------------------------------------------------------------------------------- /tests/test_core_stress_control.py: -------------------------------------------------------------------------------- 1 | import os 2 | import glob 3 | import pytest 4 | import random 5 | import numpy as np 6 | 7 | from matmodlab2 import * 8 | from testing_utils import * 9 | 10 | 11 | @pytest.mark.parametrize("realization", range(0, 10)) 12 | def test_stress_control(realization): 13 | 14 | jobid = "stress_control_{0:04d}".format(realization) 15 | 16 | failtol = 5.0e-7 17 | Nsteps = np.random.randint(20, 101) # upper limit exclusive 18 | head = ( 19 | "Time", 20 | "E.XX", 21 | "E.YY", 22 | "E.ZZ", 23 | "E.XY", 24 | "E.YZ", 25 | "E.XZ", 26 | "S.XX", 27 | "S.YY", 28 | "S.ZZ", 29 | "S.XY", 30 | "S.YZ", 31 | "S.XZ", 32 | ) 33 | data = np.zeros((Nsteps, len(head))) 34 | 35 | # 36 | # Parameters 37 | # 38 | E = 10.0 ** np.random.uniform(0.0, 12.0) 39 | NU = np.random.uniform(-0.95, 0.45) 40 | K = E / 3.0 / (1.0 - 2.0 * NU) 41 | G = E / 2.0 / (1.0 + NU) 42 | params = {"E": E, "Nu": NU} 43 | 44 | # 45 | # Generate the path and analytical solution 46 | # 47 | eps = np.array( 48 | [2.0 * (np.random.rand() - 0.5) * np.random.randint(0, 2) for _ in range(6)] 49 | ) 50 | eps_iso = (np.sum(eps[:3]) / 3.0) * np.array([1.0, 1.0, 1.0, 0.0, 0.0, 0.0]) 51 | eps_dev = eps - eps_iso 52 | sig = 3.0 * K * eps_iso + 2.0 * G * eps_dev 53 | 54 | for idx, t in enumerate(np.linspace(0.0, 1.0, Nsteps)): 55 | curr_eps = t * eps 56 | curr_sig = t * sig 57 | data[idx, 0] = t 58 | data[idx, 1:7] = curr_eps 59 | data[idx, 7:] = curr_sig 60 | 61 | # 62 | # Run the strain-controlled version 63 | # 64 | mps_eps = MaterialPointSimulator(jobid + "_eps") 65 | material = ElasticMaterial(**params) 66 | mps_eps.assign_material(material) 67 | for (i, row) in enumerate(data[1:]): 68 | increment = row[0] - data[i, 0] 69 | mps_eps.run_step("E", row[1:7], increment=increment) 70 | 71 | # 72 | # Run the stress-controlled version 73 | # 74 | mps_sig = MaterialPointSimulator(jobid + "_sig") 75 | material = ElasticMaterial(**params) 76 | mps_sig.assign_material(material) 77 | for (i, row) in enumerate(data[1:]): 78 | increment = row[0] - data[i, 0] 79 | mps_sig.run_step("S", row[7:], increment=increment) 80 | 81 | # 82 | # Analysis 83 | # 84 | data_eps = mps_eps.get2(*head) 85 | data_sig = mps_sig.get2(*head) 86 | assert data.shape == data_eps.shape and data.shape == data_sig.shape 87 | 88 | has_passed = True 89 | dt = data[1, 0] - data[0, 0] 90 | for idx, key in enumerate(head): 91 | gold = data[:, idx] 92 | eps = data_eps[:, idx] 93 | sig = data_sig[:, idx] 94 | 95 | basis = max(1.0, np.trapz(np.abs(gold), dx=dt)) 96 | err_eps = np.trapz(np.abs(gold - eps), dx=dt) / basis 97 | err_sig = np.trapz(np.abs(gold - sig), dx=dt) / basis 98 | print("STRAIN ERROR: ", err_eps) 99 | print("STRESS ERROR: ", err_sig) 100 | if max(err_eps, err_sig) > failtol: 101 | has_passed = False 102 | 103 | assert has_passed 104 | -------------------------------------------------------------------------------- /tests/test_environment.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | This file contains tests that focus on general set-up 4 | of the python environment. They also check things that 5 | probably don't need any checking. 6 | """ 7 | 8 | import sys 9 | import pathlib 10 | 11 | 12 | # Ensure that 'matmodlab' is imported from parent directory. 13 | sys.path.insert(0, str(pathlib.Path(__file__).absolute().parent.parent)) 14 | 15 | try: 16 | import matmodlab2 17 | except ImportError: 18 | matmodlab2 = None 19 | 20 | 21 | def test_absolute_truth(): 22 | """Ensure that the testing library is working.""" 23 | # Setup 24 | 25 | # Test 26 | assert True 27 | 28 | # Teardown 29 | 30 | 31 | def test_require_python3(): 32 | """The module 'matmodlab' and these tests require at least Python 3.0.""" 33 | # Setup 34 | 35 | # Test 36 | assert sys.version_info > (3, 0) or sys.version_info > (2, 6) 37 | 38 | # Teardown 39 | 40 | 41 | def test_import(): 42 | """Ensure that 'matmodlab' is imported.""" 43 | # Setup 44 | 45 | # Test 46 | assert matmodlab2 is not None 47 | 48 | # Teardown 49 | 50 | 51 | def test_initialize(): 52 | """Do something simple with 'matmodlab'.""" 53 | # Setup 54 | 55 | # Test 56 | assert "MaterialPointSimulator" in matmodlab2.__all__ 57 | 58 | # Teardown 59 | 60 | 61 | if __name__ == "__main__": 62 | test_import() 63 | -------------------------------------------------------------------------------- /tests/test_fitting_hyperopt.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | import numpy as np 4 | from matmodlab2 import ( 5 | MaterialPointSimulator, 6 | PolynomialHyperelasticMaterial, 7 | MooneyRivlinMaterial, 8 | ) 9 | from matmodlab2.fitting.hyperopt import hyperopt 10 | from matmodlab2.fitting.hyperfit import HyperFit 11 | from matmodlab2.core.numerix import rms_error, calculate_bounded_area, get_area 12 | 13 | 14 | def test_hyperfit(): 15 | 16 | # Run a simulation to generate data 17 | parameters = {"D1": 1.5e-5, "C10": 1e6, "C01": 0.1e6} 18 | 19 | # Set up the simulator 20 | mps = MaterialPointSimulator("test1") 21 | mps.material = PolynomialHyperelasticMaterial(**parameters) 22 | # mps.material = MooneyRivlinMaterial(**parameters) 23 | 24 | # Drive the *incompressible* material through a path of uniaxial stress by 25 | # prescribing the deformation gradient. 26 | mps.run_step("ESS", (1.0, 0, 0), frames=50) 27 | 28 | # Now fit the model 29 | dtype = "Uniaxial Data" 30 | e1 = mps.get("E.XX") 31 | s1 = mps.get("S.XX") 32 | opt = hyperopt("Uniaxial Data", e1, s1, order=2, i2dep=False) 33 | 34 | mps = MaterialPointSimulator("test2") 35 | parameters["C10"] = opt.popt[0] 36 | parameters["C01"] = opt.popt[1] 37 | mps.material = PolynomialHyperelasticMaterial(**parameters) 38 | mps.run_step("ESS", (1.0, 0, 0), frames=50) 39 | s2 = mps.get("S.XX") 40 | t = mps.get("Time") 41 | assert rms_error(t, s1, t, s2, 0) < 0.01 42 | -------------------------------------------------------------------------------- /tests/test_fitting_mcgen.py: -------------------------------------------------------------------------------- 1 | import os 2 | import pytest 3 | from testing_utils import * 4 | 5 | try: 6 | import pandas 7 | from matmodlab2.fitting.mcgen import * 8 | except ImportError: 9 | pandas = None 10 | 11 | this_d = os.path.dirname(os.path.realpath(__file__)) 12 | 13 | 14 | @pytest.mark.skipif(pandas is None, reason="pandas not imported") 15 | def test_mcgen(): 16 | """example test case""" 17 | # Baseline solution 18 | c = np.array([3.292, 181.82]) 19 | p = np.array( 20 | [ 21 | [0.0001, 2489], 22 | [0.001, 1482], 23 | [0.01, 803], 24 | [0.1, 402], 25 | [1, 207], 26 | [10, 124], 27 | [100, 101], 28 | [0, 222], 29 | ], 30 | dtype=np.float64, 31 | ) 32 | f = os.path.join(this_d, "data/mcgen.csv") 33 | mc = MasterCurve.Import( 34 | f, ref_temp=75.0, apply_log=True, fitter=PRONY, optimizer=FMIN, optwlf=False 35 | ) 36 | mc.fit() 37 | 38 | s1 = "WLF coefficients not within tolerance" 39 | assert np.allclose(mc.wlf_opt, c, rtol=1.0e-3, atol=1.0e-3), s1 40 | 41 | s2 = "Prony series not within tolerance" 42 | assert np.allclose(mc.mc_fit[:, 1], p[:, 1], rtol=1.0e-2, atol=1.0e-2), s2 43 | 44 | 45 | if __name__ == "__main__": 46 | test_mcgen() 47 | -------------------------------------------------------------------------------- /tests/test_materials_expansion.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | import numpy as np 4 | from matmodlab2 import * 5 | from testing_utils import * 6 | 7 | 8 | @pytest.mark.parametrize("itemp", np.random.uniform(0.0, 100.0, 1)) 9 | @pytest.mark.parametrize("dtemp", np.random.uniform(10.0, 50.0, 1)) 10 | @pytest.mark.parametrize("alpha", np.random.uniform(1e-5, 1e-4, 1)) 11 | def test_expansion(itemp, dtemp, alpha): 12 | temp = (itemp, itemp + dtemp) 13 | E, Nu = 500, 0.45 14 | mps = MaterialPointSimulator("Job-1", initial_temp=temp[0]) 15 | material = ElasticMaterial(E=E, Nu=Nu) 16 | material.Expansion(alpha) 17 | mps.material = material 18 | 19 | mps.run_step("ESS", (0.01, 0, 0), temperature=temp[0], frames=20) 20 | mps.run_step(("DE", "DE", "DE"), (0, 0, 0), temperature=temp[1], frames=20) 21 | 22 | out = mps.get2("Temp", "E.XX", "S.XX", "S.YY", "S.ZZ", "EM.XX") 23 | 24 | errors = [] 25 | for (i, row) in enumerate(out[1:], start=1): 26 | dtemp = out[i, 0] - temp[0] 27 | ee = out[i, 1] - alpha * dtemp 28 | assert abs(ee - out[i, -1]) < 1e-6 29 | diff = E * ee + Nu * (out[i, 3] + out[i, 4]) - out[i, 2] 30 | errors.append(abs(diff / out[i, 2])) 31 | 32 | if any([abs(x) > 1e-10 for x in errors]): 33 | raise Exception("maximum error = {0}".format(max(errors))) 34 | 35 | return 36 | 37 | 38 | if __name__ == "__main__": 39 | test_expansion(75, 25, 1e-5) 40 | -------------------------------------------------------------------------------- /tests/test_materials_mooney_rivlin.py: -------------------------------------------------------------------------------- 1 | # Hyperelastic parameters, D1 set to a large number to force incompressibility 2 | import pytest 3 | import numpy as np 4 | 5 | np.seterr(invalid="raise") 6 | 7 | from matmodlab2 import MaterialPointSimulator, MooneyRivlinMaterial 8 | from testing_utils import * 9 | 10 | 11 | def test_mooney_rivlin(): 12 | parameters = {"D1": 1.0e12, "C10": 1e6, "C01": 0.1e6} 13 | 14 | # stretch to 300% 15 | lam = np.linspace(0.5, 3, 50) 16 | 17 | # Set up the simulator 18 | mps = MaterialPointSimulator("test1") 19 | mps.material = MooneyRivlinMaterial(**parameters) 20 | 21 | # Drive the *incompressible* material through a path of uniaxial stress by 22 | # prescribing the deformation gradient. 23 | Fij = lambda x: (x, 0, 0, 0, 1 / np.sqrt(x), 0, 0, 0, 1 / np.sqrt(x)) 24 | mps.run_step("F", Fij(lam[0]), frames=10) 25 | mps.run_step("F", Fij(1), frames=1) 26 | mps.run_step("F", Fij(lam[-1]), frames=20) 27 | 28 | # analytic solution for true and engineering stress 29 | C10, C01 = parameters["C10"], parameters["C01"] 30 | s = 2 * C01 * lam - 2 * C01 / lam**2 + 2 * C10 * lam**2 - 2 * C10 / lam 31 | 32 | lam_ = np.exp(mps.get("E.XX")) 33 | ss = mps.get("S.XX") - mps.get("S.ZZ") 34 | 35 | # check the actual solutions 36 | assert abs(np.amax(ss) - np.amax(s)) / np.amax(s) < 1e-6 37 | assert abs(np.amin(ss) - np.amin(s)) / np.amin(s) < 1e-6 38 | -------------------------------------------------------------------------------- /tests/test_materials_polyhyper.py: -------------------------------------------------------------------------------- 1 | # Hyperelastic parameters, D1 set to a large number to force incompressibility 2 | import pytest 3 | import numpy as np 4 | 5 | from matmodlab2 import MaterialPointSimulator, PolynomialHyperelasticMaterial 6 | from testing_utils import * 7 | 8 | 9 | def test_polynomial_hyperelastic(): 10 | parameters = {"D1": 1.0e-15, "C10": 1e6, "C01": 0.1e6} 11 | 12 | # stretch to 300% 13 | lam = np.linspace(0.5, 3, 50) 14 | 15 | # Set up the simulator 16 | mps = MaterialPointSimulator("test1") 17 | mps.material = PolynomialHyperelasticMaterial(**parameters) 18 | 19 | # Drive the *incompressible* material through a path of uniaxial stress by 20 | # prescribing the deformation gradient. 21 | Fij = lambda x: (x, 0, 0, 0, 1 / np.sqrt(x), 0, 0, 0, 1 / np.sqrt(x)) 22 | mps.run_step("F", Fij(lam[0]), frames=10) 23 | mps.run_step("F", Fij(1), frames=1) 24 | mps.run_step("F", Fij(lam[-1]), frames=20) 25 | 26 | # analytic solution for true and engineering stress 27 | C10, C01 = parameters["C10"], parameters["C01"] 28 | s = 2 * C01 * lam - 2 * C01 / lam**2 + 2 * C10 * lam**2 - 2 * C10 / lam 29 | 30 | lam_ = np.exp(mps.get("E.XX")) 31 | ss = mps.get("S.XX") - mps.get("S.ZZ") 32 | print(ss) 33 | 34 | # check the actual solutions 35 | assert abs(np.amax(ss) - np.amax(s)) / np.amax(s) < 1e-6 36 | assert abs(np.amin(ss) - np.amin(s)) / np.amin(s) < 1e-6 37 | -------------------------------------------------------------------------------- /tests/test_materials_user_interface.py: -------------------------------------------------------------------------------- 1 | """Materials do not need to subclass the matmodlab2.core.material.Material base 2 | class, they need only provide an `eval` method. This test verifies that that is 3 | the case. 4 | 5 | """ 6 | import pytest 7 | 8 | import numpy as np 9 | from matmodlab2 import * 10 | from testing_utils import * 11 | 12 | 13 | class MyMaterial: 14 | def __init__(self, **parameters): 15 | E = parameters["E"] 16 | Nu = parameters["Nu"] 17 | self.G = E / 2.0 / (1.0 + Nu) 18 | self.K = E / 3.0 / (1.0 - 2.0 * Nu) 19 | 20 | def eval(self, time, dtime, temp, dtemp, F0, F, strain, d, stress, statev, **kwds): 21 | K3, G2 = 3.0 * self.K, 2.0 * self.G 22 | Lam = (K3 - G2) / 3.0 23 | ddsdde = np.zeros((6, 6)) 24 | ddsdde[np.ix_(range(3), range(3))] = Lam 25 | ddsdde[range(3), range(3)] += G2 26 | ddsdde[range(3, 6), range(3, 6)] = self.G 27 | stress = stress + np.dot(ddsdde, d * dtime) 28 | return stress, statev, ddsdde 29 | 30 | 31 | def test_uniaxial_strain(): 32 | K = 9.980040e09 33 | G = 3.750938e09 34 | E = 9.0 * K * G / (3.0 * K + G) 35 | Nu = (3.0 * K - 2.0 * G) / (2.0 * (3.0 * K + G)) 36 | parameters = {"K": K, "G": G, "E": E, "Nu": Nu} 37 | pathtable = [[1.0, 0.0, 0.0], [2.0, 0.0, 0.0], [1.0, 0.0, 0.0], [0.0, 0.0, 0.0]] 38 | mps = MaterialPointSimulator("Job") 39 | material = MyMaterial(**parameters) 40 | mps.assign_material(material) 41 | for c in pathtable: 42 | mps.run_step("E", c, scale=-0.5) 43 | H = K + 4.0 / 3.0 * G 44 | Q = K - 2.0 / 3.0 * G 45 | a = mps.get2("E.XX", "S.XX", "S.YY", "S.ZZ") 46 | eps_xx = mps.data[:, 4] 47 | assert np.allclose(a[:, 2], a[:, 3]) 48 | assert np.allclose(a[:, 1], H * a[:, 0]) 49 | assert np.allclose(a[:, 2], Q * a[:, 0]) 50 | assert np.allclose(eps_xx, a[:, 0]) 51 | -------------------------------------------------------------------------------- /tests/test_materials_viscoelastic.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | import numpy as np 4 | from matmodlab2 import * 5 | from testing_utils import * 6 | 7 | 8 | def test_viscoelastic(): 9 | 10 | mps = MaterialPointSimulator("viscoelastic", initial_temp=75) 11 | 12 | parameters = {"D1": 1.0e-15, "C10": 1e6, "C01": 0.1e6} 13 | 14 | wlf = [75, 35, 50] 15 | prony = np.array( 16 | [ 17 | [0.35, 600.0], 18 | [0.15, 20.0], 19 | [0.25, 30.0], 20 | [0.05, 40.0], 21 | [0.05, 50.0], 22 | [0.15, 60.0], 23 | ] 24 | ) 25 | 26 | material = PolynomialHyperelasticMaterial(**parameters) 27 | material.Expansion(1e-5) 28 | material.Viscoelastic(wlf, prony) 29 | mps.material = material 30 | 31 | mps.add_step("ESS", (0.1, 0.0, 0.0), increment=1.0, temperature=75.0, frames=10) 32 | mps.add_step("EEE", (0.0, 0.0, 0.0), increment=50.0, temperature=95.0, frames=50) 33 | 34 | try: 35 | # test passes if it runs 36 | mps.run() 37 | except BaseException: 38 | raise Exception("viscoelastic failed to run") 39 | -------------------------------------------------------------------------------- /tests/test_optimize_optimizer.py: -------------------------------------------------------------------------------- 1 | """Test the optimization capabilities. 2 | 3 | Test is a trivial linear elastic material exercised through a path of uniaxial 4 | stress. The tests check that the optimized Young's modulus is close to the 5 | specified value 6 | 7 | """ 8 | import os 9 | import glob 10 | import pytest 11 | import shutil 12 | import numpy as np 13 | from matmodlab2 import * 14 | from matmodlab2.optimize import Optimizer, OptimizeVariable 15 | import testing_utils as tu 16 | 17 | 18 | def teardown_module(): 19 | tu.teardown_module() 20 | for dirname in glob.glob("*.eval"): 21 | if os.path.isdir(dirname): 22 | shutil.rmtree(dirname) 23 | 24 | 25 | E = 10.0 26 | 27 | 28 | def func(x, xnames, evald, job, *args): 29 | parameters = {"E": x[0], "Nu": 0.1} 30 | mps = MaterialPointSimulator(job) 31 | mps.material = ElasticMaterial(**parameters) 32 | mps.run_step("ESS", [0.1, 0.0, 0.0]) 33 | mps.run_step("ESS", [0.0, 0.0, 0.0]) 34 | sxx = np.array(mps.df["S.XX"]) 35 | exx = np.array(mps.df["E.XX"]) 36 | youngs = [] 37 | for (i, e) in enumerate(exx): 38 | if abs(e) < 1e-12: 39 | continue 40 | youngs.append(sxx[i] / e) 41 | youngs = np.average(youngs) 42 | return youngs - E 43 | 44 | 45 | def run_method(method): 46 | E = OptimizeVariable("E", 8, bounds=(7, 12)) 47 | xinit = [ 48 | E, 49 | ] 50 | optimizer = Optimizer( 51 | method, func, xinit, method=method, maxiter=25, tolerance=1.0e-4 52 | ) 53 | optimizer.run() 54 | return optimizer.xopt 55 | 56 | 57 | def test_optimize_cobyla(): 58 | xopt = run_method("cobyla") 59 | err = xopt[0] - E 60 | assert err < 1e-4 61 | 62 | 63 | def test_powell(): 64 | xopt = run_method("powell") 65 | err = xopt[0] - E 66 | assert err < 1e-4 67 | 68 | 69 | def test_simplex(): 70 | xopt = run_method("simplex") 71 | err = xopt[0] - E 72 | assert err < 1e-4 73 | --------------------------------------------------------------------------------