
macro makepath 1
   "make chi(k) and chi(R) for a single path"
   ff2chi($1, group=path$1)
   fftf(real = path$1.chi)
end macro
macro showpath 1
   "show -|chi(R)| for a path"
   makepath $1
   plot(path$1.r, -path$1.chir_mag, $2)
end macro


read_data(../data/cu_chi.dat, group = data, type=chi)
unguess 
guess  s02   = 1.
guess  e0    = 1.
guess  ss2   = 0.002
guess  ss2_2 = 0.002
guess  ss2_3 = 0.002
guess  dr    = 0.001
guess  dr_2  = 0.001
guess  dr_3  = 0.001

path(index  = 1, 
     feff   = ../feff/feffcu01.dat, 
     label  = "Cu metal first neighbor", 
     s02    = s02, 
     sigma2 = ss2,
     delr   = dr, 
     e0     = e0 )

path(2,  ../feff/feffcu02.dat,     s02 = s02, e0 = e0, 
     sigma2  = ss2_2,      delr=dr_2)

path(3,  ../feff/feffcu03.dat,     s02 = s02, e0 = e0, 
     sigma2  = ss2_3,      delr=dr_3)

set kmin = 2,   kmax=17, kweight=2, dk1 = 1, dk2=1
set rmin = 1.5, rmax =3.4

feffit(1-3, chi = data.chi, k=data.k,group = fit)

show @variables, chi_square, r_factor, n_idp, &fit_iteration

newplot data.r, data.chir_mag, xmax=7
plot    fit.r,  fit.chir_mag
showpath 1  "color=blue"
showpath 2  "color=red"
showpath 3  "color=black"
