ISORROPIA II (Fountoukis & Nenes, 2007)

Overview

ISORROPIA II is an inorganic aerosol thermodynamic equilibrium model for the K⁺–Ca²⁺–Mg²⁺–NH₄⁺–Na⁺–SO₄²⁻–NO₃⁻–Cl⁻–H₂O system. It computes the equilibrium partitioning of semi-volatile inorganic species between gas, aqueous, and solid phases.

The implementation supports two solution modes via the stable parameter:

  • Metastable (stable=0, default): No solid precipitation — the aerosol is assumed to be a liquid solution at all relative humidities.
  • Stable (stable=1): Solid precipitation is allowed — salts crystallize when the solution becomes supersaturated. The mutual deliquescence relative humidity (MDRH) from Table 5 is enforced: below the MDRH for the given salt mixture, the aerosol is completely dry (crystalline). Temperature-dependent DRH values follow Eq. 17 and Table 4.

Reference: Fountoukis, C. and Nenes, A.: ISORROPIA II: a computationally efficient thermodynamic equilibrium model for K⁺–Ca²⁺–Mg²⁺–NH₄⁺–Na⁺–SO₄²⁻–NO₃⁻–Cl⁻–H₂O aerosols, Atmos. Chem. Phys., 7, 4639–4659, 2007.

Aerosol.IsorropiaEquilibrium — Function
IsorropiaEquilibrium(; name=:IsorropiaEquilibrium)

ISORROPIA II inorganic aerosol thermodynamic equilibrium model for the K⁺–Ca²⁺–Mg²⁺–NH₄⁺–Na⁺–SO₄²⁻–NO₃⁻–Cl⁻–H₂O system.

Supports both metastable (no solids) and stable (with solid precipitation) solution modes, controlled by the stable parameter (0=metastable, 1=stable).

The model solves 51 coupled algebraic equations:

  • 8 mass balance equations (with solid stoichiometric contributions in stable mode)
  • 1 charge balance (electroneutrality)
  • 5 aqueous equilibrium expressions (HSO₄⁻, NH₃, HNO₃, HCl, H₂O)
  • 1 ZSR water content equation with MDRH cutoff (Eqs. 16-18, 22)
  • 1 ionic strength definition
  • 16 activity coefficient equations (Kusik-Meissner, Eqs. 9-13)
  • 19 solid precipitation equations (Fischer-Burmeister NCP complementarity)

In stable mode, solid salts precipitate when the solution becomes supersaturated. Each solid equilibrium uses a smooth complementarity formulation: either the solid amount is zero, or the solution is exactly at saturation.

Deliquescence: Temperature-dependent DRH values are computed for each salt using Eq. 17 and Table 4. The mutual deliquescence relative humidity (MDRH) from Table 5 is enforced in stable mode: below the MDRH, the aerosol water content is driven to zero, producing a completely dry (crystalline) aerosol. In metastable mode, the MDRH cutoff is not applied.

Activity coefficients are computed using the Kusik-Meissner binary relationship (Eqs. 9-13) with temperature correction (Eq. 14).

Reference: Fountoukis, C. and Nenes, A.: ISORROPIA II: a computationally efficient thermodynamic equilibrium model for K⁺–Ca²⁺–Mg²⁺–NH₄⁺–Na⁺–SO₄²⁻–NO₃⁻–Cl⁻–H₂O aerosols, Atmos. Chem. Phys., 7, 4639–4659, 2007.

source

Data Provenance

This implementation was developed from the published scientific literature. No source code from the original ISORROPIA or ISORROPIA II Fortran implementations was used. The specific data sources are:

Equations and algorithms: All governing equations — including the van't Hoff temperature dependence (Eq. 5), Kusik-Meissner activity coefficient model (Eqs. 9–13), temperature correction (Eq. 14), ZSR water content method (Eq. 16), DRH temperature dependence (Eq. 17), and composition-dependent MDRH selection (Eq. 22) — are from the primary reference: Fountoukis and Nenes (2007).

Thermodynamic equilibrium constants (K₀, A, B parameters for 23 reactions): Table 2 of Fountoukis and Nenes (2007).

Deliquescence relative humidity (DRH at 298.15 K and temperature correction coefficients for 19 salts): Table 4 of Fountoukis and Nenes (2007).

Mutual deliquescence relative humidity (MDRH thresholds for 6 composition regimes): Table 5 of Fountoukis and Nenes (2007).

Kusik-Meissner Q parameters (q and charge product z for 18 binary electrolyte pairs): Originally from Kusik, C. L. and Meissner, H. P.: Electrolyte activity coefficients in inorganic processing, AIChE Symp. Ser., 74(173), 14–20, 1978; as compiled for atmospheric aerosol applications by Kim, Y. P., Seinfeld, J. H., and Saxena, P.: Atmospheric gas-aerosol equilibrium: II. Analysis of common approximations and activity coefficient calculation methods, Aerosol Sci. Technol., 19, 182–198, 1993.

ZSR binary molality lookup tables (molality as a function of water activity for 19 binary electrolyte-water systems, 100 entries each): From the Extended AIM Aerosol Thermodynamics Model (E-AIM, Model III; http://www.aim.env.uea.ac.uk/aim/aim.php), developed by Clegg, S. L., Brimblecombe, P., and Wexler, A. S. These values are computed from Pitzer-Simonson-Clegg thermodynamic equations fitted to experimental measurements of binary electrolyte-water systems at 298.15 K.

Numerical solver approach: This implementation differs architecturally from the original ISORROPIA II Fortran code. Rather than using the composition-regime-based solution strategy of the original (which selects among dozens of specialized subroutines), this implementation formulates the full system of 51 coupled algebraic equations and solves them simultaneously using a nonlinear solver. Solid precipitation uses a smooth Fischer-Burmeister complementarity formulation rather than explicit case-based logic.

Implementation

The model solves a system of coupled algebraic equations that depends on the solution mode:

Metastable mode (stable=0, default): 21 equations total

  • 8 mass balance equations (no solid terms)
  • 1 electroneutrality (charge balance) equation
  • 5 aqueous equilibrium expressions (HSO₄⁻, NH₃, HNO₃, HCl, H₂O)
  • 1 ZSR water content equation (Eq. 16)
  • 1 ionic strength definition
  • 5 activity coefficient equations (Kusik-Meissner, Eqs. 9-13, with temperature correction Eq. 14)

Stable mode (stable=1): Additional equations for solid precipitation

  • All metastable equations plus 19+ solid equilibrium equations using complementarity constraints

The solid precipitation uses a smooth complementarity formulation: for each solid salt, either its amount is zero (undersaturated) or the ion activity product equals the solubility product (at dissolution equilibrium). In metastable mode (stable=0), all solid equations reduce to s = 0.

State Variables

using DataFrames, ModelingToolkit, Symbolics, DynamicQuantities
using Aerosol

sys = IsorropiaEquilibrium()
compiled = mtkcompile(sys)

vars = unknowns(compiled)
DataFrame(
    :Name => [string(Symbolics.tosymbol(v, escape = false)) for v in vars],
    :Units => [dimension(ModelingToolkit.get_unit(v)) for v in vars],
    :Description => [ModelingToolkit.getdescription(v) for v in vars]
)
26×3 DataFrame
RowNameUnitsDescription
StringDimensio…String
1s_Na2SO4m⁻³ molSolid Na₂SO₄ concentration
2s_NaNO3m⁻³ molSolid NaNO₃ concentration
3s_NaClm⁻³ molSolid NaCl concentration
4c_Nam⁻³ molAqueous Na⁺ concentration
5s_CaSO4m⁻³ molSolid CaSO₄ concentration
6s_LCm⁻³ molSolid letovicite (NH₄)₃H(SO₄)₂ concentration
7s_K2SO4m⁻³ molSolid K₂SO₄ concentration
8s_NH4HSO4m⁻³ molSolid NH₄HSO₄ concentration
9c_HSO4m⁻³ molAqueous HSO₄⁻ concentration
10s_MgSO4m⁻³ molSolid MgSO₄ concentration
11s_KHSO4m⁻³ molSolid KHSO₄ concentration
12c_SO4m⁻³ molAqueous SO₄²⁻ concentration
13c_NH4m⁻³ molAqueous NH₄⁺ concentration
14s_NH4NO3m⁻³ molSolid NH₄NO₃ concentration
15g_NH3m⁻³ molGas-phase NH₃ concentration
16s_MgNO32m⁻³ molSolid Mg(NO₃)₂ concentration
17g_HNO3m⁻³ molGas-phase HNO₃ concentration
18c_NO3m⁻³ molAqueous NO₃⁻ concentration
19s_KNO3m⁻³ molSolid KNO₃ concentration
20c_Clm⁻³ molAqueous Cl⁻ concentration
21c_Cam⁻³ molAqueous Ca²⁺ concentration
22c_Km⁻³ molAqueous K⁺ concentration
23c_Mgm⁻³ molAqueous Mg²⁺ concentration
24c_Hm⁻³ molAqueous H⁺ concentration
25W_wm⁻³ kgAerosol liquid water content
26I_skg⁻¹ molIonic strength of the solution

Parameters

params = parameters(compiled)
DataFrame(
    :Name => [string(Symbolics.tosymbol(p, escape = false)) for p in params],
    :Units => [dimension(ModelingToolkit.get_unit(p)) for p in params],
    :Default => [ModelingToolkit.getdefault(p) for p in params],
    :Description => [ModelingToolkit.getdescription(p) for p in params]
)
90×4 DataFrame
RowNameUnitsDefaultDescription
StringDimensio…RealString
1W_Na_totalm⁻³ mol0.0Total sodium concentration
2W_SO4_totalm⁻³ mol1.0e-7Total sulfate concentration
3W_NH3_totalm⁻³ mol2.0e-7Total ammonia + ammonium concentration
4W_NO3_totalm⁻³ mol1.0e-7Total nitrate + nitric acid concentration
5W_Cl_totalm⁻³ mol0.0Total chloride + HCl concentration
6W_Ca_totalm⁻³ mol0.0Total calcium concentration
7W_K_totalm⁻³ mol0.0Total potassium concentration
8W_Mg_totalm⁻³ mol0.0Total magnesium concentration
9T_envK298.15Ambient temperature
10RH0.8Ambient relative humidity (dimensionless)
11stable0Solution mode: 0=metastable (no solids), 1=stable (with solids)
12K8_B6.12NH4NO3 dissolution B (dimensionless)
13K21_B-5.393NH3 dissolution heat capacity parameter (dimensionless)
14K14_A0.0CaSO4 dissolution A (dimensionless)
15K4_B16.83HNO3 gas-liquid heat capacity parameter (dimensionless)
16K13_B16.9NaCl dissolution B (dimensionless)
17unity1.0Dimensionless unity constant
18K16_A-8.698CaCl2 dissolution A (dimensionless)
19K13_0kg⁻² mol²37.66NaCl dissolution K0
20K18_0kg⁻³ mol³24.016KHSO4 dissolution K0
21K21s_B0.0MgSO4 dissolution B (dimensionless)
22K1_0kg⁻¹ mol0.01015HSO4 dissociation equilibrium constant at T0
23K18_A-8.423KHSO4 dissolution A (dimensionless)
24K3_0_atmm kg⁻³ s² mol²1.971e6HCl gas-liquid equilibrium constant at T0 in atm units
25K1_A8.85HSO4 dissociation enthalpy parameter (dimensionless)
26K14_0kg⁻² mol²4.319e-5CaSO4 dissolution K0
27K8_A-74.38NH4NO3 dissolution A (dimensionless)
28K12_A-8.22NaNO3 dissolution A (dimensionless)
29K9_A-71.0NH4Cl dissolution A (dimensionless)
30K4_0_atmm kg⁻³ s² mol²2.511e6HNO3 gas-liquid equilibrium constant at T0 in atm units
31K19_A-14.08KNO3 dissolution A (dimensionless)
32K3_B19.91HCl gas-liquid heat capacity parameter (dimensionless)
33K15_A-11.299Ca(NO3)2 dissolution A (dimensionless)
34K15_B0.0Ca(NO3)2 dissolution B (dimensionless)
35K6_0kg⁻³ mol³138.3NH4HSO4 dissolution K0
36K5_A-2.65(NH4)2SO4 dissolution A (dimensionless)
37K22s_0kg⁻³ mol³2.507e15Mg(NO3)2 dissolution K0
38K7_A-5.19Letovicite dissolution A (dimensionless)
39R_gas_sim² kg s⁻² K⁻¹ mol⁻¹8.31446Gas constant (SI)
40K23_B0.0MgCl2 dissolution B (dimensionless)
41K20_B19.95KCl dissolution B (dimensionless)
42K10_0kg⁻³ mol³0.4799Na2SO4 dissolution K0
43K21s_0kg⁻² mol²107900.0MgSO4 dissolution K0
44K5_0kg⁻³ mol³1.817(NH4)2SO4 dissolution K0
45K22s_A-8.754Mg(NO3)2 dissolution A (dimensionless)
46T_0K298.15Reference temperature for thermodynamic data
47K10_A0.98Na2SO4 dissolution A (dimensionless)
48K12_0kg⁻² mol²11.97NaNO3 dissolution K0
49K3_A30.2HCl gas-liquid enthalpy parameter (dimensionless)
50Kw_0kg⁻² mol²1.01e-14Water dissociation equilibrium constant at T0
51Kw_B26.92Water dissociation heat capacity parameter (dimensionless)
52K5_B38.57(NH4)2SO4 dissolution B (dimensionless)
53half0.5Dimensionless half constant
54K20_0kg⁻² mol²8.68KCl dissolution K0
55Kw_A-22.52Water dissociation enthalpy parameter (dimensionless)
56K23_A-1.347MgCl2 dissolution A (dimensionless)
57K7_B54.4Letovicite dissolution B (dimensionless)
58K8_0_atm2m⁻² kg² s⁻⁴4.3559e-17NH4NO3 dissolution K0 in atm²
59K14_B0.0CaSO4 dissolution B (dimensionless)
60K23_0kg⁻³ mol³9.557e21MgCl2 dissolution K0
61K17_A-9.585K2SO4 dissolution A (dimensionless)
62K6_B15.83NH4HSO4 dissolution B (dimensionless)
63K17_0kg⁻³ mol³0.01569K2SO4 dissolution K0
64K22_0kg⁻¹ mol1.805e-5NH3 dissociation equilibrium constant at T0
65K16_B0.0CaCl2 dissolution B (dimensionless)
66K1_B25.14HSO4 dissociation heat capacity parameter (dimensionless)
67K7_0kg⁻⁵ mol⁵29.3Letovicite dissolution K0
68K18_B17.96KHSO4 dissolution B (dimensionless)
69K17_B45.81K2SO4 dissolution B (dimensionless)
70K21_0_atmm kg⁻² s² mol57.64NH3 dissolution equilibrium constant at T0 in atm units
71K9_0_atm2m⁻² kg² s⁻⁴1.086e-16NH4Cl dissolution K0 in atm²
72K10_B39.75Na2SO4 dissolution B (dimensionless)
73K11_B14.75NaHSO4 dissolution B (dimensionless)
74K6_A-2.87NH4HSO4 dissolution A (dimensionless)
75K22_A-1.5NH3 dissociation enthalpy parameter (dimensionless)
76K16_0kg⁻³ mol³7.974e11CaCl2 dissolution K0
77K11_A0.79NaHSO4 dissolution A (dimensionless)
78K15_0kg⁻³ mol³606700.0Ca(NO3)2 dissolution K0
79K22s_B0.0Mg(NO3)2 dissolution B (dimensionless)
80K20_A-6.902KCl dissolution A (dimensionless)
81K19_B19.39KNO3 dissolution B (dimensionless)
82K21s_A36.798MgSO4 dissolution A (dimensionless)
83K22_B26.92NH3 dissociation heat capacity parameter (dimensionless)
84K11_0kg⁻³ mol³24130.0NaHSO4 dissolution K0
85K21_A13.79NH3 dissolution enthalpy parameter (dimensionless)
86K13_A-1.56NaCl dissolution A (dimensionless)
87K12_B16.01NaNO3 dissolution B (dimensionless)
88K19_0kg⁻² mol²0.872KNO3 dissolution K0
89K9_B2.4NH4Cl dissolution B (dimensionless)
90K4_A29.17HNO3 gas-liquid enthalpy parameter (dimensionless)

Equations

equations(sys)
51-element Vector{Symbolics.Equation}:
 0 ~ -W_Na_total + c_Na(t) + 2s_Na2SO4(t) + s_NaCl(t) + s_NaHSO4(t) + s_NaNO3(t)
 0 ~ -W_SO4_total + c_HSO4(t) + c_SO4(t) + s_CaSO4(t) + s_K2SO4(t) + s_KHSO4(t) + 2s_LC(t) + s_MgSO4(t) + s_NH42SO4(t) + s_NH4HSO4(t) + s_Na2SO4(t) + s_NaHSO4(t)
 0 ~ -W_NH3_total + c_NH4(t) + g_NH3(t) + 3s_LC(t) + 2s_NH42SO4(t) + s_NH4Cl(t) + s_NH4HSO4(t) + s_NH4NO3(t)
 0 ~ -W_NO3_total + c_NO3(t) + g_HNO3(t) + 2s_CaNO32(t) + s_KNO3(t) + 2s_MgNO32(t) + s_NH4NO3(t) + s_NaNO3(t)
 0 ~ -W_Cl_total + c_Cl(t) + g_HCl(t) + 2s_CaCl2(t) + s_KCl(t) + 2s_MgCl2(t) + s_NH4Cl(t) + s_NaCl(t)
 0 ~ -W_Ca_total + c_Ca(t) + s_CaCl2(t) + s_CaNO32(t) + s_CaSO4(t)
 0 ~ -W_K_total + c_K(t) + 2s_K2SO4(t) + s_KCl(t) + s_KHSO4(t) + s_KNO3(t)
 0 ~ -W_Mg_total + c_Mg(t) + s_MgCl2(t) + s_MgNO32(t) + s_MgSO4(t)
 0 ~ 2c_Ca(t) - c_Cl(t) + c_H(t) - c_HSO4(t) + c_K(t) + 2c_Mg(t) + c_NH4(t) - c_NO3(t) + c_Na(t) - c_OH(t) - 2c_SO4(t)
 0 ~ (-K1_0*c_HSO4(t)*exp(K1_A*(-1.0 + T_0 / T_env) + K1_B*(1.0 + log(T_0 / T_env) + (-T_0) / T_env))*(γ_HHSO4(t)^2)) / W_w(t) + (c_H(t)*c_SO4(t)*(γ_H2SO4(t)^3)) / (W_w(t)^2)
 ⋮
 0 ~ Aerosol._iso2_fb_ncp(s_Na2SO4(t), unity + (-c_SO4(t)*((c_Na(t) / W_w(t))^2)*(γ_Na2SO4(t)^3)) / (K10_0*W_w(t)*exp(K10_A*(-1.0 + T_0 / T_env) + K10_B*(1.0 + log(T_0 / T_env) + (-T_0) / T_env))))*stable + s_Na2SO4(t)*(-stable + unity)
 0 ~ Aerosol._iso2_fb_ncp(s_NaHSO4(t), unity + (-c_H(t)*c_Na(t)*c_SO4(t)*(sqrt((γ_HHSO4(t)*γ_NaCl(t)) / γ_HCl(t))^3)) / (K11_0*(W_w(t)^3)*exp(K11_A*(-1.0 + T_0 / T_env) + K11_B*(1.0 + log(T_0 / T_env) + (-T_0) / T_env))))*stable + s_NaHSO4(t)*(-stable + unity)
 0 ~ Aerosol._iso2_fb_ncp(s_NaNO3(t), unity + (-c_NO3(t)*c_Na(t)*(γ_NaNO3(t)^2)) / (K12_0*(W_w(t)^2)*exp(K12_A*(-1.0 + T_0 / T_env) + K12_B*(1.0 + log(T_0 / T_env) + (-T_0) / T_env))))*stable + s_NaNO3(t)*(-stable + unity)
 0 ~ Aerosol._iso2_fb_ncp(s_NaCl(t), unity + (-c_Cl(t)*c_Na(t)*(γ_NaCl(t)^2)) / (K13_0*(W_w(t)^2)*exp(K13_A*(-1.0 + T_0 / T_env) + K13_B*(1.0 + log(T_0 / T_env) + (-T_0) / T_env))))*stable + s_NaCl(t)*(-stable + unity)
 0 ~ Aerosol._iso2_fb_ncp(s_NH42SO4(t), unity + (-c_SO4(t)*((c_NH4(t) / W_w(t))^2)*(γ_NH42SO4(t)^3)) / (K5_0*W_w(t)*exp(K5_A*(-1.0 + T_0 / T_env) + K5_B*(1.0 + log(T_0 / T_env) + (-T_0) / T_env))))*stable + s_NH42SO4(t)*(-stable + unity)
 0 ~ Aerosol._iso2_fb_ncp(s_NH4HSO4(t), unity + (-c_H(t)*c_NH4(t)*c_SO4(t)*(sqrt((γ_HHSO4(t)*γ_NH4Cl(t)) / γ_HCl(t))^3)) / (K6_0*(W_w(t)^3)*exp(K6_A*(-1.0 + T_0 / T_env) + K6_B*(1.0 + log(T_0 / T_env) + (-T_0) / T_env))))*stable + s_NH4HSO4(t)*(-stable + unity)
 0 ~ Aerosol._iso2_fb_ncp(s_LC(t), unity + (-c_HSO4(t)*c_SO4(t)*sqrt((γ_HHSO4(t)*γ_NH4Cl(t)) / γ_HCl(t))*((c_NH4(t) / W_w(t))^3)*(γ_NH42SO4(t)^3.0000000000000004)) / (K7_0*(W_w(t)^2)*exp(K7_A*(-1.0 + T_0 / T_env) + K7_B*(1.0 + log(T_0 / T_env) + (-T_0) / T_env))))*stable + s_LC(t)*(-stable + unity)
 0 ~ Aerosol._iso2_fb_ncp(s_NH4NO3(t), unity + (-(R_gas_si^2)*(T_env^2)*g_HNO3(t)*g_NH3(t)) / (K8_0*exp(K8_A*(-1.0 + T_0 / T_env) + K8_B*(1.0 + log(T_0 / T_env) + (-T_0) / T_env))))*stable + s_NH4NO3(t)*(-stable + unity)
 0 ~ Aerosol._iso2_fb_ncp(s_NH4Cl(t), unity + (-(R_gas_si^2)*(T_env^2)*g_HCl(t)*g_NH3(t)) / (K9_0*exp(K9_A*(-1.0 + T_0 / T_env) + K9_B*(1.0 + log(T_0 / T_env) + (-T_0) / T_env))))*stable + s_NH4Cl(t)*(-stable + unity)

Analysis

Equilibrium Constants vs Temperature (cf. Table 2)

The equilibrium constants follow the van't Hoff temperature dependence (Eq. 5):

\[K(T) = K_0 \exp\left[A\left(\frac{T_0}{T} - 1\right) + B\left(1 + \ln\frac{T_0}{T} - \frac{T_0}{T}\right)\right]\]

using Plots

T_range = collect(260.0:1.0:320.0)

K1_vals = [Aerosol._iso2_eq_const(1.015e-2, 8.85, 25.14, T) for T in T_range]
K4_vals = [Aerosol._iso2_eq_const(2.511e6, 29.17, 16.83, T) for T in T_range]
K3_vals = [Aerosol._iso2_eq_const(1.971e6, 30.20, 19.91, T) for T in T_range]
Kw_vals = [Aerosol._iso2_eq_const(1.010e-14, -22.52, 26.92, T) for T in T_range]

p = plot(T_range, K1_vals, label="K1 (HSO4 dissoc.)", yscale=:log10,
    xlabel="Temperature (K)", ylabel="Equilibrium Constant",
    title="Temperature Dependence of Equilibrium Constants (Eq. 5)")
plot!(p, T_range, K4_vals, label="K4 (HNO3)")
plot!(p, T_range, K3_vals, label="K3 (HCl)")
plot!(p, T_range, Kw_vals, label="Kw (H2O)")
p
Example block output

Activity Coefficients vs Ionic Strength (cf. Eqs. 9-13)

Kusik-Meissner binary mean activity coefficients at 298.15 K:

I_range = collect(0.01:0.1:30.0)

gamma_NaCl = [Aerosol._iso2_km_gamma(2.23, 1, I) for I in I_range]
gamma_NH4Cl = [Aerosol._iso2_km_gamma(0.82, 1, I) for I in I_range]
gamma_H2SO4 = [Aerosol._iso2_km_gamma(-0.10, 2, I) for I in I_range]
gamma_HNO3 = [Aerosol._iso2_km_gamma(2.60, 1, I) for I in I_range]
gamma_HCl = [Aerosol._iso2_km_gamma(6.00, 1, I) for I in I_range]

p = plot(I_range, gamma_NaCl, label="NaCl (q=2.23)", yscale=:log10,
    xlabel="Ionic Strength (mol/kg)", ylabel="Mean Activity Coefficient",
    title="Kusik-Meissner Activity Coefficients (Eqs. 9-13)")
plot!(p, I_range, gamma_NH4Cl, label="NH4Cl (q=0.82)")
plot!(p, I_range, gamma_H2SO4, label="H2SO4 (q=-0.10)")
plot!(p, I_range, gamma_HNO3, label="HNO3 (q=2.60)")
plot!(p, I_range, gamma_HCl, label="HCl (q=6.00)")
p
Example block output

ZSR Water Content vs RH (cf. Eq. 16)

Aerosol water content for pure salt aerosols computed using the ZSR method:

RH_range = collect(0.10:0.01:0.98)

# (NH4)2SO4: c_NH4 = 2e-7 mol/m³, c_SO4 = 1e-7 mol/m³
W_as = [Aerosol._iso2_zsr_water(rh, 0.0, 2e-7, 1e-7, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)
        for rh in RH_range]

# NaCl: c_Na = 1e-7 mol/m³, c_Cl = 1e-7 mol/m³
W_nacl = [Aerosol._iso2_zsr_water(rh, 1e-7, 0.0, 0.0, 0.0, 0.0, 1e-7, 0.0, 0.0, 0.0)
          for rh in RH_range]

p = plot(RH_range, W_as, label="(NH4)2SO4",
    xlabel="Relative Humidity", ylabel="Water Content (kg/m3)",
    title="ZSR Aerosol Water Content (Eq. 16)")
plot!(p, RH_range, W_nacl, label="NaCl")
p
Example block output

DRH vs Temperature (cf. Figure 2, Eq. 17, Table 4)

Deliquescence relative humidity (DRH) for individual salts as a function of temperature. DRH(T) = DRH(T₀) × exp(coeff × (1/T - 1/T₀)) where T₀ = 298.15 K. Salts with large positive coefficients (e.g., NH₄NO₃, Ca(NO₃)₂) show strong temperature dependence, while salts with near-zero coefficients (e.g., CaSO₄, KHSO₄, KNO₃) are essentially temperature-independent.

T_drh = collect(250.0:1.0:320.0)

# Select representative salts spanning different behaviors
salts = [
    (:NH42SO4, "(NH₄)₂SO₄"), (:NH4NO3, "NH₄NO₃"), (:NaCl, "NaCl"),
    (:Na2SO4, "Na₂SO₄"), (:NH4HSO4, "NH₄HSO₄"), (:CaNO32, "Ca(NO₃)₂"),
    (:K2SO4, "K₂SO₄"), (:MgSO4, "MgSO₄"), (:KCl, "KCl"),
]

p = plot(xlabel="Temperature (K)", ylabel="DRH",
    title="Deliquescence RH vs Temperature (Eq. 17, Table 4)",
    legend=:outerright, size=(800, 450))
for (sym, label) in salts
    drh0, coeff = Aerosol._ISO2_DRH[sym]
    drh_vals = [Aerosol._iso2_drh_T(drh0, coeff, T) for T in T_drh]
    plot!(p, T_drh, drh_vals, label=label)
end
p
Example block output

MDRH: Mutual Deliquescence (Table 5)

The mutual deliquescence relative humidity (MDRH) is the minimum RH at which any aqueous phase can exist for a mixture of salts. Below MDRH, the aerosol is completely crystalline. The MDRH depends on the salt mixture composition (sulfate ratio R₁ and presence of crustal/sodium species). In stable mode, the water content is smoothly driven to zero below MDRH using a logistic transition function.

Composition RegimeMDRH
Crustal species present0.200
Na present, no crustal (sulfate-poor)0.363
NH₄-only (sulfate-poor)0.540
NH₄-only (sulfate-rich)0.400
Na present (sulfate-rich)0.363
Crustal species present (sulfate-rich)0.200

Equilibrium Partitioning: Gas-Aerosol Split

The fraction of semi-volatile species in the aerosol phase as a function of RH, for a sulfate-poor continental aerosol (SO₄=1e-7, NH₃=3e-7, NO₃=1e-7 mol/m³):

using NonlinearSolve, SciMLBase

RH_vals = collect(0.70:0.05:0.95)

NH4_frac = Float64[]
NO3_frac = Float64[]

for rh in RH_vals
    op = Pair{Symbolics.Num, Float64}[
        compiled.RH => rh,
        compiled.W_SO4_total => 1e-7,
        compiled.W_NH3_total => 3e-7,
        compiled.W_NO3_total => 1e-7,
        compiled.c_SO4 => 9.5e-8,
        compiled.c_NO3 => 5e-8,
        compiled.c_Cl => 1e-20,
        compiled.c_H => 1e-11,
        compiled.c_OH => 1e-14,
        compiled.I_s => 10.0,
    ]
    # Fill in default guesses for unknowns not explicitly set
    op_keys = Set(first.(op))
    for u in unknowns(compiled)
        if !(u in op_keys)
            g_val = ModelingToolkit.getguess(u)
            if g_val !== nothing
                push!(op, u => Float64(g_val))
            end
        end
    end
    prob = NonlinearProblem(compiled, op)
    sol = solve(prob, RobustMultiNewton(); maxiters=10000)
    if sol.retcode == SciMLBase.ReturnCode.Success
        push!(NH4_frac, sol[compiled.c_NH4] / 3e-7)
        push!(NO3_frac, sol[compiled.c_NO3] / 1e-7)
    else
        push!(NH4_frac, NaN)
        push!(NO3_frac, NaN)
    end
end

p = plot(RH_vals, NH4_frac, label="NH4+ / (NH4+ + NH3)",
    xlabel="Relative Humidity", ylabel="Aerosol Fraction",
    title="Gas-Aerosol Partitioning vs RH (Sulfate-Poor)")
plot!(p, RH_vals, NO3_frac, label="NO3- / (NO3- + HNO3)")
p
Example block output

Figures 6–9: Model Intercomparison Cases (Table 8)

The following figures reproduce Figures 6–9 from Fountoukis and Nenes (2007), showing equilibrium aerosol composition vs. relative humidity for four representative cases from Table 8. Input concentrations are converted from µg/m³ to mol/m³. The metastable solution is shown (set stable=1 to include solid precipitation).

Figure 6: Urban Aerosol — Sulfate Rich (Case 3, Table 8)

Aerosol composition vs. RH for an urban sulfate-rich case (1 < R₁ < 2): Na=0, H₂SO₄=15.0, NH₃=2.0, HNO₃=10.0, HCl=0, Ca=0.9, K=1.0, Mg=0 µg/m³. Panels show (a) aerosol water, (b) K⁺, (c) NH₄⁺, and (d) NO₃⁻, all in µg/m³.

# Re-create system for this block
sys = IsorropiaEquilibrium()
compiled = mtkcompile(sys)

# Helper: sweep RH from high to low using continuation for solver convergence
function solve_iso2_sweep(compiled, Na, SO4, NH3, NO3, Cl, Ca, K, Mg;
                          RH_range=0.95:-0.01:0.30)
    RH_ok, W_vals = Float64[], Float64[]
    c = Dict(s => Float64[] for s in [:Na,:NH4,:SO4,:HSO4,:NO3,:Cl,:Ca,:K,:Mg,:H,:OH])
    g = Dict(s => Float64[] for s in [:NH3,:HNO3,:HCl])
    prev = nothing

    for rh in RH_range
        params = [compiled.RH => rh, compiled.W_Na_total => Na,
                  compiled.W_SO4_total => SO4, compiled.W_NH3_total => NH3,
                  compiled.W_NO3_total => NO3, compiled.W_Cl_total => Cl,
                  compiled.W_Ca_total => Ca, compiled.W_K_total => K,
                  compiled.W_Mg_total => Mg]
        if prev !== nothing
            guesses = [compiled.c_SO4 => prev[:SO4], compiled.c_HSO4 => prev[:HSO4],
                       compiled.c_NH4 => prev[:NH4], compiled.c_NO3 => prev[:NO3],
                       compiled.c_Cl => prev[:Cl], compiled.c_H => prev[:H],
                       compiled.c_OH => prev[:OH], compiled.I_s => prev[:I],
                       compiled.W_w => prev[:W]]
        else
            # Sulfate ratio R₁ determines aerosol regime
            R1 = SO4 > 0 ? (NH3 + Na + 2*Ca + K + 2*Mg) / SO4 : 100.0
            if R1 < 2  # Sulfate-rich: acidic aerosol
                guesses = [compiled.c_SO4 => max(0.5*SO4, 1e-20),
                           compiled.c_HSO4 => max(0.5*SO4, 1e-20),
                           compiled.c_NH4 => max(0.99*NH3, 1e-20),
                           compiled.c_NO3 => 1e-10, compiled.c_Cl => 1e-20,
                           compiled.c_H => 1e-7, compiled.c_OH => 1e-18,
                           compiled.I_s => 15.0, compiled.W_w => 1e-7,
                           compiled.g_NH3 => 1e-10, compiled.g_HNO3 => max(0.99*NO3, 1e-20)]
            else  # Sulfate-poor: more neutral aerosol
                guesses = [compiled.c_SO4 => max(0.85*SO4, 1e-20),
                           compiled.c_HSO4 => max(0.15*SO4, 1e-20),
                           compiled.c_NH4 => max(min(NH3, 2*SO4)*0.8, 1e-20),
                           compiled.c_NO3 => max(0.3*NO3, 1e-20),
                           compiled.c_Cl => max(0.3*Cl, 1e-20),
                           compiled.c_H => 1e-10, compiled.c_OH => 1e-13,
                           compiled.I_s => 10.0]
            end
        end

        # Fill in default guesses for any unknowns not explicitly set
        op = vcat(params, guesses)
        op_keys = Set(first.(op))
        for u in unknowns(compiled)
            if !(u in op_keys)
                g_val = ModelingToolkit.getguess(u)
                if g_val !== nothing
                    push!(op, u => Float64(g_val))
                end
            end
        end
        prob = NonlinearProblem(compiled, op)
        sol = solve(prob, RobustMultiNewton(); maxiters=10000)

        if sol.retcode == SciMLBase.ReturnCode.Success
            push!(RH_ok, rh); push!(W_vals, sol[compiled.W_w])
            for s in [:Na,:NH4,:SO4,:HSO4,:NO3,:Cl,:Ca,:K,:Mg,:H,:OH]
                push!(c[s], sol[getproperty(compiled, Symbol(:c_, s))])
            end
            push!(g[:NH3], sol[compiled.g_NH3])
            push!(g[:HNO3], sol[compiled.g_HNO3])
            push!(g[:HCl], sol[compiled.g_HCl])
            prev = Dict(:SO4=>sol[compiled.c_SO4], :HSO4=>sol[compiled.c_HSO4],
                        :NH4=>sol[compiled.c_NH4], :NO3=>sol[compiled.c_NO3],
                        :Cl=>sol[compiled.c_Cl], :H=>sol[compiled.c_H],
                        :OH=>sol[compiled.c_OH], :I=>sol[compiled.I_s],
                        :W=>sol[compiled.W_w])
        end
    end
    reverse!(RH_ok); reverse!(W_vals)
    for v in values(c); reverse!(v); end
    for v in values(g); reverse!(v); end
    return RH_ok, W_vals, c, g
end

# Case 3 (Urban, sulfate rich) from Table 8
RH6, W6, c6, g6 = solve_iso2_sweep(compiled,
    0.0, 15.0e-6/98.08, 2.0e-6/17.03, 10.0e-6/63.01, 0.0,
    0.9e-6/40.08, 1.0e-6/39.10, 0.0)

p6a = plot(RH6, W6 .* 1e9, label="Metastable", xlabel="RH", ylabel="µg/m³",
    title="(a) Aerosol Water", legend=:topleft)
p6b = plot(RH6, c6[:K] .* 39.10e6, label="K⁺", xlabel="RH", ylabel="µg/m³",
    title="(b) Potassium")
p6c = plot(RH6, c6[:NH4] .* 18.04e6, label="NH₄⁺", xlabel="RH", ylabel="µg/m³",
    title="(c) Ammonium")
p6d = plot(RH6, c6[:NO3] .* 62.00e6, label="NO₃⁻", xlabel="RH", ylabel="µg/m³",
    title="(d) Nitrate")
plot(p6a, p6b, p6c, p6d, layout=(2,2), size=(800,600),
    plot_title="Figure 6: Urban (Case 3, Sulfate Rich)")
Example block output

Figure 7: Marine Aerosol — Sulfate Poor, Crustal Rich (Case 12, Table 8)

Aerosol composition vs. RH for a marine case (R₁ > 2, R₂ > 2): Na=3.0, H₂SO₄=3.0, NH₃=0.020, HNO₃=2.0, HCl=3.121, Ca=0.36, K=0.45, Mg=0.13 µg/m³. Panels show (a) aerosol water, (b) K⁺, (c) Na⁺ (metastable — no NaCl solid), and (d) Mg²⁺. The original Fig. 7(c) shows NaCl(s), which is zero in the metastable state.

# Re-create system for this block
sys = IsorropiaEquilibrium()
compiled = mtkcompile(sys)

# Helper function
function solve_iso2_sweep(compiled, Na, SO4, NH3, NO3, Cl, Ca, K, Mg;
                          RH_range=0.95:-0.01:0.30)
    RH_ok, W_vals = Float64[], Float64[]
    c = Dict(s => Float64[] for s in [:Na,:NH4,:SO4,:HSO4,:NO3,:Cl,:Ca,:K,:Mg,:H,:OH])
    g = Dict(s => Float64[] for s in [:NH3,:HNO3,:HCl])
    prev = nothing
    for rh in RH_range
        params = [compiled.RH => rh, compiled.W_Na_total => Na,
                  compiled.W_SO4_total => SO4, compiled.W_NH3_total => NH3,
                  compiled.W_NO3_total => NO3, compiled.W_Cl_total => Cl,
                  compiled.W_Ca_total => Ca, compiled.W_K_total => K,
                  compiled.W_Mg_total => Mg]
        if prev !== nothing
            guesses = [compiled.c_SO4 => prev[:SO4], compiled.c_HSO4 => prev[:HSO4],
                       compiled.c_NH4 => prev[:NH4], compiled.c_NO3 => prev[:NO3],
                       compiled.c_Cl => prev[:Cl], compiled.c_H => prev[:H],
                       compiled.c_OH => prev[:OH], compiled.I_s => prev[:I],
                       compiled.W_w => prev[:W]]
        else
            R1 = SO4 > 0 ? (NH3 + Na + 2*Ca + K + 2*Mg) / SO4 : 100.0
            if R1 < 2
                guesses = [compiled.c_SO4 => max(0.5*SO4, 1e-20),
                           compiled.c_HSO4 => max(0.5*SO4, 1e-20),
                           compiled.c_NH4 => max(0.99*NH3, 1e-20),
                           compiled.c_NO3 => 1e-10, compiled.c_Cl => 1e-20,
                           compiled.c_H => 1e-7, compiled.c_OH => 1e-18,
                           compiled.I_s => 15.0, compiled.W_w => 1e-7,
                           compiled.g_NH3 => 1e-10, compiled.g_HNO3 => max(0.99*NO3, 1e-20)]
            else
                guesses = [compiled.c_SO4 => max(0.85*SO4, 1e-20),
                           compiled.c_HSO4 => max(0.15*SO4, 1e-20),
                           compiled.c_NH4 => max(min(NH3, 2*SO4)*0.8, 1e-20),
                           compiled.c_NO3 => max(0.3*NO3, 1e-20),
                           compiled.c_Cl => max(0.3*Cl, 1e-20),
                           compiled.c_H => 1e-10, compiled.c_OH => 1e-13,
                           compiled.I_s => 10.0]
            end
        end
        op = vcat(params, guesses)
        op_keys = Set(first.(op))
        for u in unknowns(compiled)
            if !(u in op_keys)
                g_val = ModelingToolkit.getguess(u)
                if g_val !== nothing
                    push!(op, u => Float64(g_val))
                end
            end
        end
        prob = NonlinearProblem(compiled, op)
        sol = solve(prob, RobustMultiNewton(); maxiters=10000)
        if sol.retcode == SciMLBase.ReturnCode.Success
            push!(RH_ok, rh); push!(W_vals, sol[compiled.W_w])
            for s in [:Na,:NH4,:SO4,:HSO4,:NO3,:Cl,:Ca,:K,:Mg,:H,:OH]
                push!(c[s], sol[getproperty(compiled, Symbol(:c_, s))])
            end
            push!(g[:NH3], sol[compiled.g_NH3])
            push!(g[:HNO3], sol[compiled.g_HNO3])
            push!(g[:HCl], sol[compiled.g_HCl])
            prev = Dict(:SO4=>sol[compiled.c_SO4], :HSO4=>sol[compiled.c_HSO4],
                        :NH4=>sol[compiled.c_NH4], :NO3=>sol[compiled.c_NO3],
                        :Cl=>sol[compiled.c_Cl], :H=>sol[compiled.c_H],
                        :OH=>sol[compiled.c_OH], :I=>sol[compiled.I_s],
                        :W=>sol[compiled.W_w])
        end
    end
    reverse!(RH_ok); reverse!(W_vals)
    for v in values(c); reverse!(v); end
    for v in values(g); reverse!(v); end
    return RH_ok, W_vals, c, g
end

# Case 12 (Marine) from Table 8
RH7, W7, c7, g7 = solve_iso2_sweep(compiled,
    3.0e-6/22.99, 3.0e-6/98.08, 0.020e-6/17.03, 2.0e-6/63.01, 3.121e-6/36.46,
    0.36e-6/40.08, 0.45e-6/39.10, 0.13e-6/24.31)

p7a = plot(RH7, W7 .* 1e9, label="Metastable", xlabel="RH", ylabel="µg/m³",
    title="(a) Aerosol Water", legend=:topleft)
p7b = plot(RH7, c7[:K] .* 39.10e6, label="K⁺", xlabel="RH", ylabel="µg/m³",
    title="(b) Potassium")
p7c = plot(RH7, c7[:Na] .* 22.99e6, label="Na⁺ (aq)", xlabel="RH", ylabel="µg/m³",
    title="(c) Na⁺ (no solids in metastable)")
p7d = plot(RH7, c7[:Mg] .* 24.31e6, label="Mg²⁺", xlabel="RH", ylabel="µg/m³",
    title="(d) Magnesium")
plot(p7a, p7b, p7c, p7d, layout=(2,2), size=(800,600),
    plot_title="Figure 7: Marine (Case 12, Sulfate Poor)")
Example block output

Figure 8: Non-urban Continental — Sulfate Poor (Case 5, Table 8)

Aerosol composition vs. RH for a non-urban continental case (R₁ > 2, R₂ < 2): Na=0.2, H₂SO₄=2.0, NH₃=8.0, HNO₃=12.0, HCl=0.2, Ca=0.12, K=0.18, Mg=0 µg/m³. Panels show (a) aerosol water, (b) NO₃⁻, and (c) NH₄⁺.

# Re-create system for this block
sys = IsorropiaEquilibrium()
compiled = mtkcompile(sys)

# Helper function
function solve_iso2_sweep(compiled, Na, SO4, NH3, NO3, Cl, Ca, K, Mg;
                          RH_range=0.95:-0.01:0.30)
    RH_ok, W_vals = Float64[], Float64[]
    c = Dict(s => Float64[] for s in [:Na,:NH4,:SO4,:HSO4,:NO3,:Cl,:Ca,:K,:Mg,:H,:OH])
    g = Dict(s => Float64[] for s in [:NH3,:HNO3,:HCl])
    prev = nothing
    for rh in RH_range
        params = [compiled.RH => rh, compiled.W_Na_total => Na,
                  compiled.W_SO4_total => SO4, compiled.W_NH3_total => NH3,
                  compiled.W_NO3_total => NO3, compiled.W_Cl_total => Cl,
                  compiled.W_Ca_total => Ca, compiled.W_K_total => K,
                  compiled.W_Mg_total => Mg]
        if prev !== nothing
            guesses = [compiled.c_SO4 => prev[:SO4], compiled.c_HSO4 => prev[:HSO4],
                       compiled.c_NH4 => prev[:NH4], compiled.c_NO3 => prev[:NO3],
                       compiled.c_Cl => prev[:Cl], compiled.c_H => prev[:H],
                       compiled.c_OH => prev[:OH], compiled.I_s => prev[:I],
                       compiled.W_w => prev[:W]]
        else
            R1 = SO4 > 0 ? (NH3 + Na + 2*Ca + K + 2*Mg) / SO4 : 100.0
            if R1 < 2
                guesses = [compiled.c_SO4 => max(0.5*SO4, 1e-20),
                           compiled.c_HSO4 => max(0.5*SO4, 1e-20),
                           compiled.c_NH4 => max(0.99*NH3, 1e-20),
                           compiled.c_NO3 => 1e-10, compiled.c_Cl => 1e-20,
                           compiled.c_H => 1e-7, compiled.c_OH => 1e-18,
                           compiled.I_s => 15.0, compiled.W_w => 1e-7,
                           compiled.g_NH3 => 1e-10, compiled.g_HNO3 => max(0.99*NO3, 1e-20)]
            else
                guesses = [compiled.c_SO4 => max(0.85*SO4, 1e-20),
                           compiled.c_HSO4 => max(0.15*SO4, 1e-20),
                           compiled.c_NH4 => max(min(NH3, 2*SO4)*0.8, 1e-20),
                           compiled.c_NO3 => max(0.3*NO3, 1e-20),
                           compiled.c_Cl => max(0.3*Cl, 1e-20),
                           compiled.c_H => 1e-10, compiled.c_OH => 1e-13,
                           compiled.I_s => 10.0]
            end
        end
        op = vcat(params, guesses)
        op_keys = Set(first.(op))
        for u in unknowns(compiled)
            if !(u in op_keys)
                g_val = ModelingToolkit.getguess(u)
                if g_val !== nothing
                    push!(op, u => Float64(g_val))
                end
            end
        end
        prob = NonlinearProblem(compiled, op)
        sol = solve(prob, RobustMultiNewton(); maxiters=10000)
        if sol.retcode == SciMLBase.ReturnCode.Success
            push!(RH_ok, rh); push!(W_vals, sol[compiled.W_w])
            for s in [:Na,:NH4,:SO4,:HSO4,:NO3,:Cl,:Ca,:K,:Mg,:H,:OH]
                push!(c[s], sol[getproperty(compiled, Symbol(:c_, s))])
            end
            push!(g[:NH3], sol[compiled.g_NH3])
            push!(g[:HNO3], sol[compiled.g_HNO3])
            push!(g[:HCl], sol[compiled.g_HCl])
            prev = Dict(:SO4=>sol[compiled.c_SO4], :HSO4=>sol[compiled.c_HSO4],
                        :NH4=>sol[compiled.c_NH4], :NO3=>sol[compiled.c_NO3],
                        :Cl=>sol[compiled.c_Cl], :H=>sol[compiled.c_H],
                        :OH=>sol[compiled.c_OH], :I=>sol[compiled.I_s],
                        :W=>sol[compiled.W_w])
        end
    end
    reverse!(RH_ok); reverse!(W_vals)
    for v in values(c); reverse!(v); end
    for v in values(g); reverse!(v); end
    return RH_ok, W_vals, c, g
end

# Case 5 (Non-urban Continental) from Table 8
RH8, W8, c8, g8 = solve_iso2_sweep(compiled,
    0.2e-6/22.99, 2.0e-6/98.08, 8.0e-6/17.03, 12.0e-6/63.01, 0.2e-6/36.46,
    0.12e-6/40.08, 0.18e-6/39.10, 0.0)

p8a = plot(RH8, W8 .* 1e9, label="Metastable", xlabel="RH", ylabel="µg/m³",
    title="(a) Aerosol Water", legend=:topleft)
p8b = plot(RH8, c8[:NO3] .* 62.00e6, label="NO₃⁻", xlabel="RH", ylabel="µg/m³",
    title="(b) Nitrate")
p8c = plot(RH8, c8[:NH4] .* 18.04e6, label="NH₄⁺", xlabel="RH", ylabel="µg/m³",
    title="(c) Ammonium")
plot(p8a, p8b, p8c, layout=(1,3), size=(900,350),
    plot_title="Figure 8: Non-urban Continental (Case 5, Sulfate Poor)")
Example block output

Figure 9: Remote Continental — Near Neutral (Case 13, Table 8)

Aerosol composition vs. RH for a remote continental case (R₁ ≈ 2): Na=0, H₂SO₄=10.0, NH₃=4.25, HNO₃=0.145, HCl=0, Ca=0.08, K=0.09, Mg=0 µg/m³. Panels show (a) aerosol water and (b) K⁺. The metastable branch is shown; set stable=1 to compute the stable (solid-forming) branch.

# Re-create system for this block
sys = IsorropiaEquilibrium()
compiled = mtkcompile(sys)

# Helper function
function solve_iso2_sweep(compiled, Na, SO4, NH3, NO3, Cl, Ca, K, Mg;
                          RH_range=0.95:-0.01:0.30)
    RH_ok, W_vals = Float64[], Float64[]
    c = Dict(s => Float64[] for s in [:Na,:NH4,:SO4,:HSO4,:NO3,:Cl,:Ca,:K,:Mg,:H,:OH])
    g = Dict(s => Float64[] for s in [:NH3,:HNO3,:HCl])
    prev = nothing
    for rh in RH_range
        params = [compiled.RH => rh, compiled.W_Na_total => Na,
                  compiled.W_SO4_total => SO4, compiled.W_NH3_total => NH3,
                  compiled.W_NO3_total => NO3, compiled.W_Cl_total => Cl,
                  compiled.W_Ca_total => Ca, compiled.W_K_total => K,
                  compiled.W_Mg_total => Mg]
        if prev !== nothing
            guesses = [compiled.c_SO4 => prev[:SO4], compiled.c_HSO4 => prev[:HSO4],
                       compiled.c_NH4 => prev[:NH4], compiled.c_NO3 => prev[:NO3],
                       compiled.c_Cl => prev[:Cl], compiled.c_H => prev[:H],
                       compiled.c_OH => prev[:OH], compiled.I_s => prev[:I],
                       compiled.W_w => prev[:W]]
        else
            R1 = SO4 > 0 ? (NH3 + Na + 2*Ca + K + 2*Mg) / SO4 : 100.0
            if R1 < 2
                guesses = [compiled.c_SO4 => max(0.5*SO4, 1e-20),
                           compiled.c_HSO4 => max(0.5*SO4, 1e-20),
                           compiled.c_NH4 => max(0.99*NH3, 1e-20),
                           compiled.c_NO3 => 1e-10, compiled.c_Cl => 1e-20,
                           compiled.c_H => 1e-7, compiled.c_OH => 1e-18,
                           compiled.I_s => 15.0, compiled.W_w => 1e-7,
                           compiled.g_NH3 => 1e-10, compiled.g_HNO3 => max(0.99*NO3, 1e-20)]
            else
                guesses = [compiled.c_SO4 => max(0.85*SO4, 1e-20),
                           compiled.c_HSO4 => max(0.15*SO4, 1e-20),
                           compiled.c_NH4 => max(min(NH3, 2*SO4)*0.8, 1e-20),
                           compiled.c_NO3 => max(0.3*NO3, 1e-20),
                           compiled.c_Cl => max(0.3*Cl, 1e-20),
                           compiled.c_H => 1e-10, compiled.c_OH => 1e-13,
                           compiled.I_s => 10.0]
            end
        end
        op = vcat(params, guesses)
        op_keys = Set(first.(op))
        for u in unknowns(compiled)
            if !(u in op_keys)
                g_val = ModelingToolkit.getguess(u)
                if g_val !== nothing
                    push!(op, u => Float64(g_val))
                end
            end
        end
        prob = NonlinearProblem(compiled, op)
        sol = solve(prob, RobustMultiNewton(); maxiters=10000)
        if sol.retcode == SciMLBase.ReturnCode.Success
            push!(RH_ok, rh); push!(W_vals, sol[compiled.W_w])
            for s in [:Na,:NH4,:SO4,:HSO4,:NO3,:Cl,:Ca,:K,:Mg,:H,:OH]
                push!(c[s], sol[getproperty(compiled, Symbol(:c_, s))])
            end
            push!(g[:NH3], sol[compiled.g_NH3])
            push!(g[:HNO3], sol[compiled.g_HNO3])
            push!(g[:HCl], sol[compiled.g_HCl])
            prev = Dict(:SO4=>sol[compiled.c_SO4], :HSO4=>sol[compiled.c_HSO4],
                        :NH4=>sol[compiled.c_NH4], :NO3=>sol[compiled.c_NO3],
                        :Cl=>sol[compiled.c_Cl], :H=>sol[compiled.c_H],
                        :OH=>sol[compiled.c_OH], :I=>sol[compiled.I_s],
                        :W=>sol[compiled.W_w])
        end
    end
    reverse!(RH_ok); reverse!(W_vals)
    for v in values(c); reverse!(v); end
    for v in values(g); reverse!(v); end
    return RH_ok, W_vals, c, g
end

# Case 13 (Remote Continental) from Table 8
RH9, W9, c9, g9 = solve_iso2_sweep(compiled,
    0.0, 10.0e-6/98.08, 4.25e-6/17.03, 0.145e-6/63.01, 0.0,
    0.08e-6/40.08, 0.09e-6/39.10, 0.0)

p9a = plot(RH9, W9 .* 1e9, label="Metastable", xlabel="RH", ylabel="µg/m³",
    title="(a) Aerosol Water", legend=:topleft)
p9b = plot(RH9, c9[:K] .* 39.10e6, label="K⁺", xlabel="RH", ylabel="µg/m³",
    title="(b) Potassium")
plot(p9a, p9b, layout=(1,2), size=(700,350),
    plot_title="Figure 9: Remote Continental (Case 13, R₁ ≈ 2)")
Example block output