Overpopulation eats supplies: If enabled, colonist overpopulation will eat supplies to survive.

Supply_loss =
   0                ...if AllowEatingSupplies is off
   0                ...if ClimateLimitsPopulation is off
   0                ...if Colonists ≤ Max_colonists
   Trunc((Colonists - Max_colonists) / 4000) + 1
                    ...otherwise

If there are fewer supplies than needed, they'll all be used up with no negative consequences.

Climate Deaths: If enabled, colonists and natives over the population limit will die.

Colonist_clans_dying =
   0                ...if ClimateLimitsPopulation is off
   0                ...if Colonist_clans ≤ Eff_max_colonist_clans
   Min(Trunc(Colonist_clans * ClimateDeathRate / 100),
       Eff_max_colonist_clans - Colonist_clans)
                    ...otherwise

Native_clans_dying =
   0                ...if ClimateLimitsPopulation is off
   0                ...if planet is unowned
   0                ...if Native_clans ≤ Max_native_clans
   Min(Trunc(Native_clans * NativeClimateDeathRate / 100),
       Max_native_clans - Native_clans)
                    ...otherwise

► Note: If the population exceeds the absolute maximum of 250000 clans (25 million people), the excess clans will die and be reported as climate deaths, even if ClimateLimitsPopulation is off.

► Note: Eff_max_colonist_clans is computed after overpopulation-eats-supplies, so it uses the new (lower) supply amount. It uses the same formula as in the Growth step, but not the same value.

Structure Losses: Planetary buildings can be lost through riots or lack of maintenance (i.e. fewer colonists than needed to support them).

Mine_loss =
   Mine_decay + Riot_loss
Factory_loss =
   Factory_decay + Riot_loss
Defense_loss =
   Defense_decay
   ...where
      Riot_loss =
          10        ...if planet has colonists, and Colonist_happiness < 40
          10        ...if planet has natives, and Native_happiness < 40
          0         ...otherwise
      Mine_decay =
          Max(Min(Mines - Maximum_mines, Eff_StructureDecay), 0)
      Factory_decay =
          Max(Min(Factories - Maximum_factories, Eff_StructureDecay), 0)
      Defense_decay =
          Max(Min(Defense_posts - Maximum_defense_posts, Eff_StructureDecay), 0)
      Eff_StructureDecay =
          StructureDecayOnUnowned
                    ...if planet is unowned
          StructureDecayPerTurn[Planet_owner]
                    ...otherwise

Population loss through riots: Fighting colonists and/or natives will lead to loss of population. Even if just one population group fights, the other one will suffer as well.

Colonist_clans_dying =
   Ceil(Colonist_clans * (40 - Colonist_happiness) / 500)
                    ...if Colonist_happiness < 20
   Ceil(Colonist_clans * (40 - Native_happiness) / 2500)
                    ...if planet has natives, and Native_happiness < 20
   0                ...otherwise

Native_clans_dying =
   Ceil(Native_clans * (40 - Native_happiness) / 500)
                    ...if Native_happiness < 20
   Ceil(Native_clans * (40 - Colonist_happiness) / 2500)
                    ...if planet has colonists, and Colonist_happiness < 20
   0                ...otherwise

Population loss from amorphous natives: Amorphous natives eat colonists after all other losses.

Colonist_clans_eaten =
   0                ...if natives are not Amorphous
   5                ...if Native_happiness ≥ 70
   20               ...if Native_happiness ≥ 50
   40               ...otherwise

If the Amorphous natives eat all your colonists or more, you'll lose the planet.

This is a testing version.
It may be incomplete, and have more bugs (or features) than the public live version at planetscentral.com.