Debian Codegraph @

wrappers/perl/lib/Xray/Feff/Phases.pm

raw
1 package Xray::Feff::Phases;
2
3 use Moose;
4 #use MooseX::Storage;
5 #with Storage('format' => 'JSON', 'io' => 'File');
6 use MooseX::NonMoose;
7 use MooseX::Aliases;
8 extends 'Xray::Feff::PhasesWrapper';
9
10
11 use JSON;
12 use List::MoreUtils qw(any);
13
14 our $VERSION = '1.00'; # Inline::MakeMake uses /^\d.\d\d$/ as the
15 # pattern for the version number -- note the
16 # two digits to the right of the dot
17
18 has 'wrapper' => (
19 is => 'ro',
20 #traits => [qw(DoNotSerialize)],
21 isa => 'Xray::Feff::PhasesWrapper',
22 init_arg => undef,
23 default => sub{ Xray::Feff::PhasesWrapper->new() },
24 #lazy => 1,
25 #builder => '_build_object',
26 );
27
28 has 'errorcode' => (is => 'rw', isa => 'Int', default => 0,);
29 has 'errormessage' => (is => 'rw', isa => 'Str', default => q{},);
30
31 ## constants from feffpath.h
32 has 'natx' => (is => 'ro', isa => 'Int', default => sub{ Xray::Feff::PhasesWrapper->_natx });
33 has 'nphx' => (is => 'ro', isa => 'Int', default => sub{ Xray::Feff::PhasesWrapper->_nphx });
34 has 'nheadx' => (is => 'ro', isa => 'Int', default => sub{ Xray::Feff::PhasesWrapper->_nheadx });
35 has 'bohr' => (is => 'ro', isa => 'Num', default => sub{ Xray::Feff::PhasesWrapper->_bohr });
36 has 'ryd' => (is => 'ro', isa => 'Num', default => sub{ Xray::Feff::PhasesWrapper->_ryd });
37 has 'hart' => (is => 'ro', isa => 'Num', default => sub{ Xray::Feff::PhasesWrapper->_hart });
38
39 ## i/o files
40 has 'phpad' => (is => 'rw', isa => 'Str', default => 'phase.pad', trigger => sub{pushback(@_, 'phpad' )});
41 has 'jsonfile' => (is => 'rw', isa => 'Str', default => 'libpotph.json', trigger => sub{pushback(@_, 'jsonfile' )});
42 has 'useperljson' => (is => 'rw', isa => 'Bool', default => 1);
43 has 'verbose' => (is => 'rw', isa => 'Bool', default => 0, trigger => sub{pushback(@_, 'verbose' )});
44
45 ## scalars
46 has 'ntitle' => (is => 'rw', isa => 'Int', default => 0, trigger => sub{pushback(@_, 'ntitle' )});
47 has 'nat' => (is => 'rw', isa => 'Int', default => 0, trigger => sub{pushback(@_, 'nat' )});
48 has 'nph' => (is => 'rw', isa => 'Int', default => 0, trigger => sub{pushback(@_, 'nph' )});
49 has 'ihole' => (is => 'rw', isa => 'Int', default => 1, trigger => sub{pushback(@_, 'ihole' )});
50 has 'rscf' => (is => 'rw', isa => 'Num', default => 4.0, trigger => sub{pushback(@_, 'rscf' )});
51 has 'lscf' => (is => 'rw', isa => 'Int', default => 0, trigger => sub{pushback(@_, 'lscf' )});
52 has 'nscmt' => (is => 'rw', isa => 'Int', default => 0, trigger => sub{pushback(@_, 'nscmt' )});
53 has 'ca' => (is => 'rw', isa => 'Num', default => 0.0, trigger => sub{pushback(@_, 'ca' )});
54 has 'nmix' => (is => 'rw', isa => 'Int', default => 0, trigger => sub{pushback(@_, 'nmix' )});
55 has 'ecv' => (is => 'rw', isa => 'Num', default => -40.0, trigger => sub{pushback(@_, 'ecv' )});
56 has 'icoul' => (is => 'rw', isa => 'Int', default => 0, trigger => sub{pushback(@_, 'icoul' )});
57 has 'ipol' => (is => 'rw', isa => 'Int', default => 0, trigger => sub{pushback(@_, 'ipol' )});
58 has 'elpty' => (is => 'rw', isa => 'Num', default => 0.0, trigger => sub{pushback(@_, 'elpty' )});
59 has 'ispin' => (is => 'rw', isa => 'Int', default => 0, trigger => sub{pushback(@_, 'ispin' )});
60 has 'angks' => (is => 'rw', isa => 'Num', default => 0.0, trigger => sub{pushback(@_, 'angks' )});
61 has 'gamach' => (is => 'rw', isa => 'Num', default => 0.0, trigger => sub{pushback(@_, 'gamach' )});
62 has 'ixc' => (is => 'rw', isa => 'Int', default => 0, trigger => sub{pushback(@_, 'ixc' )});
63 has 'vr0' => (is => 'rw', isa => 'Num', default => 0.0, trigger => sub{pushback(@_, 'vr0' )});
64 has 'vi0' => (is => 'rw', isa => 'Num', default => 0.0, trigger => sub{pushback(@_, 'vi0' )});
65 has 'ixc0' => (is => 'rw', isa => 'Int', default => 0, trigger => sub{pushback(@_, 'ixc0' )});
66 has 'iafolp' => (is => 'rw', isa => 'Int', default => 0, trigger => sub{pushback(@_, 'iafolp' )});
67 has 'rgrd' => (is => 'rw', isa => 'Num', default => 0.0, trigger => sub{pushback(@_, 'rgrd' )});
68 has 'iunf' => (is => 'rw', isa => 'Int', default => 0, trigger => sub{pushback(@_, 'iunf' )});
69 has 'inters' => (is => 'rw', isa => 'Int', default => 0, trigger => sub{pushback(@_, 'inters' )});
70 has 'totvol' => (is => 'rw', isa => 'Num', default => 0.0, trigger => sub{pushback(@_, 'totvol' )});
71 has 'jumprm' => (is => 'rw', isa => 'Int', default => 0, trigger => sub{pushback(@_, 'jumprm' )});
72 has 'nohole' => (is => 'rw', isa => 'Int', default => 0, trigger => sub{pushback(@_, 'nohole' )});
73
74 ## three vectors
75 has 'evec' => (traits => ['Array'],
76 is => 'rw',
77 isa => 'ArrayRef[Num]',
78 default => sub { [0,0,0] },
79 trigger => \&evec_set, );
80 has 'xivec' => (traits => ['Array'],
81 is => 'rw',
82 isa => 'ArrayRef[Num]',
83 default => sub { [0,0,0] },
84 trigger => \&xivec_set, );
85 has 'spvec' => (traits => ['Array'],
86 is => 'rw',
87 isa => 'ArrayRef[Num]',
88 default => sub { [0,0,0] },
89 trigger => \&spvec_set, );
90 #has 'ptz' => (is => 'rw', isa => 'ArrayRef[ArrayRef]', default => sub{[]});
91
92
93 ## potentials information
94 has 'iz' => (is => 'rw', isa => 'ArrayRef', default => sub{[]}, trigger => sub{set_pot_array(@_, "iz")});
95 has 'potlbl' => (is => 'rw', isa => 'ArrayRef', default => sub{[]}, trigger => sub{set_pot_array(@_, "potlbl")});
96 has 'lmaxsc' => (is => 'rw', isa => 'ArrayRef', default => sub{[]}, trigger => sub{set_pot_array(@_, "lmaxsc")});
97 has 'lmaxph' => (is => 'rw', isa => 'ArrayRef', default => sub{[]}, trigger => sub{set_pot_array(@_, "lmaxph")});
98 has 'xnatph' => (is => 'rw', isa => 'ArrayRef', default => sub{[]}, trigger => sub{set_pot_array(@_, "xnatph")});
99 has 'spinph' => (is => 'rw', isa => 'ArrayRef', default => sub{[]}, trigger => sub{set_pot_array(@_, "spinph")});
100 has 'folp' => (is => 'rw', isa => 'ArrayRef', default => sub{[]}, trigger => sub{set_pot_array(@_, "folp")});
101 has 'xion' => (is => 'rw', isa => 'ArrayRef', default => sub{[]}, trigger => sub{set_pot_array(@_, "xion")});
102
103 ## atoms list
104 has 'iphat' => (is => 'rw', isa => 'ArrayRef', default => sub{[]});
105 has 'rat' => (is => 'rw', isa => 'ArrayRef[ArrayRef]', default => sub{[]});
106
107 has 'titles' => (is => 'rw', isa => 'ArrayRef', default => sub{[]}, trigger => \&set_titles_array);
108
109
110
111 sub BUILD {
112 my ($self) = @_;
113 $self->wrapper->_create_phases;
114 return $self;
115 };
116
117 sub DEMOLISH {
118 my ($self) = @_;
119 #print "in my DEMOLISH\n";
120 #print $self->wrapper, $/;
121 $self->wrapper->_cleanup;
122 return $self;
123 };
124
125 sub clear {
126 my ($self) = @_;
127 $self->wrapper->_clear_phases;
128 return $self;
129 };
130
131 sub _dump {
132 my ($self) = @_;
133 $self->wrapper->_dump;
134 return $self;
135 };
136
137 sub _json_c {
138 my ($self) = @_;
139 my $ret = $self->wrapper->_read_libpotph_json;
140 $self->_fetch;
141 return $ret;
142 };
143 sub _json_pp {
144 my ($self) = @_;
145 my $json_text = $self->_slurp($self->jsonfile);
146 my $rhash = decode_json($json_text);
147
148 foreach my $meth (qw(ntitle nat nph ihole rscf lscf nscmt ca nmix ecv icoul ipol elpty ispin angks gamach
149 ixc vr0 vi0 ixc0 iafolp rgrd iunf inters totvol jumprm nohole
150 iz potlbl lmaxsc lmaxph xnatph spinph folp xion titles)) {
151 my $att = ($meth eq 'nat') ? 'natt'
152 : ($meth eq 'rscf') ? 'rfms1'
153 : ($meth eq 'lscf') ? 'lfms1'
154 : ($meth eq 'ca') ? 'ca1'
155 : ($meth eq 'vr0') ? 'vro'
156 : ($meth eq 'vi0') ? 'vio'
157 : ($meth eq 'iphat') ? 'iphatx'
158 : $meth;
159 $self->$meth($rhash->{$att});
160 };
161 ## truncate lists to correct size
162 foreach my $meth (qw(iz potlbl lmaxsc lmaxph xnatph spinph folp xion)) {
163 $#{$self->$meth} = $self->nph;
164 };
165 $#{$self->titles} = $self->ntitle;
166 my @lables = ();
167 foreach my $pl (@{$self->potlbl}) {
168 push @lables, sprintf("%-6s", $pl);
169 };
170 $self->potlbl(\@lables);
171 my @titles = ();
172 foreach my $ti (@{$self->titles}) {
173 push @titles, sprintf("%-79s\0", $ti);
174 };
175 $self->titles(\@titles);
176
177 my @rat = ();
178 my $x = $rhash->{x};
179 my $y = $rhash->{y};
180 my $z = $rhash->{z};
181 foreach my $i (0 .. $rhash->{natt}-1) {
182 my $this = [$x->[$i], $y->[$i], $z->[$i]];
183 push @rat, $this;
184 };
185 $self->rat(\@rat);
186 $self->wrapper->_set_rat_array(map {@$_} @rat); # flatten argument, then unflatten for the C struct
187
188 my $ip = $rhash->{iphatx};
189 $self->iphat($ip);
190 $self->wrapper->_set_iphat_array(@$ip);
191 };
192
193
194 sub phases {
195 my ($self) = @_;
196 my $ret = $self->wrapper->_make_phases;
197 ## fetch polarization tensor
198 $self->errormessage($self->wrapper->_errormessage);
199 $self->errorcode($self->wrapper->_errorcode);
200 if ($ret) {
201 printf("%s\n\t(error code %d)\n", $self->errormessage, $self->errorcode);
202 };
203 return $ret;
204 };
205
206 sub _fetch {
207 my ($self) = @_;
208 foreach my $att (qw(ntitle nat nph ihole rscf lscf nscmt ca nmix ecv icoul ipol elpty ispin angks gamach
209 ixc vr0 vi0 ixc0 iafolp rgrd iunf inters totvol jumprm nohole)) {
210 my $method = '_'.$att;
211 $self->$att($self->wrapper->$method);
212 };
213 foreach my $att (qw(evec xivec spvec)) {
214 my $method = '_'.$att;
215 $self->$att([$self->wrapper->$method]);
216 };
217 foreach my $att (qw(iz potlbl lmaxsc lmaxph xnatph spinph folp xion titles iphat)) { ## rat
218 my $method = '_'.$att.'_array';
219 $self->$att([$self->wrapper->$method]);
220 };
221 my @biglist = $self->wrapper->_rat_array;
222 my @rat = ();
223 while (@biglist) { # rat[nat][3] is returned as a flattened list (x1,y1,z1,x2,y2,z2,...xN,yN,zN)
224 my $this = [shift(@biglist), shift(@biglist), shift(@biglist)];
225 push @rat, $this;
226 };
227 $self->rat(\@rat);
228 return $self;
229 };
230
231
232 ## ------------------------------------------------------------
233 ## trigger methods
234
235 sub pushback {
236 my ($self, $new, $old, $which) = @_;
237 #print "setting $which\n";
238 #return if (any {$_ eq $which} qw(gamach));
239 my $method = '_set_' . lc($which);
240 if ($self->meta->get_attribute($which)->type_constraint eq 'Num') {
241 $self->wrapper->$method(1.0*$new);
242 } elsif ($self->meta->get_attribute($which)->type_constraint eq 'Bool') {
243 my $val = ($new) ? 1 : 0;
244 $self->wrapper->$method($val);
245 } else {
246 $self->wrapper->$method($new);
247 };
248 $self->ipol(1) if (($which eq 'elpty') and $self->wrapper->_elpty);
249 if ($which eq 'jsonfile') {
250 ($self->useperljson) ? $self->_json_pp : $self->_json_c;
251 };
252 };
253
254 sub evec_set {
255 my ($self, $vec) = @_;
256 $self->wrapper->_set_evec(1.0*$vec->[0], 1.0*$vec->[1], 1.0*$vec->[2]);
257 $self->ipol(1) if ($vec->[0] or $vec->[1] or $vec->[2]);
258 return $self;
259 };
260 sub xivec_set {
261 my ($self, $vec) = @_;
262 $self->wrapper->_set_xivec(1.0*$vec->[0], 1.0*$vec->[1], 1.0*$vec->[2]);
263 $self->ipol(1) if ($vec->[0] or $vec->[1] or $vec->[2]);
264 return $self;
265 };
266 sub spvec_set {
267 my ($self, $vec) = @_;
268 $self->wrapper->_set_spvec(1.0*$vec->[0], 1.0*$vec->[1], 1.0*$vec->[2]);
269 $self->ispin(1) if ($vec->[0] or $vec->[1] or $vec->[2]);
270 return $self;
271 };
272
273 sub set_pot_array {
274 my ($self, $new, $old, $which) = @_;
275 #print "setting $which\n";
276 my @list;
277 if ($which =~ m{iz|iphat|lmaxsc|lmaxph}) {
278 @list = map {int($_)} @$new; # constrain to be integer
279 #print join("|", @list), $/ if $which eq 'iz';
280 } elsif ($which =~ m{xnatph|folp|xion|spinph}) {
281 @list = map {$_*1.0} @$new; # constrain to be float
282 } elsif ($which =~ m{potlbl}) {
283 foreach my $s (@$new) { # constrain to be 6 characters or less
284 push @list, (length($s) > 6) ? substr($s,0,6) : $s;
285 };
286 };
287 my $method = '_set_' . lc($which) . '_array';
288 $self->wrapper->$method(@list);
289 return $self;
290 };
291
292 sub set_titles_array {
293 my ($self, $new, $old) = @_;
294 my @list;
295 foreach my $s (@$new) { # constrain to be 6 characters or less
296 push @list, (length($s) > 6) ? substr($s,0,6) : $s;
297 };
298 $self->wrapper->_set_titles_array(@list);
299 return $self;
300 };
301
302 sub set_rat_array {
303 my ($self, $new, $old) = @_;
304 my @list = map {@$_} @{$new}; # flatten rat, which is a list of lists
305 $self->wrapper->_set_rat_array(@list);
306 return $self;
307 };
308
309 sub _slurp {
310 my ($class, $file) = @_;
311 local $/;
312 return q{} if (not -e $file);
313 return q{} if (not -r $file);
314 open(my $FH, $file);
315 my $text = <$FH>;
316 close $FH;
317 return $text;
318 };
319
320 sub serialize {
321 my ($self, $fname) = @_;
322 $self->store($fname);
323 };
324
325
326 no Moose;
327 __PACKAGE__->meta->make_immutable;
328 1;
329
330
331
332 =head1 NAME
333
334 Xray::FeffPath - Moose wrapper around an Inline::C interface to libfeffpath
335
336 =head1 VERSION
337
338 1.00
339
340 =head1 SYNOPSIS
341
342 This provides a simple object oriented interface to the C<feffphases>
343 wrapper around Feff's C<libpotph> subroutine. C<feffphases> combines
344 the potentials and phase shifts calculations, writing a F<phase.pad>
345 file to disk.
346
347 The following computes the phase shifts for copper metal:
348
349 #!/usr/bin/perl
350 use strict;
351 use warnings;
352 use Xray::Feff::Phases;
353 my $cu = Xray::Feff::Phases->new;
354 ##--- gather information about the calculation and cluster
355 $cu->jsonfile('../fortran/libpotph.json');
356 ##--- set the output file
357 $cu->phpad('cu_phases.pad');
358 ##--- run feff's potentials and phases calculator
359 $cu->phases;
360
361 =head1 INSTALLATION
362
363 See L<Xray::Feff>.
364
365 =head1 METHODS
366
367 =over 4
368
369 =item C<new>
370
371 Create the FeffPhases object
372
373 my $phases = Xray::Feff::Phases->new();
374
375 =item C<clear>
376
377 Reinitialize the phases object
378
379 $path->clear;
380
381 =item C<phases>
382
383 Compute the phases and write the output file, F<phase.pad> or as
384 specified by the C<phpad> attribute.
385
386 $path->phases;
387
388 =back
389
390 To destroy a FeffPath object, simply do
391
392 undef $path;
393
394 Deallocation of memory in the C stuct will be handled by the wrapper.
395
396 =head1 ATTRIBUTES
397
398 Each of the members of the FEFFPATH struct is wrapped in a getter
399 method of the same name. Each of the following exists:
400
401 =head2 Scalar valued attributes
402
403 =over 4
404
405 =item C<phpad> (character, default = phase.pad)
406
407 The path for writing the F<phase.pad> file.
408
409 =item C<jsonfile> (character, default = libpotph.json)
410
411 The path to the F<libpth.json> file. The JSON file is read
412 immediately upon setting this attribute.
413
414 =item C<errorcode> (integer)
415
416 An integer error code from either C<phases>. Check for non-zero
417 value. See C<errormessage> for an explanation of the problem.
418
419 =item C<errormessage> (string)
420
421 A explanation of words of the problem found during C<phases>.
422
423 $path->phases;
424 if ($path->errorcode) {
425 print $path->errormessage;
426 };
427 ## ==prints==>
428 Blah blah blah
429
430 =iten C<verbose> (boolean)
431
432 Controls whether Feff writes its screen messages. False means to run
433 Feff silently.
434
435 =item C<ntitle> (int)
436
437 number of header lines (TITLE)
438
439 =item C<titles> (\*\*char)
440
441 (nheadx) array of header string (TITLE)
442
443 =item C<nat> (int)
444
445 number of atoms in cluster (ATOMS)
446
447 =item C<rat> (\*\*double)
448
449 (3,natx) cartesian coordinates of atoms in cluster (ATOMS)
450
451 =item C<iphat> (\*int)
452
453 (natx) unique potential indeces of atoms in cluster (ATOMS)
454
455 =item C<nph> (int)
456
457 number of unique potentials (POTENTIALS)
458
459 =item C<iz> (\*int)
460
461 (0:nphx) Z numbers of unique potentials (POTENTIALS)
462
463 =item C<potlbl> (\*\*char)
464
465 (0:nphx) labels of unique potentials (POTENTIALS)
466
467 =item C<lmaxsc> (\*int)
468
469 (0:nphx) l max for SCF for each potential (POTENTIALS)
470
471 =item C<lmaxph> (\*int)
472
473 (0:nphx) l max for FMS for each potential (POTENTIALS)
474
475 =item C<xnatph> (\*double)
476
477 (0:nphx) stoichiometry of each potential (POTENTIALS)
478
479 =item C<spinph> (\*double)
480
481 (0:nphx) spin on each unique potential (POTENTIALS)
482
483 =item C<ihole> (int)
484
485 edge index, 1=K, 4=L3, etc (HOLE/EDGE)
486
487 =item C<rscf> (double)
488
489 cluster radius for self-consistent calculation (SCF)
490
491 =item C<lscf> (int)
492
493 0=solid, 1=molecule (SCF)
494
495 =item C<nscmt> (int)
496
497 max number of self-consistency iterations (SCF)
498
499 =item C<ca> (double)
500
501 self-consistency convergence accelerator (SCF)
502
503 =item C<nmix> (int)
504
505 number of mixing iterations before Broyden (SCF)
506
507 =item C<ecv> (double)
508
509 core/valence separation energy (SCF)
510
511 =item C<icoul> (int)
512
513 obsolete param. for handling Coulomb potential (SCF)
514
515 =item C<ipol> (int)
516
517 1=do polarization calculation (POLARIZATION)
518
519 =item C<evec> (\*double)
520
521 (3) polarization array (POLARIZATION)
522
523 =item C<elpty> (double)
524
525 eccentricity of elliptical light (ELLIPTICITY)
526
527 =item C<xivec> (\*double)
528
529 (3) ellipticity array (ELLIPTICITY)
530
531 =item C<ispin> (int)
532
533 +/-2 = do spin calculation (SPIN)
534
535 =item C<spvec> (\*double)
536
537 (3) spin array (SPIN)
538
539 =item C<angks> (double)
540
541 angle between spin and incidient beam (SPIN)
542
543 =item C<ptz> (double complex)
544
545 (-1:1,-1:1) polarization tensor (return)
546
547 =item C<gamach> (double)
548
549 tabulated core-hole lifetime (return)
550
551 =item C<ixc> (int)
552
553 exchange index (EXCHANGE)
554
555 =item C<vr0> (double)
556
557 Fermi level offset (EXCHANGE)
558
559 =item C<vi0> (double)
560
561 constant broadening (EXCHANGE)
562
563 =item C<ixc0> (int)
564
565 exchange index for background function (EXCHANGE)
566
567 =item C<iafolp> (int)
568
569 1=do automated overlapping (FOLP & AFOLP)
570
571 =item C<folp> (\*double)
572
573 (0:nphx) overlapping fractions (FOLP & AFOLP)
574
575 =item C<xion> (\*double)
576
577 (0:nphx) potential ionizations (ION)
578
579 =item C<rgrd> (double)
580
581 radial grid used for the potentials/phases (RGRID)
582
583 =item C<iunf> (int)
584
585 1=unfreeze f electrons (UNFREEZEF)
586
587 =item C<inters> (int)
588
589 (INTERSTITIAL)
590
591 =item C<totvol> (double)
592
593 (INTERSTITIAL)
594
595 =item C<jumprm> (int)
596
597 1=remove potential jumps at muffin tin radii (JUMPRM)
598
599 =item C<nohole> (int)
600
601 1=compute without core-hole (NOHOLE)
602
603 =back
604
605 =head2 Constants from feffpath.h
606
607 The following constants are captured from the feffpath header file:
608
609 =over 4
610
611 =item C<natx> (1000)
612
613 The maximum number of atoms in the cluster.
614
615 =item C<nphx> (11)
616
617 The maximum number of unique potentials.
618
619 =item C<nheadx> (30)
620
621 The maximum number of title l;ines
622
623 =item C<bohr> (0.529177249)
624
625 A unit of length, in Angstrom.
626
627 =item C<ryd> (13.605698)
628
629 A Rydberg, a unit of energy, in eV.
630
631 =item C<hart> (27.211396)
632
633 A Hartree, a unit of energy, in eV.
634
635 =back
636
637 =head2 3-vector array-reference
638
639 =over 4
640
641 =item C<evec>
642
643 The electric vector of the incident beam for the polarization
644 calculation. Note that the setter's argument is an array reference as
645 is the getter's return value.
646
647 $phases->evec([0,0,1]);
648 $evec_ref = $phases->evec;
649 print join(", ", @$evec_ref);
650 ## ==prints==> 0, 0, 1
651
652 Setting C<evec> will also set C<ipol> to true.
653
654 =item C<xivec>
655
656 The Poynting vector of the incident beam for the ellipticity
657 calculation. Note that the setter's argument is an array reference as
658 is the getter's return value.
659
660 $phases->xivec([1,1,0]);
661 $xivec_ref = $phases->xivec;
662 print join(", ", @$xivec_ref);
663 ## ==prints==> 1, 1, 0
664
665 Setting C<xivec> will also set C<ipol> to true.
666
667 =item C<spvec>
668
669 The Poynting vector of the incident beam for the ellipticity
670 calculation. Note that the setter's argument is an array reference as
671 is the getter's return value.
672
673 $phases->xivec([1,1,0]);
674 $xivec_ref = $phases->xivec;
675 print join(", ", @$xivec_ref);
676 ## ==prints==> 1, 1, 0
677
678 Setting C<xivec> will also set C<ispin> to true.
679
680 =back
681
682 =head2 Array-references decribing the unique potentials
683
684 =over 4
685
686 =item C<iz>
687
688 A reference to an array containing the Z numbers of each unique
689 potential.
690
691 =item C<potlbl>
692
693 Label for each potential index (up to 6 characters)
694
695 =item C<lmaxsc>
696
697 Maximum angular momentum for use in self consistency calculation
698
699 =item C<lmaxph>
700
701 Maximum angular momentum for use in XANES calculation
702
703 =item C<xnatph>
704
705 Stoichiometry of each potential in the cluster
706
707 =item C<spinph>
708
709 Spin on each potential
710
711 =item C<folp>
712
713 Overlap fraction for each potential
714
715 =item C<xion>
716
717 Ionization on each potential.
718
719 =back
720
721 =head2 Array-references decribing the unique potentials
722
723 =over 4
724
725 =item C<iphat>
726
727 =item C<rat>
728
729 =back
730
731 =head1 Error codes
732
733 The error codes returned by the C<phases> methods are the sums of the
734 codes actually found by the method call, thus the returned error codes
735 are meant to be interpreted bitwise.
736
737 =over 4
738
739 =item I<1>
740
741 Too many unique potentials
742
743 =item I<2>
744
745 Too many atoms
746
747 =item I<4>
748
749 Edge index ust be between 1 and 9, i.e. K to M5
750
751 =item I<8>
752
753 A potential is defined with an invalid Z number
754
755 =item I<16>
756
757 A potential is defined with an invalid angular momentum
758
759 =item I<32>
760
761 A potential is defined with a negative stoichiometry
762
763 =item I<64>
764
765 Overlap fraction must be between 0.7 and 1.5
766
767 =item I<128>
768
769 invalid ionization in potentials list (NOT USED)
770
771 =item I<256>
772
773 bad rscf (NOT USED)
774
775 =item I<512>
776
777 Convergence accelerator (ca) should be around 0.2, maybe a bit smaller
778
779 =item I<1024>
780
781 Core/valence separation energy (ecv) must be negative
782
783 =item I<2048>
784
785 Exchange index (ixc) be 0, 1, 2, 3, or 5
786
787 =item I<4096>
788
789 Radial grid (rgrid) should be around 0.05, maybe a bit smaller, not negative
790
791 =item I<8192>
792
793 Invalid potential index used or additional absorber in cluster
794
795 =back
796
797
798 =head1 EXTERNAL DEPENDENCIES
799
800 =over 4
801
802 =item *
803
804 L<Inline>, and L<Inline::C>
805
806 =item *
807
808 L<Moose>
809
810 =item *
811
812 L<MooseX::NonMoose> and L<MooseX::Aliases>
813
814 =back
815
816 =head1 BUGS AND LIMITATIONS
817
818 =over 4
819
820 =item *
821
822 Need better methods for moving C<rat> and C<iphat> into and out of the
823 C struct. I think I need to know a bit more about the eventual UI
824 intended to replace the F<feff.inp> file....
825
826 =item *
827
828 Polarization tensor is not handled at all.
829
830 =back
831
832
833 Please report problems to Bruce Ravel (bravel AT bnl DOT gov)
834
835 Patches are welcome.
836
837 =head1 AUTHOR
838
839 Bruce Ravel (bravel AT bnl DOT gov)
840
841 L<https://github.com/bruceravel>
842
843 =head1 LICENSE AND COPYRIGHT
844
845 To the extent possible, the authors have waived all rights granted by
846 copyright law and related laws for the code and documentation that
847 make up the Perl Interface to the feffpath library. While information
848 about Authorship may be retained in some files for historical reasons,
849 this work is hereby placed in the Public Domain. This work is
850 published from: United States.
851
852 Note that the feffphases and libpotph libraries themselves are NOT public
853 domain, nor is the Fortran source code for Feff that it relies upon.
854
855 Author: Bruce Ravel (bravel AT bnl DOT gov).
856 Created: 5 June, 2015
857
858 =cut