MecSimCalc
ExploreSearchCreateDocsCommunityBlogPricing
    Apps

    Starred
    Go to app
    App Docs

Documentation of how to use 2D Heat Equation Visualizer

The 2D Heat Equation

The unsteady heat equation is a partial differential equation that describes the distribution of heat in a bulk material over time and solving it results in the temperature distribution to be calculated. The equation itself consist of a first derivative in time and second derivatives in space, one for each dimension considered. In the 2D case, the equation is written as follows:

Tt=α[2Tx2+2Ty2]\frac{\partial T}{\partial t} = \alpha \left[ \frac{\partial^2 T}{\partial x^2} + \frac{\partial^2 T}{\partial y^2} \right]

where:

T=T = temperature [C][^{\circ}C]

t=t = time [s][s]

α=\alpha = thermal diffusivity coefficient [m2/s][m^2/s]

x=x = first spatial dimension [m][m]

y=y = second spatial dimension [m][m]

The heat equation can also include source terms of the form, f(t,x,y)f(t, x, y), but these have not been included in this app for simplicity.


As the heat equation is a parabolic partial differential equation, no matter how many spatial dimensions are considered, it can be solved using the Forward Time Centered Space (FTCS) method. This is a conditionally stable method, and so the time step must be below a certain value to achieve a stable solution. The maximum time step can be calculated as: time step size(spatial step size)24αtime\ step\ size \leq \frac{(spatial\ step\ size)^2}{4 \alpha}.


It is important to note for the operation of this app that the solution can take some time to be calculated, and if the time is too great, the calculation will not be completed. To reduce the calculation time, decrease the number of spatial steps, or the number of pixels in the image used for the domain size and initial condition, or increase the time step size. As mentioned above, the time step has a maximum value based on the spatial step size, which is set in this app by the "pixel to distance conversion factor". Decreasing the number of time or spatial steps will also decrease the calculation time and this app generally works best if the input image contains less than about 100x100 pixels.


Inputs

Multiple inputs are required to run a simulation in this app, which are explained below. All inputs are provided with default values expect for the domain size & initial condition image, as the user must upload an image themselves, however and example image is provided.


Thermal Diffusivity

Thermal diffusivity is defined as: α=kρcp\alpha = \frac{k}{\rho c_p}, where kk is thermal conductivity in units of Wm,C\frac{W}{m, ^{\circ}C}, ρ\rho is density in units of frackgm3frac{kg}{m^3}, and cpc_p is specific heat capacity in units of Jkg,C\frac{J}{kg, ^{\circ}C}. It is a measure of the speed at which heat travels through a material, and can be though of as a measure of the material's "thermal inertia". Thermal diffusivity has units of m2s\frac{m^2}{s}.


Generally, as the domain size increases, the thermal diffusivity should also be increased in order to see a significant change in the results in a reasonable amount of time. By default, thermal diffusivity is set to a value of 1, which should be good for domains about 100 by 100 spatial steps (or 100 by 100 pixels for the input image).


Domain Size and Initial Conditions

The domain size as well as the size of steps in space are set using the input image in conjunction with the input "pixels to distance conversion factor". This conversion factor scales the image up using scipy.ndimage.interpolation.zoom() to effectively refine the spatial mesh at the cost of computational power. As this conversion factor must be 1\geq 1, the spatial mesh can only be refined, not coarsened.


An initial condition is also required to set the initial temperature of each point in the spatial domain. This is set in this app using the same input image as is used for the domain size. The initial temperature of the points are set based on how darks the pixels in the input image are. On a technical level, each pixel in a digital image can be represented by 3 integers denoting "Hue", "Saturation", and "Value" or HSV, similarly to how pixels can be represented by Red, Green, and Blue values. The "Value" of HSV is a measure of how dark a pixel is. This app extracts the "Value" of each pixel in the image, setting black pixels (Value = 0) to the maximum temperature and pixels with Value = 1 to the minimum temperature, both also set as inputs.


For the best results in creating your own domain & initial conditions, begin with a white canvas in any image editing program, set its size in pixels, draw the desired initial condition in grayscale, and save the image as a .png or .jpg file. If making your own initial condition images, it is preferable to save them as .png files as .jpg compression can alter the color values of some of the pixels in the image.


Boundary Conditions

Four boundary conditions (BCs) are required as the 2D heat equation contains two second derivative in space. These can be set to either be a constant temperature (Dirichlet BC) or a constant temperature flux (Neumann BC). Constant temperature boundary conditions simply set the temperature at the edges of the domain to the user-defined value. Constant flux boundary conditions will act as a "mirror" if the user input value is set to 0, effectively allowing symmetrical geometries to be cut in half or quarters, reducing the number of spatial points required in the calculation, and so also reducing calculation time. If a temperature flux BC is set to a non-zero value, designated here as "nn", it will act as though nC/sn^{\circ}C/s is passing though that boundary. The direction of this flux will be from the higher value to the lower, which in practice means that the flux will be negative for the boundaries at x=0 and y=0, and positive for the boundaries at x=max and y=max.


For corner points, if 2 of the same BCs meet, the average of the two set temperatures or set fluxes will be calculated and used. If a Dirichlet and Neumann BC meet, the Dirichlet BC will take priority.


In theory, both types of BCs discussed here can also be functions of time, and both types can be applied to a boundary at the same time, but these aspects have been omitted from this app for simplicity.


Simulation Time

Any amount of time (>0>0 seconds) can be set as the simulation time. Increasing the simulation time will also increase the computation time, and if it takes too long, the app will timeout and no results will be produced. Increasing the time step will have the opposite result, but because the FTCS method is conditionally stable, decreasing the time step too much will result in an unstable solution. To prevent this, ensure that time step(spatial step)24αtime\ step \leq \frac{(spatial\ step)^2}{4 \alpha}. In the context of this app, spatial step=pixel to distance conversion factorspatial\ step = pixel\ to\ distance\ conversion\ factor.


Outputs

This app outputs contour plots of the temperature distribution over the domain. The number of output plots is provided as an input with a minimum value of 2. The output plots are evenly spaced across the time domain, with the first always at t=0st=0\, s and the last always at t=tmaxst=t_{max}\, s.

Similar apps:
Engineering
Computer Science
Featured
Math
Mechanical Engineering
Numerical Analysis

Copyright © MecSimCalc 2024
Terms | Privacy