matador.export package¶
The export module provides interfaces to write matador-created dictionaries/Crystal objects to several file formats.
Currently supported formats:
CASTEP’s .cell and .param
the Protein Data Bank’s .pdb
input files for Quantum Espresso (written as .in)
XCrysden’s .xsf
- the custom .res file format based on SHELX used first by AIRSS
-
matador.export.
doc2param
(doc, path, overwrite=False, hash_dupe=False, spin=False)[source]¶ Write basic .param file from single doc.
- Parameters
- Keyword Arguments
- Returns
- list of strings to write to file, with implicit newlines,
and the required file extension.
- Return type
-
matador.export.
doc2cell
(doc, path, overwrite=False, hash_dupe=False, spin=False)[source]¶ Write .cell file for single doc.
- Parameters
- Keyword Arguments
- Returns
- list of strings to write to file, with implicit newlines,
and the required file extension.
- Return type
-
matador.export.
doc2pdb
(doc, path, info=True, hash_dupe=True)[source]¶ Write a simple .pdb for single doc.
-
matador.export.
doc2pwscf
(doc, path, template=None, spacing=None)[source]¶ Write the structural part of QE input file based on the provided matador doc. Will calculate the correct kpoint_mp_grid if spacing is provided.
-
matador.export.
doc2res
(doc, path, overwrite=False, hash_dupe=False, info=True, spoof_titl=False, sort_atoms=True)[source]¶ Write .res file for single doc.
- Parameters
- Keyword Arguments
info (bool) – require info in res file header
spoof_titl (bool) – make up fake info for file header (for use with e.g. cryan)
sorted (bool) – if False, atoms are not sorted (this will not be a valid res file)
overwrite (bool) – whether or not to overwrite colliding files.
hash_dupe (bool) – whether or not to create a unique filename for any colliding files, or just skip writing them.
-
matador.export.
doc2xsf
(doc, path, write_energy=False, write_forces=False, overwrite=False)[source]¶ Write an .xsf file for a matador document, with positions in Cartesian coordinates. Optionally, write the energy in a comment at the top of the file for use with aenet.
- Parameters
- Keyword Arguments
-
matador.export.
query2files
(cursor, dirname=None, max_files=10000, top=None, prefix=None, cell=None, param=None, res=None, pdb=None, json=None, xsf=None, markdown=True, latex=False, subcmd=None, argstr=None, **kwargs)[source]¶ Many-to-many convenience function for many structures being written to many file types.
- Parameters
cursor (
list
ofdict
/AtomicSwapper
) – list of matador dictionaries to write out.- Keyword Arguments
dirname (str) – the folder to save the results into. Will be created if non-existent. Will have integer appended to it if already existing.
max_files (int) – if the number of files to be written exceeds this number, then raise RuntimeError.
**kwargs (dict) – dictionary of {filetype: bool(whether to write)}. Accepted file types are cell, param, res, pdb, json, xsf, markdown and latex.
-
matador.export.
doc2arbitrary
(doc, path, overwrite=False, hash_dupe=False)[source]¶ Write a Python dictionary into a standard CASTEP-style keyword: value file.
Submodules¶
matador.export.export module¶
This file implements functions that write files from matador documents or Crystal objects.
-
matador.export.export.
query2files
(cursor, dirname=None, max_files=10000, top=None, prefix=None, cell=None, param=None, res=None, pdb=None, json=None, xsf=None, markdown=True, latex=False, subcmd=None, argstr=None, **kwargs)[source]¶ Many-to-many convenience function for many structures being written to many file types.
- Parameters
cursor (
list
ofdict
/AtomicSwapper
) – list of matador dictionaries to write out.- Keyword Arguments
dirname (str) – the folder to save the results into. Will be created if non-existent. Will have integer appended to it if already existing.
max_files (int) – if the number of files to be written exceeds this number, then raise RuntimeError.
**kwargs (dict) – dictionary of {filetype: bool(whether to write)}. Accepted file types are cell, param, res, pdb, json, xsf, markdown and latex.
-
matador.export.export.
doc2param
(doc, path, overwrite=False, hash_dupe=False, spin=False)[source]¶ Write basic .param file from single doc.
- Parameters
- Keyword Arguments
- Returns
- list of strings to write to file, with implicit newlines,
and the required file extension.
- Return type
-
matador.export.export.
doc2cell
(doc, path, overwrite=False, hash_dupe=False, spin=False)[source]¶ Write .cell file for single doc.
- Parameters
- Keyword Arguments
- Returns
- list of strings to write to file, with implicit newlines,
and the required file extension.
- Return type
-
matador.export.export.
doc2pdb
(doc, path, info=True, hash_dupe=True)[source]¶ Write a simple .pdb for single doc.
-
matador.export.export.
doc2json
(doc, path, overwrite=False, hash_dupe=True)[source]¶ Return raw JSON document as stored in database.
-
matador.export.export.
doc2pwscf
(doc, path, template=None, spacing=None)[source]¶ Write the structural part of QE input file based on the provided matador doc. Will calculate the correct kpoint_mp_grid if spacing is provided.
-
matador.export.export.
doc2res
(doc, path, overwrite=False, hash_dupe=False, info=True, spoof_titl=False, sort_atoms=True)[source]¶ Write .res file for single doc.
- Parameters
- Keyword Arguments
info (bool) – require info in res file header
spoof_titl (bool) – make up fake info for file header (for use with e.g. cryan)
sorted (bool) – if False, atoms are not sorted (this will not be a valid res file)
overwrite (bool) – whether or not to overwrite colliding files.
hash_dupe (bool) – whether or not to create a unique filename for any colliding files, or just skip writing them.
-
matador.export.export.
doc2xsf
(doc, path, write_energy=False, write_forces=False, overwrite=False)[source]¶ Write an .xsf file for a matador document, with positions in Cartesian coordinates. Optionally, write the energy in a comment at the top of the file for use with aenet.
- Parameters
- Keyword Arguments
matador.export.utils module¶
This submodule includes some useful utility functions for exporting data.
-
matador.export.utils.
file_writer_function
(function)[source]¶ Wrapper for file writers to safely overwrite/hash duplicate files.