| 1 |
#!/usr/bin/perl -w |
| 2 |
|
| 3 |
use strict; |
| 4 |
use warnings; |
| 5 |
use Test::More tests => 32; |
| 6 |
use Cwd; |
| 7 |
|
| 8 |
use Xray::Feff; |
| 9 |
|
| 10 |
|
| 11 |
my $epsilon = 1e-4; |
| 12 |
|
| 13 |
my $phases = Xray::Feff::Phases->new(); |
| 14 |
ok(ref($phases) =~ m{Feff::Phases}, "object created ".$phases); |
| 15 |
|
| 16 |
$phases -> jsonfile("../fortran/libpotph.json"); |
| 17 |
$phases -> _json_pp; |
| 18 |
|
| 19 |
$phases -> phpad("foo.pad"); |
| 20 |
ok($phases->wrapper->_phpad eq "foo.pad", "set phpad"); |
| 21 |
|
| 22 |
ok($phases->nat == 177, "nat"); |
| 23 |
ok($phases->wrapper->_nat == 177, "nat, wrapper"); |
| 24 |
|
| 25 |
ok($phases->nph == 1, "nph"); |
| 26 |
ok($phases->wrapper->_nph == 1, "nph, wrapper"); |
| 27 |
|
| 28 |
ok($phases->ntitle == 1, "ntitle"); |
| 29 |
ok($phases->wrapper->_ntitle == 1, "ntitle, wrapper"); |
| 30 |
|
| 31 |
ok($phases->ihole == 1, "ihole"); |
| 32 |
ok($phases->wrapper->_ihole == 1, "ihole, wrapper"); |
| 33 |
|
| 34 |
ok(abs($phases->gamach - 1.72919) < $epsilon, "gamach"); |
| 35 |
ok(abs($phases->wrapper->_gamach - 1.72919) < $epsilon, "gamach, wrapper"); |
| 36 |
|
| 37 |
ok(abs($phases->rgrd - 0.05) < $epsilon, "rgrd"); |
| 38 |
ok(abs($phases->wrapper->_rgrd - 0.05) < $epsilon, "rgrd, wrapper"); |
| 39 |
|
| 40 |
ok((($phases->iz->[0] == 29) and ($phases->iz->[1] == 29)), "iz array"); |
| 41 |
#print '>>>> ', join("|", $phases->wrapper->_iz_array), $/; |
| 42 |
ok(((($phases->wrapper->_iz_array)[0] == 29) and (($phases->wrapper->_iz_array)[1] == 29)), "iz array, wrapper"); |
| 43 |
|
| 44 |
ok((($phases->potlbl->[0] =~ m{\ACu\s*\z}) and ($phases->potlbl->[1] =~ m{\ACu\s*\z})), "potlbl array"); |
| 45 |
ok(((($phases->wrapper->_potlbl_array)[0] =~ m{\ACu\s*\z}) and (($phases->wrapper->_potlbl_array)[1] =~ m{\ACu\s*\z})), |
| 46 |
"potlbl array, wrapper"); |
| 47 |
|
| 48 |
# #print join(",", $phases->wrapper->_iz_array), $/; |
| 49 |
# #print join(",", @{$phases->iz}), $/; |
| 50 |
ok((($phases->lmaxsc->[0] == 2) and ($phases->lmaxsc->[1] == 2)), "lmaxsc array"); |
| 51 |
ok(((($phases->wrapper->_lmaxsc_array)[0] == 2) and (($phases->wrapper->_lmaxsc_array)[1] == 2)), |
| 52 |
"lmaxsc array, wrapper"); |
| 53 |
|
| 54 |
ok((($phases->xnatph->[0] == 1) and ($phases->xnatph->[1] == 100)), "xnatph array"); |
| 55 |
ok(((($phases->wrapper->_xnatph_array)[0] == 1) and (($phases->wrapper->_xnatph_array)[1] == 100)), |
| 56 |
"xnatph array, wrapper"); |
| 57 |
|
| 58 |
ok( ( (abs($phases->folp->[0] - 1.15) < $epsilon) and |
| 59 |
(abs($phases->folp->[1] - 1.15) < $epsilon) ), "folp array"); |
| 60 |
|
| 61 |
ok( ( (abs(($phases->wrapper->_folp_array)[0] - 1.15) < $epsilon) and |
| 62 |
(abs(($phases->wrapper->_folp_array)[1] - 1.15) < $epsilon) ), "folp array, wrapper"); |
| 63 |
|
| 64 |
|
| 65 |
## rat is confusing ... it needs to be flattened and unflattened using |
| 66 |
## the the interface provided by Inline::C |
| 67 |
## |
| 68 |
## the next several tests check a few points to verify that this is |
| 69 |
## working correctly and specific atom coordinates can be found correctly |
| 70 |
my $i = 1; |
| 71 |
ok( ( (abs( ($phases->wrapper->_rat_array)[($i-1)*3+0] ) < $epsilon) and |
| 72 |
(abs( ($phases->wrapper->_rat_array)[($i-1)*3+1] ) < $epsilon) and |
| 73 |
(abs( ($phases->wrapper->_rat_array)[($i-1)*3+2] ) < $epsilon) ), "atom no. $i"); |
| 74 |
|
| 75 |
$i = 2; |
| 76 |
ok( ( (abs( ($phases->wrapper->_rat_array)[($i-1)*3+0] - 1.805 ) < $epsilon) and |
| 77 |
(abs( ($phases->wrapper->_rat_array)[($i-1)*3+1] - 1.805 ) < $epsilon) and |
| 78 |
(abs( ($phases->wrapper->_rat_array)[($i-1)*3+2] ) < $epsilon) ), "atom no. $i"); |
| 79 |
|
| 80 |
$i = 3; |
| 81 |
ok( ( (abs( ($phases->wrapper->_rat_array)[($i-1)*3+0] + 1.805 ) < $epsilon) and |
| 82 |
(abs( ($phases->wrapper->_rat_array)[($i-1)*3+1] - 1.805 ) < $epsilon) and |
| 83 |
(abs( ($phases->wrapper->_rat_array)[($i-1)*3+2] ) < $epsilon) ), "atom no. $i"); |
| 84 |
|
| 85 |
$i = 13; |
| 86 |
ok( ( (abs( ($phases->wrapper->_rat_array)[($i-1)*3+0] ) < $epsilon) and |
| 87 |
(abs( ($phases->wrapper->_rat_array)[($i-1)*3+1] + 1.805 ) < $epsilon) and |
| 88 |
(abs( ($phases->wrapper->_rat_array)[($i-1)*3+2] + 1.805 ) < $epsilon) ), "atom no. $i"); |
| 89 |
|
| 90 |
$i = 23; |
| 91 |
ok( ( (abs( ($phases->wrapper->_rat_array)[($i-1)*3+0] + 1.805 ) < $epsilon) and |
| 92 |
(abs( ($phases->wrapper->_rat_array)[($i-1)*3+1] - 3.610 ) < $epsilon) and |
| 93 |
(abs( ($phases->wrapper->_rat_array)[($i-1)*3+2] - 1.805 ) < $epsilon) ), "atom no. $i"); |
| 94 |
|
| 95 |
$i = 177; |
| 96 |
ok( ( (abs( ($phases->wrapper->_rat_array)[($i-1)*3+0] + 1.805 ) < $epsilon) and |
| 97 |
(abs( ($phases->wrapper->_rat_array)[($i-1)*3+1] + 1.805 ) < $epsilon) and |
| 98 |
(abs( ($phases->wrapper->_rat_array)[($i-1)*3+2] + 7.220 ) < $epsilon) ), "atom no. $i"); |
| 99 |
|
| 100 |
ok( ($phases->iphat->[0] == 0 and |
| 101 |
$phases->iphat->[1] == 1 and |
| 102 |
$phases->iphat->[176] == 1), "iphat"); |
| 103 |
ok( (($phases->wrapper->_iphat_array)[0] == 0 and |
| 104 |
($phases->wrapper->_iphat_array)[1] == 1 and |
| 105 |
($phases->wrapper->_iphat_array)[176] == 1 ), "iphat, wrapper"); |
| 106 |
|
| 107 |
|
| 108 |
# foreach my $i (1,2,3,13,23,177) { |
| 109 |
# print join("|", $i, ($phases->wrapper->_rat_array)[($i-1)*3+0], |
| 110 |
# ($phases->wrapper->_rat_array)[($i-1)*3+1], |
| 111 |
# ($phases->wrapper->_rat_array)[($i-1)*3+2] ), $/; |
| 112 |
# }; |
| 113 |
|
| 114 |
# print join("|", 2, rat(1,2), rat(2,2), rat(3,2), iphat(2)), $/; |
| 115 |
# print join("|", 3, rat(1,3), rat(2,3), rat(3,3), iphat(3)), $/; |
| 116 |
# print join("|", 13, rat(1,13), rat(2,13), rat(3,13), iphat(13)), $/; |
| 117 |
# print join("|", 23, rat(1,23), rat(2,23), rat(3,23), iphat(23)), $/; |
| 118 |
|
| 119 |
|
| 120 |
#$phases->phases; |
| 121 |
unlink("foo.pad"); |
| 122 |
undef $phases; |
| 123 |
|
| 124 |
# print join(",", $self->wrapper->_iz_array), $/; |
| 125 |
# print join(",", $self->wrapper->_xnatph_array), $/; |
| 126 |
# 29,29 |
| 127 |
# 1,100 |
| 128 |
# ntitle 1 |
| 129 |
# nat 177 |
| 130 |
# nph 1 |
| 131 |
# ihole 1 |
| 132 |
# rscf -1 |
| 133 |
# lscf 0 |
| 134 |
# nscmt 0 |
| 135 |
# ca 0 |
| 136 |
# nmix 1 |
| 137 |
# ecv -40 |
| 138 |
# icoul 0 |
| 139 |
# elpty 0 |
| 140 |
# ispin 0 |
| 141 |
# angks 0 |
| 142 |
# gamach 1.72918818490579 |
| 143 |
# ixc 0 |
| 144 |
# vr0 0 |
| 145 |
# vi0 0 |
| 146 |
# ixc0 0 |
| 147 |
# iafolp 0 |
| 148 |
# rgrd 0.0500000007450581 |
| 149 |
# iunf 0 |
| 150 |
# inters 0 |
| 151 |
# totvol 0 |
| 152 |
# jumprm 0 |
| 153 |
# nohole -1 |