Skip to content

particula.dynamics.condensation.mass_transfer

mass_transfer

Particle Vapor Equilibrium, condensation, and evaporation based on partial pressures to calculate dm/dt or other forms of particle growth and decay.

Equation
  • dm/dt = 4π × radius × Di × Mi × f(Kn, α) × delta_pi / (R × T)
  • radius : The particle radius in m.
  • Di : The diffusion coefficient of species i in m²/s.
  • Mi : The molar mass of species i in kg/mol.
  • f(Kn, α) : Transition function based on Knudsen number and accommodation coefficient.
  • delta_pi : Difference in partial pressures between gas and particle phases in Pa.
  • R : Gas constant in J/(mol·K).
  • T : Temperature in K.
References
  • Seinfeld, J. H., & Pandis, S. N. (2016). Atmospheric Chemistry and Physics: From Air Pollution to Climate Change (3rd ed.). John Wiley & Sons, Inc.
  • Topping, D., & Bane, M. (2022). Introduction to Aerosol Modelling (D. Topping & M. Bane, Eds.). Wiley. https://doi.org/10.1002/9781119625728
  • Aerosol Modeling: Chapter 2, Equation 2.40

get_first_order_mass_transport_k

get_first_order_mass_transport_k(particle_radius: Union[float, NDArray[float64]], vapor_transition: Union[float, NDArray[float64]], diffusion_coefficient: Union[float, NDArray[float64]] = 2e-05) -> Union[float, NDArray[np.float64]]

Calculate the first-order mass transport coefficient per particle.

This function computes the coefficient K that governs how fast mass is transported to or from a particle in a vapor. The equation is:

  • K = 4π × radius × D × X
    • K : Mass transport coefficient [m³/s].
    • radius : Particle radius [m].
    • D : Diffusion coefficient of the vapor [m²/s].
    • X : Vapor transition correction factor [unitless].

Parameters:

  • - particle_radius

    The radius of the particle [m].

  • - vapor_transition

    The vapor transition correction factor [unitless].

  • - diffusion_coefficient

    The diffusion coefficient of the vapor [m²/s]. Defaults to 2e-5 (approx. air).

Returns:

  • Union[float, NDArray[float64]]
    • The first-order mass transport coefficient per particle [m³/s].

Examples:

Float input
import particula as par
par.dynamics.get_first_order_mass_transport_k(
    particle_radius=1e-6,
    vapor_transition=0.6,
    diffusion_coefficient=2e-9
)
# Output: 1.5079644737231005e-14
Array input
import particula as par
par.dynamics.get_first_order_mass_transport_k(
    particle_radius=np.array([1e-6, 2e-6]),
    vapor_transition=np.array([0.6, 0.6]),
    diffusion_coefficient=2e-9
)
# Output: array([1.50796447e-14, 6.03185789e-14])
References
  • Aerosol Modeling: Chapter 2, Equation 2.49
  • Wikipedia contributors, "Mass diffusivity," https://en.wikipedia.org/wiki/Mass_diffusivity
Source code in particula/dynamics/condensation/mass_transfer.py
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
@validate_inputs(
    {
        "particle_radius": "nonnegative",
    }
)
def get_first_order_mass_transport_k(
    particle_radius: Union[float, NDArray[np.float64]],
    vapor_transition: Union[float, NDArray[np.float64]],
    diffusion_coefficient: Union[float, NDArray[np.float64]] = 2e-5,
) -> Union[float, NDArray[np.float64]]:
    """Calculate the first-order mass transport coefficient per particle.

    This function computes the coefficient K that governs how fast mass is
    transported to or from a particle in a vapor. The equation is:

    - K = 4π × radius × D × X
        - K : Mass transport coefficient [m³/s].
        - radius : Particle radius [m].
        - D : Diffusion coefficient of the vapor [m²/s].
        - X : Vapor transition correction factor [unitless].

    Arguments:
        - particle_radius : The radius of the particle [m].
        - vapor_transition : The vapor transition correction factor [unitless].
        - diffusion_coefficient : The diffusion coefficient of the vapor [m²/s].
          Defaults to 2e-5 (approx. air).

    Returns:
        - The first-order mass transport coefficient per particle [m³/s].

    Examples:
        ```py title="Float input"
        import particula as par
        par.dynamics.get_first_order_mass_transport_k(
            particle_radius=1e-6,
            vapor_transition=0.6,
            diffusion_coefficient=2e-9
        )
        # Output: 1.5079644737231005e-14
        ```

        ```py title="Array input"
        import particula as par
        par.dynamics.get_first_order_mass_transport_k(
            particle_radius=np.array([1e-6, 2e-6]),
            vapor_transition=np.array([0.6, 0.6]),
            diffusion_coefficient=2e-9
        )
        # Output: array([1.50796447e-14, 6.03185789e-14])
        ```

    References:
        - Aerosol Modeling: Chapter 2, Equation 2.49
        - Wikipedia contributors, "Mass diffusivity,"
          https://en.wikipedia.org/wiki/Mass_diffusivity
    """
    if (
        isinstance(vapor_transition, np.ndarray)
        and vapor_transition.dtype == np.float64
        and vapor_transition.ndim == 2
    ):  # extent radius
        particle_radius = particle_radius[:, np.newaxis]  # type: ignore
    return (
        4 * np.pi * particle_radius * diffusion_coefficient * vapor_transition
    )

get_mass_transfer

get_mass_transfer(mass_rate: NDArray[float64], time_step: float, gas_mass: NDArray[float64], particle_mass: NDArray[float64], particle_concentration: NDArray[float64]) -> NDArray[np.float64]

Route mass transfer calculation to single or multiple-species routines.

Depending on whether gas_mass represents one or multiple species, this function calls either calculate_mass_transfer_single_species or calculate_mass_transfer_multiple_species. The primary calculation involves:

  • mass_to_change = mass_rate × time_step × particle_concentration

Parameters:

  • - mass_rate

    The rate of mass transfer per particle [kg/s].

  • - time_step

    The time step for the mass transfer calculation [s].

  • - gas_mass

    The available mass of gas species [kg].

  • - particle_mass

    The mass of each particle [kg].

  • - particle_concentration

    The concentration of particles [#/m³].

Returns:

  • NDArray[float64]
    • The mass transferred (array with the same shape as particle_mass).

Examples:

Single species input
import particula as par
par.dynamics.get_mass_transfer(
    mass_rate=np.array([0.1, 0.5]),
    time_step=10,
    gas_mass=np.array([0.5]),
    particle_mass=np.array([1.0, 50]),
    particle_concentration=np.array([1, 0.5])
)
Multiple species input
import particula as par
par.dynamics.get_mass_transfer(
    mass_rate=np.array([[0.1, 0.05, 0.03], [0.2, 0.15, 0.07]]),
    time_step=10,
    gas_mass=np.array([1.0, 0.8, 0.5]),
    particle_mass=np.array([[1.0, 0.9, 0.8], [1.2, 1.0, 0.7]]),
    particle_concentration=np.array([5, 4])
)
Source code in particula/dynamics/condensation/mass_transfer.py
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
@validate_inputs(
    {
        "mass_rate": "finite",
        "time_step": "positive",
        "gas_mass": "nonnegative",
        "particle_mass": "nonnegative",
        "particle_concentration": "nonnegative",
    }
)
def get_mass_transfer(
    mass_rate: NDArray[np.float64],
    time_step: float,
    gas_mass: NDArray[np.float64],
    particle_mass: NDArray[np.float64],
    particle_concentration: NDArray[np.float64],
) -> NDArray[np.float64]:
    """Route mass transfer calculation to single or multiple-species routines.

    Depending on whether gas_mass represents one or multiple species, this
    function calls either calculate_mass_transfer_single_species or
    calculate_mass_transfer_multiple_species. The primary calculation
    involves:

    - mass_to_change = mass_rate × time_step × particle_concentration

    Arguments:
        - mass_rate : The rate of mass transfer per particle [kg/s].
        - time_step : The time step for the mass transfer calculation [s].
        - gas_mass : The available mass of gas species [kg].
        - particle_mass : The mass of each particle [kg].
        - particle_concentration : The concentration of particles [#/m³].

    Returns:
        - The mass transferred (array with the same shape as particle_mass).

    Examples:
        ```py title="Single species input"
        import particula as par
        par.dynamics.get_mass_transfer(
            mass_rate=np.array([0.1, 0.5]),
            time_step=10,
            gas_mass=np.array([0.5]),
            particle_mass=np.array([1.0, 50]),
            particle_concentration=np.array([1, 0.5])
        )
        ```

        ```py title="Multiple species input"
        import particula as par
        par.dynamics.get_mass_transfer(
            mass_rate=np.array([[0.1, 0.05, 0.03], [0.2, 0.15, 0.07]]),
            time_step=10,
            gas_mass=np.array([1.0, 0.8, 0.5]),
            particle_mass=np.array([[1.0, 0.9, 0.8], [1.2, 1.0, 0.7]]),
            particle_concentration=np.array([5, 4])
        )
        ```
    """
    if gas_mass.size == 1:  # Single species case
        return get_mass_transfer_of_single_species(
            mass_rate,
            time_step,
            gas_mass,
            particle_mass,
            particle_concentration,
        )
    # Multiple species case
    return get_mass_transfer_of_multiple_species(
        mass_rate,
        time_step,
        gas_mass,
        particle_mass,
        particle_concentration,
    )

get_mass_transfer_of_multiple_species

get_mass_transfer_of_multiple_species(mass_rate: NDArray[float64], time_step: float, gas_mass: NDArray[float64], particle_mass: NDArray[float64], particle_concentration: NDArray[float64]) -> NDArray[np.float64]

Calculate mass transfer for multiple gas species.

Here, gas_mass has multiple elements (each species). For each species, this function calculates mass_to_change for all particle bins:

  • mass_to_change = mass_rate × time_step × particle_concentration

Then it limits or scales that mass based on available gas mass and particle mass in each species bin.

  1. Computes the mass change each particle would take during time_step.
  2. Scales condensation so the column sum never exceeds gas_mass.
  3. Scales evaporation so the column sum never exceeds the particle inventory of that species.
  4. Clips the result so no individual bin evaporates more mass than it owns.

Parameters:

  • - mass_rate

    The mass transfer rate per particle for each gas species [kg/s].

  • - time_step

    The time step [s].

  • - gas_mass

    The available mass of each gas species [kg].

  • - particle_mass

    The mass of each particle for each gas species [kg].

  • - particle_concentration

    The concentration of particles [#/m³].

Returns:

  • NDArray[float64]
    • The mass transferred for multiple gas species, matching the shape of (particle_mass).

Examples:

Multiple species input
import particula as par
par.dynamics.get_mass_transfer_of_multiple_species(
    mass_rate=np.array([[0.1, 0.05, 0.03], [0.2, 0.15, 0.07]]),
    time_step=10,
    gas_mass=np.array([1.0, 0.8, 0.5]),
    particle_mass=np.array([[1.0, 0.9, 0.8], [1.2, 1.0, 0.7]]),
    particle_concentration=np.array([5, 4])
)
# Output: array([...])
Source code in particula/dynamics/condensation/mass_transfer.py
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
@validate_inputs(
    {
        "mass_rate": "finite",
        "time_step": "positive",
        "gas_mass": "nonnegative",
        "particle_mass": "nonnegative",
        "particle_concentration": "nonnegative",
    }
)
def get_mass_transfer_of_multiple_species(
    mass_rate: NDArray[np.float64],
    time_step: float,
    gas_mass: NDArray[np.float64],
    particle_mass: NDArray[np.float64],
    particle_concentration: NDArray[np.float64],
) -> NDArray[np.float64]:
    """Calculate mass transfer for multiple gas species.

    Here, gas_mass has multiple elements (each species). For each species,
    this function calculates mass_to_change for all particle bins:

    - mass_to_change = mass_rate × time_step × particle_concentration

    Then it limits or scales that mass based on available gas mass and
    particle mass in each species bin.

    1. Computes the mass change each particle *would* take during `time_step`.
    2. Scales condensation so the **column sum** never exceeds `gas_mass`.
    3. Scales evaporation so the **column sum** never exceeds the particle
       inventory of that species.
    4. Clips the result so no individual bin evaporates more mass than it owns.

    Arguments:
        - mass_rate : The mass transfer rate per particle for each gas
            species [kg/s].
        - time_step : The time step [s].
        - gas_mass : The available mass of each gas species [kg].
        - particle_mass : The mass of each particle for each gas species [kg].
        - particle_concentration : The concentration of particles [#/m³].

    Returns:
        - The mass transferred for multiple gas species, matching the shape
          of (particle_mass).

    Examples:
        ```py title="Multiple species input"
        import particula as par
        par.dynamics.get_mass_transfer_of_multiple_species(
            mass_rate=np.array([[0.1, 0.05, 0.03], [0.2, 0.15, 0.07]]),
            time_step=10,
            gas_mass=np.array([1.0, 0.8, 0.5]),
            particle_mass=np.array([[1.0, 0.9, 0.8], [1.2, 1.0, 0.7]]),
            particle_concentration=np.array([5, 4])
        )
        # Output: array([...])
        ```
    """
    mass_to_change = calc_mass_to_change(
        mass_rate, time_step, particle_concentration
    )
    mass_to_change, evap_sum, neg_mask = apply_condensation_limit(
        mass_to_change, gas_mass
    )
    mass_to_change = apply_evaporation_limit(
        mass_to_change,
        particle_mass,
        particle_concentration,
        evap_sum,
        neg_mask,
    )
    return apply_per_bin_limit(
        mass_to_change, particle_mass, particle_concentration
    )

get_mass_transfer_of_single_species

get_mass_transfer_of_single_species(mass_rate: NDArray[float64], time_step: float, gas_mass: NDArray[float64], particle_mass: NDArray[float64], particle_concentration: NDArray[float64]) -> NDArray[np.float64]

Calculate mass transfer for a single gas species.

This function assumes gas_mass has a size of 1 (single species). It first computes the total mass_to_change per particle:

  • mass_to_change = mass_rate × time_step × particle_concentration

Then it scales or limits that mass based on available gas mass and particle mass.

Parameters:

  • - mass_rate

    Mass transfer rate per particle [kg/s].

  • - time_step

    The time step [s].

  • - gas_mass

    Total available mass of the gas species [kg].

  • - particle_mass

    The mass of each particle [kg].

  • - particle_concentration

    Particle concentration [#/m³].

Returns:

  • NDArray[float64]
    • The amount of mass transferred for the single gas species, shaped like particle_mass.

Examples:

Single species input
import particula as par
par.dynamics.get_mass_transfer_of_single_species(
    mass_rate=np.array([0.1, 0.5]),
    time_step=10,
    gas_mass=np.array([0.5]),
    particle_mass=np.array([1.0, 50]),
    particle_concentration=np.array([1, 0.5])
)
# Output: array([...])
Source code in particula/dynamics/condensation/mass_transfer.py
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
@validate_inputs(
    {
        "mass_rate": "finite",
        "time_step": "positive",
        "gas_mass": "nonnegative",
        "particle_mass": "nonnegative",
        "particle_concentration": "nonnegative",
    }
)
def get_mass_transfer_of_single_species(
    mass_rate: NDArray[np.float64],
    time_step: float,
    gas_mass: NDArray[np.float64],
    particle_mass: NDArray[np.float64],
    particle_concentration: NDArray[np.float64],
) -> NDArray[np.float64]:
    """Calculate mass transfer for a single gas species.

    This function assumes gas_mass has a size of 1 (single species).
    It first computes the total mass_to_change per particle:

    - mass_to_change = mass_rate × time_step × particle_concentration

    Then it scales or limits that mass based on available gas mass and
    particle mass.

    Arguments:
        - mass_rate : Mass transfer rate per particle [kg/s].
        - time_step : The time step [s].
        - gas_mass : Total available mass of the gas species [kg].
        - particle_mass : The mass of each particle [kg].
        - particle_concentration : Particle concentration [#/m³].

    Returns:
        - The amount of mass transferred for the single gas species, shaped
          like particle_mass.

    Examples:
        ```py title="Single species input"
        import particula as par
        par.dynamics.get_mass_transfer_of_single_species(
            mass_rate=np.array([0.1, 0.5]),
            time_step=10,
            gas_mass=np.array([0.5]),
            particle_mass=np.array([1.0, 50]),
            particle_concentration=np.array([1, 0.5])
        )
        # Output: array([...])
        ```
    """
    mass_to_change = calc_mass_to_change(
        mass_rate, time_step, particle_concentration
    )
    mass_to_change, evap_sum, neg_mask = apply_condensation_limit(
        mass_to_change, gas_mass
    )
    mass_to_change = apply_evaporation_limit(
        mass_to_change,
        particle_mass,
        particle_concentration,
        evap_sum,
        neg_mask,
    )
    return apply_per_bin_limit(
        mass_to_change, particle_mass, particle_concentration
    )

get_mass_transfer_rate

get_mass_transfer_rate(pressure_delta: Union[float, NDArray[float64]], first_order_mass_transport: Union[float, NDArray[float64]], temperature: Union[float, NDArray[float64]], molar_mass: Union[float, NDArray[float64]]) -> Union[float, NDArray[np.float64]]

Calculate the mass transfer rate for a particle.

This function calculates the mass transfer rate dm/dt, leveraging the difference in partial pressure (pressure_delta) and the first-order mass transport coefficient (K). The equation is:

  • dm/dt = (K × Δp × M) / (R × T)
    • dm/dt : Mass transfer rate [kg/s].
    • K : First-order mass transport coefficient [m³/s].
    • Δp : Partial pressure difference [Pa].
    • M : Molar mass [kg/mol].
    • R : Universal gas constant [J/(mol·K)].
    • T : Temperature [K].

Parameters:

  • - pressure_delta

    The difference in partial pressure [Pa].

  • - first_order_mass_transport

    The mass transport coefficient [m³/s].

  • - temperature

    The temperature [K].

  • - molar_mass

    The molar mass [kg/mol].

Returns:

  • Union[float, NDArray[float64]]
    • The mass transfer rate [kg/s].

Examples:

Single value input
import particula as par
par.dynamics.mass_transfer_rate(
    pressure_delta=10.0,
    first_order_mass_transport=1e-17,
    temperature=300.0,
    molar_mass=0.02897
)
# Output: 1.16143004e-21
Array input
import particula as par
par.dynamics.mass_transfer_rate(
    pressure_delta=np.array([10.0, 15.0]),
    first_order_mass_transport=np.array([1e-17, 2e-17]),
    temperature=300.0,
    molar_mass=0.02897
)
# Output: array([1.16143004e-21, 3.48429013e-21])
References
  • Aerosol Modeling: Chapter 2, Equation 2.41
  • Seinfeld and Pandis, "Atmospheric Chemistry and Physics," Equation 13.3
Source code in particula/dynamics/condensation/mass_transfer.py
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
@validate_inputs(
    {
        "pressure_delta": "finite",
        "first_order_mass_transport": "finite",
        "temperature": "positive",
        "molar_mass": "positive",
    }
)
def get_mass_transfer_rate(
    pressure_delta: Union[float, NDArray[np.float64]],
    first_order_mass_transport: Union[float, NDArray[np.float64]],
    temperature: Union[float, NDArray[np.float64]],
    molar_mass: Union[float, NDArray[np.float64]],
) -> Union[float, NDArray[np.float64]]:
    """Calculate the mass transfer rate for a particle.

    This function calculates the mass transfer rate dm/dt, leveraging the
    difference in partial pressure (pressure_delta) and the first-order
    mass transport coefficient (K). The equation is:

    - dm/dt = (K × Δp × M) / (R × T)
        - dm/dt : Mass transfer rate [kg/s].
        - K : First-order mass transport coefficient [m³/s].
        - Δp : Partial pressure difference [Pa].
        - M : Molar mass [kg/mol].
        - R : Universal gas constant [J/(mol·K)].
        - T : Temperature [K].

    Arguments:
        - pressure_delta : The difference in partial pressure [Pa].
        - first_order_mass_transport : The mass transport coefficient [m³/s].
        - temperature : The temperature [K].
        - molar_mass : The molar mass [kg/mol].

    Returns:
        - The mass transfer rate [kg/s].

    Examples:
        ```py title="Single value input"
        import particula as par
        par.dynamics.mass_transfer_rate(
            pressure_delta=10.0,
            first_order_mass_transport=1e-17,
            temperature=300.0,
            molar_mass=0.02897
        )
        # Output: 1.16143004e-21
        ```

        ```py title="Array input"
        import particula as par
        par.dynamics.mass_transfer_rate(
            pressure_delta=np.array([10.0, 15.0]),
            first_order_mass_transport=np.array([1e-17, 2e-17]),
            temperature=300.0,
            molar_mass=0.02897
        )
        # Output: array([1.16143004e-21, 3.48429013e-21])
        ```

    References:
        - Aerosol Modeling: Chapter 2, Equation 2.41
        - Seinfeld and Pandis, "Atmospheric Chemistry and Physics,"
            Equation 13.3
    """
    return np.array(
        first_order_mass_transport
        * pressure_delta
        * molar_mass
        / (GAS_CONSTANT * temperature),
        dtype=np.float64,
    )

get_radius_transfer_rate

get_radius_transfer_rate(mass_rate: Union[float, NDArray[float64]], particle_radius: Union[float, NDArray[float64]], density: Union[float, NDArray[float64]]) -> Union[float, NDArray[np.float64]]

Convert mass rate to radius growth/evaporation rate.

This function converts the mass transfer rate (dm/dt) into a radius change rate (dr/dt). The equation is:

  • dr/dt = (1 / 4πr²ρ) × dm/dt
    • dr/dt : Radius change rate [m/s].
    • r : Particle radius [m].
    • ρ : Particle density [kg/m³].
    • dm/dt : Mass change rate [kg/s].

Parameters:

  • - mass_rate

    The mass transfer rate [kg/s].

  • - particle_radius

    The radius of the particle [m].

  • - density

    The density of the particle [kg/m³].

Returns:

  • Union[float, NDArray[float64]]
    • The radius growth (or evaporation) rate [m/s].

Examples:

Single value input
import particula as par
par.dynamics.radius_transfer_rate(
    mass_rate=1e-21,
    particle_radius=1e-6,
    density=1000
)
# Output: 7.95774715e-14
Array input
import particula as par
par.dynamics.radius_transfer_rate(
    mass_rate=np.array([1e-21, 2e-21]),
    particle_radius=np.array([1e-6, 2e-6]),
    density=1000
)
# Output: array([7.95774715e-14, 1.98943679e-14])
Source code in particula/dynamics/condensation/mass_transfer.py
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
@validate_inputs(
    {
        "mass_rate": "finite",
        "particle_radius": "nonnegative",
        "density": "positive",
    }
)
def get_radius_transfer_rate(
    mass_rate: Union[float, NDArray[np.float64]],
    particle_radius: Union[float, NDArray[np.float64]],
    density: Union[float, NDArray[np.float64]],
) -> Union[float, NDArray[np.float64]]:
    """Convert mass rate to radius growth/evaporation rate.

    This function converts the mass transfer rate (dm/dt) into a radius
    change rate (dr/dt). The equation is:

    - dr/dt = (1 / 4πr²ρ) × dm/dt
        - dr/dt : Radius change rate [m/s].
        - r : Particle radius [m].
        - ρ : Particle density [kg/m³].
        - dm/dt : Mass change rate [kg/s].

    Arguments:
        - mass_rate : The mass transfer rate [kg/s].
        - particle_radius : The radius of the particle [m].
        - density : The density of the particle [kg/m³].

    Returns:
        - The radius growth (or evaporation) rate [m/s].

    Examples:
        ```py title="Single value input"
        import particula as par
        par.dynamics.radius_transfer_rate(
            mass_rate=1e-21,
            particle_radius=1e-6,
            density=1000
        )
        # Output: 7.95774715e-14
        ```

        ```py title="Array input"
        import particula as par
        par.dynamics.radius_transfer_rate(
            mass_rate=np.array([1e-21, 2e-21]),
            particle_radius=np.array([1e-6, 2e-6]),
            density=1000
        )
        # Output: array([7.95774715e-14, 1.98943679e-14])
        ```
    """
    # Type narrowing: handle 2D mass_rate with array particle_radius
    radius_for_calc: Union[float, NDArray[np.float64]] = particle_radius
    if isinstance(mass_rate, np.ndarray) and mass_rate.ndim == 2:
        if isinstance(particle_radius, np.ndarray):
            radius_for_calc = particle_radius[:, np.newaxis]
    return mass_rate / (density * 4 * np.pi * radius_for_calc**2)