imaginary part is missing

after performing sf_calc(), imaginary parts of F_Ni, F_NiO1.... is missing (imaginary parts are 0). Q_x is real number in 0.1 < Q_x < 5


Function SF(occ, ASF, xx , z, u)
	wave ASF
	variable occ, xx, u, z
	variable/c ci = sqrt(-1)
	
	variable/c rtn = (occ * ASF * exp(ci*xx*z)*exp(-0.5*(xx*u)^2))
	
	return rtn
End


Function SF_calc()
	ASF_calc()
	
	wave Q_x
	wavestats/q Q_x
	variable/g u_res
	u_res = 1.1 / V_max
	
	variable/g u_Ni, u_Ni_eff
	u_Ni = 0.5
	u_Ni_eff = sqrt(u_res^2 + u_Ni^2)
	
	variable/g u_O, u_O_eff
	u_O = 0.1
	u_O_eff = sqrt(u_res^2 + u_O^2)
	
	//UNIT CELL AND CTR //
	Make/O/C/N=(numpnts(Q_x)) F_Ni, F_ctr
	wave ASF_Ni, ASF_Ni2, ASF_O
	
	variable/c ci = sqrt(-1)
	F_Ni = SF(uc_occ, ASF_Ni, Q_x, d_spacing, u_Ni)
	F_ctr = 1 / (1-exp(-ci*Q_x*d_spacing))
	
	
	//PASSIVATED NiO LAYER//
	Make/O/C/N=(numpnts(Q_x)) F_NiO1, F_NiO2, F_NiO3
	variable/g gap1, gap2, gap3
	
	gap1 = d_spacing
	gap2 = d_spacing
	gap3 = d_spacing * 1.1
	
	F_NiO1 = SF(2, ASF_Ni, Q_x, gap1, 0.5)
	F_NiO2  = SF(2, ASF_Ni, Q_x, gap2, 0.5)
	F_NiO3 = SF(2, ASF_Ni, Q_x, gap3, 0.5)
	
	Make/O/N=(numpnts(Q_x)) I_tot
	I_tot = magsqr(F_Ni*F_ctr + F_NiO1 + F_NiO2 + F_NiO3)
	
 	Make/O/N=3 coefwave
 	coefwave[0] = gap1
 	coefwave[1] = gap2
 	coefwave[2] = gap3
End

See the reply that I gave in your other post. You must do what you want ONE STEP AT A TIME. Your complex and long code has far too many basics mistakes to debug properly.

--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAH
One of those basic mistakes is that a complex function must be declared with /C:
Function/C SF(occ, ASF, xx , z, u)
. The /C flag tells Igor's compiler that the function returns a complex number.

I would also recommend reading the Programming help a few times. Each time through you will retain a bit more. The first time through a manual like the Programming help it is very hard to put together a coherent impression of the contents.

John Weeks
WaveMetrics, Inc.
support@wavemetrics.com