def calc_iintraFZ(Q, QmaxIntegrate, maxQ, elementList, element, x, y, z, elementParameters, aff_mean_squared): """Function to calculate the intramolecular contribution of i(Q) (eq. 41). Parameters ---------- Q : numpy array momentum transfer (nm^-1) fe_Q : numpy array effective electric form factor Ztot : int total Z number QmaxIntegrate : float maximum Q value for the intagrations maxQ : float maximum Q value elementList : dictionary("element": multiplicity) chemical elements of the sample with their multiplicity element : string chemical element multiplicity : int chemical element multiplicity element : string array array with the elements in the xyz_file x, y, z : float array atomic coordinate in the xyz_file (nm) elementParameters : dictionary("element": parameters) chemical elements of the sample with their parameters element : string chemical element parameters : list list of the parameters (Z, a1, b1, a2, b2, a3, b3, a4, b4, c, M, K, L) Returns ------- iintra_Q : numpy array intramolecular contribution of i(Q) """ iintra_Q = np.zeros(Q.size) sinpq = np.zeros(Q.size) for ielem in range(len(element)): for jelem in range(len(element)): if ielem != jelem: # print(ielem, jelem) # print(type(element[ielem])) # print(element[ielem], elementList[element[ielem]], element[jelem], elementList[element[jelem]]) f_Qi = MainFunctions.calc_aff(element[ielem], Q, elementParameters) f_Qj = MainFunctions.calc_aff(element[jelem], Q, elementParameters) f_i = np.mean(elementList[element[ielem]] * f_Qi / 3) f_j = np.mean(elementList[element[jelem]] * f_Qj / 3) # f_i = np.mean(f_Qi) # f_j = np.mean(f_Qj) ff = f_i * f_j d = Utility.calc_distMol(x[ielem], y[ielem], z[ielem], x[jelem], y[jelem], z[jelem]) if d != 0.0: iintra_Q += ff * np.sin(d * Q) / (d * Q) iintra_Q[Q == 0.0] = ff iintra_Q[(Q > QmaxIntegrate) & (Q <= maxQ)] = 0.0 iintra_Q /= np.mean(aff_mean_squared) # iintra_Q /= 3 return iintra_Q
def calc_iintra(Q, fe_Q, Ztot, QmaxIntegrate, maxQ, elementList, element, x, y, z, elementParameters): """Function to calculate the intramolecular contribution of i(Q) (eq. 41). Parameters ---------- Q : numpy array momentum transfer (nm^-1) fe_Q : numpy array effective electric form factor Ztot : int total Z number QmaxIntegrate : float maximum Q value for the intagrations maxQ : float maximum Q value elementList : dictionary("element": multiplicity) chemical elements of the sample with their multiplicity element : string chemical element multiplicity : int chemical element multiplicity element : string array array with the elements in the xyz_file x, y, z : float array atomic coordinate in the xyz_file (nm) elementParameters : dictionary("element": parameters) chemical elements of the sample with their parameters element : string chemical element parameters : list list of the parameters (Z, a1, b1, a2, b2, a3, b3, a4, b4, c, M, K, L) Returns ------- iintra_Q : numpy array intramolecular contribution of i(Q) """ iintra_Q = np.zeros(Q.size) sinpq = np.zeros(Q.size) for ielem in range(len(element)): for jelem in range(len(element)): if ielem != jelem: Kpi = MainFunctions.calc_Kp(fe_Q, element[ielem], Q, elementParameters) Kpj = MainFunctions.calc_Kp(fe_Q, element[jelem], Q, elementParameters) KK = Kpi * Kpj d = Utility.calc_distMol(x[ielem], y[ielem], z[ielem], x[jelem], y[jelem], z[jelem]) if d != 0.0: iintra_Q += KK * np.sin(d * Q) / (d * Q) iintra_Q[Q == 0.0] = KK iintra_Q[(Q > QmaxIntegrate) & (Q <= maxQ)] = 0.0 iintra_Q /= Ztot**2 # iintra_Q /= 3 return iintra_Q