Reading data from crystal structure and chemical fragment files into PoreMatMod.jl
This section details how to load data into PoreMatMod.jl, including the handling of paths to data and input file formats.
Crystal structures
Accepted file formats for crystal structures (containing atomic coordinates and unit cell information) are .cif (see here) and .cssr.
Crystal structure files (.cif, .cssr) are read from the path rc[:paths][:crystals].
Read in the crystal structure of IRMOF-1.cif and infer its bonding graph:
parent = Crystal("IRMOF-1.cif")
infer_bonds!(parent, true) # true b/c we want periodic bonds includedThe Crystal constructor returns a Crystal data structure. The infer_bonds! function infers the bonding graph of the crystal structure (nodes: atoms, edges: bonds) based on interatomic distances–-necessary for subgraph matching. Both Crystal and infer_bonds! are inherited from Xtals.jl (see the docs).
Query and Replacement Fragments
Accepted file formats for chemical fragments (list of atoms and their Cartesian coordinates) are .xyz (see here).
Query and replacement fragment files (.xyz) are read from the path rc[:paths][:moieties].
N.b. masked atoms of query fragments must be labeled with ! for replace operations. For substructure searches using substructure_search, any ! tags are ignored (the atoms are treated according to their chemical species).
Read in the chemical fragment p-phenylene.xyz:
query = moiety("p-phenylene.xyz")The moiety reader also returns a Crystal data structure but with a (arbitrary) unit cube unit cell.
Changing the Data Directories
rc[:paths][:crystals] and rc[:paths][:moieties] default to ./data/crystals and ./data/moieties, respectively.
To change the paths from where the input files are read, change rc[:paths][:crystals] and rc[:paths][:moieties].
Suppose we wish to store our .cif files in ~/my_xtals and our .xyz files in our present working directory.
rc[:paths][:crystals] = joinpath(homedir(), "my_xtals")
rc[:paths][:moiety] = pwd() Other data
PoreMatMod.jl draws atomic masses and covalent radii from Xtals.jl.
Detailed documentation for functions
PoreMatMod.moiety — Functionq = moiety(xyz_filename)Generates a moiety (Crystal) from an .xyz file found in rc[:paths][:moieties].
Use set_path_to_data or set rc[:paths][:moieties] to change the path from which the XYZ file is read.
Atoms appended with '!' are tagged for replacement via substructure_replace.
Bonds are inferred automatically via infer_bonds!.
Arguments
xyz_filename::Union{String,Nothing}the moiety input file name, an.xyzfile; if set tonothingthe moiety is the null set.bonding_rules::Union{Vector{BondingRule},Nothing}(optional) a list of rules to use for inferring the bonding network of the atoms loaded from the XYZ file. If set tonothing, the default rules are used.
Xtals.Crystal — Typecrystal = Crystal(filename;
check_neutrality=true, net_charge_tol=1e-4,
check_overlap=true, convert_to_p1=true,
read_bonds_from_file=false, wrap_coords=true,
include_zero_charges=true,
remove_duplicates=false,
species_col=["_atom_site_type_symbol", "_atom_site_label"]
) # read from file
crystal = Crystal(name, box, atoms, charges) # construct from matter, no bonds, P1-symmetry assumedRead a crystal structure file (.cif or .cssr) and populate a Crystal data structure, or construct a Crystal data structure directly.
Arguments
filename::String: the name of the crystal structure file (include ".cif" or ".cssr") read fromPATH_TO_CRYSTALS.check_neutrality::Bool: check for charge neutralitynet_charge_tol::Float64: when checking for charge neutrality, throw an error if the absolute value of the net charge is larger than this value.check_overlap::Bool: throw an error if overlapping atoms are detected.convert_to_p1::Bool: If the structure is not in P1 it will be converted to P1 symmetry using the symmetry rules from the_symmetry_equiv_pos_as_xyzlist in the .cif file. (We do not use the space groups name to look up symmetry rules).read_bonds_from_file::Bool: Whether or not to read bonding information from cif file. If false, the bonds can be inferred later. note that, if the crystal is not in P1 symmetry, we cannot both read bonds and convert to P1 symmetry.wrap_coords::Bool: iftrue, enforce that fractional coords of atoms and charges are in [0,1]³ by mod(x, 1)include_zero_charges::Bool: iffalse, do not include incrystal.chargesatoms which have zero charges, in order to speed up the electrostatic calculations. Iftrue,include the atoms incrystal.chargesthat have zero charge, ensuring that the number of atoms is equal to the number of charges and thatcrystal.charges.coords.xfandcrystal.atoms.coords.xfare the same.remove_duplicates::Bool: remove duplicate atoms and charges. an atom is duplicate only if it is the same species.species_col::Array{String}: which column to use for species identification forcrystal.atoms.species. we use a priority list: we check for the first entry ofspecies_colin the .cif file; if not present, we then use the second entry, and so on.infer_bonds::Union{Symbol, Missing}: if set, bonds are inferred according to the chosen method (:cordero or :voronoi). If set, must specifyperiodic_boundaries. By default, bonds are not inferred.periodic_boundaries::Union{Bool, Missing}: use withinfer_bondsto specify treatment of the unit cell boundary. Settrueto treat the unit cell edge as a periodic boundary (allow bonds across it); setfalseto restrict bonding to within the local unit cell.
across periodic unit cell boundaries; if false, bonds are only inferred within the local unit cell; if missing (default), bonds are not inferred.
Returns
crystal::Crystal: A crystal containing the crystal structure information
Attributes
name::AbstractString: name of crystal structurebox::Box: unit cell (Bravais Lattice)atoms::Atoms: list of Atoms in crystal unit cellcharges::Charges: list of point charges in crystal unit cellbonds::MetaGraph: Unweighted, undirected graph showing all of the atoms that are bonded within the crystalsymmetry::SymmetryInfo: symmetry inforomation
Xtals.infer_bonds! — Functioninfer_bonds!(crystal, include_bonds_across_periodic_boundaries; bonding_rules=rc[:bonding_rules])Populate the bonds in the crystal object based on the bonding rules. If a pair doesn't have a suitable rule then they will not be considered bonded.
:* is considered a wildcard and can be substituted for any species. It is a good idea to include a bonding rule between two :* to allow any atoms to bond as long as they are close enough.
The bonding rules are hierarchical, i.e. the first bonding rule takes precedence over the latter ones.
Arguments
crystal::Crystal: The crystal that bonds will be added to.include_bonds_across_periodic_boundaries::Bool: Whether to check across the periodic boundary when calculating bonds.bonding_rules::Array{BondingRule, 1}: The array of bonding rules that will be used to fill the bonding information. They are applied in the order that they appear.rc[:bonding_rules]will be used if none provided.calculate_vectors::Bool: Optional. Settrueto annotate all edges in thebondsgraph with vector information.
Xtals.BondingRule — Typebonding_rule = BondingRule(:Ca, :O, 2.0)
bonding_rules = [BondingRule(:H, :*, 1.2),
BondingRule(:*, :*, 1.9)]A rule for determining if two atoms within a crystal are bonded.
Attributes
species_i::Symbol: One of the atoms types for this bond rulespecies_j::Symbol: The other atom type for this bond rulemax_dist: The maximum distance between the atoms for bonding to occur
Xtals.strip_numbers_from_atom_labels! — Functionstrip_numbers_from_atom_labels!(crystal)Strip numbers from labels for crystal.atoms. Precisely, for atom in crystal.atoms, find the first number that appears in atom. Remove this number and all following characters from atom. e.g. C12 –> C Ba12A_3 –> Ba
Arguments
crystal::Crystal: The crystal containing the crystal structure information