open-atmos / PySDM

Pythonic particle-based (super-droplet) warm-rain/aqueous-chemistry cloud microphysics package with box, parcel & 1D/2D prescribed-flow examples in Python, Julia and Matlab
https://open-atmos.github.io/PySDM/
GNU General Public License v3.0
56 stars 32 forks source link

Particle size spectrum per volume is dependent on volume size? #1342

Closed jbarr444 closed 3 months ago

jbarr444 commented 3 months ago

Hi,

When running the Shipway and Hill example, it seems that the values in the 'dry spectrum' product are proportional to the height bin size. How does this work? Is this intentional?

Thanks, Jason

slayoo commented 3 months ago

Thank you @jbarr444 for reporting it! It is consistent with the code - the default parameters of this product indeed skip normalisation by dv ...

https://github.com/open-atmos/PySDM/blob/1a15de0e156217ed26185be6d439e0ad3ab52e82/PySDM/products/size_spectral/particle_size_spectrum.py#L75

... but it is nether intuitive nor useful at all!

It seems to me that it is a remnant of the fact that this product has been developed along with the Box environment, but here it is used with the single-column one.

Stay tuned for a fix.

slayoo commented 3 months ago

@jbarr444 this is now merged and released as PySDM v2.63. Please confirm if that solves the issue, thanks!

jbarr444 commented 3 months ago

Hi,

Thanks for the quick fix! Yes, the distribution normalization factor seems to now have a fixed value (aside from small random sampling error), but it is consistently about 80% of what I expect. When I use 50 / cm^3 particles_per_volume_STP, then running this code:

z = output['z'] z500 = np.argmin(np.abs(z - 5e2)) r = settings.r_bins_edges_dry dr = r[1:] - r[:-1] print(output['dry spectrum'][z500, :, 0]@dr / 1e6)

it prints about 40.

I'm sure this is a completely unrelated issue, and I am a student, so I'm wondering if I'm doing something wrong here.

jbarr444 commented 3 months ago

It seems to be off by rho_STP, but I did think it was supposed to already per volume, not per mass ?

slayoo commented 3 months ago

@jbarr444, thanks. Expressing the concentration "as if measured at standard temperature, pressure and RH (abbreviated as STP here)" will introduce the rho_STP scaling factor. This is consistent with how aerosol measurements are reported. So, even without starting the simulation, there should be a factor of rho_STP scaling difference between per-volume concentrations and per-volume-at-STP values. See, e.g., here: https://www.osti.gov/servlets/purl/1846263 (section 2.5) Currently, the ParticleSizeSpectrumPerVolume product reports concentrations nomalized by the actual air volume. If we go for STP values, this needs to be divided by the air density and multiplied by the air density at STP.

Would it help to introduce the stp option in the ParticleSizeSpectrumPerVolume product (as we offer it in other PySDM products)?

jbarr444 commented 3 months ago

@slayoo Aha! That makes sense. I suppose the actual density happened to be around 1 kg / m^3 in my case..? If it's not too much of a hassle I think the STP option would be nice to do this sort of sanity check that I was trying to do, considering that the potential temperature is hard-coded in this example. Thanks for the help!

slayoo commented 3 months ago

voilà: https://github.com/open-atmos/PySDM/pull/1346

slayoo commented 3 months ago

Merged and released: https://github.com/open-atmos/PySDM/releases/tag/v2.64 Please confirm if the stp option works for you (ctor argument in the ParticleSizeSpectrumPerVolume class)