예제 #1
0
        public void Run(Clock clock, IClimateCO2CycleState state, IDimensions dimensions)
        {
            var s = state;
            var t = clock.Current;

            if (clock.IsFirstTimestep)
            {
                s.co2decay1 = s.lifeco1;
                s.co2decay2 = Math.Exp(-1.0 / s.lifeco2);
                s.co2decay3 = Math.Exp(-1.0 / s.lifeco3);
                s.co2decay4 = Math.Exp(-1.0 / s.lifeco4);
                s.co2decay5 = Math.Exp(-1.0 / s.lifeco5);

                s.TerrCO2Stock[t] = s.TerrCO2Stock0;

                s.cbox1[t] = 283.53;
                s.cbox2[t] = 5.62;
                s.cbox3[t] = 6.29;
                s.cbox4[t] = 2.19;
                s.cbox5[t] = 0.15;
                s.acco2[t] = s.cbox1[t] + s.cbox2[t] + s.cbox3[t] + s.cbox4[t] + s.cbox5[t];
            }
            else
            {
                if (t == Timestep.FromYear(2011))
                {
                    s.tempIn2010 = s.temp[Timestep.FromYear(2010)];
                }

                if (t > Timestep.FromYear(2010))
                {
                    s.TerrestrialCO2[t] = (s.temp[t - 1] - s.tempIn2010) * s.TerrCO2Sens * s.TerrCO2Stock[t - 1] / s.TerrCO2Stock0;
                }
                else
                {
                    s.TerrestrialCO2[t] = 0;
                }

                s.TerrCO2Stock[t] = Math.Max(s.TerrCO2Stock[t - 1] - s.TerrestrialCO2[t], 0.0);

                s.globc[t] = s.mco2[t] + s.TerrestrialCO2[t];

                // Calculate CO2 concentrations
                s.cbox1[t] = s.cbox1[t - 1] * s.co2decay1 + 0.000471 * s.co2frac1 * (s.globc[t]);
                s.cbox2[t] = s.cbox2[t - 1] * s.co2decay2 + 0.000471 * s.co2frac2 * (s.globc[t]);
                s.cbox3[t] = s.cbox3[t - 1] * s.co2decay3 + 0.000471 * s.co2frac3 * (s.globc[t]);
                s.cbox4[t] = s.cbox4[t - 1] * s.co2decay4 + 0.000471 * s.co2frac4 * (s.globc[t]);
                s.cbox5[t] = s.cbox5[t - 1] * s.co2decay5 + 0.000471 * s.co2frac5 * (s.globc[t]);

                s.acco2[t] = s.cbox1[t] + s.cbox2[t] + s.cbox3[t] + s.cbox4[t] + s.cbox5[t];
            }
        }
예제 #2
0
        public void Run(Clock clock, IClimateCO2CycleState state, IDimensions dimensions)
        {
            var s = state;
            var t = clock.Current;

            if (clock.IsFirstTimestep)
            {
                s.co2decay1 = s.lifeco1;
                s.co2decay2 = Math.Exp(-1.0 / s.lifeco2);
                s.co2decay3 = Math.Exp(-1.0 / s.lifeco3);
                s.co2decay4 = Math.Exp(-1.0 / s.lifeco4);
                s.co2decay5 = Math.Exp(-1.0 / s.lifeco5);

                s.TerrCO2Stock[t] = s.TerrCO2Stock0;

                s.cbox1[t] = s.cbox10;
                s.cbox2[t] = s.cbox20;
                s.cbox3[t] = s.cbox30;
                s.cbox4[t] = s.cbox40;
                s.cbox5[t] = s.cbox50;
                s.acco2[t] = s.cbox1[t] + s.cbox2[t] + s.cbox3[t] + s.cbox4[t] + s.cbox5[t];
            }
            else
            {
                if (t == Timestep.FromYear(2011))
                {
                    s.tempIn2010 = s.temp[Timestep.FromYear(2010)];
                }

                if (t > Timestep.FromYear(2010))
                {

                    s.TerrestrialCO2[t] = (s.temp[t - 1] - s.tempIn2010) * s.TerrCO2Sens * s.TerrCO2Stock[t - 1] / s.TerrCO2Stock0;
                }
                else
                    s.TerrestrialCO2[t] = 0;

                s.TerrCO2Stock[t] = Math.Max(s.TerrCO2Stock[t - 1] - s.TerrestrialCO2[t], 0.0);

                s.globc[t] = s.mco2[t] + s.TerrestrialCO2[t];

                // Calculate CO2 concentrations
                s.cbox1[t] = s.cbox1[t - 1] * s.co2decay1 + 0.000471 * s.co2frac1 * (s.globc[t]);
                s.cbox2[t] = s.cbox2[t - 1] * s.co2decay2 + 0.000471 * s.co2frac2 * (s.globc[t]);
                s.cbox3[t] = s.cbox3[t - 1] * s.co2decay3 + 0.000471 * s.co2frac3 * (s.globc[t]);
                s.cbox4[t] = s.cbox4[t - 1] * s.co2decay4 + 0.000471 * s.co2frac4 * (s.globc[t]);
                s.cbox5[t] = s.cbox5[t - 1] * s.co2decay5 + 0.000471 * s.co2frac5 * (s.globc[t]);

                s.acco2[t] = s.cbox1[t] + s.cbox2[t] + s.cbox3[t] + s.cbox4[t] + s.cbox5[t];
            }
        }