Closed pkienzle closed 1 year ago
Closing this ticket because I don't see this as useful in general.
Here's a core-multishell model with large PD on the core. The details on the shells are smoothed away in the profile even though the multilayer shell clearly shows up as a peak in the scattering.
Shifting the profile to align on the core-shell boundary or on the center of the third shell would introduce other artifacts.
import numpy as np
from scipy.stats import truncnorm
from sasmodels.weights import get_weights
from sasmodels.models.core_multi_shell import profile
import matplotlib.pyplot as plt
%matplotlib inline
sld_core, sld_solvent = 2.2, 2.2
radius, radius_pd = 564, 0.3
thickness = np.array([14.8, 14.9, 5.7, 14.9, 14.8])
thickness_pd = 0.1
sld = np.array([2.0, 2.27, 0.15, 2.27, 2.0])
n = len(thickness)
# Cheating because all thickness have the same pd. Otherwise we need
# to scale each thickness by 1 + 3*pd to get the max possible value
z_max = radius*(1 + 3*radius_pd) + sum(thickness)*(1 + 3*thickness_pd)
nlines, nz = 50000, 200
z = np.linspace(0, z_max, nz)
rhos = np.empty((nlines, nz))
pars = np.empty((nlines, n+1))
for k in range(nlines):
# Truncated normal defines bounds using number of sigmas from the mean.
# That is, the lower limit with mean + sigma*a = 0 requires a = -mean/sigma.
# For polydisperse parameters, sigma = pd*mean, therefore a = -1/pd
rk = truncnorm.rvs(-1/radius_pd, np.inf, radius, radius*radius_pd)
tk = truncnorm.rvs(-1/thickness_pd, np.inf, thickness, thickness*thickness_pd)
pars[k, 0] = rk
pars[k, 1:] = tk
zk, rhok = profile(sld_core, rk, sld_solvent, n, sld, tk)
rhos[k] = np.interp(z, zk, rhok)
rho_avg = np.mean(rhos, axis=0)
# Average profile, dominated by pd in radius
nplot = min(400, nlines)
plt.plot(z, rho_avg, color='b')
# Fuzziness plot
plt.figure()
plt.plot(z, rhos[:nplot].T, color='b', alpha=0.1)
# Histograms of the individual parameters, to check that they are truncated normal
plt.figure()
for k in range(n+1):
plt.subplot(2,3,k+1)
plt.hist(pars[:, k], bins=50)
None
With polydispersity there is a distribution of profiles. How can this be represented on a plot?
A simple approach is to generate many different profiles and over-plot them. Here is an example for a core-shell sphere:
The result is the following plot: