|
static void | write (const std::string &fcif, const double *abc_angles, const int natom, const std::string *atom_site_labels, const double *atom_site_fract_coords, const std::string &title="# generated by ABACUS", const std::string &data_tag="data_?", const int rank=0, const double *atom_site_occups=nullptr, const std::string &cell_formula_units_z="1") |
| Print the CIF file from the given information.
|
|
static void | write (const std::string &fcif, const std::vector< double > &abc_angles, const std::vector< std::string > &atom_site_labels, const std::vector< double > &atom_site_fract_coords, const std::string &title="# generated by ABACUS", const std::string &data_tag="data_?", const int rank=0, const std::vector< double > &atom_site_occups={}, const std::string &cell_formula_units_z="1") |
| A Pybind wrapper for the static method write.
|
|
static void | write (const std::string &fcif, const UnitCell &ucell, const std::string &title="# generated by ABACUS", const std::string &data_tag="data_?", const int rank=0) |
| Write CIF file with the whole UnitCell instance.
|
|
static void | read (const std::string &fcif, std::map< std::string, std::vector< std::string > > &out, const int rank=0) |
| Read the CIF file and store the information in the map.
|
|
CifParser
INTRODUCTION
In short
Tools for CIF file I/O.
Supported structure of CIF
A example (official template of CIF) is shown here (https://www.iucr.org/__data/iucr/ftp/pub/form.cif), but present impl. is ONLY capable to parse a CIF with ONE structure. If there are multiple structures in the CIF file, unexpected behavior may occur.
A CIF file always contain two kinds of data structure, the first is simply the key-value pair, the second is table which is lead by a keyword "loop_".
Key-value pair
key-value pair can have two types:
Type 1: the most general _KEY1 VALUE1 _KEY2 VALUE2 ... Type 2: text box _KEY1 ; very long text VeRy LoNg TeXt ... ;
Table
The table in CIF must be lead by a keyword "loop_", and all titles of the columns will be list first, then all the rest are the values of the table. For example: loop_ _KEY1 _KEY2 _KEY3 ... VALUE11 VALUE21 VALUE31 VALUE12 VALUE22 VALUE32 ... Once the number of values cannot be divided by the number of keys, will cause an assertion error.
Usage of this "class"
Read CIF file and store the information in a map
type the following line: std::map<std::string, std::vector<std::string>> cif_info; ModuleIO::CifParser::read("test.cif", cif_info);
Information of the cif file will stored in key-value pair manner, like cif_info["_cell_length_a"] = {"2.46772428"}; cif_info["_cell_length_b"] = {"2.46772428"}; ... cif_info["_atom_site_label"] = {"C1", "C2", ...}; cif_info["_atom_site_fract_x"] = {"0.00000000", "0.33333300", ...}; ... NOTE1: only keys in table will have value with length larger than 1, otherwise all words will be saved in the only element in std::vector<std::string>. For example please see unittest of this class at source/source_io/test/cif_io_test.cpp. NOTE2: One should note that for some cif files, the number will be in the format like "0.00000000(1)", which means the uncertainty of the number is 1 in the last digit. In this case, user should be careful to convert the string to double by its own.
Write CIF file with the given information.
ModuleIO::CifParser::write("test.cif", ...); For detailed usage, see the static methods in the class. A to-be-deprecated usage is simple as: ModuleIO::CifParser cif("test.cif", ucell); , where ucell is an instance of UnitCell. This usage is not encouraged.
Pythonization information
- function write it is recommended to pythonize the 2nd overload of this function, the 3rd one will be deprecated in the future.
- function read this function can be directly pythonized.