.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples\wall_heat_conduction.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_wall_heat_conduction.py: 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. .. GENERATED FROM PYTHON SOURCE LINES 16-25 .. code-block:: Python # 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 .. GENERATED FROM PYTHON SOURCE LINES 26-30 Create the boundary conditions ------------------------------- One warm, one cold. The position of the cold boundary condition is adjusted later on. .. GENERATED FROM PYTHON SOURCE LINES 30-34 .. code-block:: Python 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) .. GENERATED FROM PYTHON SOURCE LINES 35-40 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. .. GENERATED FROM PYTHON SOURCE LINES 40-46 .. code-block:: Python 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, ] .. GENERATED FROM PYTHON SOURCE LINES 47-49 Place the nodes adjacent to each other --------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 49-55 .. code-block:: Python 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") .. GENERATED FROM PYTHON SOURCE LINES 56-58 Add resistors between the nodes -------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 58-61 .. code-block:: Python resistors = connect_cells_with_resistors([*capacitors, bc_warm, bc_cold]) .. GENERATED FROM PYTHON SOURCE LINES 62-65 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. .. GENERATED FROM PYTHON SOURCE LINES 65-69 .. code-block:: Python network = RCNetwork(load_from_pickle=False, load_solution=False) network.rc_objects.set_lists(capacitors=capacitors, resistors=resistors, boundaries=[bc_warm, bc_cold]) .. GENERATED FROM PYTHON SOURCE LINES 70-73 Solve network. -------------------------------------- We solve the network stationary, which is done analytically. This is fast and mathematically "perfect". .. GENERATED FROM PYTHON SOURCE LINES 73-75 .. code-block:: Python network.solve_stationary() .. GENERATED FROM PYTHON SOURCE LINES 76-78 Plot heat conduction over wall width ------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 78-85 .. code-block:: Python 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() .. GENERATED FROM PYTHON SOURCE LINES 86-89 Parse the result to show it in ParaView ---------------------------------------- Open the case in ParaView using the 00_simulation.pvd file .. GENERATED FROM PYTHON SOURCE LINES 89-95 .. code-block:: Python network.rc_solution.write_paraview_data( folder=os.path.normpath(r"/path/to/result/folder"), use_degrees_celsius=False, # temperature is already in °C ) .. GENERATED FROM PYTHON SOURCE LINES 96-97 The resulting diagram looks like this: .. GENERATED FROM PYTHON SOURCE LINES 99-101 .. image:: /_static/examples/wall_heat_conduction_result.svg :width: 100% .. GENERATED FROM PYTHON SOURCE LINES 103-104 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. .. rst-class:: sphx-glr-example-tags 🏷 Tags: network, solving, build, stationary, geometric .. _sphx_glr_download_auto_examples_wall_heat_conduction.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: wall_heat_conduction.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: wall_heat_conduction.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: wall_heat_conduction.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_