def y(self): """ Define the function in terms of x to return some value """ svol = 1.5 * 0.0172**2 / 370**2 # scattering volume in cm^3 self.update_params() mkey = 'Solvent' sol_density = tuple(np.ones_like(self.__Density__[mkey])) R = self.__R__[mkey] rho, eirho, adensity, rhor, eirhor, adensityr = calc_rho( R=tuple(R), material=tuple(self.__material__[mkey]), relement=self.relement, density=tuple(self.__Density__[mkey]), sol_density=sol_density, Energy=self.Energy, Rmoles=tuple(self.__Rmoles__[mkey]), NrDep=self.NrDep) for mkey in self.__mkeys__: if mkey != 'Solvent': trho, teirho, tadensity, trhor, teirhor, tadensityr = calc_rho( R=tuple(self.__R__[mkey]), material=tuple(self.__material__[mkey]), relement=self.relement, density=tuple(self.__Density__[mkey]), sol_density=sol_density, Energy=self.Energy, Rmoles=tuple(self.__Rmoles__[mkey]), NrDep=self.NrDep) vf = np.array(self.__VolFrac__[mkey]) rho = rho + vf * trho eirho = eirho + vf * teirho adensity = adensity + vf * tadensity major = np.sum(self.__R__[self.__mkeys__[0]]) minor = np.sum( np.array(self.__R__[self.__mkeys__[0]]) * np.array(self.__RzRatio__[self.__mkeys__[0]])) self.output_params['scaler_parameters'][ 'Diameter (Angstroms)'] = 2 * major self.output_params['scaler_parameters'][ 'Height (Angstroms)'] = 2 * minor if self.dist == 'LogNormal': dstd = 2 * np.sqrt((np.exp(self.Rsig**2) - 1) * np.exp(2 * np.log(major) + self.Rsig**2)) hstd = 2 * np.sqrt((np.exp(self.Rsig**2) - 1) * np.exp(2 * np.log(minor) + self.Rsig**2)) self.output_params['scaler_parameters'][ 'Diameter_Std (Angstroms)'] = dstd self.output_params['scaler_parameters'][ 'Height_Std (Angstroms)'] = hstd else: self.output_params['scaler_parameters'][ 'Diameter_Std (Angstroms)'] = 2 * self.Rsig self.output_params['scaler_parameters'][ 'Height_Std (Angstroms)'] = 2 * self.Rsig * minor / major if type(self.x) == dict: sqf = {} key = 'SAXS-term' sqft = self.ellipsoid_dict( tuple(self.x[key]), tuple(self.__R__[self.__mkeys__[0]]), tuple(self.__RzRatio__[self.__mkeys__[0]]), self.Rsig, tuple(rho), tuple(eirho), tuple(adensity), dist=self.dist, Np=self.Np, Nalf=self.Nalf) if self.SF is None: struct = np.ones_like( self.x[key] ) # hard_sphere_sf(self.x[key], D = self.D, phi = 0.0) elif self.SF == 'Hard-Sphere': struct = hard_sphere_sf(self.x[key], D=self.D, phi=self.phi) else: struct = sticky_sphere_sf(self.x[key], D=self.D, phi=self.phi, U=self.U, delta=0.01) for key in self.x.keys(): if key == 'SAXS-term': sqf[key] = self.norm * 6.022e20 * sqft[ key] * struct + self.sbkg # in cm^-1 if key == 'Cross-term': sqf[key] = self.norm * 6.022e20 * sqft[ key] * struct + self.cbkg # in cm^-1 if key == 'Resonant-term': sqf[key] = self.norm * 6.022e20 * sqft[ key] * struct + self.abkg # in cm^-1 key1 = 'Total' total = self.norm * 6.022e20 * sqft[key1] * struct + self.sbkg if not self.__fit__: dr, rdist, totalR = self.calc_Rdist( tuple(self.__R__[self.__mkeys__[0]]), self.Rsig, self.dist, self.Np) self.output_params['Distribution'] = {'x': dr, 'y': rdist} self.output_params['Total'] = {'x': self.x[key], 'y': total} for key in self.x.keys(): self.output_params[key] = {'x': self.x[key], 'y': sqf[key]} xtmp, ytmp = create_steps(self.__R__[self.__mkeys__[0]], rho) self.output_params['rho_r'] = {'x': xtmp, 'y': ytmp} xtmp, ytmp = create_steps(self.__R__[self.__mkeys__[0]], eirho) self.output_params['eirho_r'] = {'x': xtmp, 'y': ytmp} xtmp, ytmp = create_steps(self.__R__[self.__mkeys__[0]], adensity) self.output_params['adensity_r'] = {'x': xtmp, 'y': ytmp} self.output_params['Structure_Factor'] = { 'x': self.x[key], 'y': struct } # xtmp,ytmp=create_steps(x=self.__R__[][:-1],y=self.__Rmoles__[:-1]) # self.output_params['Rmoles_radial']={'x':xtmp,'y':ytmp} # xtmp, ytmp = create_steps(x=self.__R__[:-1], y=self.__RzRatio__[:-1]) # self.output_params['RzRatio_radial'] = {'x': xtmp, 'y': ytmp} # xtmp, ytmp = create_steps(x=self.__R__[:-1], y=self.__density__[:-1]) # self.output_params['Density_radial'] = {'x': xtmp, 'y': ytmp} else: if self.SF is None: struct = np.ones_like(self.x) elif self.SF == 'Hard-Sphere': struct = hard_sphere_sf(self.x, D=self.D, phi=self.phi) else: struct = sticky_sphere_sf(self.x, D=self.D, phi=self.phi, U=self.U, delta=0.01) tsqf, eisqf, asqf, csqf = self.ellipsoid( tuple(self.x), tuple(self.__R__[self.__mkeys__[0]]), tuple(self.__RzRatio__[self.__mkeys__[0]]), self.Rsig, tuple(rho), tuple(eirho), tuple(adensity), dist=self.dist, Np=self.Np, Nalf=self.Nalf) sqf = self.norm * np.array( tsqf) * 6.022e20 * struct + self.sbkg # in cm^-1 # if not self.__fit__: #Generate all the quantities below while not fitting asqf = self.norm * np.array( asqf) * 6.022e20 * struct + self.abkg # in cm^-1 eisqf = self.norm * np.array( eisqf) * 6.022e20 * struct + self.sbkg # in cm^-1 csqf = self.norm * np.array( csqf) * 6.022e20 * struct + self.cbkg # in cm^-1 sqerr = np.sqrt(6.022e20 * self.norm * self.flux * tsqf * svol + self.sbkg) sqwerr = (6.022e20 * self.norm * tsqf * svol * self.flux + self.sbkg + 2 * (0.5 - np.random.rand(len(tsqf))) * sqerr) dr, rdist, totalR = self.calc_Rdist( tuple(self.__R__[self.__mkeys__[0]]), self.Rsig, self.dist, self.Np) self.output_params['Distribution'] = {'x': dr, 'y': rdist} self.output_params['simulated_total_w_err'] = { 'x': self.x, 'y': sqwerr, 'yerr': sqerr } self.output_params['Total'] = {'x': self.x, 'y': sqf} self.output_params['Resonant-term'] = {'x': self.x, 'y': asqf} self.output_params['SAXS-term'] = {'x': self.x, 'y': eisqf} self.output_params['Cross-term'] = {'x': self.x, 'y': csqf} xtmp, ytmp = create_steps(self.__R__[self.__mkeys__[0]], rho) self.output_params['rho_r'] = {'x': xtmp, 'y': ytmp} xtmp, ytmp = create_steps(self.__R__[self.__mkeys__[0]], eirho) self.output_params['eirho_r'] = {'x': xtmp, 'y': ytmp} xtmp, ytmp = create_steps(self.__R__[self.__mkeys__[0]], adensity) self.output_params['adensity_r'] = {'x': xtmp, 'y': ytmp} self.output_params['Structure_Factor'] = {'x': self.x, 'y': struct} # xtmp, ytmp = create_steps(x=self.__R__[:-1], y=self.__Rmoles__[:-1]) # self.output_params['Rmoles_radial'] = {'x':xtmp , 'y': ytmp} # sqf = self.output_params[self.term]['y'] # xtmp, ytmp = create_steps(x=self.__R__[:-1], y=self.__RzRatio__[:-1]) # self.output_params['RzRatio_radial'] = {'x': xtmp, 'y': ytmp} # xtmp, ytmp = create_steps(x=self.__R__[:-1], y=self.__density__[:-1]) # self.output_params['Density_radial'] = {'x': xtmp, 'y': ytmp} return sqf
def y(self): """ Define the function in terms of x to return some value """ svol = 1.5 * 0.0172**2 / 370**2 # scattering volume in cm^3 self.output_params = {'scaler_parameters': {}} self.update_params() mkey = 'Solvent' sol_density = tuple(np.ones_like(self.__Density__[mkey])) R = self.__R__[mkey] rho, eirho, adensity, rhor, eirhor, adensityr = calc_rho( R=tuple(R), material=tuple(self.__material__[mkey]), relement=self.relement, density=tuple(self.__Density__[mkey]), sol_density=sol_density, Energy=self.Energy, Rmoles=tuple(self.__Rmoles__[mkey]), NrDep=self.NrDep) for mkey in self.__mkeys__: if mkey != 'Solvent': trho, teirho, tadensity, trhor, teirhor, tadensityr = calc_rho( R=tuple(self.__R__[mkey]), material=tuple(self.__material__[mkey]), relement=self.relement, density=tuple(self.__Density__[mkey]), sol_density=sol_density, Energy=self.Energy, Rmoles=tuple(self.__Rmoles__[mkey]), NrDep=self.NrDep) vf = np.array(self.__VolFrac__[mkey]) rho = rho + vf * trho eirho = eirho + vf * teirho adensity = adensity + vf * tadensity if type(self.x) == dict: sqf = {} for key in self.x.keys(): sqf[key] = self.norm * 6.022e20 * self.new_sphere_dict( tuple(self.x[key]), tuple(self.__R__[self.__mkeys__[0]]), self.Rsig, tuple(rho), tuple(eirho), tuple(adensity), key=key, dist=self.dist, Np=self.Np) # in cm^-1 if self.SF is None: struct = np.ones_like( self.x[key] ) # hard_sphere_sf(self.x[key], D = self.D, phi = 0.0) elif self.SF == 'Hard-Sphere': struct = hard_sphere_sf(self.x[key], D=self.D, phi=self.phi) else: struct = sticky_sphere_sf(self.x[key], D=self.D, phi=self.phi, U=self.U, delta=0.01) if key == 'SAXS-term': sqf[key] = sqf[key] * struct + self.sbkg if key == 'Cross-term': sqf[key] = sqf[key] * struct + self.cbkg if key == 'Resonant-term': sqf[key] = sqf[key] * struct + self.abkg key1 = 'Total' total = self.norm * 6.022e20 * struct * self.new_sphere_dict( tuple(self.x[key]), tuple(self.__R__[self.__mkeys__[0]]), self.Rsig, tuple(rho), tuple(eirho), tuple(adensity), key=key1, dist=self.dist, Np=self.Np) + self.sbkg # in cm^-1 if not self.__fit__: dr, rdist, totalR = self.calc_Rdist( tuple(self.__R__[self.__mkeys__[0]]), self.Rsig, self.dist, self.Np) self.output_params['Distribution'] = {'x': dr, 'y': rdist} self.output_params['Simulated_total_wo_err'] = { 'x': self.x[key], 'y': total } self.output_params['Total'] = {'x': self.x[key], 'y': total} for key in self.x.keys(): self.output_params[key] = {'x': self.x[key], 'y': sqf[key]} self.output_params['rho_r'] = { 'x': rhor[:, 0], 'y': rhor[:, 1] } self.output_params['eirho_r'] = { 'x': eirhor[:, 0], 'y': eirhor[:, 1] } self.output_params['adensity_r'] = { 'x': adensityr[:, 0], 'y': adensityr[:, 1] } self.output_params['Structure_Factor'] = { 'x': self.x[key], 'y': struct } else: if self.SF is None: struct = np.ones_like(self.x) elif self.SF == 'Hard-Sphere': struct = hard_sphere_sf(self.x, D=self.D, phi=self.phi) else: struct = sticky_sphere_sf(self.x, D=self.D, phi=self.phi, U=self.U, delta=0.01) tsqf, eisqf, asqf, csqf = self.new_sphere( tuple(self.x), tuple(self.__R__[self.__mkeys__[0]]), self.Rsig, tuple(rho), tuple(eirho), tuple(adensity), dist=self.dist, Np=self.Np) sqf = self.norm * np.array( tsqf) * 6.022e20 * struct + self.sbkg # in cm^-1 # if not self.__fit__: #Generate all the quantities below while not fitting asqf = self.norm * np.array( asqf) * 6.022e20 * struct + self.abkg # in cm^-1 eisqf = self.norm * np.array( eisqf) * 6.022e20 * struct + self.sbkg # in cm^-1 csqf = self.norm * np.array( csqf) * 6.022e20 * struct + self.cbkg # in cm^-1 sqerr = np.sqrt(6.020e20 * self.flux * self.norm * tsqf * struct * svol + self.sbkg) sqwerr = (6.022e20 * tsqf * svol * self.flux * self.norm * struct + self.sbkg + 2 * (0.5 - np.random.rand(len(tsqf))) * sqerr) dr, rdist, totalR = self.calc_Rdist( tuple(self.__R__[self.__mkeys__[0]]), self.Rsig, self.dist, self.Np) self.output_params['Distribution'] = {'x': dr, 'y': rdist} self.output_params['simulated_total_w_err'] = { 'x': self.x, 'y': sqwerr, 'yerr': sqerr } self.output_params['Total'] = {'x': self.x, 'y': sqf} self.output_params['Resonant-term'] = {'x': self.x, 'y': asqf} self.output_params['SAXS-term'] = {'x': self.x, 'y': eisqf} self.output_params['Cross-term'] = {'x': self.x, 'y': csqf} self.output_params['rho_r'] = {'x': rhor[:, 0], 'y': rhor[:, 1]} self.output_params['eirho_r'] = { 'x': eirhor[:, 0], 'y': eirhor[:, 1] } self.output_params['adensity_r'] = { 'x': adensityr[:, 0], 'y': adensityr[:, 1] } self.output_params['Structure_Factor'] = {'x': self.x, 'y': struct} return sqf
def y(self): """ Define the function in terms of x to return some value """ self.output_params = {'scaler_parameters': {}} self.update_params() rho, eirho, adensity, rhor, eirhor, adensityr = self.calc_rho(R=tuple(self.__R__), material=tuple(self.__material__), relement=self.relement, density=tuple(self.__density__), sol_density=tuple(self.__sol_density__), Energy=self.Energy, Rmoles=tuple(self.__Rmoles__), NrDep=self.NrDep) if type(self.x) == dict: sqf = {} for key in self.x.keys(): sqf[key] = self.norm * 6.022e20 * self.new_sphere_dict(tuple(self.x[key]), tuple(self.__R__), self.Rsig, tuple(rho), tuple(eirho), tuple(adensity), key=key, dist=self.dist,Np=self.Np) # in cm^-1 if self.SF is None: struct = np.ones_like(self.x[key]) # hard_sphere_sf(self.x[key], D = self.D, phi = 0.0) elif self.SF == 'Hard-Sphere': struct = hard_sphere_sf(self.x[key], D=self.D, phi=self.phi) else: struct = sticky_sphere_sf(self.x[key], D=self.D, phi=self.phi, U=self.U, delta=0.01) if key == 'SAXS-term': sqf[key] = sqf[key] * struct + self.sbkg if key == 'Cross-term': sqf[key] = sqf[key] * struct + self.cbkg if key == 'Resonant-term': sqf[key] = sqf[key] * struct + self.abkg key1 = 'Total' total = self.norm * 6.022e20 * struct * self.new_sphere_dict(tuple(self.x[key]), tuple(self.__R__), self.Rsig, tuple(rho), tuple(eirho), tuple(adensity), key=key1,dist=self.dist,Np=self.Np) + self.sbkg # in cm^-1 if not self.__fit__: self.output_params['Simulated_total_wo_err'] = {'x': self.x[key], 'y': total} self.output_params['rho_r'] = {'x': rhor[:, 0], 'y': rhor[:, 1]} self.output_params['eirho_r'] = {'x': eirhor[:, 0], 'y': eirhor[:, 1]} self.output_params['adensity_r'] = {'x': adensityr[:, 0], 'y': adensityr[:, 1]} self.output_params['Structure_Factor'] = {'x': self.x, 'y': struct} else: if self.SF is None: struct = np.ones_like(self.x) elif self.SF == 'Hard-Sphere': struct = hard_sphere_sf(self.x, D=self.D, phi=self.phi) else: struct = sticky_sphere_sf(self.x, D=self.D, phi=self.phi, U=self.U, delta=0.01) tsqf, eisqf, asqf, csqf = self.new_sphere(tuple(self.x), tuple(self.__R__), self.Rsig, tuple(rho), tuple(eirho), tuple(adensity),dist=self.dist,Np=self.Np) sqf = self.norm * np.array(tsqf) * 6.022e20 * struct + self.sbkg # in cm^-1 # if not self.__fit__: #Generate all the quantities below while not fitting asqf = self.norm * np.array(asqf) * 6.022e20 * struct + self.abkg # in cm^-1 eisqf = self.norm * np.array(eisqf) * 6.022e20 * struct + self.sbkg # in cm^-1 csqf = self.norm * np.array(csqf) * 6.022e20 * struct + self.cbkg # in cm^-1 svol = 0.2 ** 2 * 1.5 * 1e-3 # scattering volume in cm^3 sqerr = np.sqrt(self.flux *self.norm*tsqf * svol) sqwerr = (tsqf * svol * self.flux*self.norm + 2 * (0.5 - np.random.rand(len(tsqf))) * sqerr) self.output_params['simulated_total_w_err'] = {'x': self.x, 'y': sqwerr, 'yerr': sqerr} self.output_params['Total'] = {'x': self.x, 'y': tsqf * svol * self.flux*self.norm} self.output_params['Resonant-term'] = {'x': self.x, 'y': asqf} self.output_params['SAXS-term'] = {'x': self.x, 'y': eisqf} self.output_params['Cross-term'] = {'x': self.x, 'y': csqf} self.output_params['rho_r'] = {'x': rhor[:, 0], 'y': rhor[:, 1]} self.output_params['eirho_r'] = {'x': eirhor[:, 0], 'y': eirhor[:, 1]} self.output_params['adensity_r'] = {'x': adensityr[:, 0], 'y': adensityr[:, 1]} self.output_params['Structure_Factor'] = {'x': self.x, 'y': struct} sqf = self.output_params[self.term]['y'] return sqf
def y(self): """ Define the function in terms of x to return some value """ self.update_params() rt, mt, dt, sdt, rmols = self.create_layers(tuple(self.__R__), tuple(self.__material__), tuple(self.__density__), tuple( self.__sol_density__), tuple(self.__Rmoles__), lnum=self.lnum) trt = np.array(rt) r = np.cumsum(rt) Rtot = np.sum(self.__R__[:-1]) thickness = Rtot * self.aspect self.output_params['scaler_parameters']['Thickness'] = 2 * thickness self.output_params['scaler_parameters']['Diameter'] = 2 * Rtot dt = np.where( ((r - trt / 2) > thickness) & ((r - trt / 2) < Rtot), 2 * (np.array(dt) - dt[-1]) * np.arcsin(thickness * np.sqrt( (Rtot**2 - (r - trt / 2)**2) / (Rtot**2 - thickness**2)) / (r - trt / 2)) / np.pi + dt[-1], np.array(dt)) self.output_params['density'] = {'x': r, 'y': dt} rho, eirho, adensity, rhor, eirhor, adensityr = self.calc_rho( R=rt, material=mt, relement=self.relement, density=tuple(dt), sol_density=sdt, Energy=self.Energy, Rmoles=tuple(rmols), NrDep=self.NrDep) if type(self.x) == dict: sqf = {} for key in self.x.keys(): sqf[key] = self.norm * 6.022e20 * self.new_sphere_dict( tuple(self.x[key]), rt, self.Rsig, tuple(rho), tuple(eirho), tuple(adensity), key=key, dist=self.dist, Np=self.Np) # in cm^-1 if self.SF is None: struct = np.ones_like( self.x[key] ) #hard_sphere_sf(self.x[key], D = self.D, phi = 0.0) elif self.SF == 'Hard-Sphere': struct = hard_sphere_sf(self.x[key], D=self.D, phi=self.phi) else: struct = sticky_sphere_sf(self.x[key], D=self.D, phi=self.phi, U=self.U, delta=0.01) if key == 'SAXS-term': sqf[key] = sqf[key] * struct + self.sbkg if key == 'Cross-term': sqf[key] = sqf[key] * struct + self.cbkg if key == 'Resonant-term': sqf[key] = sqf[key] * struct + self.abkg key1 = 'Total' total = self.norm * 6.022e20 * struct * self.new_sphere_dict( tuple(self.x[key]), rt, self.Rsig, tuple(rho), tuple(eirho), tuple(adensity), key=key1, dist=self.dist, Np=self.Np) + self.sbkg # in cm^-1 if not self.__fit__: self.output_params['Simulated_total_wo_err'] = { 'x': self.x[key], 'y': total } self.output_params['rho_r'] = { 'x': rhor[:, 0], 'y': rhor[:, 1] } self.output_params['eirho_r'] = { 'x': eirhor[:, 0], 'y': eirhor[:, 1] } self.output_params['adensity_r'] = { 'x': adensityr[:, 0], 'y': adensityr[:, 1] } self.output_params['Structure_Factor'] = { 'x': self.x, 'y': struct } else: if self.SF is None: struct = np.ones_like(self.x) elif self.SF == 'Hard-Sphere': struct = hard_sphere_sf(self.x, D=self.D, phi=self.phi) else: struct = sticky_sphere_sf(self.x, D=self.D, phi=self.phi, U=self.U, delta=0.01) tsqf, eisqf, asqf, csqf = self.new_sphere(tuple(self.x), rt, self.Rsig, tuple(rho), tuple(eirho), tuple(adensity), dist=self.dist, Np=self.Np) sqf = self.norm * np.array( tsqf) * 6.022e20 * struct + self.sbkg #in cm^-1 # if not self.__fit__: #Generate all the quantities below while not fitting asqf = self.norm * np.array( asqf) * 6.022e20 * struct + self.abkg #in cm^-1 eisqf = self.norm * np.array( eisqf) * 6.022e20 * struct + self.sbkg #in cm^-1 csqf = self.norm * np.array( csqf) * 6.022e20 * struct + self.cbkg # in cm^-1 svol = 0.2**2 * 1.5 * 1e-3 # scattering volume in cm^3 sqerr = np.sqrt(self.flux * tsqf * svol) sqwerr = (tsqf * svol * self.flux + 2 * (0.5 - np.random.rand(len(tsqf))) * sqerr) self.output_params['simulated_total_w_err'] = { 'x': self.x, 'y': sqwerr, 'yerr': sqerr } self.output_params['Total'] = { 'x': self.x, 'y': tsqf * svol * self.flux } self.output_params['Resonant-term'] = {'x': self.x, 'y': asqf} self.output_params['SAXS-term'] = {'x': self.x, 'y': eisqf} self.output_params['Cross-term'] = {'x': self.x, 'y': csqf} self.output_params['rho_r'] = {'x': rhor[:, 0], 'y': rhor[:, 1]} self.output_params['eirho_r'] = { 'x': eirhor[:, 0], 'y': eirhor[:, 1] } self.output_params['adensity_r'] = { 'x': adensityr[:, 0], 'y': adensityr[:, 1] } self.output_params['Structure_Factor'] = {'x': self.x, 'y': struct} sqf = self.output_params[self.term]['y'] return sqf
def y(self): """ Define the function in terms of x to return some value """ scale = 1e27 / 6.022e23 svol = 1.5 * 0.0172**2 / 370**2 # scattering volume in cm^3 self.output_params = {'scaler_parameters': {}} self.update_params() rho, eirho, adensity, rhor, eirhor, adensityr = calc_rho( R=tuple(self.__R__), material=tuple(self.__material__), relement=self.relement, density=tuple(self.__density__), sol_density=tuple(self.__sol_density__), Energy=self.Energy, Rmoles=tuple(self.__Rmoles__), NrDep=self.NrDep) if type(self.x) == dict: sqf = {} for key in self.x.keys(): sqf[key] = self.norm * 6.022e20 * self.new_sphere_dict( tuple(self.x[key]), tuple(self.__R__), self.Rsig, tuple(rho), tuple(eirho), tuple(adensity), key=key, dist=self.dist, Np=self.Np) # in cm^-1 if self.SF is None: struct = np.ones_like( self.x[key] ) # hard_sphere_sf(self.x[key], D = self.D, phi = 0.0) elif self.SF == 'Hard-Sphere': struct = hard_sphere_sf(self.x[key], D=self.D, phi=self.phi) else: struct = sticky_sphere_sf(self.x[key], D=self.D, phi=self.phi, U=self.U, delta=0.01) if key == 'SAXS-term': sqf[key] = sqf[key] * struct + self.sbkg if key == 'Cross-term': sqf[key] = sqf[key] * struct + self.cbkg if key == 'Resonant-term': sqf[key] = sqf[key] * struct + self.abkg key1 = 'Total' total = self.norm * 6.022e20 * struct * self.new_sphere_dict( tuple(self.x[key]), tuple(self.__R__), self.Rsig, tuple(rho), tuple(eirho), tuple(adensity), key=key1, dist=self.dist, Np=self.Np) + self.sbkg # in cm^-1 if not self.__fit__: dr, rdist, totalR = self.calc_Rdist(tuple(self.__R__), self.Rsig, self.dist, self.Np) self.output_params['Distribution'] = {'x': dr, 'y': rdist} self.output_params['Simulated_total_wo_err'] = { 'x': self.x[key], 'y': total } self.output_params['Total'] = {'x': self.x[key], 'y': total} for key in self.x.keys(): self.output_params[key] = {'x': self.x[key], 'y': sqf[key]} self.output_params['rho_r'] = { 'x': rhor[:, 0], 'y': rhor[:, 1], 'names': ['r (Angs)', 'Electron Density (el/Angs^3)'] } self.output_params['eirho_r'] = { 'x': eirhor[:, 0], 'y': eirhor[:, 1], 'names': ['r (Angs)', 'Electron Density (el/Angs^3)'] } self.output_params['adensity_r'] = { 'x': adensityr[:, 0], 'y': adensityr[:, 1] * scale, 'names': ['r (Angs)', 'Density (Molar)'] } # in Molar self.output_params['Structure_Factor'] = { 'x': self.x[key], 'y': struct } xtmp, ytmp = create_steps(x=self.__R__[:-1], y=self.__Rmoles__[:-1]) self.output_params['Rmoles_radial'] = {'x': xtmp, 'y': ytmp} xtmp, ytmp = create_steps(x=self.__R__[:-1], y=self.__density__[:-1]) self.output_params['Density_radial'] = {'x': xtmp, 'y': ytmp} else: if self.SF is None: struct = np.ones_like(self.x) elif self.SF == 'Hard-Sphere': struct = hard_sphere_sf(self.x, D=self.D, phi=self.phi) else: struct = sticky_sphere_sf(self.x, D=self.D, phi=self.phi, U=self.U, delta=0.01) tsqf, eisqf, asqf, csqf = self.new_sphere(tuple(self.x), tuple(self.__R__), self.Rsig, tuple(rho), tuple(eirho), tuple(adensity), dist=self.dist, Np=self.Np) sqf = self.norm * np.array( tsqf) * 6.022e20 * struct + self.sbkg # in cm^-1 # if not self.__fit__: #Generate all the quantities below while not fitting asqf = self.norm * np.array( asqf) * 6.022e20 * struct + self.abkg # in cm^-1 eisqf = self.norm * np.array( eisqf) * 6.022e20 * struct + self.sbkg # in cm^-1 csqf = self.norm * np.array( csqf) * 6.022e20 * struct + self.cbkg # in cm^-1 sqerr = np.sqrt(6.020e20 * self.flux * self.norm * tsqf * struct * svol + self.sbkg) sqwerr = (6.022e20 * tsqf * svol * self.flux * self.norm * struct + self.sbkg + 2 * (0.5 - np.random.rand(len(tsqf))) * sqerr) dr, rdist, totalR = self.calc_Rdist(tuple(self.__R__), self.Rsig, self.dist, self.Np) self.output_params['Distribution'] = {'x': dr, 'y': rdist} self.output_params['simulated_total_w_err'] = { 'x': self.x, 'y': sqwerr, 'yerr': sqerr } self.output_params['Total'] = {'x': self.x, 'y': sqf} self.output_params['Resonant-term'] = {'x': self.x, 'y': asqf} self.output_params['SAXS-term'] = {'x': self.x, 'y': eisqf} self.output_params['Cross-term'] = {'x': self.x, 'y': csqf} self.output_params['rho_r'] = { 'x': rhor[:, 0], 'y': rhor[:, 1], 'names': ['r (Angs)', 'Electron Density (el/Angs^3)'] } self.output_params['eirho_r'] = { 'x': eirhor[:, 0], 'y': eirhor[:, 1], 'names': ['r (Angs)', 'Electron Density (el/Angs^3)'] } self.output_params['adensity_r'] = { 'x': adensityr[:, 0], 'y': adensityr[:, 1] * scale, 'names': ['r (Angs)', 'Density (Molar)'] } # in Molar self.output_params['Structure_Factor'] = {'x': self.x, 'y': struct} xtmp, ytmp = create_steps(x=self.__R__[:-1], y=self.__Rmoles__[:-1]) self.output_params['Rmoles_radial'] = {'x': xtmp, 'y': ytmp} sqf = self.output_params[self.term]['y'] xtmp, ytmp = create_steps(x=self.__R__[:-1], y=self.__density__[:-1]) self.output_params['Density_radial'] = {'x': xtmp, 'y': ytmp} return sqf