Skip to content

Instantly share code, notes, and snippets.

View adtzlr's full-sized avatar
📝
You'll never know when the idea kicks in.

Andreas Dutzler adtzlr

📝
You'll never know when the idea kicks in.
View GitHub Profile
@adtzlr
adtzlr / minimal-fea-3d_alternative.py
Created December 15, 2023 08:44
3D Finite Element Analysis in 100 Lines of Python Code (Alternative Assembly)
import numpy as np
from types import SimpleNamespace as SN
from scipy.sparse import csr_matrix as sparse
from scipy.sparse.linalg import spsolve
import meshio
def Mesh(npoints, a=0, b=1):
grid = np.linspace(a, b, npoints)
points = np.pad(grid[:, None], ((0, 0), (0, 2)))
cells = np.arange(npoints).repeat(2)[1:-1].reshape(-1, 2)
@adtzlr
adtzlr / minimal-fea-3d-hyperelastic.py
Last active December 17, 2023 21:35
3D Hyperelastic Finite Element Analysis in 150 Lines of Python Code
import numpy as np
from types import SimpleNamespace as SN
from scipy.sparse import csr_matrix
from scipy.sparse.linalg import spsolve
import matplotlib.pyplot as plt
def Cube(a=(0, 0, 0), b=(1, 1, 1), n=(2, 2, 2)):
grid = np.linspace(a[0], b[0], n[0])
points = np.pad(grid[:, None], ((0, 0), (0, 2)))
@adtzlr
adtzlr / minimal-fea-3d.py
Created December 13, 2023 09:19
3D Finite Element Analysis in 100 Lines of Python Code
import numpy as np
from types import SimpleNamespace as SN
from scipy.sparse import csr_matrix as sparse
from scipy.sparse.linalg import spsolve
import meshio
def Mesh(npoints, a=0, b=1):
grid = np.linspace(a, b, npoints)
points = np.pad(grid[:, None], ((0, 0), (0, 2)))
cells = np.arange(npoints).repeat(2)[1:-1].reshape(-1, 2)
@adtzlr
adtzlr / minimal-fea-1d.py
Created December 8, 2023 23:47
1D Finite Element Analysis in 100 Lines of Python Code
import numpy as np
from types import SimpleNamespace as SN
from scipy.sparse import csr_array as sparray
from scipy.sparse.linalg import spsolve
import matplotlib.pyplot as plt
def Mesh(npoints):
points = np.linspace(0, 1, npoints)
cells = np.arange(len(points)).repeat(2)[1:-1].reshape(-1, 2)
@adtzlr
adtzlr / conical-spring.bdf
Created October 7, 2021 07:16
mesh of a conical spring
$
BEGIN BULK
$
$ ELEMENT CONNECTIVITY =========================================================
$
CQUAD4 1 1 5 1 478 477
CQUAD4 2 1 477 478 72 57
CQUAD4 3 1 57 72 480 479
CQUAD4 4 1 479 480 73 58
CQUAD4 5 1 58 73 482 481