Skip to content

Instantly share code, notes, and snippets.

@bertrand-faure
Created January 16, 2019 10:08
Show Gist options
  • Save bertrand-faure/701fe217104a26b4bcc6ffb4c46c2b31 to your computer and use it in GitHub Desktop.
Save bertrand-faure/701fe217104a26b4bcc6ffb4c46c2b31 to your computer and use it in GitHub Desktop.
Minimal example for pdf mismatch in fluids
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