Skip to content

Commit 9cdcbea

Browse files
authored
Installation instructions + schedule test (#979)
* Installation instructions + schedule test * bump version to 0.18 * bump versions of submodules
1 parent dd60a35 commit 9cdcbea

File tree

11 files changed

+85
-20
lines changed

11 files changed

+85
-20
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
## Unreleased
44

5+
## v0.18
6+
7+
- Installation main instructions in docs + schedule tests [#979](https://github.com/SpeedyWeather/SpeedyWeather.jl/pull/979)
58
- Bug fix: Cloud reflectivity on half level above not below [#978](https://github.dev/SpeedyWeather/SpeedyWeather.jl/pull/978)
69
- Fix absorptivity_water_vapor and absorptivity_cloud_base default values [#974](https://github.com/SpeedyWeather/SpeedyWeather.jl/pull/974)
710
- Particle advection GPU ready [#897](https://github.com/SpeedyWeather/SpeedyWeather.jl/pull/897)

LowerTriangularArrays/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "LowerTriangularArrays"
22
uuid = "ed20b33f-a660-45d0-a353-9c8c20bb5814"
33
authors = ["LowerTriangularArrays contributors"]
4-
version = "0.1.1"
4+
version = "0.1.2"
55

66
[deps]
77
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"

RingGrids/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "RingGrids"
22
uuid = "d1845624-ad4f-453b-8ff4-a8db365bf3a7"
33
authors = ["RingGrids contributors"]
4-
version = "0.1.1"
4+
version = "0.1.2"
55

66
[deps]
77
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"

SpeedyTransforms/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "SpeedyTransforms"
22
uuid = "ed023a3f-7a3c-42dd-bab6-68c21c8c3105"
33
authors = ["SpeedyTransforms contributors"]
4-
version = "0.1.1"
4+
version = "0.1.2"
55

66
[deps]
77
AbstractFFTs = "621f4979-c628-5d54-868e-fcf4e3e8185c"

SpeedyWeather/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "SpeedyWeather"
22
uuid = "9e226e20-d153-4fed-8a5b-493def4f21a9"
33
authors = ["SpeedyWeather contributors"]
4-
version = "0.17.4"
4+
version = "0.18"
55

66
[deps]
77
AbstractFFTs = "621f4979-c628-5d54-868e-fcf4e3e8185c"

SpeedyWeather/src/dynamics/clock.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,16 @@ Adapt.adapt_structure(to, ::Clock) = nothing
3434
function timestep!(clock::Clock, Δt; increase_counter::Bool = true)
3535
clock.time += Δt
3636
# the first timestep is a half-step and doesn't count
37-
return clock.timestep_counter += increase_counter
37+
clock.timestep_counter += increase_counter
38+
return nothing
3839
end
3940

4041
# pretty printing
4142
function Base.show(io::IO, C::Clock)
4243
println(io, "$(typeof(C))")
4344
keys = propertynames(C)
44-
return print_fields(io, C, keys)
45+
print_fields(io, C, keys)
46+
return nothing
4547
end
4648

4749
# copy!

SpeedyWeather/src/output/schedule.jl

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@ start+p, but p is rounded to match the multiple of the model timestep.
1111
Periodic schedules and event schedules can be combined, executing at both.
1212
A Schedule is supposed to be added into callbacks as fields
1313
14-
Base.@kwdef struct MyCallback
14+
@kwdef struct MyCallback
1515
schedule::Schedule = Schedule(every=Day(1))
1616
other_fields
1717
end
1818
19-
see also `initialize!(::Schedule,::Clock)` and `isscheduled(::Schedule,::Clock)`.
19+
see also `initialize!(::Schedule, ::Clock)` and `isscheduled(::Schedule, ::Clock)`.
2020
2121
Fields
2222
$(TYPEDFIELDS)"""
23-
Base.@kwdef mutable struct Schedule <: AbstractSchedule
23+
@kwdef mutable struct Schedule <: AbstractSchedule
2424
"[OPTION] Execute every time period, first timestep excluded. Default=never."
2525
every::Second = Second(typemax(Int))
2626

@@ -37,19 +37,18 @@ Base.@kwdef mutable struct Schedule <: AbstractSchedule
3737
counter::Int = 0
3838
end
3939

40-
"""
41-
$(TYPEDSIGNATURES)
40+
"""$(TYPEDSIGNATURES)
4241
A Schedule based on DateTime arguments, For two consecutive time steps i, i+1, an event is
4342
scheduled at i+1 when it occurs in (i,i+1]."""
4443
Schedule(times::DateTime...) = Schedule(times = DateTime[times...])
4544

46-
"""
47-
$(TYPEDSIGNATURES)
45+
"""$(TYPEDSIGNATURES)
4846
Initialize a Schedule with a Clock (which is assumed to have been initialized).
4947
Takes both scheduler.every and scheduler.times into account, such that
5048
both periodic and events can be scheduled simultaneously. But execution will
5149
happen only once if they coincide on a given time step."""
5250
function initialize!(scheduler::Schedule, clock::Clock)
51+
clock.Δt == Millisecond(0) && error("Clock needs to be initialized with a non-zero time step before initializing schedule.")
5352
schedule = falses(clock.n_timesteps) # initialize schedule as BitVector
5453

5554
# PERIODIC SCHEDULE, always AFTER scheduler.every time period has passed

SpeedyWeather/test/output/schedule.jl

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,28 @@
1616
# adapted schedule time step should be within 20%
1717
@test schedule.every.value Second(hour).value rtol = 2.0e-1
1818
@test schedule.steps period / hour rtol = 2.0e-1
19+
20+
for _ in 1:clock.n_timesteps
21+
SpeedyWeather.timestep!(clock, clock.Δt)
22+
isscheduled(schedule, clock)
23+
end
24+
25+
@test schedule.counter == sum(schedule.schedule) > 1
26+
27+
# reinitialize clock
28+
clock = Clock()
29+
period = Day(1)
30+
initialize!(clock, time_stepping, period)
31+
32+
schedule = Schedule(clock.time + Hour(6))
33+
initialize!(schedule, clock)
34+
@test sum(schedule.schedule) == 1
35+
@test schedule.counter == 0 # no execution of isscheduled yet
36+
37+
for _ in 1:clock.n_timesteps
38+
SpeedyWeather.timestep!(clock, clock.Δt)
39+
isscheduled(schedule, clock)
40+
end
41+
@test schedule.counter == 1
1942
end
2043
end

SpeedyWeatherInternals/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "SpeedyWeatherInternals"
22
uuid = "34489162-d270-4603-8b96-37b04f830d73"
33
authors = ["SpeedyWeatherInternals contributors"]
4-
version = "0.1.2"
4+
version = "0.1.3"
55

66
[deps]
77
ComponentArrays = "b0b7db55-cfe3-40fc-9ded-d10e2dbeff66"

docs/src/differentiability.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
SpeedyWeather.jl is written with differentiability in mind. This means that our model is differentiable by automatic differentiation (AD). If you are interested in machine learning (ML), this means that you can integrate our model directly into your ML models without the need to first train your neural networks offline. For atmospheric modellers this means that you get an adjoint model for free which is always generated automatically, so that we don't need to maintain it separately. This allows you to calibrate SpeedyWeather.jl in a fully automatic and data-driven way.
44

5-
!!! warning Work in progress
5+
!!! warning "Work in progress"
66
The differentiability of SpeedyWeather.jl is still work in progress and some parts of this documentation might be not be always updated to the latest state. We will extend this documentation over time. Don't hesitate to contact us via GitHub issues or mail when you have questions or want to collaborate.
77

88
For the differentiability of our model we rely on [Enzyme.jl](https://github.com/EnzymeAD/Enzyme.jl). If you've used Enzyme before, just go ahead and try to differentiate the model! It should work. We have checked the correctness of the gradients extensively against a finite differences differentiation with [FiniteDifferences.jl](https://github.com/JuliaDiff/FiniteDifferences.jl/). In the following we present a simple example how we can take the gradient of a single timestep of the primitive equation model with respect to one of the model parameter.
99

10-
!!! warning Enzyme with Julia 1.11
10+
!!! warning "Enzyme with Julia 1.11"
1111
Currently there are still some issues with Enzyme in Julia 1.11, we recommend to use Julia 1.10 for the following
1212

1313
## Differentiating through a single timestep

0 commit comments

Comments
 (0)