Skip to content

Commit bceddf1

Browse files
authored
Merge pull request #374 from JuliaDynamics/hw/bump_sciml
bump sciml versions
2 parents 6165e4f + aad2298 commit bceddf1

19 files changed

Lines changed: 235 additions & 110 deletions

NEWS.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# NetworkDynamics Release Notes
22

3-
## v0.10.18 Changelog
3+
## v1.0.0 Changelog
44

55
- **ModelingToolkit v11 compatibility** ([#344](https://github.com/JuliaDynamics/NetworkDynamics.jl/pull/344)):
66
- Raises compat from `ModelingToolkit` v10 to v11. MTK v11 split into `ModelingToolkitBase` (MIT-licensed) and `ModelingToolkit` (AGPL-licensed); NetworkDynamics.jl now only requires the MIT-licensed `ModelingToolkitBase` as a direct dependency, dropping the AGPL dependency.
@@ -15,6 +15,7 @@
1515
- The default initial state for fixpoint search now applies guesses and formulas automatically (`guess=true, apply_formulas=true`).
1616
- **`NWState` constructor** gains `guess`, `apply_formulas`, and `verbose` keyword arguments. With `default=true` (the default), values are filled in order: defaults/inits → `InitFormula`s → guesses (if `guess=true`) → `GuessFormula`s. `apply_formulas=true` by default; `guess=false` by default.
1717
- `doctor` check: added smoketest for the observable function (`obsf`) of each component.
18+
- `SciMLBase@3` and `OrdinaryDfifEq@7` compat. Most notably, upstream `DiffEq` changed its default `initializealg` to *check* rather than *reinit* inconsistent initial conditions. To preserve the previous behavior, the `ODEProblem(nw::Network, ...)` constructor now defaults to `initializealg=BrownFullBasicInit()` (deliberately differing from the OrdinaryDiffEq default). Pass `initializealg=...` to the constructor to override. Also, the interface of the `VectorContinuousComponentCallback` changed to fit that of `VectorContinuousCallback`: the affect now receives a buffer with per-element up or down crossing information rather than a single event idx.
1819

1920
## v0.10.17 Changelog
2021
- **Open-loop linearization** ([#341](https://github.com/JuliaDynamics/NetworkDynamics.jl/pull/341)):

NetworkDynamicsInspector/Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ GraphMakie = "0.6"
3636
Graphs = "1.12.0"
3737
NetworkDynamics = "1, 0.10"
3838
Observables = "0.5.5"
39-
OrderedCollections = "1.8.0"
39+
OrderedCollections = "1.8.0, 2"
4040
PrecompileTools = "1.2.1"
41-
SciMLBase = "2.75.1"
41+
SciMLBase = "3"
4242
WGLMakie = "0.13"
4343
julia = "1.10"

NetworkDynamicsInspector/test/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Graphs = "≥0.0.1"
2828
ModelingToolkitBase = "≥0.0.1"
2929
NetworkDynamics = "≥0.0.1"
3030
NetworkDynamicsInspector = "≥0.0.1"
31-
OrdinaryDiffEqTsit5 = "1.1.0"
31+
OrdinaryDiffEqTsit5 = "1.1.0, 2"
3232
SafeTestsets = "0.1.0"
3333
SciCompDSL = "≥0.0.1"
3434
Test = "1"

Project.toml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Accessors = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697"
1212
ArgCheck = "dce04be8-c92d-5529-be00-80e4d2c0e197"
1313
Atomix = "a9b6321e-bd34-4604-b9c9-b65b8de01458"
1414
ConstructionBase = "187b0558-2788-49d3-abe0-74a17ed4e7c9"
15+
DiffEqBase = "2b5f629d-d688-5b77-993f-72d75c75574e"
1516
DiffEqCallbacks = "459566f4-90b8-5000-8ac3-15dfb0a30def"
1617
DifferentiationInterface = "a0c0ee7d-e4b9-4e03-894e-1c5f64a51d63"
1718
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
@@ -67,9 +68,10 @@ Accessors = "0.1.43"
6768
Adapt = "4.0.4"
6869
ArgCheck = "2.3.0"
6970
Atomix = "1"
70-
CUDA = "5.5.2"
71+
CUDA = "5.5.2, 6"
7172
ConstructionBase = "1.6.0"
7273
DataFrames = "1"
74+
DiffEqBase = "7"
7375
DiffEqCallbacks = "4.2.2"
7476
DifferentiationInterface = "0.7"
7577
DocStringExtensions = "0.9.3"
@@ -80,29 +82,29 @@ Hungarian = "0.7.0"
8082
InteractiveUtils = "1"
8183
KernelAbstractions = "0.9.18"
8284
LinearAlgebra = "1"
83-
LinearSolve = "3.46.1"
85+
LinearSolve = "3,4"
8486
MacroTools = "0.5.15"
8587
Mixers = "0.1.2"
8688
ModelingToolkitBase = "1.21"
8789
Moshi = "0.3"
8890
NNlib = "0.9.13"
8991
NonlinearSolve = "4"
90-
OrderedCollections = "1.8.0"
92+
OrderedCollections = "1.8.0, 2"
9193
Polyester = "0.7.12"
92-
PreallocationTools = "0.4.23, 1"
94+
PreallocationTools = "1"
9395
PrecompileTools = "1.2.1"
9496
Printf = "1.10.0"
9597
Random = "1"
96-
RecursiveArrayTools = "3.27.0"
98+
RecursiveArrayTools = "4"
9799
RuntimeGeneratedFunctions = "0.5.15"
98-
SciMLBase = "2"
100+
SciMLBase = "3"
99101
SparseArrays = "1"
100102
SparseConnectivityTracer = "0.6, 1"
101103
Static = "1.1.1"
102104
StaticArrays = "1.9.4"
103105
SteadyStateDiffEq = "2.2.0"
104106
StyledStrings = "1.0.3"
105-
SymbolicIndexingInterface = "0.3.27"
107+
SymbolicIndexingInterface = "0.3.36"
106108
SymbolicUtils = "4"
107109
Symbolics = "7"
108110
TimerOutputs = "0.5.23"

benchmark/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Chairmarks = "1.3.1"
3131
Graphs = "≥0.0.1"
3232
Makie = "0.24"
3333
NetworkDynamics = "≥0.0.1"
34-
OrderedCollections = "1.7.0"
34+
OrderedCollections = "1.7.0, 2"
3535
PkgBenchmark = "0.2.12"
3636
PrettyTables = "3"
3737
ProgressMeter = "1.10.2"

docs/Project.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Bonito = "≥0.0.1"
4545
CairoMakie = "0.15"
4646
Chairmarks = "1.3.1"
4747
DataFrames = "≥0.0.1"
48-
DataInterpolations = "7, 8"
48+
DataInterpolations = "9"
4949
DiffEqCallbacks = "4.2.2"
5050
Distributions = "0.25.117"
5151
Documenter = "1.8.0"
@@ -60,10 +60,10 @@ ModelingToolkitBase = "≥0.0.1"
6060
NetworkDynamics = "≥0.0.1"
6161
NetworkDynamicsInspector = "≥0.0.1"
6262
NonlinearSolve = "≥0.0.1"
63-
OrdinaryDiffEqNonlinearSolve = "1.3.0"
64-
OrdinaryDiffEqRosenbrock = "1.4.0"
65-
OrdinaryDiffEqSDIRK = "1"
66-
OrdinaryDiffEqTsit5 = "1.1.0"
63+
OrdinaryDiffEqNonlinearSolve = "2"
64+
OrdinaryDiffEqRosenbrock = "2"
65+
OrdinaryDiffEqSDIRK = "2"
66+
OrdinaryDiffEqTsit5 = "2"
6767
Plots = "1.40.9"
6868
Printf = "≥0.0.1"
6969
Random = "≥0.0.1"

docs/examples/getting_started_with_network_dynamics.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ nd_2 = Network(g, nd_diffusion_vertex_2, nd_diffusion_edge_2)
224224
We define the first diffusion as x ~ $N(0,1)^\mathrm{2}$ and the second diffusion as ϕ ~ $N(0,1)$. So the propagation
225225
of the diffusion from node 0 to node 2 is given by creating a vector:
226226
=#
227-
x0_2 = vec(transpose([randn(rng, N) .^ 2 randn(rng, N)]))
227+
x0_2 = collect(vec(transpose([randn(rng, N) .^ 2 randn(rng, N)])))
228228

229229
# We then define the `ODEProblem`:
230230
ode_prob_2 = ODEProblem(nd_2, x0_2, (0.0, 3.0))
@@ -290,7 +290,7 @@ g = barabasi_albert(N, k)
290290
nd_diffusion_vertex_2 = VertexModel(; f=diffusionvertex_f!, g=1:2, dim=2, sym=[:x, ])
291291
nd_diffusion_edge_2 = EdgeModel(; g=AntiSymmetric(diffusionedge_g!), outsym=[:flow_x, :flow_ϕ])
292292
nd_2 = Network(g, nd_diffusion_vertex_2, nd_diffusion_edge_2)
293-
x0_2 = vec(transpose([randn(rng, N) .^ 2 randn(rng, N)]))
293+
x0_2 = collect(vec(transpose([randn(rng, N) .^ 2 randn(rng, N)])))
294294
ode_prob_2 = ODEProblem(nd_2, x0_2, (0.0, 3.0))
295295
Main.test_execution_styles(ode_prob_2) #src
296296
sol_2 = solve(ode_prob_2, Tsit5());

docs/src/callbacks.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ The main entry points are the types [`ContinuousComponentCallback`](@ref),
2828
[`VectorContinuousComponentCallback`](@ref) and [`DiscreteComponentCallback`](@ref). All of those objects combine a [`ComponentCondition`](@ref) with an [`ComponentAffect`](@ref).
2929

3030
The "normal" [`ContinuousComponentCallback`](@ref) and [`DiscreteComponentCallback`](@ref) have a condition which returns a single value. The corresponding affect is triggered when the return value hits zero.
31-
In contrast, the "vector" version has an in-place condition which writes `len` outputs. When any of those outputs hits zero, the affect is triggered with an additional argument `event_idx` which tells the effect which dimension encountered the zerocrossing.
31+
In contrast, the "vector" version has an in-place condition which writes `len` outputs. When any of those outputs hits zero, the affect is triggered once with an additional argument `event_signs`: a length-`len` vector where entry `i` is `0` (no crossing), `+1` (upcrossing) or `-1` (downcrossing) for the `i`-th output. The affect resolves the crossing direction (and any simultaneous crossings) itself. This mirrors the `affect!(integrator, event_signs)` interface of the underlying [`VectorContinuousCallback`](@extref SciMLBase.VectorContinuousCallback).
3232

3333
There is a special type [`PresetTimeComponentCallback`](@ref) which has no explicit condition and triggers the affect at given times.
3434
This internally generates a [`PresetTimeCallback`](@extref DiffEqCallbacks.PresetTimeCallback) object from `DiffEqCallbacks.jl`.
@@ -64,11 +64,15 @@ affect = ComponentAffect([:u], [:p]) do u, p, ctx
6464
obs = NWState(ctx.integrator)[VIndex(ctx.vidx, :obs)] # extract some observed state from context
6565
println("Trigger affect at t=$t")
6666
end
67-
vectoraffect = ComponentAffect([:u], [:p]) do u, p, event_idx, ctx
68-
if event_idx == 1
69-
u[:u] = 0 # change state
70-
else
71-
u[:p] = 0 # change parameter
67+
vectoraffect = ComponentAffect([:u], [:p]) do u, p, event_signs, ctx
68+
for i in eachindex(event_signs)
69+
event_signs[i] == 0 && continue # skip outputs that did not cross
70+
if i == 1
71+
u[:u] = 0 # first output crossed: change state
72+
else
73+
u[:p] = 0 # second output crossed: change parameter
74+
end
75+
# event_signs[i] is +1 for an upcrossing and -1 for a downcrossing
7276
end
7377
end
7478
```
@@ -78,7 +82,7 @@ However the affect gets passed a `ctx` "context" object, which is a named tuple
7882
Lastly we need to define the actual callback object using [`ContinuousComponentCallback`](@ref)/[`VectorContinuousComponentCallback`](@ref):
7983
```julia
8084
ccb = ContinuousComponentCallback(condition, affect; kwargs...)
81-
vccb = VectorContinuousComponentCallback(condition, affect; kwargs...)
85+
vccb = VectorContinuousComponentCallback(condition, affect, len; kwargs...)
8286
```
8387
where the `kwargs` are passed to the underlying [`SciMLBase.VectorContinuousCallback`](@extref) to finetune the zerocrossing-detection.
8488

docs/src/mtk_integration.md

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -397,41 +397,38 @@ function attach_limint_callback!(cf, namespace)
397397
end
398398
end
399399
400-
upcrossing_affect = ComponentAffect([], [satmax, satmin]) do u, p, eventidx, ctx
401-
if eventidx == 1
400+
# A single affect handles all three conditions. `event_signs[i]` tells us for each
401+
# condition output `i` whether it crossed and in which direction: `0` no crossing,
402+
# `+1` upcrossing, `-1` downcrossing.
403+
affect = ComponentAffect([], [satmax, satmin]) do u, p, event_signs, ctx
404+
if event_signs[1] > 0 # upper saturation upcrossing
402405
println("$namespace: /⎺ reached upper saturation at $(round(ctx.t, digits=4))s")
403406
p[satmax] = 1.0
404407
p[satmin] = 0.0
405-
elseif eventidx == 2
408+
end
409+
if event_signs[2] > 0 # lower saturation upcrossing
406410
println("$namespace: \\_ reached lower saturation at $(round(ctx.t, digits=4))s")
407411
p[satmax] = 0.0
408412
p[satmin] = 1.0
409-
elseif eventidx == 3
410-
# upcrossing means, forcing went from negative to positive, i.e. we leave lower saturation
413+
end
414+
if event_signs[3] > 0
415+
# forcing went from negative to positive, i.e. we leave lower saturation
411416
insatmin = !iszero(p[satmin])
412417
if insatmin
413418
println("$namespace: _/ left lower saturation at $(round(ctx.t, digits=4))s")
414419
p[satmin] = 0.0
415420
end
416-
else
417-
error("Unknown event index $eventidx")
418-
end
419-
end
420-
421-
downcrossing_affect = ComponentAffect([],[satmax]) do u, p, eventidx, ctx
422-
if eventidx == 3 # downcrossing means nothing for saturation affects
423-
# downcrossing means, forcing went from positive to negative, i.e. we leave upper saturation
421+
elseif event_signs[3] < 0
422+
# forcing went from positive to negative, i.e. we leave upper saturation
424423
insatmax = !iszero(p[satmax])
425424
if insatmax
426425
println("$namespace: ⎺\\ left upper saturation at $(round(ctx.t, digits=4))s")
427426
p[satmax] = 0.0
428427
end
429-
else
430-
error("Unknown event index $eventidx")
431428
end
432429
end
433430
434-
cb = VectorContinuousComponentCallback(condition, upcrossing_affect, 3; affect_neg! = downcrossing_affect)
431+
cb = VectorContinuousComponentCallback(condition, affect, 3)
435432
436433
# finally add callback to component
437434
NetworkDynamics.add_callback!(cf, cb)

ext/NetworkDynamicsCUDAExt.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,9 @@ _adapt_rgf(f) = f
155155
function _adapt_diffcache(to, c::DiffCache)
156156
du = adapt(to, c.du)
157157
dual_du = adapt(to, c.dual_du)
158-
DiffCache(du, dual_du, c.any_du)
159-
# N = length(c.dual_du) ÷ length(c.du) - 1
160-
# DiffCache(du, N)
158+
# PreallocationTools 1.x added the `warn_on_resize` field to `DiffCache`; pass all
159+
# fields positionally to hit the struct constructor (not the `(u, siz, chunks)` one).
160+
DiffCache(du, dual_du, c.any_du, c.warn_on_resize)
161161
end
162162

163163
end

0 commit comments

Comments
 (0)