Format Specific Options¶
abinit¶
acemolecule-input¶
acemolecule-out¶
ase.io.acemolecule.
read_acemolecule_out
(filename)[source]¶Interface to ACEMoleculeReader and return values for corresponding quantity :param filename: :type filename: ACE-Molecule log file. :param quantity: :type quantity: One of atoms, energy, forces, excitation-energy.
- Returns
- quantity = ‘excitation-energy’ – returns None. This is placeholder function to run TDDFT calculations without IndexError.
- quantity = ‘energy’ – returns energy as float value.
- quantity = ‘forces’ – returns force of each atoms as numpy array of shape (natoms, 3).
- quantity = ‘atoms’ – returns ASE atoms object.
aims¶
ase.io.aims.
read_aims
(filename, apply_constraints=True)[source]¶Import FHI-aims geometry type files.
Reads unitcell, atom positions and constraints from a geometry.in file.
If geometric constraint (symmetry parameters) are in the file include that information in atoms.info[“symmetry_block”]
ase.io.aims.
write_aims
(filename, atoms, scaled=False, geo_constrain=False, velocities=False, ghosts=None, info_str=None, wrap=False)[source]¶Method to write FHI-aims geometry files.
Writes the atoms positions and constraints (only FixAtoms is supported at the moment).
- Parameters
filename – str Name of file to output structure to
atoms – ase.atoms.Atoms structure to output to the file
scaled – bool If True use fractional coordinates instead of Cartesian coordinates
symmetry_block – list of str List of geometric constraints as defined in: https://arxiv.org/abs/1908.01610
velocities – bool If True add the atomic velocity vectors to the file
ghosts – list of Atoms A list of ghost atoms for the system
info_str – str A string to be added to the header of the file
wrap – bool Wrap atom positions to cell before writing
aims-output¶
bundletrajectory¶
ase.io.bundletrajectory.
read_bundletrajectory
(filename, index=-1)[source]¶Reads one or more atoms objects from a BundleTrajectory.
Arguments:
- filename: str
The name of the bundle (really a directory!)
- index: int
An integer specifying which frame to read, or an index object for reading multiple frames. Default: -1 (reads the last frame).
castep-castep¶
ase.io.castep.
read_castep_castep
(fd, index=None)[source]¶Reads a .castep file and returns an atoms object. The calculator information will be stored in the calc attribute.
There is no use of the “index” argument as of now, it is just inserted for convenience to comply with the generic “read()” in ase.io
Please note that this routine will return an atom ordering as found within the castep file. This means that the species will be ordered by ascending atomic numbers. The atoms witin a species are ordered as given in the original cell file.
Note: This routine returns a single atoms_object only, the last configuration in the file. Yet, if you want to parse an MD run, use the novel function \(read_md()\)
castep-cell¶
ase.io.castep.
read_castep_cell
(fd, index=None, calculator_args={}, find_spg=False, units={'Eh': 27.2113845, 'Pascal': 160217653000.0, 'a0': 0.5291772108, 'c': 299792458, 'e': 1.60217653e-19, 'hbar': 6.58211915e-16, 'kB': 8.617343e-05, 'me': 0.00054857990945, 't0': 2.4188843276239763e-17})[source]¶Read a .cell file and return an atoms object. Any value found that does not fit the atoms API will be stored in the atoms.calc attribute.
By default, the Castep calculator will be tolerant and in the absence of a castep_keywords.json file it will just accept all keywords that aren’t automatically parsed.
ase.io.castep.
write_castep_cell
(fd, atoms, positions_frac=False, force_write=False, precision=6, magnetic_moments=None, castep_cell=None)[source]¶This CASTEP export function write minimal information to a .cell file. If the atoms object is a trajectory, it will take the last image.
Note that function has been altered in order to require a filedescriptor rather than a filename. This allows to use the more generic write() function from formats.py
Note that the “force_write” keywords has no effect currently.
- Parameters
positions_frac – boolean. If true, positions are printed as fractional rather than absolute. Default is false.
castep_cell – if provided, overrides the existing CastepCell object in the Atoms calculator
precision – number of digits to which lattice and positions are printed
magnetic_moments – if None, no SPIN values are initialised. If ‘initial’, the values from get_initial_magnetic_moments() are used. If ‘calculated’, the values from get_magnetic_moments() are used. If an array of the same length as the atoms object, its contents will be used as magnetic moments.
castep-geom¶
ase.io.castep.
read_castep_geom
(fd, index=None, units={'Eh': 27.2113845, 'Pascal': 160217653000.0, 'a0': 0.5291772108, 'c': 299792458, 'e': 1.60217653e-19, 'hbar': 6.58211915e-16, 'kB': 8.617343e-05, 'me': 0.00054857990945, 't0': 2.4188843276239763e-17})[source]¶Reads a .geom file produced by the CASTEP GeometryOptimization task and returns an atoms object. The information about total free energy and forces of each atom for every relaxation step will be stored for further analysis especially in a single-point calculator. Note that everything in the .geom file is in atomic units, which has been conversed to commonly used unit angstrom(length) and eV (energy).
Note that the index argument has no effect as of now.
Contribution by Wei-Bing Zhang. Thanks!
Routine now accepts a filedescriptor in order to out-source the gz and bz2 handling to formats.py. Note that there is a fallback routine read_geom() that behaves like previous versions did.
castep-md¶
ase.io.castep.
read_castep_md
(fd, index=None, return_scalars=False, units={'Eh': 27.2113845, 'Pascal': 160217653000.0, 'a0': 0.5291772108, 'c': 299792458, 'e': 1.60217653e-19, 'hbar': 6.58211915e-16, 'kB': 8.617343e-05, 'me': 0.00054857990945, 't0': 2.4188843276239763e-17})[source]¶Reads a .md file written by a CASTEP MolecularDynamics task and returns the trajectory stored therein as a list of atoms object.
Note that the index argument has no effect as of now.
castep-phonon¶
ase.io.castep.
read_castep_phonon
(fd, index=None, read_vib_data=False, gamma_only=True, frequency_factor=None, units={'Eh': 27.2113845, 'Pascal': 160217653000.0, 'a0': 0.5291772108, 'c': 299792458, 'e': 1.60217653e-19, 'hbar': 6.58211915e-16, 'kB': 8.617343e-05, 'me': 0.00054857990945, 't0': 2.4188843276239763e-17})[source]¶Reads a .phonon file written by a CASTEP Phonon task and returns an atoms object, as well as the calculated vibrational data if requested.
Note that the index argument has no effect as of now.
cfg¶
ase.io.cfg.
read_cfg
(f)[source]¶Read atomic configuration from a CFG-file (native AtomEye format). See: http://mt.seas.upenn.edu/Archive/Graphics/A/
ase.io.cfg.
write_cfg
(f, a)[source]¶Write atomic configuration to a CFG-file (native AtomEye format). See: http://mt.seas.upenn.edu/Archive/Graphics/A/
cif¶
ase.io.cif.
read_cif
(fileobj, index, store_tags=False, primitive_cell=False, subtrans_included=True, fractional_occupancies=True, reader='ase')[source]¶Read Atoms object from CIF file. index specifies the data block number or name (if string) to return.
If index is None or a slice object, a list of atoms objects will be returned. In the case of index is None or slice(None), only blocks with valid crystal data will be included.
If store_tags is true, the info attribute of the returned Atoms object will be populated with all tags in the corresponding cif data block.
If primitive_cell is true, the primitive cell will be built instead of the conventional cell.
If subtrans_included is true, sublattice translations are assumed to be included among the symmetry operations listed in the CIF file (seems to be the common behaviour of CIF files). Otherwise the sublattice translations are determined from setting 1 of the extracted space group. A result of setting this flag to true, is that it will not be possible to determine the primitive cell.
If fractional_occupancies is true, the resulting atoms object will be tagged equipped with an array \(occupancy\). Also, in case of mixed occupancies, the atom’s chemical symbol will be that of the most dominant species.
String reader is used to select CIF reader. Value \(ase\) selects built-in CIF reader (default), while \(pycodcif\) selects CIF reader based on \(pycodcif\) package.
cp2k-dcd¶
ase.io.cp2k.
read_cp2k_dcd
(fileobj, index=-1, ref_atoms=None, aligned=False)[source]¶Read a DCD file created by CP2K.
To yield one Atoms object at a time use
iread_cp2k_dcd
.Note: Other programs use other formats, they are probably not compatible.
If ref_atoms is not given, all atoms will have symbol ‘X’.
To make sure that this is a dcd file generated with the DCD_ALIGNED_CELL key in the CP2K input, you need to set
aligned
to True to get cell information. Make sure you do not set it otherwise, the cell will not match the atomic coordinates! See (this discussion)[https://groups.google.com/forum/#!searchin/cp2k/Outputting$20cell$20information$20and$20fractional$20coordinates%7Csort:relevance/cp2k/72MhYykrSrQ/5c9Jaw7S9yQJ] for details.
crystal¶
cube¶
ase.io.cube.
read_cube
(fileobj, read_data=True, program=None, verbose=False)[source]¶Read atoms and data from CUBE file.
- fileobjstr or file
Location to the cubefile.
- read_databoolean
If set true, the actual cube file content, i.e. an array containing the electronic density (or something else )on a grid and the dimensions of the corresponding voxels are read.
- program: str
Use program=’castep’ to follow the PBC convention that first and last voxel along a direction are mirror images, thus the last voxel is to be removed. If program=None, the routine will try to catch castep files from the comment lines.
- verbosebool
Print some more information to stdout.
Returns a dict with the following keys:
‘atoms’: Atoms object
‘data’ : (Nx, Ny, Nz) ndarray
‘origin’: (3,) ndarray, specifying the cube_data origin.
ase.io.cube.
write_cube
(fileobj, atoms, data=None, origin=None, comment=None)[source]¶Function to write a cube file.
- fileobj: str or file object
File to which output is written.
- atoms: Atoms object
Atoms object specifying the atomic configuration.
- data3dim numpy array, optional (default = None)
Array containing volumetric data as e.g. electronic density
- origin3-tuple
Origin of the volumetric data (units: Angstrom)
- commentstr, optional (default = None)
Comment for the first line of the cube file.
db¶
dftb¶
dlp-history¶
dlp4¶
ase.io.dlp4.
read_dlp4
(f, symbols=None)[source]¶Read a DL_POLY_4 config/revcon file.
Typically used indirectly through read(‘filename’, atoms, format=’dlp4’).
Can be unforgiven with custom chemical element names. Please complain to alin@elena.space for bugs.
ase.io.dlp4.
write_dlp4
(f, atoms, levcfg=0, title='CONFIG generated by ASE')[source]¶Write a DL_POLY_4 config file.
Typically used indirectly through write(‘filename’, atoms, format=’dlp4’).
Can be unforgiven with custom chemical element names. Please complain to alin@elena.space in case of bugs
dmol-arc¶
dmol-car¶
dmol-incoor¶
elk¶
eon¶
espresso-in¶
ase.io.espresso.
read_espresso_in
(fileobj)[source]¶Parse a Quantum ESPRESSO input files, ‘.in’, ‘.pwi’.
ESPRESSO inputs are generally a fortran-namelist format with custom blocks of data. The namelist is parsed as a dict and an atoms object is constructed from the included information.
- Parameters
fileobj (file | str) – A file-like object that supports line iteration with the contents of the input file, or a filename.
- Returns
atoms – Structure defined in the input file.
- Return type
- Raises
KeyError – Raised for missing keys that are required to process the file
ase.io.espresso.
write_espresso_in
(fd, atoms, input_data=None, pseudopotentials=None, kspacing=None, kpts=None, koffset=(0, 0, 0), **kwargs)[source]¶Create an input file for pw.x.
Use set_initial_magnetic_moments to turn on spin, if ispin is set to 2 with no magnetic moments, they will all be set to 0.0. Magnetic moments will be converted to the QE units (fraction of valence electrons) using any pseudopotential files found, or a best guess for the number of valence electrons.
Units are not converted for any other input data, so use Quantum ESPRESSO units (Usually Ry or atomic units).
Keys with a dimension (e.g. Hubbard_U(1)) will be incorporated as-is so the \(i\) should be made to match the output.
Implemented features:
- Conversion of
ase.constraints.FixAtoms
and
ase.constraints.FixCartesian
.\(starting_magnetization\) derived from the \(mgmoms\) and pseudopotentials (searches default paths for pseudo files.)
Automatic assignment of options to their correct sections.
Interpretation of ibrav (cell must exactly match the vectors defined in the QE docs).
Not implemented:
Lists of k-points
Other constraints
Hubbard parameters
Validation of the argument types for input
Validation of required options
Reorientation for ibrav settings
Noncollinear magnetism
- Parameters
fd (file) – A file like object to write the input file to.
atoms (Atoms) – A single atomistic configuration to write to \(fd\).
input_data (dict) – A flat or nested dictionary with input parameters for pw.x
pseudopotentials (dict) – A filename for each atomic species, e.g. {‘O’: ‘O.pbe-rrkjus.UPF’, ‘H’: ‘H.pbe-rrkjus.UPF’}. A dummy name will be used if none are given.
kspacing (float) – Generate a grid of k-points with this as the minimum distance, in A^-1 between them in reciprocal space. If set to None, kpts will be used instead.
kpts ((int, int, int) or dict) – If kpts is a tuple (or list) of 3 integers, it is interpreted as the dimensions of a Monkhorst-Pack grid. If kpts is a dict, it will either be interpreted as a path in the Brillouin zone (*) if it contains the ‘path’ keyword, otherwise it is converted to a Monkhorst-Pack grid (**). (*) see ase.dft.kpoints.bandpath (**) see ase.calculators.calculator.kpts2sizeandoffsets
koffset ((int, int, int)) – Offset of kpoints in each direction. Must be 0 (no offset) or 1 (half grid offset). Setting to True is equivalent to (1, 1, 1).
espresso-out¶
ase.io.espresso.
read_espresso_out
(fileobj, index=-1, results_required=True)[source]¶Reads Quantum ESPRESSO output files.
The atomistic configurations as well as results (energy, force, stress, magnetic moments) of the calculation are read for all configurations within the output file.
Will probably raise errors for broken or incomplete files.
- Parameters
fileobj (file|str) – A file like object or filename
index (slice) – The index of configurations to extract.
results_required (bool) – If True, atomistic configurations that do not have any associated results will not be included. This prevents double printed configurations and incomplete calculations from being returned as the final configuration with no results data.
- Yields
structure (Atoms) – The next structure from the index slice. The Atoms has a SinglePointCalculator attached with any results parsed from the file.
exciting¶
extxyz¶
ase.io.extxyz.
read_extxyz
(fileobj, index=-1, properties_parser=<function key_val_str_to_dict>)¶Read from a file in Extended XYZ format
index is the frame to read, default is last frame (index=-1). properties_parser is the parse to use when converting the properties line to a dictionary,
extxyz.key_val_str_to_dict
is the default and can deal with most use cases,extxyz.key_val_str_to_dict_regex
is slightly faster but has fewer features.
ase.io.extxyz.
write_extxyz
(fileobj, images, comment='', columns=None, write_info=True, write_results=True, plain=False, vec_cell=False, append=False, tolerant=False)¶Write output in extended XYZ format
Optionally, specify which columns (arrays) to include in output, and whether to write the contents of the Atoms.info dict to the XYZ comment line (default is True) and the results of any calculator attached to this Atoms.
gaussian¶
gaussian-out¶
ase.io.gaussian.
read_gaussian_out
(filename, index=-1, quantity='atoms')[source]¶Interface to GaussianReader and returns various quantities. No support for multiple images in one file!
quantity = ‘structures’ -> all structures from the file
quantity = ‘atoms’ -> structure from the archive section
quantity = ‘energy’ -> from the archive section
quantity = ‘force’ -> last entry from the file
quantity = ‘dipole’ -> from the archive section
quantity = ‘version’ -> from the archive section
quantity = ‘multiplicity’ -> from the archive section
quantity = ‘charge’ -> from the archive section
gen¶
gif¶
ase.io.animation.
write_gif
(filename, images, writer=None, interval=200, save_count=100, save_parameters=None, ax=None, **kwargs)¶
gromacs¶
ase.io.gromacs.
read_gromacs
(filename)[source]¶From: http://manual.gromacs.org/current/online/gro.html C format “%5d%-5s%5s%5d%8.3f%8.3f%8.3f%8.4f%8.4f%8.4f” python: starting from 0, including first excluding last 0:4 5:10 10:15 15:20 20:28 28:36 36:44 44:52 52:60 60:68
Import gromacs geometry type files (.gro). Reads atom positions, velocities(if present) and simulation cell (if present)
gromos¶
html¶
json¶
jsv¶
lammps-data¶
ase.io.lammpsdata.
read_lammps_data
(fileobj, Z_of_type=None, style='full', sort_by_id=False, units='metal')[source]¶Method which reads a LAMMPS data file.
sort_by_id: Order the particles according to their id. Might be faster to switch it off. Units are set by default to the style=metal setting in LAMMPS.
lammps-dump-binary¶
ase.io.lammpsrun.
read_lammps_dump_binary
(fileobj, index=-1, colnames=None, intformat='SMALLBIG', **kwargs)[source]¶Read binary dump-files (after binary2txt.cpp from lammps/tools)
- Parameters
fileobj – file-stream containing the binary lammps data
index – integer or slice object (default: get the last timestep)
colnames – data is columns and identified by a header
intformat – lammps support different integer size. Parameter set at compile-time and can unfortunately not derived from data file
- Returns
list of Atoms-objects
- Return type
list
lammps-dump-text¶
magres¶
mp4¶
ase.io.animation.
write_mp4
(filename, images, writer=None, interval=200, save_count=100, save_parameters=None, ax=None, **kwargs)¶
mustem¶
mysql¶
netcdftrajectory¶
nwchem-in¶
nwchem-out¶
postgresql¶
pov¶
proteindatabank¶
qbox¶
res¶
ase.io.res.
read_res
(filename, index=-1)[source]¶Read input in SHELX (.res) format
Multiple frames are read if \(filename\) contains a wildcard character, e.g. \(file_*.res\). \(index\) specifes which frames to retun: default is last frame only (index=-1).
ase.io.res.
write_res
(filename, images, write_info=True, write_results=True, significant_figures=6)[source]¶Write output in SHELX (.res) format
To write multiple images, include a % format string in filename, e.g. \(file_%03d.res\).
Optionally include contents of Atoms.info dictionary if \(write_info\) is True, and/or results from attached calculator if \(write_results\) is True (only energy results are supported).
rmc6f¶
ase.io.rmc6f.
read_rmc6f
(filename, atom_type_map=None)[source]¶Parse a RMCProfile rmc6f file into ASE Atoms object
- Parameters
filename (file|str) – A file like object or filename.
atom_type_map (dict{str:str}) –
Map of atom types for conversions. Mainly used if there is an atom type in the file that is not supported by ASE but want to map to a supported atom type instead.
Example to map deuterium to hydrogen: atom_type_map = { ‘D’: ‘H’ }
- Returns
structure – The Atoms object read in from the rmc6f file.
- Return type
ase.io.rmc6f.
write_rmc6f
(filename, atoms, order=None, atom_type_map=None)[source]¶Write output in rmc6f format - RMCProfile v6 fractional coordinates
- Parameters
filename (file|str) – A file like object or filename.
atoms (Atoms object) – The Atoms object to be written.
order (list[str]) – If not None, gives a list of atom types for the order to write out each.
atom_type_map (dict{str:str}) –
Map of atom types for conversions. Mainly used if there is an atom type in the Atoms object that is a placeholder for a different atom type. This is used when the atom type is not supported by ASE but is in RMCProfile.
Example to map hydrogen to deuterium: atom_type_map = { ‘H’: ‘D’ }
struct¶
traj¶
trj¶
turbomole¶
turbomole-gradient¶
v-sim¶
vasp¶
ase.io.vasp.
read_vasp
(filename='CONTCAR')[source]¶Import POSCAR/CONTCAR type file.
Reads unitcell, atom positions and constraints from the POSCAR/CONTCAR file and tries to read atom types from POSCAR/CONTCAR header, if this fails the atom types are read from OUTCAR or POTCAR file.
ase.io.vasp.
write_vasp
(filename, atoms, label='', direct=False, sort=None, symbol_count=None, long_format=True, vasp5=False, ignore_constraints=False)[source]¶Method to write VASP position (POSCAR/CONTCAR) files.
Writes label, scalefactor, unitcell, # of various kinds of atoms, positions in cartesian or scaled coordinates (Direct), and constraints to file. Cartesian coordiantes is default and default label is the atomic species, e.g. ‘C N H Cu’.
vasp-out¶
vasp-xdatcar¶
ase.io.vasp.
read_vasp_xdatcar
(filename='XDATCAR', index=-1)[source]¶Import XDATCAR file
Reads all positions from the XDATCAR and returns a list of Atoms objects. Useful for viewing optimizations runs from VASP5.x
Constraints ARE NOT stored in the XDATCAR, and as such, Atoms objects retrieved from the XDATCAR will not have constraints set.
vasp-xml¶
x3d¶
ase.io.x3d.
write_x3d
(filename, atoms, format=None)[source]¶Writes to html using X3DOM.
- Parameters
- str or file-like object, filename or output file object (filename) –
- Atoms object to be rendered (atoms) –
- str, either 'X3DOM' for web-browser compatibility or 'X3D' (format) – to be readable by Blender. \(None\) to detect format based on file extension (‘.html’ -> ‘X3DOM’, ‘.x3d’ -> ‘X3D’)
xsd¶
ase.io.xsd.
write_xsd
(filename, images, connectivity=None)[source]¶Takes Atoms object, and write materials studio file atoms: Atoms object filename: path of the output file connectivity: number of atoms by number of atoms matrix for connectivity between atoms (0 not connected, 1 connected)
note: material studio file cannot use a partial periodic system. If partial perodic system was inputted, full periodicity was assumed.
xsf¶
xtd¶
ase.io.xtd.
read_xtd
(filename, index=-1)[source]¶Import xtd file (Materials Studio)
Xtd files always come with arc file, and arc file contains all the relevant information to make atoms so only Arc file needs to be read
ase.io.xtd.
write_xtd
(filename, images, connectivity=None, moviespeed=10)[source]¶Takes Atoms object, and write materials studio file atoms: Atoms object filename: path of the output file moviespeed: speed of animation. between 0 and 10
note: material studio file cannot use a partial periodic system. If partial perodic system was inputted, full periodicity was assumed.
xyz¶
ase.io.xyz.
read_xyz
(fileobj, index=-1, properties_parser=<function key_val_str_to_dict>)[source]¶Read from a file in Extended XYZ format
index is the frame to read, default is last frame (index=-1). properties_parser is the parse to use when converting the properties line to a dictionary,
extxyz.key_val_str_to_dict
is the default and can deal with most use cases,extxyz.key_val_str_to_dict_regex
is slightly faster but has fewer features.
ase.io.xyz.
write_xyz
(fileobj, images, comment='', columns=None, write_info=True, write_results=True, plain=False, vec_cell=False, append=False, tolerant=False)[source]¶Write output in extended XYZ format
Optionally, specify which columns (arrays) to include in output, and whether to write the contents of the Atoms.info dict to the XYZ comment line (default is True) and the results of any calculator attached to this Atoms.