Leaf stomatal profit-max


source

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:

  1. Sweep gs from g0 to gs_max (30 points).
  2. At each gs, compute the full leaf physics chain: boundary layer → energy balance → photosynthesis → water potential.
  3. Compute normalised GAIN = An/An_max and COST = vulnerability(ψ_leaf).
  4. PROFIT = GAIN - COST. Find the gs that maximises profit.
  5. Clamp to Medlyn gs (hydraulics can only reduce gs, never increase it).
  6. Recompute final fluxes at the optimal gs.

Example leaf_stomatal_profit_max()