def calc_aff_mean_squared(numAtoms, elementList, Q, elementParameters): """Function to calculate the mean squared effective electron Form Factor, <f>^2 (eq. FZ-5). Parameters ---------- numAtoms : int number of atoms in the molecule elementList : dictionary("element": multiplicity) chemical elements of the sample with their multiplicity element : string chemical element multiplicity : int chemical element multiplicity Q : numpy array momentum transfer (nm^-1) 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 ------- aff_mean_squared : numpy array squared of the mean form factor: <f>^2 """ aff_mean_squared = np.zeros(Q.size) for element, multiplicity in elementList.items(): aff_mean_squared += multiplicity * MainFunctions.calc_aff( element, Q, elementParameters) aff_mean_squared /= numAtoms aff_mean_squared = aff_mean_squared**2 return aff_mean_squared
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