(Demeter main page) (Cookbook main page)

Atoms and Feff

The Atoms and Feff interfaces are evolving in Demeter. Their features and interfaces are subject to change.

How do I run Atoms using Demeter?

This script replicates almost all the functionality of any prior version of Atoms.

   1 #!/usr/bin/perl
   2 use Demeter;  ## strict and warnings imported automatically with Demeter
   3 
   4 my $atoms = Demeter::Atoms->new(file => "ybco.inp");
   5 print $atoms->Write("feff6");

It's that simple. A Feff6 input file will be written to standard output.

At this moment, Demeter is not reading CIF files, but that is a small chore. When CIF import is supported, Demeter will figure out the input format seamlessly.

Output files are formed using templates. Currently templates exist for feff6, feff7, feff8, absorption, and atoms. The argument to the Write method chooses the output template.

In the future, OpenBabel will be used to write other output formats, such as Protein Data Bank, Alchemy, and so on. If you need one of those immediately, it would be simple to write a new template.

How do I run Feff using Demeter?

See Demeter/Feff for an overview of Demeter's interface with Feff.

This script reads a Feff input file, computes the potentials, runs the path finder, and serializes the results to a file. Although this example reads a file actually called feff.inp, the Feff input file need not actually be called that (which is a huge improvement over old skool Feff!)

   1 #!/usr/bin/perl
   2 use Demeter; ## strict and warnings imported automatically with Demeter
   3 
   4 my $feff = Demeter::Feff -> new(file => "feff/feff.inp");
   5 $feff->set(workspace=>"feff", screen=>1,);
   6 
   7 $feff -> potph;         # use Feff to compute potnetials
   8 $feff -> pathfinder;    # use Demeter's pathfinder
   9 
  10 ### Freezing this cluster+pathlist to a YAML
  11 $feff->freeze("feff/feff.yaml");

Here is the screen output of this script. The first few lines are familiar to anyone who has ever run Feff. Only the first part of Feff is run -- the part that computes the potentials and writes the phase.bin file. The lines starting with equals signs are the progress messages of the path finder.

At the end, the state of the Feff calculation is written to the file feff.yaml. This is a text file in the YAML format which has been compressed in the gzip format. This file is used to do things with the results of the path finder calculation.

Writing an interpretation of the Feff calculation

This script writes an interpretation of the Feff calculation which is rather like the one presented in Artemis.

   1 #!/usr/bin/perl 
   2 use Demeter; ## strict and warnings imported automatically with Demeter
   3 
   4 ## Deserializing the feff.yaml file;
   5 my $feff = Demeter::Feff -> new(yaml => "feff/feff.yaml");
   6 print $feff->intrp;

Some new information (compared to Artemis) is available in this interpretation. Demeter uses heuristics to make a guess about which paths are significant. The Importance column displays this guess. Paths with an importance of 2 probably cannot be ignored. These tend to be single scattering paths and colinear or nearly colinear multiple scattering paths. Paths with an importance of 1 include various triangles and four legged paths that "rattle" between the absorber and one other atoms. These may or may not be important. Paths with 0 importance probably do not carry significant spectral weight. Please not that these evaluations are determined by heuristics. I try to be conservative, preferring false positives to false negatives. You should always check your paths.

At the end of each line is a description of the paths geometry which, hopefully, will help you visualize the structure of the path.

Writing a paths.dat file and running genfmt

This script finishes off the Feff calculation in a way that closely resembles the normal behavior of Feff. Demeter writes a paths.dat file (line 7) then runs Feff's genfmt segment (line 10) which writes out the feffNNNN.dat files.

   1 #!/usr/bin/perl 
   2 use Demeter; ## strict and warnings imported automatically with Demeter
   3 
   4 ## Deserializing feff.yaml;
   5 my $feff = Demeter::Feff -> new(yaml => "feff/feff.yaml");
   6 
   7 $feff->pathsdat(); # all paths
   8 #$feff->pathsdat(1,2,6,9); # the first four SS paths
   9 
  10 $feff->genfmt;

The genfmt output can be controlled using the argument of the pathsdat method, which is a list of path indeces. (See line 8, which is commented out.) Only those paths will be written to feffNNNN.dat files by genfmt since only those paths will be listed in the paths.dat file.

Examining the geometries contributing to the degeneracy of a path

One of the features of Demeter's path finder is that it remembers the scattering geometries of every degenerate path. This is demonstrated in this script, which writes out the guts of a paths.dat file with one entry for each of the degenerate paths.

   1 #!/usr/bin/perl 
   2 use Demeter; ## strict and warnings imported automatically with Demeter
   3 
   4 ## Deserializing feff.yaml;
   5 my $feff = Demeter::Feff -> new("feff/feff.yaml");
   6 my @list_of_paths = $feff->pathlist;
   7 
   8 ### The 6 scattering geometries that contribute to path #2:
   9 my $sp = $list_of_paths[1];
  10 my $j=1000;
  11 foreach my $s ($sp->all_strings) {
  12   print $sp -> pathsdat(index=>++$j, string=>$s, angles=>1);
  13 };

Here is what gets printed:

Note that the pathlist method of the Feff object (line 6) returns a list of ScatteringPath objects. The pathsdat method of the ScatteringPath object is used to write out the paths.dat entry for each scattering geometry.

Plotting paths

This script imports the serialized path finder calculation and plots the first several paths. The next recipe is the first hint about how ScatteringPath objects will be used in a fit.

   1 #!/usr/bin/perl 
   2 use Demeter; ## strict and warnings imported automatically with Demeter
   3 
   4 my $plot_features = Demeter::Plot -> new();
   5 $plot_features->legend(key_dy => 0.05, # set nice legend parameters for the plot
   6                        key_x  => 0.6);
   7 
   8 ## Deserializing feff.yaml;
   9 my $feff = Demeter::Feff -> new(yaml => "feff/feff.yaml");
  10 my @list_of_paths = $feff->pathlist;
  11 
  12 ### Plotting the first 6 paths
  13 my @pobjects = ();
  14 foreach my $i (0 .. 5) {
  15   my $j = $i+1;
  16   Demeter::Path -> new()
  17       -> set(sp    => $list_of_paths[$i],
  18              index => $j,
  19             )
  20         -> plot('r');
  21 };

Here is the plot. The sharp observer will see one difference between this list of paths and what a normal Feff6 calculation using the default heap and keep criteria values would produce. The fourth path is one which falls below the heap criterion, which uses a plane wave approximation to find paths which are too small to put onto the heap. With no such capability, Demeter's path finder includes that path in the final list.


attachment:paths.png

How do I integrate the Feff and Fitting systems in Demeter?

Here is the multiple data set copper fit from the data handling recipes page rewritten to use the Feff and ScatteringPath objects, along with the lguess and characteristic value model building tools:

   1 #!/usr/bin/perl     ### multiple data set fit to Cu foil data at two temperatures
   2 use Demeter; ## strict and warnings imported automatically with Demeter
   3 
   4 my $plot = Demeter::Plot -> new();
   5 ## -----------------------------------------------------------
   6 my $demeter = Demeter->new();
   7 $demeter -> set_mode(screen  => 0, ifeffit => 1, file => ">mdsfit.iff",);
   8 
   9 my @common = (fft_kmin   => 3,    fft_kmax   => 14,
  10               bft_rmax   => 1.0,  bft_rmax   => 4.3,
  11               fit_k1     => 1,    fit_k3     => 1,);
  12 
  13 my $data_010k = Demeter::Data -> new();
  14 $data_010k -> set(@common);
  15 $data_010k -> set(file        => "cu10k.chi",
  16                   label      => '10 K copper data',
  17                   cv         => 10,
  18                  );
  19 my $data_150k = Demeter::Data -> new();
  20 $data_150k -> set(@common);
  21 $data_150k -> set(file       => "cu150k.chi",
  22                   label      => '150 K copper data',
  23                   cv         => 150,
  24                  );
  25 
  26 ###--- make GDS objects for an isotropic expansion, correlated Debye model
  27 my @gdsobjects =  
  28    (Demeter::GDS -> new(type => 'lguess', name => 'alpha', mathexp => 0,),
  29     $demeter -> simpleGDS("guess amp = 1"),   ## here is some syntactic sugar provided by the Tools module
  30     Demeter::GDS -> new(type => 'guess',  name => 'enot',  mathexp => 0,),
  31     Demeter::GDS -> new(type => 'guess',  name => 'theta', mathexp => 500,),
  32     Demeter::GDS -> new(type => 'set',    name => 'sigmm', mathexp => 0.0005,),
  33    );
  34 
  35 ## thaw a Feff calculation
  36 my $feff = Demeter::Feff -> new(yaml => "cu_feff.yaml");
  37 my @scattering_paths = $feff->pathlist;
  38 
  39 ## make Path objects for the first 6 paths in copper (3 shell fit)
  40 my @paths_010k = ();
  41 foreach my $i (0 .. 5) {
  42   my $j = $i+1;
  43   $paths_010k[$i] = Demeter::Path -> new();
  44   $paths_010k[$i]->set(data     => $data_010k,
  45                        sp       => $scattering_paths[$i],
  46                        label    => "10K, path $j",
  47                        s02      => 'amp',
  48                        e0       => 'enot',
  49                        delr     => 'alpha*reff',
  50                        sigma2   => 'debye([cv], theta) + sigmm',
  51                       );
  52 };
  53 
  54 ## clone these 5 paths for the second data set
  55 my @paths_150k = ();
  56 foreach my $i (0 .. 4) {
  57   my $j = $i+1;
  58   $paths_150k[$i] = $paths_010k[$i] -> clone(data   => $data_150k,
  59                                              label  => "150K, path $j",
  60                                             );
  61 };
  62 
  63 ## make a Fit object
  64 my $fitobject = Demeter::Fit -> new(gds   => \@gdsobjects,
  65                                     data  => [$data_010k, $data_150k],
  66                                     paths => [@paths_010k, @paths_150k],
  67                                    );
  68 ## do the fit
  69 $fitobject -> fit;

A Feff calculation on copper metal is thawed at line 36 and the list of paths is read at line 37. Then at line 45, the sp attribute is set to a thawed ScatteringPath from the Feff calculation. When using a ScatteringPath object rather than directly reading a feffNNNN.dat file, you do not (must not!) set the file and folder attributes by hand. Note that the feffNNNN.dat file is given a strange name which is chosen to avoid filename collisions resulting from rerunning Feff or from running multiple Feff calculations.

When Demeter sets up the fit at line 66, it will notice that the feffNNNN.dat file does not exist for any of the Path objects and will run Feff to make them as soon as it is needed.

/!\ Note that in version 0.1 there are still some shortcomings in Demeter's serialization scheme. You need to be careful that Demeter can find the phase.bin file from the original Feff calculation. Fixing this shortcoming is one of the goals for version 0.2.


Demeter/Cookbook/03AtomsAndFeff (last edited 2009-10-09 19:46:31 by localhost)