Planar stationary heat problem¶

Open In Colab Binder

Compute the stationary temperature distribution in a planar problem.

In [1]:
import matplotlib.pyplot as plt
import torch

from torchfem.data import get_data
from torchfem.io import import_mesh
from torchfem.materials import IsotropicConductivity2D
from torchfem.planar import PlanarHeat

# Set default data type to double precision
torch.set_default_dtype(torch.float64)

# Dimensions (thickness of plate t and edge length L)
t = 0.01
L = 0.2

Static heat equation on planar domain¶

In [2]:
# Material model
material = IsotropicConductivity2D(kappa=1000.0)

# Import mesh
mesh = import_mesh(get_data("plate_hole.vtk"), material)

plate = PlanarHeat(mesh.nodes, mesh.elements, material)
plate.thickness[:] = t

# Fixed boundary at left end
left = plate.nodes[:, 0] < 1e-6
plate.constraints[left] = True
plate.displacements[left, 0] = 10.0

# Load at right end
right = plate.nodes[:, 0] > L - 1e-6
plate.constraints[right] = True
plate.displacements[right, 0] = 20.0

# Solve
temp, rfl, hf, temp_grad, _ = plate.solve(verbose=True)
─── torch-fem · solve ──────────────────────────────────────────────────────────────────
 model    PlanarHeat · 790 elem · 451 dof · float64
 machine  AMD EPYC 7763 64-Core Processor · 2 threads · 16 GB RAM
 solver   spsolve · direct · scipy · cpu
 newton   rtol 1e-08 · atol 1e-06 · ≤10 it
────────────────────────────────────────────────────────────────────────────────────────
   Increment   Load factor      Steps  Iterations         Residual   Wall time
           1             1          1           1         1.82e-12      0.01 s
────────────────────────────────────────────────────────────────────────────────────────
 converged · 1 increment · 1 iteration · 0.01 s
In [3]:
fig, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2, 2, figsize=(10, 10))

plate.plot(
    node_property=temp,
    cmap="magma",
    title="Temperature",
    ax=ax1,
)
plate.plot(
    node_property=rfl,
    cmap="coolwarm",
    title="Surface heat flux",
    ax=ax2,
)
plate.plot(
    element_property=-hf,
    cmap="coolwarm",
    title="Heat flux",
    color="lightgray",
    ax=ax3,
)
plate.plot(
    element_property=temp_grad,
    title="Temperature Gradient",
    ax=ax4,
    cmap="viridis",
    color="lightgray",
)
plt.tight_layout()
plt.show()
No description has been provided for this image