Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Pop15 test for Julia1.9 #187

Merged
merged 3 commits into from
Apr 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/World3/population/common_pop/subsystems.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ function death_rate(; name, params=_params, inits=_inits, tables=_tables, ranges
@variables dr(t) pop(t)
@variables fpc(t) sopc(t) iopc(t) ppolx(t)
@variables ehspc(t) = inits[:hsapc] # Line 22 Appendix A
@variables cdr(t) le(t) lmf(t) hsapc(t) lmhs(t) lmhs1(t) lmhs2(t) fpu(t) cmi(t) lmc(t) lmp(t)
@variables fpu(t) = inits[:fpu]
@variables lmf(t) = inits[:lmf]
@variables cmi(t) = inits[:cmi]
@variables cdr(t) le(t) hsapc(t) lmhs(t) lmhs1(t) lmhs2(t) lmc(t) lmp(t)
Comment on lines +13 to +16
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doing this here makes the plots for pop15 work, but the other plots were working already with

 @variables cdr(t) le(t) lmf(t) hsapc(t) lmhs(t) lmhs1(t) lmhs2(t) fpu(t) cmi(t) lmc(t) lmp(t)

It is unclear why this is the case and we opened issue #188 to investigate it.


eqs = [
cdr ~ 1000.0 * dr / pop # Line 18 Appendix A
Expand Down
2 changes: 1 addition & 1 deletion src/World3/population/pop15/initialisations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ _inits = Dict{Symbol, Float64}(
:p1 => 5.3e7,
:p2 => 2.1e8,
:p3 => 2.2e8,
:p4 => 1.4e8,
:p4 => 1.8e8,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked: page 173, Appendix C of DGFW.

:p5 => 1.6e8,
:p6 => 1.5e8,
:p7 => 1.3e8,
Expand Down
21 changes: 11 additions & 10 deletions src/World3/population/pop15/plots.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using DifferentialEquations
function historicalrunsolution()
isdefined(@__MODULE__, :_solution_historicalrun) && return _solution_historicalrun
global _solution_historicalrun = solve(historicalrun(), (1900, 2100))
global _solution_historicalrun = WorldDynamics.solve(historicalrun(), (1900, 2100); solver = Rodas5())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR removes the AutoVern9 method on top of Rodas5. Keeping it raises a mass matrix issue, but removing it results in oscillating plots. We're keeping AutoVern9 in all other plots. We keep investigating the issue in #60.

return _solution_historicalrun
end

Expand Down Expand Up @@ -98,7 +99,7 @@ function fig_87(; kwargs...)
parameters_2_87[:lt2] = 1900

system = historicalrun(params=parameters_2_87)
solution = solve(system, (1900, 2100))
solution = WorldDynamics.solve(system, (1900, 2100); solver = Rodas5())

return plotvariables(solution, (t, 1900, 2100), _variables_a(); title="Fig. 2.87c", kwargs...)
end
Expand All @@ -117,7 +118,7 @@ function fig_88(; kwargs...)
parameters_2_88[:cfood] = 2500

system = historicalrun(params=parameters_2_88)
solution = solve(system, (1900, 2100))
solution = WorldDynamics.solve(system, (1900, 2100); solver = Rodas5())

return plotvariables(solution, (t, 1900, 2100), _variables_a(); title="Fig. 2.88c", kwargs...)
end
Expand All @@ -132,7 +133,7 @@ function fig_89(; kwargs...)
parameters_2_89[:lt2] = 1900

system = historicalrun(params=parameters_2_89)
solution = solve(system, (1900, 2100))
solution = WorldDynamics.solve(system, (1900, 2100); solver = Rodas5())

return plotvariables(solution, (t, 1900, 2100), _variables_a(); title="Fig. 2.89c", kwargs...)
end
Expand Down Expand Up @@ -170,7 +171,7 @@ function fig94solution()
new_equations[96] = pop.extra ~ 0.1 * pop.p6 + 0.25 * pop.p7 + 0.3 * pop.p8 + 0.25 * pop.p9 + 0.1 * pop.p10

@named new_system = ODESystem(new_equations)
global _solution_94 = solve(new_system, (1900, 2100))
global _solution_94 = WorldDynamics.solve(new_system, (1900, 2100); solver = Rodas5())

return _solution_94
end
Expand Down Expand Up @@ -207,7 +208,7 @@ function fig_96(; kwargs...)
parameters_2_96[:fcest] = 1975

system = historicalrun(params=parameters_2_96)
solution = solve(system, (1900, 2100))
solution = WorldDynamics.solve(system, (1900, 2100); solver = Rodas5())

return plotvariables(solution, (t, 1900, 2100), _variables_a(); title="Fig. 2.96c", kwargs...)
end
Expand All @@ -223,7 +224,7 @@ function fig_97(; kwargs...)
parameters_2_97[:zpgt] = 1975

system = historicalrun(params=parameters_2_97)
solution = solve(system, (1900, 2100))
solution = WorldDynamics.solve(system, (1900, 2100); solver = Rodas5())

return plotvariables(solution, (t, 1900, 2100), _variables_a(); title="Fig. 2.97c", kwargs...)
end
Expand All @@ -238,7 +239,7 @@ function fig_98(; kwargs...)
parameters_2_98[:lt] = 2000

system = historicalrun(params=parameters_2_98)
solution = solve(system, (1900, 2100))
solution = WorldDynamics.solve(system, (1900, 2100); solver = Rodas5())

return plotvariables(solution, (t, 1900, 2100), _variables_a(); title="Fig. 2.98c", kwargs...)
end
Expand All @@ -254,7 +255,7 @@ function fig_99(; kwargs...)
parameters_2_99[:fcest] = 1975

system = historicalrun(params=parameters_2_99)
solution = solve(system, (1900, 2100))
solution = WorldDynamics.solve(system, (1900, 2100); solver = Rodas5())

return plotvariables(solution, (t, 1900, 2100), _variables_a(); title="Fig. 2.99c", kwargs...)
end
Expand All @@ -271,7 +272,7 @@ function fig_100(; kwargs...)
parameters_2_100[:zpgt] = 1975

system = historicalrun(params=parameters_2_100)
solution = solve(system, (1900, 2100))
solution = WorldDynamics.solve(system, (1900, 2100); solver = Rodas5())

return plotvariables(solution, (t, 1900, 2100), _variables_a(); title="Fig. 2.100c", kwargs...)
end