def get(self, key, unit=None, default=None, with_unit=False): """ Retrieve fdf-keyword from the file """ # First split into specification and key key, tmp_unit = name_spec(key) if unit is None: unit = tmp_unit found, fdf = self._read(key) if not found: return default # The keyword is found... if fdf.startswith('%block'): found, fdf = self._read_block(key) if not found: return default else: return fdf # We need to process the returned value further. fdfl = fdf.split() # Check whether this is a logical flag if len(fdfl) == 1: # This *MUST* be a boolean # SCF.Converge.H # defaults to .true. return True elif fdfl[1] in _LOGICAL_TRUE: return True elif fdfl[1] in _LOGICAL_FALSE: return False # It is something different. # Try and figure out what it is if len(fdfl) == 3: # We expect it to be a unit if unit is None: # Get group of unit group = unit_group(fdfl[2]) # return in default sisl units unit = unit_default(group) if with_unit and tmp_unit is not None: # The user has specifically requested the unit: # key{unit} return '{0:.4f} {1}'.format( float(fdfl[1]) * unit_convert(fdfl[2], unit), unit) elif not with_unit: return float(fdfl[1]) * unit_convert(fdfl[2], unit) return ' '.join(fdfl[1:])
def get(self, key, unit=None, default=None, with_unit=False): """ Retrieve fdf-keyword from the file """ # First split into specification and key key, tmp_unit = name_spec(key) if unit is None: unit = tmp_unit found, fdf = self._read(key) if not found: return default # The keyword is found... if fdf.startswith('%block'): found, fdf = self._read_block(key) if not found: return default else: return fdf # We need to process the returned value further. fdfl = fdf.split() # Check whether this is a logical flag if len(fdfl) == 1: # This *MUST* be a boolean # SCF.Converge.H # defaults to .true. return True elif fdfl[1] in _LOGICAL_TRUE: return True elif fdfl[1] in _LOGICAL_FALSE: return False # It is something different. # Try and figure out what it is if len(fdfl) == 3: # We expect it to be a unit if unit is None: # Get group of unit group = unit_group(fdfl[2]) # return in default sisl units unit = unit_default(group) if with_unit and tmp_unit is not None: # The user has specifically requested the unit: # key{unit} return '{0:.4f} {1}'.format(float(fdfl[1]) * unit_convert(fdfl[2], unit), unit) elif not with_unit: return float(fdfl[1]) * unit_convert(fdfl[2], unit) return ' '.join(fdfl[1:])
# Check against integers from numbers import Integral # Import sile objects from .tbtrans import tbtncSileSiesta from ..sile import * from sisl.utils import * # Import the geometry object from sisl import Geometry, Atom, SuperCell from sisl._help import _str from sisl.units.siesta import unit_convert __all__ = ['tbtprojncSileSiesta', 'phtprojncSileSiesta'] Bohr2Ang = unit_convert('Bohr', 'Ang') Ry2eV = unit_convert('Ry', 'eV') Ry2K = unit_convert('Ry', 'K') eV2Ry = unit_convert('eV', 'Ry') class tbtprojncSileSiesta(tbtncSileSiesta): """ TBtrans projection file object """ _trans_type = 'TBT.Proj' add_sile('TBT.Proj.nc', tbtprojncSileSiesta) # Add spin-dependent files add_sile('TBT_DN.Proj.nc', tbtprojncSileSiesta) add_sile('TBT_UP.Proj.nc', tbtprojncSileSiesta)
from __future__ import print_function # Import sile objects from .sile import SileCDFSIESTA from ..sile import * # Import the geometry object from sisl import Geometry, Atom, SuperCell, Grid from sisl.units.siesta import unit_convert from sisl.quantity import Hamiltonian import numpy as np __all__ = ['ncSileSiesta'] Bohr2Ang = unit_convert('Bohr', 'Ang') Ry2eV = unit_convert('Ry', 'eV') class ncSileSiesta(SileCDFSIESTA): """ SIESTA file object """ def read_sc(self): """ Returns a SuperCell object from a SIESTA.nc file """ cell = np.array(self._value('cell'), np.float64) # Yes, this is ugly, I really should implement my unit-conversion tool cell *= Bohr2Ang cell.shape = (3, 3) nsc = np.array(self._value('nsc'), np.int32)
# Import sile objects from .sile import SileCDFSIESTA from ..sile import * from sisl.utils import * # Import the geometry object from sisl import Geometry, Atom, SuperCell from sisl._help import _str from sisl.units.siesta import unit_convert __all__ = ['tbtncSileSiesta', 'phtncSileSiesta'] __all__ += ['dHncSileSiesta'] Bohr2Ang = unit_convert('Bohr', 'Ang') Ry2eV = unit_convert('Ry', 'eV') eV2Ry = unit_convert('eV', 'Ry') class tbtncSileSiesta(SileCDFSIESTA): """ TBtrans file object """ _trans_type = 'TBT' def _value_avg(self, name, tree=None, avg=False): """ Local method for obtaining the data from the SileCDF. This method checks how the file is access, i.e. whether data is stored in the object or it should be read consequtively. """ if self._access > 0:
Sile object for reading/writing XV files """ from __future__ import print_function import numpy as np # Import sile objects from .sile import SileSiesta from ..sile import * # Import the geometry object from sisl import Geometry, Atom, SuperCell from sisl.units.siesta import unit_convert Bohr2Ang = unit_convert('Bohr', 'Ang') __all__ = ['XVSileSiesta'] class XVSileSiesta(SileSiesta): """ XV file object """ def _setup(self): """ Setup the `XVSileSiesta` after initialization """ self._comment = [] @Sile_fh_open def write_geom(self, geom): """ Writes the geometry to the contained file """
""" from __future__ import print_function import numpy as np # Import sile objects from .sile import SileCDFSIESTA from ..sile import * # Import the geometry object from sisl import Geometry, SuperCell, Grid from sisl.units.siesta import unit_convert __all__ = ['gridncSileSiesta'] Bohr2Ang = unit_convert('Bohr', 'Ang') class gridncSileSiesta(SileCDFSIESTA): """ SIESTA Grid file object """ def read_supercell(self): """ Returns a SuperCell object from a SIESTA.grid.nc file """ cell = np.array(self._value('cell'), np.float64) # Yes, this is ugly, I really should implement my unit-conversion tool cell *= Bohr2Ang cell.shape = (3, 3) return SuperCell(cell)