nanotools.totalenergy module

Created on 2020-05-11

@author: Vincent Michaud-Rioux

class nanotools.totalenergy.TotalEnergy(system, energy=NOTHING, solver=NOTHING, classname: str = NOTHING)[source]

Bases: Base

TotalEnergy class.

Examples:

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.solve()
print(calc.energy.etot)
system

Object containing system related parameters.

Type:

nanotools.system.System

energy

Object containing the total energy and its derivatives (force, stress, etc.).

Type:

nanotools.energy.Energy

solver

Object containing solver related parameters.

Type:

nanotools.solver.Solver

get_average_field(field, axis)[source]

Loads field from self.solver.restart.densityPath and compute the average along a given axis.

Parameters:
  • field (str/NDArray) – str: HDF5 path. For example, “potential/effective”. NDArray: 3d array.

  • axis (int) – Axis remaining after averaging. The value should be between 0 and 2.

Returns:

Average field.

Return type:

NDArray

get_field(field)[source]

Loads field from self.solver.restart.densityPath.

get_magnetic_moments()[source]

Returns the magnetic moments.

get_number_of_atoms()[source]

Returns the number of atoms.

get_potential(name, units='si')[source]

Returns the number of atoms.

Parameters:
  • name (string) – Path to the HDF5 file containing the potential data.

  • units (string, optional) – Unit of energy for the potential.

get_total_energy()[source]

Returns the total energy.

get_total_energy_per_atom()[source]

Returns the total energy per atom.

get_total_magnetic_moment()[source]

Returns the total magnetic moment.

plot_field(field, axis, filename=None, show=True)[source]

Plots a field averaged along a given axis.

Parameters:
  • field (str) – Path in the HDF5 filed pointed to by self.solver.restart.densityPath.

  • axis (int) – Axis remaining after averaging. The value should be between 0 and 2.

  • filename (str, optional) – If not None, then the figure is saved to filename.

  • show (bool, optional) – If True block and show figure. If False, do not show figure.

Returns:

A figure handle.

Return type:

fig (matplotlib.figure.Figure)

smooth_field(field, axis, width=2.0, shape='erf')[source]

Smooths a field by circular convolution.

Parameters:
  • field (str/NDArray) – str: Path in the HDF5 filed pointed to by self.solver.restart.density. For example, “potential/effective”. NDArray: 3d array.

  • axis (int) – Axis remaining after averaging. The value should be between 0 and 2.

  • width (float) – Unit system (‘atomic’ or ‘si’)

solve(input='nano_scf_in', output='nano_scf_out')[source]

Performs a self-consistent calculation to obtain the ground state total energy.

Parameters:
  • input (str) – The object is saved to an input file input to be read by the Fortran program.

  • output (str) – The results (with various extensions) are moved to files output and the results are loaded to the object.

supercell(T)[source]

Replaces the underlying System object with a supercell System object.

Parameters:

T (NDArray) – A (3x3) linear transformation.

Returns: