Leaf stomatal profit-max
leaf_stomatal_profit_max
def leaf_stomatal_profit_max(
physcon:PhysCon, atmos:Atmos, leaf:Leaf, # Must have: g0, g1_medlyn, minl_wp, a_psi.
flux:Flux
)->Flux: # With converged gs, An, Tleaf, psi_leaf, etc.
Stomatal conductance via Medlyn + profit-maximisation.
Algorithm:
- Sweep gs from g0 to gs_max (30 points).
- At each gs, compute the full leaf physics chain: boundary layer → energy balance → photosynthesis → water potential.
- Compute normalised GAIN = An/An_max and COST = vulnerability(ψ_leaf).
- PROFIT = GAIN - COST. Find the gs that maximises profit.
- Clamp to Medlyn gs (hydraulics can only reduce gs, never increase it).
- Recompute final fluxes at the optimal gs.