Ok @parthum I’ve got it! The solution is quick but my answer is long to give you some context as requested. Please don’t hesitate to continue this conversation if anything is unclear!
code:
using MimIDICE2010
using Mimi
m = MimiDICE2010.get_model()
set_dimension!(m, :time, 2000:10:2590)
# As an example I just pulled our defaults that are meant for 2005:10:2095 here, they might not make sense in this context of different years!
params = MimiDICE2010.dice2010_excel_parameters()
update_params!(m, params, update_timesteps = true)
run(m)
explanation:
At a high level, as you guessed, updating dimensions requires a bit more involved work than updating parameters because of the underlying structure of the model and the flow of allocation of space etc. (I won’t bore you with details unless you want them).
You are spot-on when you say the problem is that updating the time index does not automatically do all of the underlying changes you need, partially because it does not know if it has enough information to do this automatically in the way you want it to.
Your first lines are correct:
using MimIDICE2010
using Mimi
m = MimiDICE2010.get_model()
set_dimension!(m, :time, 2000:10:2590)
But now looking at the next step in the tutorial, you need to update any parameters with the :time
dimension so that
(1) the parameter dimensions match your new dimensions (not technically needed here because 2000:10:2590
is the same length as 2005:10:2595
but that’s not always the case (ie. if you had said det_dimension!(m, :time, 2000:10:2050
)
(2) explicitly tell the model you want to update underlying labels to match your new time steps
To do this we can do with the handy update_params
function that takes a model m
, a dictionary params
, and an (optional but in this case needed) flag update_timesteps
that forces the model to update its time labels.
In this case I’m just grabbing our default parameters since it’s the same length, but in practice you may have different values for these different years, or you might need to adjust the number of values etc. The function below is an internal one we use to read in our formatted Excel file of DICE parameters and produce a dictionary. If you’ve worked with DICE you may have seen that (fairly ugly) spreadsheet before.
params = MimiDICE2010.dice2010_excel_parameters()
Now we update the parameters and run the model!
update_params!(m, params, update_timesteps = true)
run(m)
If you are curious, params
in the console looks like this:
julia> params
Dict{Symbol,Any} with 56 entries:
:aisrate => 9.93664e-5
:S => [0.24554, 0.231036, 0.224214, 0.22125, 0.220242, 0.220209, 0.220649, 0.221267, 0.22195, 0.222638 … 0.229543, 0.229543, 0.229543, 0.22954…
:sigma => [0.144519, 0.121685, 0.103662, 0.0892681, 0.0776454, 0.0681652, 0.0603594, 0.0538759, 0.0484469, 0.0438664 … 0.0109233, 0.0108438, 0.010…
:forcoth => [0.83, 0.777, 0.724, 0.671, 0.618, 0.565, 0.512, 0.459, 0.406, 0.353 … 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3]
:mu0 => 1600.0
:therm0 => 0.1
:t2xco2 => 3.2
:b33 => 0.99925
:mat1 => 829.0
:cost1 => [0.0650336, 0.053423, 0.0444285, 0.0373729, 0.0317736, 0.0272818, 0.0236418, 0.0206644, 0.0182074, 0.0161633 … 0.00265948, 0.00263037, 0…
:gis0 => 0.0
:elasmu => 1.5
:c4 => 0.05
:b22 => 0.94796
:c1 => 0.208
:b12 => 0.12
:b32 => 0.00075
:tatm0 => 0.83
:etree => [1.6, 1.28, 1.024, 0.8192, 0.65536, 0.524288, 0.41943, 0.335544, 0.268435, 0.214748 … 2.2836e-5, 1.82688e-5, 1.4615e-5, 1.1692e-5, 9.353…
:ml0 => 10010.0
⋮ => ⋮