Skip to content
Snippets Groups Projects
Commit a1c3a648 authored by Boman Romain's avatar Boman Romain
Browse files

add principal strain extraction script

parent 52bc0067
Branches devel/bb2024
No related tags found
No related merge requests found
Pipeline #53773 passed
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
#
# extract principal strains from results
# (run this script in the workspace folder)
import gmsh
import numpy as np
gmsh.initialize()
gmsh.merge('mesh.msh')
gmsh.merge('smooth_strain_tensor.msh')
dataType, tags, data, time, numComp = gmsh.view.getModelData(1, 0)
# compute the 3 principal strains from nodal strain tensor
e1s = []
e2s = []
e3s = []
for epl in data:
[xx, xy, xz, yx, yy, yz, zx, zy, zz] = epl
# compute the 3 principal strains
epl = np.array([[xx, xy, xz], [yx, yy, yz], [zx, zy, zz]])
eigvals = np.linalg.eigvals(epl)
eigvals = np.sort(eigvals)
e1s.append(eigvals[0])
e2s.append(eigvals[1])
e3s.append(eigvals[2])
e1s = np.array(e1s)
e2s = np.array(e2s)
e3s = np.array(e3s)
# display min of lowest principal strain and max of highest principal strain
print(f'e1_min = {np.min(e1s)}')
print(f'e3_max = {np.max(e3s)}')
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment