To be able to edit code and run cells, you need to run the notebook yourself. Where would you like to run the notebook?

In the cloud (experimental)

Binder is a free, open source service that runs scientific notebooks in the cloud! It will take a while, usually 2-7 minutes to get a session.

On your computer

(Recommended if you want to store your changes.)

  1. Copy the notebook URL:
  2. Run Pluto

    (Also see: How to install Julia and Pluto)

  3. Paste URL in the Open box

Frontmatter

If you are publishing this notebook on the web, you can set the parameters below to provide HTML metadata. This is useful for search engines and social media.

Author 1
Error message

The package ClimateMARGO.jl could not load because it failed to initialize.

That's not nice! Things you could try:

  • Restart the notebook.
  • Try a different Julia version.
  • Contact the developers of ClimateMARGO.jl about this error.

You might find useful information in the package installation log:

👀 Reading hidden code
begin
import Pkg
Pkg.activate("/Users/fons/Documents/MargoAPI.jl/")
ENV["JULIA_MARGO_LOAD_PYPLOT"] = "no thank you"
import ClimateMARGO
using ClimateMARGO.Models
using ClimateMARGO.Optimization
using ClimateMARGO.Diagnostics
end
❔
  Activating new project at `/Users/fons/Documents/MargoAPI.jl`
---
👀 Reading hidden code
Enter cell code...
65.9 μs
12
👀 Reading hidden code
dt = 12
10.1 μs
Error message

Another cell defining ClimateMARGO contains errors.

C'est la vie !
begin
model_parameters = deepcopy(ClimateMARGO.IO.included_configurations["default"])::ClimateModelParameters
model_parameters.domain = Domain(Float64(dt), 2020.0, 2200.0)
model_parameters.economics.baseline_emissions = ramp_emissions(model_parameters.domain)
model_parameters.economics.extra_CO₂ = zeros(size(model_parameters.economics.baseline_emissions))
end
👀 Reading hidden code
---

Base.@kwdef mutable struct MRGA{T}
M::T
R::T
G::T
A::T
end
👀 Reading hidden code
44.6 ms
Error message

UndefVarError: ClimateModel not defined

model = ClimateModel(model_parameters)
👀 Reading hidden code
---
Error message

Another cell defining ClimateMARGO and model_results contains errors.

model_results(model)
👀 Reading hidden code
---
max_slope = Dict("mitigate"=>1. /40., "remove"=>1. /40., "geoeng"=>1. /80., "adapt"=> 0.)
👀 Reading hidden code
26.1 μs

Current syntax

👀 Reading hidden code
189 μs
enforce_maxslope! (generic function with 1 method)
function enforce_maxslope!(controls;
dt,
max_slope=Dict("mitigate"=>1. /40., "remove"=>1. /40., "geoeng"=>1. /80., "adapt"=> 0.)
)
controls.mitigate[1] = 0.0
controls.remove[1] = 0.0
controls.geoeng[1] = 0.0
# controls.adapt[1] = 0.0
for i in 2:length(controls.mitigate)
controls.mitigate[i] = clamp(
controls.mitigate[i],
controls.mitigate[i-1] - max_slope["mitigate"]*dt,
controls.mitigate[i-1] + max_slope["mitigate"]*dt
)
controls.remove[i] = clamp(
controls.remove[i],
controls.remove[i-1] - max_slope["remove"]*dt,
controls.remove[i-1] + max_slope["remove"]*dt
)
controls.geoeng[i] = clamp(
controls.geoeng[i],
controls.geoeng[i-1] - max_slope["geoeng"]*dt,
controls.geoeng[i-1] + max_slope["geoeng"]*dt
)
controls.adapt[i] = clamp(
controls.adapt[i],
controls.adapt[i-1] - max_slope["adapt"]*dt,
controls.adapt[i-1] + max_slope["adapt"]*dt
)
end
end
👀 Reading hidden code
4.2 ms
Error message

UndefVarError: t not defined

N = length(t(model))
👀 Reading hidden code
---
Error message

Another cell defining ClimateMARGO contains errors.

begin
model.controls.geoeng .= 0.5
enforce_maxslope!(model.controls; dt=dt)
model.controls
end
👀 Reading hidden code
---

Compact syntax

👀 Reading hidden code
166 μs
# function enforce_maxslope!(controls;
# max_slope=MRGA(1/40, 1/40, 1/80, 0)
# )
# for (tech, value) in controls
# value[1] = 0.0
# for i in 2:N
# value[i] = clamp(
# value[i],
# value[i-1] - max_slope[tech]*dt,
# value[i-1] + max_slope[tech]*dt
# )
# end
# end
# end
👀 Reading hidden code
10.2 μs
Error message

Another cell defining ClimateMARGO contains errors.

model.economics
👀 Reading hidden code
---
Error message

UndefVarError: ClimateModel not defined

Stack trace

Here is what happened, the most recent locations are first:

  1. model_results(model::ClimateModel) = Dict(    :controls => model.controls,

model_results(model::ClimateModel) = Dict(
:controls => model.controls,
:computed => Dict(
:temperatures => Dict(
:baseline => T_adapt(model),
:M => T_adapt(model; M=true),
:MR => T_adapt(model; M=true, R=true),
:MRG => T_adapt(model; M=true, R=true, G=true),
:MRGA => T_adapt(model; M=true, R=true, G=true, A=true),
),
:emissions => Dict(
:baseline => effective_emissions(model),
:M => effective_emissions(model; M=true),
:MRGA => effective_emissions(model; M=true, R=true),
),
:concentrations => Dict(
:baseline => c(model),
:M => c(model; M=true),
:MRGA => c(model; M=true, R=true),
),
:damages => Dict(
:baseline => costs_dict(damage(model; discounting=true), model),
:MRGA => costs_dict(damage(model; M=true, R=true, G=true, A=true, discounting=true), model),
),
:costs => Dict(
:M => costs_dict(cost(model; M=true, discounting=true), model),
:R => costs_dict(cost(model; R=true, discounting=true), model),
:G => costs_dict(cost(model; G=true, discounting=true), model),
:A => costs_dict(cost(model; A=true, discounting=true), model),
:MRGA => costs_dict(cost(model; M=true, R=true, G=true, A=true, discounting=true), model),
),
),
)
👀 Reading hidden code
---
costs_dict (generic function with 1 method)




function costs_dict(costs, model)
Dict(
:discounted => costs,
:total_discounted => sum(costs .* model.domain.dt),
)
end

👀 Reading hidden code
532 μs