(SP4E 2018, Homework 3)<br/> Authors: Sajjad Azimi, Alessia Ferraro
The main.cc program is written to construct and solve a physical problems related to system of particles. In this specific case the goal is to solve the 2-dimensional heat equation to describe the variation of temperature over time when a source term is present. The primitive equation is solved via a pseudo-spectral method, making use of finite differences in time and spectral discretization in space with Fourier expansion in x and y directions.
The relevant classes for the implementation are the followings:
- MaterialPoint: Class derived from Particles, containing spatially located virtual massless particles that carry a temperature and a heat transfer coefficient.
- MaterialPointFactory: Class responsible for the creation of the specific simulation that solves the heat transfer equation. It derives from the ParticleFactory interface and builds the system with the suitable type of particles and solver.
- Matrix: Storage Class for the temperature and the heat-transfer values of each particles in the domain. Each element (i,j) represents a position in the physical space with the corresponding values of these scalar quantities.
- FFT: Wrapping interface for FFTW. Class responsible to compute forward and backward DFT for input matrices.
- ComputeTemperature: Solver class responsible for the time integration of the heat equation. At each time-step the right-hand side (spatial derivatives and source term) is evaluated in the Fourier space, then transformed back to the physical space and used to update the Temperature distrubutions for the next iteration. Although a stationary source term does not require to be evolved in time (and to be computed in the spectral space at each time step) we decided to keep a general structure as much as possible in order to allow for future implementation of routines to handle with time-dependent source terms. <br/>
The python script TH_gen.py generates the initial conditions for the temperature and heat source terms in a given domain as follow:
- Heat-rate is uniformly distributed within a circular portion of radius R of the simulation box and zero elsewhere
- Temperature can be homogeneously zero or follow a multivariate Gaussian distribution with given mean and covariance values.<br/>
For both the scalar quantities parameters are set in order to satisfy zero homogeneous boundary conditions.<br/> The output is then saved to a .txt file containing as many rows as grid points and 12 columns ( x, y, z, vx, vy, vz, Fx, Fy, Fz, m, T, h )
<center><img src="initTH.png" alt="initTH" width="500"/></center>
Zero boundary conditions are enforced in the physical space after the computation of the new temperature and heat-rate fields. A class to handle the boundary condition is derived from compute and is added as a new compute to the list of computes of systemevolution. After updating the temperature distribution by computeTemperature class, the zero temperature boundary conditions are taken care of in computeTemperatureBoundary class. Because of the spatial periodicity of FFT this is done only on the left and bottom boundaries.
Four unit tests are written to validate the FFT functions including one test for forward transform, one test for backward transform and two tests for computeFrequencies. Two unit tests with appropriate fixtures are written in a file called test_computeTemperature.cc to validate the computeTemperature class. One of these tests checks that for a uniform distribution of temperature without heat source the temperature does not change (sujet 4.2). The second unit test is to check that the temperature of a system with a point source and a point sink reaches a steady state with broken linear shape (sujet 4.3). The second test takes almost 10 seconds.
There are two ways to visualize the result of the simulation: 1- With x and y positions and temperature as the third coordinate of the points to get a 3d surface of the temperature distribution. 2- With x and y positions and temperature as a measure for the colors of the particles to have a 2d distribution of the points in a contour-like figure.
Because of the modular structure of the project, the work was naturally divided between the two authors as follows:
- Alessia Ferraro: Implementation of the ComputeTemperature class and related functions in the Matrix class, Python script to generate initial conditions for Temperature and Heat-rate.
- Sajjad Azimi: Implementation of the FFT interface, implementation of the computeTemperatureBoundary and implementation of the validating unit tests.