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

# 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
plate = import_mesh(get_data("plate_hole.vtk"), material, thickness=t)

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

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

# Solve
temp, rfl, hf, temp_grad, _ = plate.solve(verbose=True)
----------------------------------------------------------------------------------------
 model    PlanarHeat | 790 elem | 451 dof | float64
 machine  AMD EPYC 9V74 80-Core Processor | 2 threads | 16 GB RAM
 solver   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.75e-12      0.00 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="white",
    edgecolor="lightgray",
    ax=ax3,
)
plate.plot(
    element_property=temp_grad,
    title="Temperature Gradient",
    ax=ax4,
    cmap="viridis",
    color="white",
    edgecolor="lightgray",
)
plt.tight_layout()
plt.show()
No description has been provided for this image