The attributes of the Atoms object can be populated in one of three ways, by reading an atoms.inp file, by reading a CIF file, or by setting the attributes programmatically.
The format of the atoms.inp file is documented elsewhere. Importing data from one is as simple as specifying the file when the Atoms object is created. In this example, an atoms.inp file is imported and an input file for FEFF6 is written to standard output.
- #!/usr/bin/perl use Demeter;
- my $atoms = Demeter::Atoms->new(file => "ybco.inp");
- print $atoms->Write("feff6");
The command-line ATOMS program that comes with DEMETER is longer than 5 lines, but does not really do much beyond this example.
Importing crystal data from a CIF file is no more difficult, however you need to explicitly tell the Atoms object that the input data is in CIF format. The Atoms object assumes that the value of the file attribute points at an atoms.inp file, so the cif attribute must be used to specify a CIF file.
- #!/usr/bin/perl use Demeter;
- my $atoms = Demeter::Atoms->new(cif => "Fe2N_ICSD.cif");
- print $atoms->Write("feff6");
The STAR::Parser module is used to interpret the CIF file. This is a quirky bit of code and my understanding of it is not so deep. There are probably examples of CIF files that do not get imported properly, but it seems to work in most cases. You should consider a valid CIF file that cannot be imported by DEMETER to be a reportable DEMETER bug.
CIF files can contain more than one structure. By default, DEMETER will import the first structure contained in the CIF file. To specify another structure, use the record attribute. Note that the counting is zero based, so this example is importing the second record in the CIF file. In a GUI like ARTEMIS, it is probably wise to let the user count from 1 and to do the translation behind the scenes.
- #!/usr/bin/perl use Demeter;
- my $atoms = Demeter::Atoms->new(cif => "AuCl.cif", record=>1);
- print $atoms->Write("feff6");