Skip to content

Commit 120d30c

Browse files
committed
Fixes benchmarks
1 parent 1256b0c commit 120d30c

7 files changed

Lines changed: 43 additions & 55 deletions

File tree

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "PlantSimEngine"
22
uuid = "9a576370-710b-4269-adf9-4f603a9c6423"
3-
authors = ["Rémi Vezy <VEZY@users.noreply.github.com> and contributors"]
43
version = "0.13.2"
4+
authors = ["Rémi Vezy <VEZY@users.noreply.github.com> and contributors"]
55

66
[deps]
77
AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"

benchmark/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ XPalm = "6b523e1e-d512-416c-8e51-a8fbef0064e7"
1414
[sources]
1515
PlantSimEngine = {path = ".."}
1616
XPalm = {rev = "PSe-with-multirate", url = "https://github.com/PalmStudio/XPalm.jl"}
17-
PlantBiophysics = {rev = "master", url = "https://github.com/VEZY/PlantBiophysics.jl"}
17+
PlantBiophysics = {rev = "update-plantsimengine", url = "https://github.com/VEZY/PlantBiophysics.jl"}

benchmark/test-multirate-buffer-benchmark.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ function benchmark_multirate_status_tracked_run(mtg, mapping, meteo, tracked, ns
8080
meteo,
8181
nsteps=nsteps,
8282
check=true,
83-
multirate=true,
8483
executor=SequentialEx(),
8584
tracked_outputs=tracked
8685
)
@@ -93,7 +92,6 @@ function benchmark_multirate_output_request_run(mtg, mapping, meteo, reqs, track
9392
meteo,
9493
nsteps=nsteps,
9594
check=true,
96-
multirate=true,
9795
executor=SequentialEx(),
9896
tracked_outputs=reqs
9997
)

benchmark/test-xpalm.jl

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,22 @@ function xpalm_default_param_create()
1818
#meteo.duration = [Dates.Day(i[1:1]) for i in meteo.duration]
1919
m = Weather(meteo)
2020

21-
out_vars = Dict{String,Any}(
22-
"Scene" => (:lai,),
23-
# "Scene" => (:LAI, :scene_leaf_area, :aPPFD, :TEff),
24-
# "Plant" => (:plant_age, :ftsw, :newPhytomerEmergence, :aPPFD, :plant_leaf_area, :carbon_assimilation, :carbon_offer_after_rm, :Rm, :TT_since_init, :TEff, :phytomer_count, :newPhytomerEmergence),
25-
"Leaf" => (:Rm, :potential_area, :TT_since_init, :TEff, :biomass, :carbon_demand, :carbon_allocation,),
26-
# "Leaf" => (:Rm, :potential_area),
27-
# "Internode" => (:Rm, :carbon_allocation, :carbon_demand),
28-
"Male" => (:Rm,),
29-
# "Female" => (:biomass,),
30-
# "Soil" => (:TEff, :ftsw, :root_depth),
21+
out_vars = Dict{Symbol,Any}(
22+
:Scene => (:lai,),
23+
# :Scene => (:LAI, :scene_leaf_area, :aPPFD, :TEff),
24+
# :Plant => (:plant_age, :ftsw, :newPhytomerEmergence, :aPPFD, :plant_leaf_area, :carbon_assimilation, :carbon_offer_after_rm, :Rm, :TT_since_init, :TEff, :phytomer_count, :newPhytomerEmergence),
25+
:Leaf => (:Rm, :potential_area, :TT_since_init, :TEff, :biomass, :carbon_demand, :carbon_allocation,),
26+
# :Leaf => (:Rm, :potential_area),
27+
# :Internode => (:Rm, :carbon_allocation, :carbon_demand),
28+
:Male => (:Rm,),
29+
# :Female => (:biomass,),
30+
# :Soil => (:TEff, :ftsw, :root_depth),
3131
)
3232

3333
# Example 1: Run the model with the default parameters (but output as a DataFrame):
3434
palm = XPalm.Palm(initiation_age=0, parameters=XPalm.default_parameters())
3535
models = XPalm.model_mapping(palm)
36-
return palm, models, out_vars, meteo
36+
return palm, models, out_vars, m
3737
end
3838

3939
function xpalm_default_param_run(palm, models, out_vars, meteo)

src/mtg/mapping/mapping.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,9 +248,9 @@ end
248248
function _show_model_mapping_plain(io::IO, mapping::ModelMapping)
249249
info = mapping.info
250250
println(io, "ModelMapping")
251-
println(io, " Validated: ", info.validated, " (", info.is_valid ? "valid" : "invalid", ")")
252-
println(io, " Multirate: ", info.is_multirate)
253-
println(io, " Scales (", length(info.scales), "): ", join(info.scales, ", "))
251+
println(io, " validated: ", info.validated, " (", info.is_valid ? "valid" : "invalid", ")")
252+
println(io, " multirate: ", info.is_multirate)
253+
println(io, " scales (", length(info.scales), "): ", join(info.scales, ", "))
254254
for scale in info.scales
255255
print(io, " - ", scale, ": ", get(info.models_per_scale, scale, 0), " model(s)")
256256
processes = get(info.processes_per_scale, scale, Symbol[])

src/run.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -655,9 +655,10 @@ function run!(
655655
_validate_meteo_duration(meteo)
656656
timeline = _timeline_context(meteo)
657657
meteo_sampler = effective_multirate ? _prepare_meteo_sampler(meteo) : nothing
658-
runtime_clock_rows = effective_multirate ? _runtime_clock_rows(object, timeline, dep_graph) : NamedTuple[]
658+
runtime_clock_rows = _runtime_clock_rows(object, timeline, dep_graph)
659659
effective_executor = executor
660660
# st = status(object)
661+
_validate_meteo_derived_timestep_requirements!(runtime_clock_rows, timeline)
661662
if effective_multirate
662663
if executor != SequentialEx()
663664
@warn string(
@@ -667,7 +668,6 @@ function run!(
667668
) maxlog = 1
668669
effective_executor = SequentialEx()
669670
end
670-
_validate_meteo_derived_timestep_requirements!(runtime_clock_rows, timeline)
671671
_warn_if_no_model_runs_at_base_timestep(runtime_clock_rows, timeline)
672672
validate_canonical_publishers(object)
673673
prepare_output_requests!(object, tracked_outputs, timeline)

src/time/runtime/clocks.jl

Lines changed: 25 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -250,41 +250,41 @@ function _resolve_meteo_hint_clock(scale::Symbol, process::Symbol, model, timeli
250250
reason = nothing
251251

252252
if !isnothing(hint.fixed)
253-
desired_sec = _seconds_from_period(hint.fixed)
254-
if !isapprox(desired_sec, base_sec; atol=1.0e-9, rtol=0.0)
253+
required_sec = _seconds_from_period(hint.fixed)
254+
if !isapprox(required_sec, base_sec; atol=1.0e-9, rtol=0.0)
255255
reason = string(
256-
"`timestep_hint.required=", hint.fixed,
257-
"` differs from meteo base step ", _format_seconds_label(base_sec), "."
256+
"Meteo base step ",
257+
_format_seconds_label(base_sec),
258+
" is outside `timestep_hint.required=",
259+
hint.fixed,
260+
"` for `",
261+
scale,
262+
"/",
263+
process,
264+
"`."
258265
)
259266
end
260267
elseif !isnothing(hint.range)
261268
lo, hi = hint.range
262269
lo_sec = _seconds_from_period(lo)
263270
hi_sec = _seconds_from_period(hi)
264-
if base_sec < lo_sec
265-
desired_sec = lo_sec
266-
reason = string(
267-
"meteo base step ", _format_seconds_label(base_sec),
268-
" is finer than required lower bound ", lo,
269-
"; using ", lo, "."
270-
)
271-
elseif base_sec > hi_sec
272-
desired_sec = hi_sec
271+
if base_sec < lo_sec || base_sec > hi_sec
273272
reason = string(
274-
"meteo base step ", _format_seconds_label(base_sec),
275-
" is coarser than required upper bound ", hi,
276-
"; attempting ", hi, "."
273+
"Meteo base step ",
274+
_format_seconds_label(base_sec),
275+
" is outside `timestep_hint.required=(",
276+
lo,
277+
", ",
278+
hi,
279+
")` for `",
280+
scale,
281+
"/",
282+
process,
283+
"`."
277284
)
278285
end
279286
end
280287

281-
if desired_sec < base_sec
282-
reason = isnothing(reason) ?
283-
string("required timestep ", _format_seconds_label(desired_sec), " is shorter than meteo; using meteo base step.") :
284-
string(reason, " Runtime does not support sub-step execution; using meteo base step.")
285-
desired_sec = base_sec
286-
end
287-
288288
dt = desired_sec / base_sec
289289
return ClockSpec(dt, 0.0), reason
290290
end
@@ -400,19 +400,9 @@ function _validate_meteo_derived_timestep_requirements!(rows, timeline::Timeline
400400
row.source == :meteo_base_step || continue
401401

402402
if !isnothing(row.hint_reason)
403-
@warn string(
404-
"Adjusted runtime timestep for `",
405-
row.scale,
406-
"/",
407-
row.process,
408-
"` from meteo-derived default: ",
409-
row.hint_reason,
410-
" Effective timestep is ",
411-
_format_seconds_label(float(row.clock.dt) * timeline.base_step_seconds),
412-
"."
413-
) maxlog = 1
403+
error(row.hint_reason)
414404
end
415405
end
416406

417407
return nothing
418-
end
408+
end

0 commit comments

Comments
 (0)