Git Product home page Git Product logo

hyperelastic's Introduction

Constitutive hyperelastic material formulations for FElupe.

PyPI version shields.io License: GPL v3 Made with love in Graz (Austria) codecov DOI Codestyle black Documentation Status PDF Documentation

This package provides the essential building blocks for constitutive hyperelastic material formulations. This includes material behaviour-independent spaces and frameworks as well as material behaviour-dependent model formulations.

Spaces (hyperelastic.spaces) are full or partial deformations on which a given material formulation should be projected to, e.g. to the distortional (part of the deformation) space. Generalized Total-Lagrange Frameworks (hyperelastic.frameworks) for isotropic hyperelastic material formulations based on the invariants of the right Cauchy-Green deformation tensor and the principal stretches enable a clean coding of isotropic material formulations.

The hyperelastic.math-module provides helpers in reduced vector (Voigt) storage for symmetric three-dimensional second-order tensors along with a matrix storage for (at least minor) symmetric three-dimensional fourth-order tensors. Shear terms are not doubled for strain-like tensors, instead all math operations take care of the reduced vector storage.

$$ \boldsymbol{C} = \begin{bmatrix} C_{11} & C_{22} & C_{33} & C_{12} & C_{23} & C_{13} \end{bmatrix}^T $$

Installation

Install Python, fire up 🔥 a terminal and run 🏃

pip install hyperelastic

Usage

Material model formulations have to be created as classes with methods for the evaluation of the gradient (stress) and the hessian (elasticity) of the strain energy function. It depends on the framework which derivatives have to be defined, e.g. the derivatives w.r.t. the invariants of the right Cauchy-Green deformation tensor or w.r.t. the principal stretches. An instance of a Framework has to be finalized by the application on a Space.

Note Define your own material model formulation with manual, automatic or symbolic differentiation with the help of your favourite package, e.g. PyTorch, JAX, Tensorflow, TensorTRAX, SymPy, etc.

First, let's import hyperelastic (and its math module).

import hyperelastic as hel
import hyperelastic.math as hm

Invariant-based material formulations

A minimal template for an invariant-based material formulation applied on the distortional space:

class MyInvariantsModel:
    def gradient(self, I1, I2, I3, statevars):
        """The gradient as the partial derivative of the strain energy function w.r.t.
        the invariants of the right Cauchy-Green deformation tensor."""

        return dWdI1, dWdI2, dWdI3, statevars

    def hessian(self, I1, I2, I3, statevars_old):
        """The hessian as the second partial derivatives of the strain energy function
        w.r.t. the invariants of the right Cauchy-Green deformation tensor."""

        return d2WdI1I1, d2WdI2I2, d2WdI3I3, d2WdI1I2, d2WdI2I3, d2WdI1I3


model = MyInvariantsModel()
framework = hel.InvariantsFramework(model)
umat = hel.DistortionalSpace(framework)

Available isotropic hyperelastic invariant-based material formulations

The typical polynomial-based material formulations (Neo-Hooke, Mooney-Rivlin, Yeoh) are all available as submodels of the third order deformation material formulation.

PyTorch

Principal stretch-based material formulations

A minimal template for a principal stretch-based material formulation applied on the distortional space:

class MyStretchesModel:
    def gradient(self, λ, statevars):
        """The gradient as the partial derivative of the strain energy function w.r.t.
        the principal stretches."""

        return [dWdλ1, dWdλ2, dWdλ3], statevars

    def hessian(self, λ, statevars_old):
        """The hessian as the second partial derivatives of the strain energy function
        w.r.t. the principal stretches."""

        return d2Wdλ1dλ1, d2Wdλ2dλ2, d2Wdλ3dλ3, d2Wdλ1dλ2, d2Wdλ2dλ3, d2Wdλ1dλ3


model = MyStretchesModel()
framework = hel.StretchesFramework(model)
umat = hel.DistortionalSpace(framework)

Available isotropic hyperelastic stretch-based material formulations

Lab

In the Lab, Simulations on homogeneous load cases provide a visualization of the material response behaviour.

import numpy as np
import hyperelastic

stretch = np.linspace(0.7, 2.5, 181)
parameters = {"C10": 0.3, "C01": 0.2}

def material(C10, C01):
    tod = hyperelastic.models.invariants.ThirdOrderDeformation(C10=C10, C01=C01)
    framework = hyperelastic.InvariantsFramework(tod)
    return hyperelastic.DeformationSpace(framework)

ux = hyperelastic.lab.Simulation(
    loadcase=hyperelastic.lab.Uniaxial(label="uniaxial"),
    stretch=np.linspace(0.7, 2.5),
    material=material,
    labels=parameters.keys(),
    parameters=parameters.values(),
)

ps = hyperelastic.lab.Simulation(
    loadcase=hyperelastic.lab.Planar(label="planar"),
    stretch=np.linspace(1.0, 2.5),
    material=material,
    labels=parameters.keys(),
    parameters=parameters.values(),
)

bx = hyperelastic.lab.Simulation(
    loadcase=hyperelastic.lab.Biaxial(label="biaxial"),
    stretch=np.linspace(1.0, 1.75),
    material=material,
    labels=parameters.keys(),
    parameters=parameters.values(),
)

fig, ax = ux.plot_stress_stretch(lw=2)
fig, ax = ps.plot_stress_stretch(ax=ax, lw=2)
fig, ax = bx.plot_stress_stretch(ax=ax, lw=2)

ax.legend()
ax.set_title(rf"Mooney-Rivlin (C10={parameters['C10']}, C01={parameters['C01']})")

fig_lab-mr

License

Hyperelastic - Constitutive hyperelastic material formulations for FElupe (C) 2024 Andreas Dutzler, Graz (Austria).

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.

hyperelastic's People

Contributors

adtzlr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

hyperelastic's Issues

Curve Fit: Find material parameters for given Experimental Data

This should be a simple wrapper for scipy.optimize.curve_fit().

Classes for hyperelastic.lab

  • Experiment: Holds all the experiment-related data in attributes, e.g. displacement, force, time, temperature, cross-sectional area, label, etc. as well as methods for stress- and stetch-evaluations
  • LoadCase: Base-class for pre-defined loadcases with methods for calculating the deformation gradient from the stretch and the (e.g. uniaxial) stress. In other words, the 1d-deformation (stretch) is converted to a 3d-deformation (gradient tensor) and the 3d stress tensor is converted back to a 1d stress related to the experiment.
  • Simulation: Create a simulation on top of a loadcase with given stretches and evaluate the stress (also for the curve-fit of scipy). In the future, numeric simulations would be a great extension.
  • Optimize: Combine experiments and simulations and find the set of parameters which give the best-fit to the experiments. Optimize.run() is then the wrapper of scipy.optimize.curve_fit().

Bugs in Generalized Invariants

  • typo in second invariant
  • use more general expressions for the initial state and default exponent=2 in \hyperelastic\models\generalized\_stretch.py

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.