Cubes with inelastic volume strains¶
All unit cubes are subjected to an inelastic (e.g. thermal) strain, while being fixed in one direction and allowing shrinkage in the two transverse directions.
In [1]:
import torch
from torchfem import Solid
from torchfem.materials import IsotropicElasticity3D
from torchfem.mesh import cube_hexa, cube_tetra
torch.set_default_dtype(torch.float64)
# Elastic material model
material = IsotropicElasticity3D(E=1000.0, nu=0.3)
3D Cube with linear hexahedrons and inelastic (e.g. thermal) strain¶
In [2]:
# Generate cube
nodes, elements = cube_hexa(5, 5, 5)
# Create model
box = Solid(nodes, elements, material)
# Set constraints
box.constraints[:, :] = False
box.constraints[nodes[:, 0] == 0.0, 0] = True
box.constraints[nodes[:, 0] == 1.0, 0] = True
box.constraints[nodes[:, 1] == 0.5, 1] = True
box.constraints[nodes[:, 2] == 0.5, 2] = True
# Set inelastic strain (isotropic shrinkage)
s = -0.1
box.ext_strain[:, :, :] = s * torch.eye(3)
# Solve
u, f, σ, F, α = box.solve()
# Plot
box.plot(u=u, node_property={"Disp": u}, show_undeformed=True)
In [3]:
print(f"Mean stress in x is {σ[:, 0, 0].mean()}. It should be {-material.E * s}.")
Mean stress in x is 100.0. It should be 100.0.
3D Cube with linear tetrahedrons and inelastic (e.g. thermal) strain¶
In [4]:
# Generate cube
nodes, elements = cube_tetra(3, 3, 3)
# Create model
box = Solid(nodes, elements, material)
# Boundary conditions
box.constraints[nodes[:, 0] == 0.0, 0] = True
box.constraints[nodes[:, 0] == 1.0, 0] = True
box.constraints[nodes[:, 1] == 0.5, 1] = True
box.constraints[nodes[:, 2] == 0.5, 2] = True
# Set inelastic strain (isotropic shrinkage)
s = -0.1
box.ext_strain[:, :, :] = s * torch.eye(3)
# Solve
u, f, σ, ε, α = box.solve()
# Plot
box.plot(u=u, node_property={"Disp": u}, show_undeformed=True)
In [5]:
print(f"Mean stress in x is {σ[:, 0, 0].mean()}. It should be {-material.E * s}.")
Mean stress in x is 100.0. It should be 100.0.