Skip to content

AeroDist doesn't throw an exception for "sampled" type modes when other modes are present #417

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Griger5 opened this issue Feb 27, 2025 · 0 comments

Comments

@Griger5
Copy link
Collaborator

Griger5 commented Feb 27, 2025

Code example:

import PyPartMC as ppmc
from PyPartMC import si

from unittest import TestCase

aero_data = ppmc.AeroData((
    {"OC": [1000 *si.kg/si.m**3, 0, 1e-3 *si.kg/si.mol, 0.001]},
))

sampled = {
    "mass_frac": [{"OC": [1]}],
    "diam_type": "geometric",
    "mode_type": "sampled",
    "size_dist": [
        {"diam": [1, 2, 3, 4]},
        {"num_conc": [100000, 200000, 300000]},
        {"not_used": [0]}
    ]
}

other = {
    "mass_frac": [{"OC": [1]}],
    "diam_type": "geometric",
    "mode_type": "log_normal",
    "geom_mean_diam": 8.64 * si.nm,
    "log10_geom_std_dev": 0.28,
    "num_conc": 2900 / si.cm**3
}

# D1 throws an exception, as it should
with TestCase.assertRaises(TestCase, Exception):
    D1 = ppmc.AeroDist(aero_data, [{"mode1":sampled}])

# this assertion should pass with the issue resolved
with TestCase.assertRaises(TestCase, Exception):
    D2 = ppmc.AeroDist(aero_data, [{"mode1":other, "mode2":sampled}])

When the size_dist parameter of a sampled-type mode has more than 2 dicts (or the dict keys aren't "diam" and "num_conc") it should throw an error. This works when the sampled mode is the first mode in AeroDist, however, it fails to throw an exception when modes of different types are present before it.

The code above should pass without errors after the issue is resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant