I, I_poly = 0.0, 0.0 for i in range(Nbins): qr = q * r[i] I += hr[i] * sinc(qr) I_poly += hr_poly[i] * sinc(qr) I /= np.amax(I) I_poly /= np.amax(I_poly) del hr, hr_poly if eta > 0.0: R = np.mean( a ) # very rough approximation, that the effective radius equals mean of a for the different particles S = calc_S(q, R, eta) else: S = np.ones(len(q)) ## save all intensities to textfile with open('Iq.d', 'w') as f: f.write('# q I(q) I(q) polydisperse S(q)\n') for i in range(M): f.write('%f %f %f %f\n' % (q[i], I[i], I_poly[i], S[i])) ## simulate exp error #input, sedlak errors (https://doi.org/10.1107/S1600576717003077) k = 10000 c = 0.85 if polydispersity > 0.0: mu = I_poly * S
dI = 0.0 for i in range(Nbins): qr = q * r[i] dI += dhr[i] * sinc(qr) dI /= np.amax(dI) I_poly += w * dI message.udpmessage({"_textarea": "."}) I_poly /= np.amax(I_poly) del dhr else: I_poly = I ## structure factor if eta > 0.0: #message.udpmessage({"_textarea":"\n\n R: %1.2f, eta: %1.2f\n" % (r_eff,eta)}) S = calc_S(q, r_eff, eta) else: S = np.ones(len(q)) ## interface roughness (Skar-Gislinge et al. DOI: 10.1039/c0cp01074j) if sigma_r > 0.0: roughness = np.exp(-(q * sigma_r)**2 / 2) I *= roughness I_poly *= roughness ## save all intensities to textfile with open('Iq.d', 'w') as f: f.write('# q I(q) I(q) polydisperse S(q)\n') for i in range(M): f.write('%f %f %f %f\n' % (q[i], I[i], I_poly[i], S[i]))