ncSileSiesta

class sisl.io.siesta.ncSileSiesta(filename, mode='r', lvl=0, access=1, *args, **kwargs)[source]

Generic NetCDF output file containing a large variety of information

Attributes

base_file

File of the current Sile

file

File of the current Sile

Methods

__init__(self, filename[, mode, lvl, access])

Initialize self.

close(self)

dir_file(self[, filename])

File of the current Sile

exist(self)

Query whether the file exists

grids(self)

Return a list of available grids in this file.

iter(self[, group, dimension, variable, …])

Iterator on all groups, variables and dimensions.

read(self, \*args, \*\*kwargs)

Generic read method which should be overloaded in child-classes

read_basis(self)

Returns a set of atoms corresponding to the basis-sets in the nc file

read_density_matrix(self, \*\*kwargs)

Returns a density matrix from the underlying NetCDF file

read_dynamical_matrix(self, \*\*kwargs)

Returns a dynamical matrix from the underlying NetCDF file

read_energy_density_matrix(self, \*\*kwargs)

Returns energy density matrix from the underlying NetCDF file

read_force(self)

Returns a vector with final forces contained.

read_force_constant(self)

Reads the force-constant stored in the nc file

read_geometry(self)

Returns Geometry object from a Siesta.nc file

read_grid(self, name[, spin])

Reads a grid in the current Siesta.nc file

read_hamiltonian(self, \*\*kwargs)

Returns a Hamiltonian from the underlying NetCDF file

read_overlap(self, \*\*kwargs)

Returns a overlap matrix from the underlying NetCDF file

read_supercell(self)

Returns a SuperCell object from a Siesta.nc file

read_supercell_nsc(self)

Returns number of supercell connections

write(self, \*args, \*\*kwargs)

Generic write method which should be overloaded in child-classes

write_basis(self, atom)

Write the current atoms orbitals as the basis

write_density_matrix(self, DM, \*\*kwargs)

Writes density matrix model to file

write_dynamical_matrix(self, D, \*\*kwargs)

Writes dynamical matrix model to file

write_energy_density_matrix(self, EDM, …)

Writes energy density matrix model to file

write_geometry(self, geom)

Creates the NetCDF file and writes the geometry information

write_hamiltonian(self, H, \*\*kwargs)

Writes Hamiltonian model to file

write_overlap(self, \*\*kwargs)

Write the overlap matrix to the NetCDF file

property base_file

File of the current Sile

close(self)
dir_file(self, filename=None)

File of the current Sile

exist(self)

Query whether the file exists

property file

File of the current Sile

grids(self)[source]

Return a list of available grids in this file.

iter(self, group=True, dimension=True, variable=True, levels=-1, root=None)

Iterator on all groups, variables and dimensions.

This iterator iterates through all groups, variables and dimensions in the Dataset

The generator sequence will _always_ be:

  1. Group

  2. Dimensions in group

  3. Variables in group

As the dimensions are generated before the variables it is possible to copy groups, dimensions, and then variables such that one always ensures correct dependencies in the generation of a new SileCDF.

Parameters
groupbool (True)

whether the iterator yields Group instances

dimensionbool (True)

whether the iterator yields Dimension instances

variablebool (True)

whether the iterator yields Variable instances

levelsint (-1)

number of levels to traverse, with respect to root variable, i.e. number of sub-groups this iterator will return.

rootstr (None)

the base root to start iterating from.

Examples

Script for looping and checking each instance.

>>> for gv in self.iter():
...     if self.isGroup(gv):
...         # is group
...     elif self.isDimension(gv):
...         # is dimension
...     elif self.isVariable(gv):
...         # is variable
read(self, *args, **kwargs)

Generic read method which should be overloaded in child-classes

Parameters
kwargs :

keyword arguments will try and search for the attribute read_<> and call it with the remaining **kwargs as arguments.

read_basis(self)[source]

Returns a set of atoms corresponding to the basis-sets in the nc file

read_density_matrix(self, **kwargs)[source]

Returns a density matrix from the underlying NetCDF file

read_dynamical_matrix(self, **kwargs)[source]

Returns a dynamical matrix from the underlying NetCDF file

This assumes that the dynamical matrix is stored in the field “H” as would the Hamiltonian. This is counter-intuitive but is required when using PHtrans.

read_energy_density_matrix(self, **kwargs)[source]

Returns energy density matrix from the underlying NetCDF file

read_force(self)[source]

Returns a vector with final forces contained.

read_force_constant(self)[source]

Reads the force-constant stored in the nc file

Returns
force constantsnumpy.ndarray with 5 dimensions containing all the forces. The 2nd dimensions contains

contains the directions, and 3rd dimensions contains -/+ displacements.

read_geometry(self)[source]

Returns Geometry object from a Siesta.nc file

read_grid(self, name, spin=0)[source]

Reads a grid in the current Siesta.nc file

Enables the reading and processing of the grids created by Siesta

Parameters
namestr

name of the grid variable to read

spinint or array_like, optional

the spin-index for retrieving one of the components. If a vector is passed it refers to the fraction per indexed component. I.e. [0.5, 0.5] will return sum of half the first two components. Default to the first component.

read_hamiltonian(self, **kwargs)[source]

Returns a Hamiltonian from the underlying NetCDF file

read_overlap(self, **kwargs)[source]

Returns a overlap matrix from the underlying NetCDF file

read_supercell(self)[source]

Returns a SuperCell object from a Siesta.nc file

read_supercell_nsc(self)[source]

Returns number of supercell connections

write(self, *args, **kwargs)

Generic write method which should be overloaded in child-classes

Parameters
**kwargs :

keyword arguments will try and search for the attribute write_ and call it with the remaining **kwargs as arguments.

write_basis(self, atom)[source]

Write the current atoms orbitals as the basis

Parameters
atomAtoms

atom specifications to write.

write_density_matrix(self, DM, **kwargs)[source]

Writes density matrix model to file

Parameters
DMDensityMatrix

the model to be saved in the NC file

write_dynamical_matrix(self, D, **kwargs)[source]

Writes dynamical matrix model to file

Parameters
DDynamicalMatrix

the model to be saved in the NC file

write_energy_density_matrix(self, EDM, **kwargs)[source]

Writes energy density matrix model to file

Parameters
EDMEnergyDensityMatrix

the model to be saved in the NC file

write_geometry(self, geom)[source]

Creates the NetCDF file and writes the geometry information

write_hamiltonian(self, H, **kwargs)[source]

Writes Hamiltonian model to file

Parameters
HHamiltonian

the model to be saved in the NC file

Effloat, optional

the Fermi level of the electronic structure (in eV), default to 0.

write_overlap(self, **kwargs)[source]

Write the overlap matrix to the NetCDF file