Skip to content

Proposal to fix catalyst-layer water storage and absorption/desorption basis - #8

Merged
gassraphael merged 7 commits into
gassraphael:model_devfrom
BjoernRingeisen:LAF_physical_baseline
Oct 1, 2026
Merged

gassraphael merged 7 commits into
gassraphael:model_devfrom
BjoernRingeisen:LAF_physical_baseline

Conversation

@PascalKargl

Copy link
Copy Markdown
Contributor

This PR collects a set of focused corrections and clarifications for the catalyst-layer ionomer-water balance.

The main change is that the ACL/CCL lambda storage basis and the corresponding water absorption/desorption source terms are now consistently based on the dry ionomer fixed-site inventory in the catalyst layers, instead of using the swollen ionomer volume as the effective storage basis.
This aligns the implementation with the definition of lambda as water per fixed sulfonic-acid site and avoids coupling the storage capacity itself to the current swollen ionomer volume.

The PR also includes documentation-only follow-up commits that clarify the units of J_lambda and the meaning of the CL water absorption/desorption terms and associated heat source/sink. These comments are intended to make the existing model intent easier to review without changing numerical behavior.

The detailed derivations and per-change rationale are documented in the individual commits.

Larger related topics, especially CL dissolved-water transport coefficients, EOD/back-diffusion and porosity, may be handled separately afterwards.

This change corrects the storage basis used for the dynamic water-content states `lambda_acl` and `lambda_ccl`.

In the source code, the catalyst-layer lambda balances are assembled from the molar source and flux terms

    rhs_lambda_acl = -J_lambda.acl_mem / pp.Hacl
                     + S_abs.v_acl + S_abs.l_acl + Sp.acl

    rhs_lambda_ccl =  J_lambda.mem_ccl / pp.Hccl
                     + S_abs.v_ccl + S_abs.l_ccl + Sp.ccl

with `rhs_lambda_acl` and `rhs_lambda_ccl` in mol_H2O m_CL^-3 s^-1. The state variables `lambda_acl` and `lambda_ccl` are dimensionless water contents, defined as mol_H2O per mol fixed sulfonic-acid sites of the dry ionomer.
Therefore, these source balances must be divided by a fixed-site storage capacity in mol_sites m_CL^-3 per lambda unit.

The previous implementation used the current swollen ionomer volume fraction as the storage basis:

    d_lambda_acl_dt =
        pp.M_eq / (pp.rho_mem * epsilon_mc(:acl, lambda_acl, T_acl, pp.Hacl, pp))
        * rhs_lambda_acl

    d_lambda_ccl_dt =
        pp.M_eq / (pp.rho_mem * epsilon_mc(:ccl, lambda_ccl, T_ccl, pp.Hccl, pp))
        * rhs_lambda_ccl

Dimensionally, this forms a molar capacity because

    pp.rho_mem
        [kg_dry_ionomer m_dry_ionomer^-3]

    epsilon_mc(...)
        [m_swollen_ionomer^3 m_CL^-3]

    pp.M_eq
        [kg_dry_ionomer mol_sites^-1]

so that

    pp.rho_mem * epsilon_mc(...) / pp.M_eq
        [mol_sites m_CL^-3]

The dimensional unit is therefore plausible, but the physical reference volume is wrong. `epsilon_mc(...)` includes the current swollen ionomer volume and therefore changes with `lambda_acl` or `lambda_ccl`. This makes the effective number of fixed sites depend on the current water uptake.
That is not consistent with the definition of lambda, because swelling changes occupied volume, porosity and effective transport properties, but it does not create or remove fixed sulfonic-acid sites.

The corrected implementation derives the storage basis from the dry ionomer mass contained in the catalyst layer.
The new helper

    cl_dry_ionomer_storage_capacity(element, Hcl, pp)

returns

    IC * epsilon_carb(element, Hcl, pp) * rho_carb / pp.M_eq

using `pp.IC_acl` for `element == :acl` and `pp.IC_ccl` for `element == :ccl`.

The quantities have the following reference bases:

    pp.IC_acl, pp.IC_ccl
        [kg_dry_ionomer kg_carbon^-1]

    epsilon_carb(element, Hcl, pp)
        [m_carbon^3 m_CL^-3]

    rho_carb
        [kg_carbon m_carbon^-3]

    pp.M_eq
        [kg_dry_ionomer mol_sites^-1]

Thus,

    IC * epsilon_carb(element, Hcl, pp) * rho_carb
        [kg_dry_ionomer m_CL^-3]

and

    IC * epsilon_carb(element, Hcl, pp) * rho_carb / pp.M_eq
        [mol_sites m_CL^-3].

The ACL and CCL lambda derivatives now use this dry fixed-site capacity:

    C_fix_acl = cl_dry_ionomer_storage_capacity(:acl, pp.Hacl, pp)
    C_fix_ccl = cl_dry_ionomer_storage_capacity(:ccl, pp.Hccl, pp)

    d_lambda_acl_dt = rhs_lambda_acl / C_fix_acl
    d_lambda_ccl_dt = rhs_lambda_ccl / C_fix_ccl

The membrane balance is intentionally left unchanged:

    d_lambda_mem_dt =
        pp.M_eq / pp.rho_mem * (J_lambda.acl_mem - J_lambda.mem_ccl) / pp.Hmem

because the membrane storage basis remains `pp.rho_mem / pp.M_eq`
[mol_sites m_membrane^-3].

This change does not alter the swelling model, porosity model, effective transport coefficients, sorption source terms or parameter values.
It only corrects the reference basis used to convert the ACL/CCL molar water balances into the dynamic states `lambda_acl` and `lambda_ccl`.
This change makes the ACL and CCL water sorption source terms use the same dry ionomer fixed-site storage basis as the dynamic `lambda_acl` and `lambda_ccl` balances.

Previously, the vapor and liquid sorption sources in the ACL and CCL were scaled with `rho_mem / M_eq`. This quantity is the fixed-site concentration of the pure dry membrane/ionomer material, with the reference volume being the volume of the dense ionomer phase itself:

rho_mem [kg dry ionomer m_ionomer^-3]
/ M_eq [kg dry ionomer mol fixed sites^-1]
= mol fixed sites m_ionomer^-3

However, `Sv_abs_acl`, `Sl_abs_acl`, `Sv_abs_ccl`, and `Sl_abs_ccl` are consumed as catalyst-layer volumetric source terms. Their reference volume must therefore be the total catalyst-layer volume, not the volume of the pure ionomer phase. Using `rho_mem / M_eq` directly in these CL source terms implicitly treated the whole catalyst-layer control volume as if it were pure ionomer/membrane material and ignored the catalyst-layer composition.

The corrected formulation uses the dry ionomer fixed-site inventory per catalyst-layer volume:

C_fix_CL = IC * epsilon_carb * rho_carb / M_eq

with

IC [kg dry ionomer kg carbon^-1]
* epsilon_carb [m_carbon^3 m_CL^-3]
* rho_carb [kg carbon m_carbon^-3]
/ M_eq [kg dry ionomer mol fixed sites^-1]
= mol fixed sites m_CL^-3

This is the correct storage basis for `lambda_acl` and `lambda_ccl`, because these water contents are defined per fixed sulfonic-acid site of the dry ionomer, while their balances are written per catalyst-layer control volume.

The resulting sorption source terms are then dimensionally and physically consistent:

gamma_sorp [s^-1]
* C_fix_CL [mol fixed sites m_CL^-3]
* (lambda_eq - lambda_CL) [mol H2O mol fixed sites^-1]
= mol H2O m_CL^-3 s^-1

This matches the `MEASorptionSources` interface and the catalyst-layer water-content balances.

To keep this storage basis consistent between the differential equations and the source-term calculation, this change reuses the helper `cl_dry_ionomer_storage_capacity(element, Hcl, pp)`. The helper centralizes the ACL/CCL-specific conversion from catalyst-layer composition to dry ionomer fixed-site capacity. It selects `IC_acl` or `IC_ccl` depending on the catalyst layer and combines it with the corresponding carbon volume fraction `epsilon_carb(...)`, `rho_carb`, and `M_eq`.

This change corrects the reference volume used to convert catalyst-layer ionomer water-content differences into catalyst-layer volumetric sorption source terms.
This change corrects the documented unit of `J_lambda` in the MEA dissolved-water balance from kg m^-2 s^-1 to mol m^-2 s^-1.

The implementation already treats `J_lambda` as a molar dissolved-water inter-layer flux. In the lambda balance, `J_lambda / H` is added directly to the molar catalyst-layer source terms `S_abs` and `Sp`, which are expressed in mol m^-3 s^-1. The `MEADissolvedWaterFlux` type is also documented as using mol m^-2 s^-1.

Git history indicates that the former Python implementation and the first Julia conversion documented this quantity as mol m^-2 s^-1. The kg-based unit appears to have been introduced later during the refactor that added per-physics derivative structures, likely while documenting nearby liquid-water fluxes, which are correctly mass-based.

Only the docstring / documentation is changed; the model equations and numerical behavior are unchanged.
This change clarifies comments and docstrings for the catalyst layer water uptake terms without changing the model equations.

The affected quantities describe water exchange between the catalyst layer ionomer phase (dissolved) and the catalyst layer pores (vapor and liquid).
Their sign can represent both directions: positive values hydrate the CL ionomer, while negative values dehydrate it. The previous wording often described these terms only as absorption, or as transport from the CL to the membrane, which was ambiguous because the implemented source terms are used directly in the ACL/CCL ionomer water balances; and there was no explicit differentiation in the wording between membrane material (ionomer) and membrane layer (PEM).

The updated documentation therefore describes these terms as absorption/desorption in the CL ionomer and clarifies that the associated heat term can act as a source or sink.
Furthermore, the explicit wording of absorption keeps the terminology separate from O2 adsorption on Pt sites, which is a different surface-related sorption model mechanism.

No numerical behavior is changed.
Update `cl_dry_ionomer_storage_capacity` so that the catalyst-layer fixed-site storage capacity is calculated directly from the dry Pt/carbon loading parameters:

    L_carb = L_Pt * (1 - wt_Pt) / wt_Pt
    C_fix = IC * L_carb / (Hcl * M_eq)

instead of deriving it through `epsilon_carb`.

For physically valid parameter sets where `epsilon_carb` is equal to the raw carbon volume fraction, both formulations are algebraically equivalent.
However, `epsilon_carb` may be clamped to keep geometric volume fractions in a numerically admissible range. That behavior is appropriate for geometric or transport-related volume-fraction calculations, but it should not silently modify a conserved dry ionomer fixed-site inventory.

This distinction became behaviorally relevant after merging the upstream changes that introduced clamping in `epsilon_carb`. The helper introduced in this PR originally reused `epsilon_carb` while that clamping was not part of the local change context. After the merge, the fixed-site capacity would have inherited the possible clamping and could therefore deviate from the dry material inventory specified by `L_Pt`, `wt_Pt`, `IC`, `Hcl`, and `M_eq`.

This commit intentionally does not add a catalyst layer geometry plausibility check.
Such a check could be added separately to detect inconsistent parameter sets, for example when the dry solid volume fractions exceed the available catalyst layer volume.
@gassraphael
gassraphael changed the base branch from main to model_dev October 1, 2026 09:57
@gassraphael
gassraphael merged commit 7a59394 into gassraphael:model_dev Oct 1, 2026
1 check passed
@gassraphael

gassraphael commented Oct 1, 2026 •

Copy link
Copy Markdown
Owner

Thank you for your proposal, I'm accepting it.

However, I'm merging it into a new branch called "model_dev". This proposal is more of a model improvement than a simple bug fix. For another collaboration, I need AlphaPEM 2.0 ready as soon as possible — we're nearly there. I prefer keeping your changes in a separate branch that could later become the basis for AlphaPEM 2.1 or 2.2.

Once AlphaPEM 2.0 is released, I'll ensure the main branch remains clean and ready for any user at any time. It should also always be calibrated for at least one dataset. This means that all future development should happen in separate branches to avoid disrupting users.

I will continue to contribute to model development, but we can jointly decide when changes are ready for a new AlphaPEM release, such as 2.1. At minimum, one complete calibration on a dataset should be performed to ensure results match or exceed those of the previous version.

Additionally, if you create new files or folders to organize new sub-models or functionality in the future, I'll grant you administrative access to those sections. This will streamline your development workflow and allow you to maintain the specific components you build.

@PascalKargl

Copy link
Copy Markdown
Contributor Author

Thank you, I think this is a very good approach.

Keeping the main branch fully functional, calibrated, and ready for users at all times makes a lot of sense to me. I also agree that model-development changes like these are better kept in a dedicated development branch until they have been sufficiently verified and are ready for a future release.

Furthermore, the latest changes introduced by this and subsequent pull requests will lead to a shift in the water balance, which may, e.g., cause some local inventories to drift into negative values or result in positive evaporation rates from dry pores.
This must first be addressed on a physical level before publishing it as a ready-to-use version.

Thank you as well for taking care of the integration of the changes into the overall project structure.

@gassraphael

Copy link
Copy Markdown
Owner

You're welcome, thank you for participating on the improvement of AlphaPEM. Your propositions are relevant and clever, I'm very happy with them ! If you have good ideas for the architecture of AlphaPEM, on top of model and documentation improvements, you can also propose them.

If you encounter such non-physical results, you may have to use the safe_helpers to restrict some equations. One efficient way to know if the program is robust enough is to launch a calibration program (with a small population) which would do calculation for very different parameters. The solver should run for all of them, and if not there is work to do to improve the robustness. I know that there are still some issues for 1D+1D which do not occur in 1D, which kills 10-15% of the experiments probably because one safe_helper should be added somewhere, but I will fix this later on.

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

Successfully merging this pull request may close these issues.

2 participants