@@ -106,6 +106,8 @@ function update_surface_temperature!(pos, model)
106
106
absorbed_luminosity = (1 - daisy. albedo) * model. solar_luminosity
107
107
end
108
108
# # Here we changed the rule to not use `log` because it isn't defined for negative numbers!
109
+ # # We also need to somehow extract a number from the uncertain number, because boolean
110
+ # # comparisons are not defined on uncertain numbers.
109
111
local_heating = meanval (absorbed_luminosity) > 0 ? 72 * (2 absorbed_luminosity - 1.8 ) + 80 : 80
110
112
model. temperature[pos... ] = (model. temperature[pos... ] + local_heating) / 2
111
113
end
@@ -145,20 +147,21 @@ function daisyworld(;
145
147
ratio = 0.5 , temperature = fill (starting_temperature, griddims)
146
148
)
147
149
148
- model = StandardABM (Daisy, space; properties, rng, agent_step! = daisy_step!, model_step! = daisyworld_step!)
150
+ T = typeof (albedo_black)
151
+ model = StandardABM (Daisy{T}, space; properties, rng, agent_step! = daisy_step!, model_step! = daisyworld_step!)
149
152
150
153
# # populate the model with random white daisies
151
154
grid = collect (positions (model))
152
155
L = length (grid)
153
156
white_positions = sample (rng, grid, round (Int, init_white* L); replace = false )
154
157
for wp in white_positions
155
- add_agent! (wp, Daisy, model, :white , rand (abmrng (model), 0 : max_age), albedo_white)
158
+ add_agent! (wp, model, :white , rand (abmrng (model), 0 : max_age), albedo_white)
156
159
end
157
160
# # and black daisies
158
161
possible_black = setdiff (grid, white_positions)
159
162
black_positions = sample (rng, possible_black, Int (init_black* L); replace = false )
160
163
for bp in black_positions
161
- add_agent! (bp, Daisy, model, :black , rand (abmrng (model), 0 : max_age), albedo_black)
164
+ add_agent! (bp, model, :black , rand (abmrng (model), 0 : max_age), albedo_black)
162
165
end
163
166
164
167
for p in positions (model)
@@ -213,11 +216,11 @@ end
213
216
214
217
run_plot_daisyworld ()
215
218
216
- # Right, this looks great! As expected, there is no band plot showed in the temperature
219
+ # Right, this looks great! As expected, there is no band plot shown in the temperature
217
220
# axis as there is no uncertainty yet. Let's change that!
218
221
219
- # %%
220
- # ## Running Daisyworld without uncertainty
222
+ # %% #src
223
+ # ## Running Daisyworld with uncertainty
221
224
222
225
# All we have to do to enable uncertainty is change the daisy albedos and starting
223
226
# temperature into numbers with uncertainty. This is as simple as changing three keywords:
0 commit comments