Skip to main content

Cube in Equilibrium

Project description

cubrium

A cube in equilibrium

PyPI version shields.io Code coverage Made with love in Graz Code style: black

Cubrium is a toolbox for the definition, solution and post-processing of homogenous loadcases in continuum mechanics of solids (statics). It uses contique for the numeric continuation of the nonlinear equilibrium equations. If you use cubrium or contique in your scientific publications, please cite my work. I'll provide a citable template with a DOI in the future.

Example 101 a.k.a hello cubrium 😎

This is an example which solves a cube with a Saint Venant-Kirchhoff (SVK) material for the case of uniaxial loading. In the first step, we init a model.

import cubrium

MDL = cubrium.init()

Constitution

In the second part, we have to define the constitutive law. We can either use one of cubrium's models or use our own umat (user material). This time we're using our own umat function for a simple SVK material.

import numpy as np

def umat_svk(F, parameters):
    """(U)ser (MAT)erial Function.
    Returns First Piola-Kirchhoff stress tensor for a given
    deformation gradient tensor with a list of material parameters."""

    # expand list of material parameters
    mu, K = parameters[:2]
    gamma = K - 2 / 3 * mu

    C = F.T @ F
    E = 1 / 2 * (C - np.eye(3))

    S = 2 * mu * E + gamma * np.trace(E) * np.eye(3)

    return F @ S

Now we have to link our umat to the cubrium model definition and specify material parameters.

MDL.GLO.constitution.umat = umat_svk
MDL.GLO.constitution.parameters = [1.0, 5000.0]

Loadcase (Kinematics and Kinetics)

A loadcase is defined with exactly 9 equations for the unsymmetric or 6 equations for the full-symmetric case. This contains either kinematic or kinetic types of equations. For the case of uniaxial loading we are building this loadcase for ourselfes. We apply an external normal force 1 and set all external shear forces and normal forces 2 and 3 to zero. A symmetric solution is enforced (no rigid body rotation is allowed). The load-proportionaly-factor is applied to the normal forces (lpftype=0). Finally we specify a title for the loadcase. This will later effect the output filenames.

def uniaxial(MDL):
    MDL.EXT.force.normal[0] = 1
    MDL.EXT.force.normal[1] = 0
    MDL.EXT.force.normal[2] = 0

    MDL.EXT.force.shear[0, 1] = 0
    MDL.EXT.force.shear[1, 2] = 0
    MDL.EXT.force.shear[0, 2] = 0

    MDL.EXT.gridvec.symmetry = [1, 1, 1]

    MDL.GLO.lpftype = 0
    MDL.GLO.title = "Uniaxial"
    return MDL

Again, we have to link our loadcase to the cubrium model and update the model with the new loadcase settings.

MDL = uniaxial(MDL)
MDL = cubrium.update(MDL)

Solver

Starting from a valid initial solution everything is ready to solve the model. Hint: x0 are the flattened components of the displacement gradient w.r.t. the undeformed coordinates (=primary unknows of the problem).

Res = cubrium.solve(MDL)(
    x0   = np.zeros(9),
    lpf0 = 0.0,
)

The results contain the extended unknowns y = (x, lpf) but no information about the internal quantities of the model. Therefore we extract the extended unknows from the Result object (Res) and recover these internal quantities (e.g. reaction forces) for all steps.

Y = np.array([res.x for res in Res])
history = cubrium.recover(Y, MDL)

Plots and Post-processing

We plot the axial stretch vs. load-proportionality-factor in direction 1.

import matplotlib.pyplot as plt

plt.plot(1+Y[:, 0], Y[:, -1], "-")
plt.xlabel("stretch $\lambda_1$")
plt.ylabel("load-proportionality-factor LPF")

Using meshio we are able to export our solution in the xdmf file format which may be further post-processed by ParaView.

cubrium.writer.xdmf(
        history,
        filename = MDL.GLO.title,
    )

An exemplary scene for ParaView 5.9.0 is available to download. Import it in ParaView (File - Load state) and choose "Choose File Names" as shown below. Voilà, a nice cube scene in 3D with a cube colored in "Cauchy Stress XX" and reaction forces scaled and colored in "Reaction Force Magnitude" is ready to animate. The whole script of this example may be downloaded here.

Finally you can watch the animated cube during the deformation.

Have fun using cubrium! If you find any bugs please submit an issue.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cubrium-0.1.2.tar.gz (23.8 kB view details)

Uploaded Source

Built Distribution

cubrium-0.1.2-py3-none-any.whl (22.7 kB view details)

Uploaded Python 3

File details

Details for the file cubrium-0.1.2.tar.gz.

File metadata

  • Download URL: cubrium-0.1.2.tar.gz
  • Upload date:
  • Size: 23.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.9.2

File hashes

Hashes for cubrium-0.1.2.tar.gz
Algorithm Hash digest
SHA256 b215bd4b8934f9fe552a0cf9db64afacc7623528ccd5d4d85800284bf1f8b52b
MD5 6ecc5b98c1b1e3b2e6069a27b5cc5070
BLAKE2b-256 32ce1058f2b922edef8c7adb87b6af5839693f2a7ca01c8b7e6ad664727dca6a

See more details on using hashes here.

File details

Details for the file cubrium-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: cubrium-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 22.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.9.2

File hashes

Hashes for cubrium-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d30225568b70714cda275589e2fbfdf65f89bafc4b3ef805a4fd437cee76dbd4
MD5 3a87e292b4e806f61fb542c559c92692
BLAKE2b-256 17a07ad8c149f4c5a1bc96c3b058fca479d932737583761f051d293f242e9ff5

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page