The molecular network couples with all of the ion state solutions in some fashion. As a result, the entire level & population balance becomes a single coupled system.
This could be treated as a single large nonlinear system. However, the relative sparseness of the linearized matrices and the widely differing timescales of the active processes means that this problem would likely be numerically ill-conditioned. It seems better to proceed using an iterative scheme developed from the present coding, looking at the ladder solutions as effectively preconditioners.
The head of newmole (at r1599) now converges pdr_co_fully.in albeit slowly.
Seems like the best way forward is to generalize from the present scheme where separate lists are kept of
reactants, products, rate_species (the last being reactants including catalysts)
to one where the reactants and products are complete lists, with type codes:
and from there extend the scheme to account for charge-transfer (or more generally within-group) reactions separately.
Prior to the NewMole branch, variables were defined for most species and reactions. This made the code rigid and time consuming to maintain. Variables with names like ipMH2s or rhephhehp were typically used.
The NewMole branch provides access where necessary using text strings to index associative arrays. In general, it is better to avoid such accesses altogether. Using a loop-and-mask pattern will extend naturally when additional states are added. The groups of states which pass through a given mask can be cached if necessary for performance.