Wall heat conduction example#

This example creates and simulates stationary heat conduction through a wall with two materials. It utilizes the geometric Nodes, which enables visualizing the network using VPython or ParaView. The case uses only one dimension (x-axis), so each y and z delta value is set to 1. Currently, sphinx-gallery (which is used to create the examples html pages) don’t let you manually add figures to the example, so you need to run the code yourself to see the result.

# sphinx_gallery_tags = ["network","solving","build", "stationary", "geometric"]
# sphinx_gallery_thumbnail_path = "_static/examples/wall_heat_conduction.svg"

import os.path

from pyrc import FluidBoundaryConditionCell, Node, connect_cells_with_resistors, RCNetwork, Cell
from pyrc.core.materials import SandLimeBrick, EPS032
from pyrc.visualization.plot import LinePlot

Create the boundary conditions#

One warm, one cold. The position of the cold boundary condition is adjusted later on.

bc_warm = FluidBoundaryConditionCell(20, position=(-0.5, 0, 0), delta=(1, 1, 1), heat_transfer_coefficient=5)
bc_cold = FluidBoundaryConditionCell(-4, position=(1, 0, 0), delta=(1, 1, 1), heat_transfer_coefficient=8)

Create the wall out of two materials#

The Wall is made of sand lime brick with 240 mm width and some heat insulation (ESP032) with 150 mm width. Each material gets two nodes per 10 mm. Because the grid is returned in a three dimensional array, we flatten it before filling it in the capacitors list.

capacitors: list[Node] = [
    *Node.create_grid(grid_size=(48, 1, 1), delta=(0.24, 1, 1), material=SandLimeBrick(), temperature=18.325).flat,
    *Node.create_grid(grid_size=(30, 1, 1), delta=(0.15, 1, 1), material=EPS032(), temperature=5).flat,
]

Place the nodes adjacent to each other#

bc_warm.place_adjacent(capacitors[0], "x")
for i, capacitor in enumerate(capacitors[:-1]):
    capacitor.place_adjacent(capacitors[i + 1], "x")
capacitors[-1].place_adjacent(bc_cold, "x")

Add resistors between the nodes#

resistors = connect_cells_with_resistors([*capacitors, bc_warm, bc_cold])

Add the objects (Capacitors, Resistors, BCs) to an RCNetwork object#

The RCNetwork class is used to solve the RC network. It just needs all the building parts in its RCObject.

network = RCNetwork(load_from_pickle=False, load_solution=False)
network.rc_objects.set_lists(capacitors=capacitors, resistors=resistors, boundaries=[bc_warm, bc_cold])

Solve network.#

We solve the network stationary, which is done analytically. This is fast and mathematically “perfect”.

network.solve_stationary()

Plot heat conduction over wall width#

positions_in_cm = [c.position[0] * 100 for c in capacitors]

plot = LinePlot(x=positions_in_cm, ys=network.rc_solution.y[-1], y_title="Temperature / °C", x_title="Wall Width / cm")
plot.plot()
plot.show()

Parse the result to show it in ParaView#

Open the case in ParaView using the 00_simulation.pvd file

network.rc_solution.write_paraview_data(
    folder=os.path.normpath(r"/path/to/result/folder"),
    use_degrees_celsius=False,  # temperature is already in °C
)

The resulting diagram looks like this:

../_images/wall_heat_conduction_result.svg

It doesn’t fit the boundary temperatures because of the assumed heat transfer coefficient between the ambient fluid and the wall. So this is actually correct.

🏷 Tags: network, solving, build, stationary, geometric

Gallery generated by Sphinx-Gallery