# Algorithm

General flow of the simulation

The algorithm runs the simulations step-by-step and phonon-by-phonon. For each phonon, the algorithm calculates a trajectory, with a time step *dt* and for as many time steps as required for the phonon to reach the cold side or until a maximum number of time steps is reached.

### Initialization

At the beginning of time, each phonon is generated at the hot side. Each phonon is assigned a frequency (wavelength) and the direction according to the source type. The frequency is assigned according to the Plank distribution of phonon frequencies at this temperature (*T*). See the picture on the main page for the example of the Plank distribution function. From the assigned frequency, the algorithm determines the phonon group velocity (*v*) from the phonon dispersion in the given material. If more than one polarization branch is available at this frequency, it is chosen randomly.

The phonon starts moving step-by-step in the assigned direction according to the following equations:

where θ is the angle between the projection to *x-y* plane and *y*-axis, and ψ is the angle to the horizontal plane, *v* is the speed, and *dt* is the time step.

### Scattering on boundaries

At each time step *dt*, the algorithm checks if phonon crossed any of the boundaries. The boundaries include the top and bottom of the simulation, left and right walls, or walls of the holes or pillars. If the boundary is crossed, the corresponding function calculates at which angle *a* phonon hits the boundary. Then, the algorithm calculates the specular scattering probability, determined by Soffer's equation:

where *p* is the specularity probability (number between zero and one), σ is the surface roughness, α is the angle to the surface, and λ is the wavelength of the phonon. Then the algorithm draws a random number between zero and one. If the number is greater than p than the scattering is diffuse, otherwise specular. If the scattering is specular, the phonon is reflected elastically, from the surface. If the scattering is diffuse, the phonon is reflected in a random direction, but using the Lambert cosine distribution of probability. After the scattering, the phonon continues the movement and keeps moving and being scattered until it either reaches the cold side, or returns to the hot side, or the time of the simulation for each phonon is over.

### Internal scattering

Besides the surface scattering, phonon can also experience internal scattering. The internal scattering means all scattering processes like impurity scattering, phonon-phonon scattering (including Normal and Umklapp scatterings). In the simulation, this kind of scattering programmed to occur when a certain time (relaxation time) passed since the last scattering of any kind. In other words, if phonon runs for too long without any scatterings, it's getting more and more likely to be scattered due to the phonon-phonon process. The relaxation time is calculated depending on the phonon frequency, temperature, and polarization.

### Distributions and statistics

Once the simulation is over for a given phonon, the algorithm collects all the phonon properties (frequency, speed, path etc.), its entrance and exit angles, and other results and stores it in files. Then, the process repeats for the required number of phonons. After simulations for all phonons are done, the algorithm calculates various distributions and statistical facts about the simulation. For example, it calculates phonon spectrum at the beginning, phonon trajectories, phonon exit angle distribution, group velocities etc. The examples of the distribution are shown above in the picture. Then, it outputs all this information into the graphs and into .csv files. Examples below show scattering maps and statistics obtained using the Monte Carlo code for a serpentine nanowire.

Last updated