sisl.io.siesta.fdfSileSiesta

class sisl.io.siesta.fdfSileSiesta(filename, *args, **kwargs)

Bases: SileSiesta

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

  • mode (str, optional) – opening mode, default to read-only

  • base (str, 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

Methods

close()

dir_file([filename, filename_base])

File of the current Sile

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

Retrieve fdf-keyword from the file

includes()

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(*args, **kwargs)

Generic read method which should be overloaded in child-classes

read_basis(*args, **kwargs)

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

read_density_matrix(*args, **kwargs)

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

read_dynamical_matrix(*args, **kwargs)

Read dynamical matrix from output of the calculation

read_energy_density_matrix(*args, **kwargs)

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

read_fermi_level(*args, **kwargs)

Read fermi-level from output of the calculation

read_force(*args, **kwargs)

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

read_force_constant(*args, **kwargs)

Read force constant from the output of the calculation

read_geometry([output])

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

read_grid(name, *args, **kwargs)

Read grid related information from any of the output files

read_hamiltonian(*args, **kwargs)

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

read_lattice([output])

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

read_lattice_nsc(*args, **kwargs)

Read supercell size using any method available

read_overlap(*args, **kwargs)

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

set(key, value[, keep])

Add the key and value to the FDF file

type(label)

Return the type of the fdf-keyword

write(*args, **kwargs)

Generic write method which should be overloaded in child-classes

write_brillouinzone(bz)

Writes Brillouinzone information to the fdf input file

write_geometry(geometry[, fmt])

Writes the geometry

write_lattice(sc[, fmt])

Writes the supercell

base_file

File of the current Sile

file

File of the current Sile

class InfoAttr(attr, regex, parser, doc='', updatable=False, default=None, found=False)

Bases: object

Holder for parsing lines and extracting information from text files

This consists of:

attr:

the name of the attribute This will be the sile.info. access point.

regex:

the regular expression used to match a line. If a str, it will be compiled as is to a regex pattern. regex.match(line) will be used to check if the value should be updated.

parser:

if regex.match(line) returns a match that is true, then this parser will be executed. The parser must be a function accepting two arguments:

def parser(attr, match)

where attr is this object, and match is the match done on the line. (Note that match.string will return the full line used to match against).

updatable:

control whether a new match on the line will update using parser. If false, only the first match will update the value

default:

the default value of the attribute

found:

whether the value has been found in the file.

__init__(attr, regex, parser, doc='', updatable=False, default=None, found=False)
attr
copy()
doc
documentation()

Returns a documentation string for this object

found
parser
process(line)
regex
updatable
value
__init__(filename, mode='r', *args, **kwargs)

Just to pass away the args and kwargs

property base_file

File of the current Sile

close()
dir_file(filename=None, filename_base='')

File of the current Sile

property file

File of the current Sile

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

Retrieve fdf-keyword from the file

Parameters
  • label (str) – the fdf-label to search for

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

  • unit (str, optional) – unit of the physical quantity to return

  • with_unit (bool, optional) – whether the physical quantity gets returned with the found unit in the fdf file.

Returns

  • value (the 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.

  • unit (if 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()[source]

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

plot

Handles all plotting possibilities for a class

static print(key, value)[source]

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

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

Read dynamical matrix from output of the calculation

Generally the mass is stored in the basis information output, but for dynamical matrices it makes sense to let the user control this, e.g. through the fdf file. By default the mass will be read from the AtomicMass key in the fdf file and not from the basis set information.

Parameters
  • order (list of str, optional) – the order of which to try and read the dynamical matrix. By default this is ["nc", "FC"].

  • cutoff_dist (float, optional) – cutoff value for the distance of the force-constants (everything farther than cutoff_dist will be set to 0 Ang). Default, no cutoff.

  • cutoff (float, optional) – absolute values below the cutoff are considered 0. Defaults to 0. eV/Ang**2.

  • trans_inv (bool, optional) – if true (default), the force-constant matrix will be fixed so that translational invariance will be enforced

  • sum0 (bool, optional) – if true (default), the sum of forces on atoms for each displacement will be forced to 0.

  • hermitian (bool, optional) – if true (default), the returned dynamical matrix will be hermitian

Notes

This is highly untested and may result in errorneous matrices. Please report back to developers about problems and suggestions.

Returns

dynamic_matrix – the dynamical matrix

Return type

DynamicalMatrix

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

Read fermi-level from output of the calculation

Parameters

order (list of str, optional) – the order of which to try and read the fermi-level. By default this is ["nc", "TSDE", "TSHS", "EIG", "bands"].

Returns

Ef – fermi-level

Return type

float

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

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

Parameters

order (list of str, optional) – the order of the forces we are trying to read, default to ["FA", "nc"]

Returns

numpy.ndarray

Return type

vector with forces for each of the atoms, along each Cartesian direction

read_force_constant(*args, **kwargs)[source]

Read force constant from the output of the calculation

Returns

force_constant – vector [*, 3, 2, *, 3] with force constant element for each of the atomic displacements

Return type

numpy.ndarray

read_geometry(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", "TSHS", "HSX", "STRUCT"] 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(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
  • name (str) – 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(*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_lattice(output=False, *args, **kwargs)[source]

Returns Lattice 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_lattice() # read from fdf
>>> fdf.read_lattice(True) # read from [XV, nc, fdf]
>>> fdf.read_lattice(order=["nc"]) # read from [nc]
>>> fdf.read_lattice(True, order=["nc"]) # read from [nc]
read_lattice_nsc(*args, **kwargs)[source]

Read supercell size using any method available

Raises

SislWarning – if none of the files can be read

read_overlap(*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"].

set(key, value, keep=True)[source]

Add the key and value to the FDF file

Parameters
  • key (str) – the fdf-key value to be set in the fdf file

  • value (str 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.

  • keep (bool, 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(label)[source]

Return the type of the fdf-keyword

Parameters

label (str) – the label to look-up

write(*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_brillouinzone(bz)[source]

Writes Brillouinzone information to the fdf input file

The bz object will be written as options in the input file. The class of bz decides which options gets written. For instance a BandStructure class will write the corresponding BandLines block.

Parameters

bz (BrillouinZone) – which setting to write to the file

Notes

Currently, only the BandStructure class may be accepted as bz.

write_geometry(geometry, fmt='.8f', *args, **kwargs)[source]

Writes the geometry

Parameters
  • geometry (Geometry) – geometry object to write

  • fmt (str, optional) – precision used to store the atomic coordinates

  • unit ({"Ang", "Bohr", "fractional", "frac"}) – the unit used when writing the data. fractional and frac are the same.

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

Writes the supercell

Parameters
  • sc (Lattice) – supercell object to write

  • fmt (str, optional) – precision used to store the lattice vectors

  • unit ({"Ang", "Bohr"}) – the unit used when writing the data.