nanotools.restart module
Created on 2020-06-16
@author: Vincent Michaud-Rioux
- class nanotools.restart.Restart(densityPath: str = '', DMkPath: str = '', DMRPath: str = '', HkPath: str = '', HRPath: str = '', ground_state_density_return: bool = True, partial_core_density_return: bool = True, neutral_atom_density_return: bool = True, potential_return: bool = True)[source]
Bases:
BaseRestartclass.The
restartclass gathers the paths of files containing previously calculated results, which can be used for restart.By default, the density is saved upon completing a ground state calculation. The
densityPathfield is then updated to point to the results. Any kind of restart will then automatically import the density given indensityPath. If the ground state density is not found indensityPaththen the code ignores it and proceeds without restart.If
DMkPathorDMRPathis set, then the k-space or real space density matrix is saved to the specified path. Next, a calculation can be restarted from either density matrix. If the ground state density matrix is not found then the code ignores it and proceeds without restart. Attention: ifDMkPathorDMRPathis set, the ground state density is no longer saved in the output file.If several attributes have valid restart data, then the precedence goes as follows:
densityPath,DMkPath,DMRPath.Example:
from nanotools import Atoms, Cell, Kpoint, System, TotalEnergy a = 2.818 # lattice constant (ang) cell = Cell(avec=[[0.,a,a],[a,0.,a],[a,a,0.]], resolution=0.12) fxyz = [[0.00,0.00,0.00],[0.25,0.25,0.25]] atoms = Atoms(fractional_positions=fxyz, formula="GaAs") sys = System(cell=cell, atoms=atoms) sys.kpoint.set_grid([5,5,5]) calc = TotalEnergy(sys) calc.solver.set_mpi_command(mpi="mpiexec -n 4") calccpy = calc.copy() # SCF calc.solve() # Restart from density (and save density automatically) calc = calccpy.copy() calc.solver.mix.maxit = 1 calc.solver.restart.densityPath = "nano_scf_out.h5" calc.solve() # Restart from density and save k-space density matrix calc = calccpy.copy() calc.solver.mix.maxit = 1 calc.solver.restart.densityPath = "nano_scf_out.h5" calc.solver.restart.DMkPath = "nano_scf_out.h5" calc.solve() # Restart from k-space density matrix and save real space density matrix calc = calccpy.copy() calc.solver.mix.maxit = 1 calc.solver.restart.DMkPath = "nano_scf_out.h5" calc.solver.restart.DMRPath = "nano_scf_out.h5" calc.solve() # Restart from real space density matrix calc = calccpy.copy() calc.solver.mix.maxit = 1 calc.solver.restart.DMRPath = "nano_scf_out.h5" calc.solve()
Attributes:
- densityPath (string):
Path to an HDF5 file. The group
/density/groundstatewill be read and used as an initial guess. Examples:restart.densityPath = "/path/to/hdf5/file"
- DMkPath (string):
Path to an HDF5 file. The group
/aomtrx/DMk, containing the k-space density matrix, will be read and used as an initial guess. Examples:restart.DMkPath = "/path/to/hdf5/file"
- DMRPath (string):
Path to an HDF5 file. The group
/aomtrx/DMR, containing the real space density matrix, will be read and used as an initial guess. Examples:restart.DMRPath = "/path/to/hdf5/file"
- HkPath (string):
Path to an HDF5 file. The group
/hamiltonian, containing the Gamma - point hamiltonian and orbital-overlap matrix. Examples:restart.HkPath = "/path/to/hdf5/file"
- HRPath (string):
Path to an HDF5 file. The group
/hamiltonian, containing the real space hamiltonian and orbital-overlap matrix. Examples:restart.HRPath = "/path/to/hdf5/file"
- ground_state_density_return (bool):
Save the ground state density to
densityPathif True, and do not save otherwise.- partial_core_density_return (bool):
Save the partial core density to
densityPathif True, and do not save otherwise.- neutral_atom_density_return (bool):
Save the neutral atom density to
densityPathif True, and do not save otherwise.- potential_return (bool):
Save the potential to
densityPathif True, and do not save otherwise.