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:
where:
temperature
time
thermal diffusivity coefficient
first spatial dimension
second spatial dimension
The heat equation can also include source terms of the form, , 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: .
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.
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 is defined as: , where is thermal conductivity in units of , is density in units of , and is specific heat capacity in units of . 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 .
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).
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 , 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.
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 "", it will act as though 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.
Any amount of time ( 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 . In the context of this app, .
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 and the last always at .
Copyright © MecSimCalc 2024
Terms | Privacy