-
-
Save bertrand-faure/701fe217104a26b4bcc6ffb4c46c2b31 to your computer and use it in GitHub Desktop.
Minimal example for pdf mismatch in fluids
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
import numpy as np | |
import fluids.particle_size_distribution as psd | |
# Sizes | |
step = 2e-9 | |
ds = np.arange(1e-9,500e-9,step) | |
# Artificial PSD with mean size at 50 nm and PDI 0.05 | |
mu1 = 50e-9 | |
sigma1 = 0.05*mu1 | |
fractions = np.exp(-1.*(ds-mu1)**2/(2*sigma1)**2) | |
# Artificial PSD with mean size at 100 nm and PDI 0.05 | |
mu2 = 100e-9 | |
sigma2 = 0.05*mu2 | |
fractions = fractions + np.exp(-1.*(ds-mu2)**2/(2*sigma2)**2) | |
# Normalization | |
fractions = fractions/fractions.sum() | |
# Plot the input pdf | |
plt.figure() | |
plt.plot(ds, fractions, label='input Volume pdf') | |
# Define the corresponding distribution in fluids - Volume/Mass weighted | |
fluids_psd = psd.ParticleSizeDistribution(ds=ds, | |
fractions=fractions, | |
order=3) | |
# Overlay the surface and mass-weighted distributions on top of the input | |
fluids_psd.plot_pdf((2,3), pts=fluids_psd.N) | |
# 2 issues: | |
# - the areas under the mass weighted data (input vs fluids) are different | |
# - the proportions of the populations do not match |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment