ciceroOslo / ciceroscm

Python version of the CICERO-SCM simple climate model/emulator
Apache License 2.0
17 stars 4 forks source link

inverse emissions calculation unstable with current parameters #137

Open benmsanderson opened 3 weeks ago

benmsanderson commented 3 weeks ago

Current implementation of inverse carbon calculation can fail due to negative CO2 concentrations generated in bisection algorithm.

convergence fails when the log is taken in the npp calculation: np.log(self.co2_hold["xCO2"] / 278.0)

(line 308, carbon_cycle_mod) Propose reducing the width of the initial window: from current

    min_guess = self.simplified_em_backward(co2_conc_now / 2, co2_conc_zero)
    max_guess = self.simplified_em_backward(co2_conc_now * 2, co2_conc_zero)

to the following: min_guess = self.simplified_em_backward(co2_conc_now / 1.2, co2_conc_zero) max_guess = self.simplified_em_backward(co2_conc_now * 1.2, co2_conc_zero)

This is still wide enough to accommodate vast annual +ve or -ve emissions, but seems in practise less likely to blow up.

Ideally, on the medium term to-do list, this should be a free parameter.

maritsandstad commented 2 weeks ago

The width of the guess should be a free parameter, that seems a bit weird, this is the most like random starting point for solution iteration, it being a free parameter seems strange...? Also, can we just require that the minimal guess be larger than zero? Did you encounter this from back-calculating with a very flat emissions profile?

benmsanderson commented 2 weeks ago

Yes - flat emissions profile (is this a divide by zero issue?). The problem with requiring that the minimal guess be larger than zero is that the algorithm is calculating the emissions, not the concentrations. The condition would need to be slightly more complex - that the lower bound on the emissions guess can’t be more than all the carbon in the atmosphere….

On 10 Jun 2024, at 09:44, Marit Sandstad @.***> wrote:

The width of the guess should be a free parameter, that seems a bit weird, this is the most like random starting point for solution iteration, it being a free parameter seems strange...? Also, can we just require that the minimal guess be larger than zero? Did you encounter this from back-calculating with a very flat emissions profile?

— Reply to this email directly, view it on GitHub https://github.com/ciceroOslo/ciceroscm/issues/137#issuecomment-2157571953, or unsubscribe https://github.com/notifications/unsubscribe-auth/AENSZZHDXOFTB2U6ZH3X2C3ZGVKNNAVCNFSM6AAAAABJBHFFQ2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNJXGU3TCOJVGM. You are receiving this because you authored the thread.

maritsandstad commented 2 weeks ago

Is there somewhere that you have your setup for this that I can have look at, maybe I can think about a slightly less ad hoc solution...