#check of 1 sphere MeO1 test simplified, k space, k_weight=0. Without restraint #set variables, now without norms for simplifying unguess guess(N_MeO1=7) guess(R_MeO1=2.10) guess(Sig_MeO1=0.004) guess(E_MeO1=0) S02=0.921 #set path Hf-O1 path(index=1, feff='feff0001.dat', label='MeO1', s02=S02*N_MeO1/degen, delr=R_MeO1-reff, sigma2=Sig_MeO1, e0=E_MeO1) noise_FT=3.92e-3 #reading the spectrum, interpolating, k range and num of data points #spectrum is 1 sphere hfo1 from the same feff with e1=5.1523,n1=7.0612,r1=2.1107,s1=7.4408e-3, the same S02 #generated in viper so could be some deviation, the result of fitting here is normal read_data(file=hfo1.chi, group=Me_chi_nonaligned,type=chi,title_lines=1) Me_chi.k=range(0,ceil(Me_chi_nonaligned.k),0.05) Me_chi.chi=interp(Me_chi_nonaligned.k,Me_chi_nonaligned.chi,Me_chi.k) kmin_Me_chi=floor(Me_chi_nonaligned.k) kmax_Me_chi=ceil(Me_chi_nonaligned.k) #fit feffit(1,k=Me_chi.k,chi=Me_chi.chi,group=fit, kmin=kmin_Me_chi,kmax=kmax_Me_chi, rmin=0,rmax=2.4,kwindow=hanning, dk=0, epsilon_k=noise_FT,kweight=0,fit_space=k) show @variables #calculate chi_square by formula manually k_step=0.05 small=k_step*1e-2 datmodel.func=(Me_chi.chi-fit.chi)**2 n_kmin=(kmin_Me_chi+small)/k_step+1 n_kmax=(kmax_Me_chi+small)/k_step #array has k=0 point as first, something not sure with indices, but now right datmodel_sliced.func=slice(datmodel.func,n_kmin+1,n_kmax+1) N_pts_Me_chi=npts(datmodel_sliced.func) chi_square_calc=N_idp/(2*N_pts_Me_chi)*vsum(datmodel_sliced.func)/epsilon_k**2 #compare manual calculation with program value show chi_square_calc, chi_square norm_chi=chi_square_calc/chi_square show norm_chi