Table of Contents
Fetching ...

PyPartMC: A Pythonic interface to a particle-resolved, Monte Carlo aerosol simulation framework

Zachary D'Aquino, Sylwester Arabas, Jeffrey Curtis, Akshunna Vaishnav, Nicole Riemer, Matthew West

TL;DR

PyPartMC provides a Pythonic interface to PartMC, a particle-resolved aerosol model, addressing installation barriers and enabling end-to-end workflows in Python and Julia. It uses a multi-language architecture with Fortran cores wrapped by C and Python bindings (pybind11), preserving performance while exposing internals. The paper demonstrates basic Python/Julia examples and three Jupyter notebooks: PySDM comparison, urban plume, and optical properties. The open-source packaging and CI ensure cross-platform reproducibility and facilitate benchmarking, education, and collaboration.

Abstract

PyPartMC is a Pythonic interface to PartMC, a stochastic, particle-resolved aerosol model implemented in Fortran. Both PyPartMC and PartMC are free, libre, and open-source. PyPartMC reduces the number of steps and mitigates the effort necessary to install and utilize the resources of PartMC. Without PyPartMC, setting up PartMC requires: working with UNIX shell, providing Fortran and C libraries, and performing standard Fortran and C source code configuration, compilation and linking. This can be challenging for those less experienced with computational research or those intending to use PartMC in environments where provision of UNIX tools is less straightforward (e.g., on Windows). PyPartMC offers a single-step installation/upgrade process of PartMC and all dependencies through the pip Python package manager on Linux, macOS, and Windows. This allows streamlined access to the unmodified and versioned Fortran internals of the PartMC codebase from both Python and other interoperable environments (e.g., Julia through PyCall). Consequently, users of PyPartMC can setup, run, process and visualize output of PartMC simulations using a single general-purpose programming language.

PyPartMC: A Pythonic interface to a particle-resolved, Monte Carlo aerosol simulation framework

TL;DR

PyPartMC provides a Pythonic interface to PartMC, a particle-resolved aerosol model, addressing installation barriers and enabling end-to-end workflows in Python and Julia. It uses a multi-language architecture with Fortran cores wrapped by C and Python bindings (pybind11), preserving performance while exposing internals. The paper demonstrates basic Python/Julia examples and three Jupyter notebooks: PySDM comparison, urban plume, and optical properties. The open-source packaging and CI ensure cross-platform reproducibility and facilitate benchmarking, education, and collaboration.

Abstract

PyPartMC is a Pythonic interface to PartMC, a stochastic, particle-resolved aerosol model implemented in Fortran. Both PyPartMC and PartMC are free, libre, and open-source. PyPartMC reduces the number of steps and mitigates the effort necessary to install and utilize the resources of PartMC. Without PyPartMC, setting up PartMC requires: working with UNIX shell, providing Fortran and C libraries, and performing standard Fortran and C source code configuration, compilation and linking. This can be challenging for those less experienced with computational research or those intending to use PartMC in environments where provision of UNIX tools is less straightforward (e.g., on Windows). PyPartMC offers a single-step installation/upgrade process of PartMC and all dependencies through the pip Python package manager on Linux, macOS, and Windows. This allows streamlined access to the unmodified and versioned Fortran internals of the PartMC codebase from both Python and other interoperable environments (e.g., Julia through PyCall). Consequently, users of PyPartMC can setup, run, process and visualize output of PartMC simulations using a single general-purpose programming language.
Paper Structure (12 sections, 6 figures, 1 table)

This paper contains 12 sections, 6 figures, 1 table.

Figures (6)

  • Figure 1: Schematic of architecture of PyPartMC depicting the coupling between Fortran, C and C++ internals and the user code written in Python or Julia.
  • Figure 2: Code listings depicting basic usage of PartMC data structures and algorithms in: (a) Python through PyPartMC; (b) Julia through PyCall and PyPartMC; (c-f) Fortran.
  • Figure 3: (a) Initial dry size distribution (light blue) and distributions after water uptake from PyPartMC and PySDM (orange and black, respectively) evaluated at a temperature of 295 Kelvin, relative humidity of 82%, and hygroscopicity parameter kappa of 1.1. Note that the solutions from PyPartMC and PySDM are almost identical, and the orange and black curve are on top of each other. (b) Relative difference in wet diameter from PyPartMC and PySDM as a function of dry diameter.
  • Figure 4: Evolution of total number concentration and total mass concentration.
  • Figure 5: (a) Number distributions $n(D)$ for the simulation with coagulation after 0, 6, 12 and 24 hours. (b) Two-dimensional number distribution of black carbon dry mass fraction and particle dry diameter after 24 hours of simulation.
  • ...and 1 more figures