fdfSileSiesta

class sisl.io.siesta.fdfSileSiesta(filename, mode='r', base=None)[source]

FDF-input file

By supplying base you can reference files in other directories. By default the base is the directory given in the file name.

Parameters
filename: str

fdf file

modestr, optional

opening mode, default to read-only

basestr, optional

base-directory to read output files from.

Examples

>>> fdf = fdfSileSiesta('tmp/RUN.fdf') # reads output files in 'tmp/' folder
>>> fdf = fdfSileSiesta('tmp/RUN.fdf', base='.') # reads output files in './' folder

Attributes

base_file

File of the current Sile

file

Return the current file name (without the directory prefix)

Methods

__init__(self, filename[, mode, base])

Initialize self.

dir_file(self[, filename])

File of the current Sile

exist(self)

Query whether the file exists

get(self, label[, default, unit, with_unit])

Retrieve fdf-keyword from the file

includes(self)

Return a list of all files that are included or otherwise necessary for reading the fdf file

print(key, value)

Return a string which is pretty-printing the key+value

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

Generic read method which should be overloaded in child-classes

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

Read the atomic species and figure out the number of atomic orbitals in their basis

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

Try and read density matrix by reading the <>.nc, <>.TSDE files, <>.DM (in that order)

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

Read dynamical matrix from output of the calculation

read_energy_density_matrix(self, \*args, …)

Try and read energy density matrix by reading the <>.nc or <>.TSDE files (in that order)

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

Read forces from the output of the calculation (forces are not defined in the input)

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

Read force constant from the output of the calculation

read_geometry(self[, output])

Returns Geometry object by reading fdf or Siesta output related files.

read_grid(self, name, \*args, \*\*kwargs)

Read grid related information from any of the output files

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

Try and read the Hamiltonian by reading the <>.nc, <>.TSHS files, <>.HSX (in that order)

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

Try and read the overlap matrix by reading the <>.nc, <>.TSHS files, <>.HSX, <>.onlyS (in that order)

read_supercell(self[, output])

Returns SuperCell object by reading fdf or Siesta output related files.

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

Read supercell size using any method available

set(self, key, value[, keep])

Add the key and value to the FDF file

type(self, label)

Return the type of the fdf-keyword

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

Generic write method which should be overloaded in child-classes

write_geometry(self, geom[, fmt])

Writes the geometry to the contained file

write_supercell(self, sc[, fmt])

Writes the supercell to the contained file

property base_file

File of the current Sile

dir_file(self, filename=None)

File of the current Sile

exist(self)

Query whether the file exists

property file

Return the current file name (without the directory prefix)

get(self, label, default=None, unit=None, with_unit=False)[source]

Retrieve fdf-keyword from the file

Parameters
labelstr

the fdf-label to search for

defaultoptional

if the label is not found, this will be the returned value (default to None)

unitstr, optional

unit of the physical quantity to return

with_unitbool, optional

whether the physical quantity gets returned with the found unit in the fdf file.

Returns
valuethe value of the fdf-label. If the label is a block, a list is returned, for

a real value a float (or if the default is of float), for an integer, an int is returned.

unitif with_unit is true this will contain the associated unit if it is specified

Examples

>>> print(open(...).readlines())
LabeleV 1. eV
LabelRy 1. Ry
Label name
FakeInt 1
%block Hello
line 1
line2
%endblock
>>> fdf.get('LabeleV') == 1. # default unit is eV
>>> fdf.get('LabelRy') == unit.siesta.unit_convert('Ry', 'eV')
>>> fdf.get('LabelRy', unit='Ry') == 1.
>>> fdf.get('LabelRy', with_unit=True) == (1., 'Ry')
>>> fdf.get('FakeInt', '0') == '1'
>>> fdf.get('LabeleV', with_unit=True) == (1., 'eV')
>>> fdf.get('Label', with_unit=True) == 'name' # no unit present on line
>>> fdf.get('Hello') == ['line 1', 'line2']
includes(self)[source]

Return a list of all files that are included or otherwise necessary for reading the fdf file

static print(key, value)[source]

Return a string which is pretty-printing the key+value

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, *args, **kwargs)[source]

Read the atomic species and figure out the number of atomic orbitals in their basis

The order of the read is shown below.

One can limit the tried files to only one file by passing only a single file ending.

Parameters
order: list of str, optional

the order of which to try and read the basis information. By default this is ['nc', 'ion', 'ORB_INDX', 'fdf']

read_density_matrix(self, *args, **kwargs)[source]

Try and read density matrix by reading the <>.nc, <>.TSDE files, <>.DM (in that order)

One can limit the tried files to only one file by passing only a single file ending.

Parameters
order: list of str, optional

the order of which to try and read the density matrix By default this is ['nc', 'TSDE', 'DM'].

read_dynamical_matrix(self, *args, **kwargs)[source]

Read dynamical matrix from output of the calculation

Parameters
order: list of str, optional

the order of which to try and read the dynamical matrix. By default this is ['nc', 'FC'].

cutoff_distfloat, optional

cutoff value for the distance of the force-constants (everything farther than cutoff_dist will be set to 0, unit in Ang.

cutofffloat, optional

absolute values below the cutoff are considered 0. Defaults to 1e-4 eV/Ang**2.

correct_fcbool, optional

correct the FC-matrix by forcing the force on the moved atom to be equal to the negative sum of all the others. Default to true.

Returns
DynamicalMatrixDynamical matrix
read_energy_density_matrix(self, *args, **kwargs)[source]

Try and read energy density matrix by reading the <>.nc or <>.TSDE files (in that order)

One can limit the tried files to only one file by passing only a single file ending.

Parameters
order: list of str, optional

the order of which to try and read the density matrix By default this is ['nc', 'TSDE'].

read_force(self, *args, **kwargs)[source]

Read forces from the output of the calculation (forces are not defined in the input)

Parameters
orderlist of str, optional

the order of the forces we are trying to read, default to ['FA', 'nc']

Returns
(*, 3)vector with forces for each of the atoms
read_force_constant(self, *args, **kwargs)[source]

Read force constant from the output of the calculation

Parameters
correct_fcbool, optional

correct the FC-matrix by forcing the force on the moved atom to be equal to the negative sum of all the others. Default to true.

Returns
(*, 3, 2, *, 3)vector with force constant element for each of the atomic displacements
read_geometry(self, output=False, *args, **kwargs)[source]

Returns Geometry object by reading fdf or Siesta output related files.

One can limit the tried files to only one file by passing only a single file ending.

Parameters
output: bool, optional

whether to read geometry from output files (default to read from the fdf file).

order: list of str, optional

the order of which to try and read the geometry. By default this is ['XV', 'nc', 'fdf'] if output is true If order is present output is disregarded.

Examples

>>> fdf = get_sile('RUN.fdf')
>>> fdf.read_geometry() # read from fdf
>>> fdf.read_geometry(True) # read from [XV, nc, fdf]
>>> fdf.read_geometry(order=['nc']) # read from [nc]
>>> fdf.read_geometry(True, order=['nc']) # read from [nc]
read_grid(self, name, *args, **kwargs)[source]

Read grid related information from any of the output files

The order of the readed data is shown below.

One can limit the tried files to only one file by passing only a single file ending.

Parameters
namestr

name of data to read. The list of names correspond to the Siesta output manual (Rho, TotalPotential, etc.), the strings are case insensitive.

order: list of str, optional

the order of which to try and read the geometry. By default this is ['nc', 'grid.nc', 'bin'] (bin refers to the binary files)

read_hamiltonian(self, *args, **kwargs)[source]

Try and read the Hamiltonian by reading the <>.nc, <>.TSHS files, <>.HSX (in that order)

One can limit the tried files to only one file by passing only a single file ending.

Parameters
order: list of str, optional

the order of which to try and read the Hamiltonian. By default this is ['nc', 'TSHS', 'HSX'].

read_overlap(self, *args, **kwargs)[source]

Try and read the overlap matrix by reading the <>.nc, <>.TSHS files, <>.HSX, <>.onlyS (in that order)

One can limit the tried files to only one file by passing only a single file ending.

Parameters
order: list of str, optional

the order of which to try and read the overlap matrix By default this is ['nc', 'TSHS', 'HSX', 'onlyS'].

read_supercell(self, output=False, *args, **kwargs)[source]

Returns SuperCell object by reading fdf or Siesta output related files.

One can limit the tried files to only one file by passing only a single file ending.

Parameters
output: bool, optional

whether to read supercell from output files (default to read from the fdf file).

order: list of str, optional

the order of which to try and read the supercell. By default this is ['XV', 'nc', 'fdf'] if output is true. If order is present output is disregarded.

Examples

>>> fdf = get_sile('RUN.fdf')
>>> fdf.read_supercell() # read from fdf
>>> fdf.read_supercell(True) # read from [XV, nc, fdf]
>>> fdf.read_supercell(order=['nc']) # read from [nc]
>>> fdf.read_supercell(True, order=['nc']) # read from [nc]
read_supercell_nsc(self, *args, **kwargs)[source]

Read supercell size using any method available

Raises
SislWarning if none of the files can be read
set(self, key, value, keep=True)[source]

Add the key and value to the FDF file

Parameters
keystr

the fdf-key value to be set in the fdf file

valuestr or list of str

the value of the string. If a str is passed a regular fdf-key is used, if a list it will be a %block.

keepbool, optional

whether old flags will be kept in the fdf file. In this case a time-stamp will be written to show when the key was overwritten.

type(self, label)[source]

Return the type of the fdf-keyword

Parameters
labelstr

the label to look-up

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_geometry(self, geom, fmt='.8f', *args, **kwargs)[source]

Writes the geometry to the contained file

write_supercell(self, sc, fmt='.8f', *args, **kwargs)[source]

Writes the supercell to the contained file