# Residuals¶

Note

The residuals specified in the input file are numbers defining accuracy of the simulation; we refer to them further as the desired residuals. The convergence process is terminated when all the residuals reach the values of the desired residuals or lower. Reaching lower values of the residuals provides more accurate solution, however, at expense of longer runtime.

The evolution of residuals is stored in real-time of the simulation run in files iteration_current_poisson.dat or iteration_quantum_current_poisson.dat. They can be directly monitored in nextnanomat during the simulation.

Our suggestion is to begin simulations using the default values, defined according to the dimensionality of the simulation domain. To obtain a compromise between the accuracy of the solutions and the simulation time, one can adjust the desired residuals.

## Quasi-Fermi Levels¶

The residuals of each quasi-Fermi level are computed as a maximum norm of the difference of values obtained in two consecutive iterations at every grid point. Therefore, this value directly corresponds to the highest local change of the quasi-Fermi levels in the simulated structure after each iteration of our algorithm.

The desired residual for the quasi-Fermi levels in the input file can be specified by assigning a value to the variable residual_fermi within the group run{}.

Once having the simulation done, the accuracy of the solution can be estimated by investigating the file bandedges.dat where both quasi-Fermi levels are outputted. Changes of the levels and related changes of the carrier concentrations, especially in the region of interest of the modeled structure, can be used to decide whether the simulation reached the desired accuracy or it should be refined.

## Carrier Densities¶

The residuals of each carrier densities are computed as a one norm of the difference of values of the carrier densities (multiplied by volumes assigned to each grid point) obtained in consecutive iterations at every grid point. Therefore, this value corresponds to a cumulative change of entire carrier distributions between two consecutive iterations. In other words, it is an integrated absolute value of a difference of carrier distributions computed in two consecutive iterations.

The desired value for the residuals of the densities can be specified in the input file using a variable residual within the section run{}.

In order to evaluate the accuracy of the solutions for your needs, it is convenient to verify the final densities and charges in the output files:

• density_electron.dat

• density_holes.dat

• total_charges.txt

Changes of orders of magnitude of integrated carriers in various important regions of the simulation should be taken into account based on these files to decide if more accurate solutions are required by reducing the respective residuals.

## Electric Potential¶

The residual for potential is computed in the exact same way as for the quasi-Fermi levels. It is computed as a maximum norm of the differences of values obtained in consecutive iterations at every grid point. Therefore, this value directly corresponds to the highest change of the electric potential after each iteration of our algorithm.

The desired value for the residual of the electric potential is only available internally in the code and is well controlled by the algorithm.

It is recommended to see the file potential.dat to estimate the accuracy of the computed electrostatic potential.

## Self-Consistent Simulations¶

The guidelines described above should be treated as a basic example aiming at developing intuition and understanding of how the simulation behaves from the numerical point of view. As all the residuals are interdependent in a specific way, it is important to have at least basic understanding of the dependencies between currents, carrier concentrations, electrostatic potential, and quasi-Fermi levels for the structure design of the interest for every simulation run, especially within a self-consistent algorithm.