Skip to content

Commit 7a37784

Browse files
committed
tests pass, ready to merge
I will only check if documentation makes sense before merging
1 parent 30287fd commit 7a37784

File tree

4 files changed

+26
-22
lines changed

4 files changed

+26
-22
lines changed

CHANGELOG.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# v0.6
22
## Massively Breaking
3-
* All systems now have the parameter container as the third argument, and
4-
mandatory as well.
53
* Complete overhaul of Discrete Systems: all systems are now one, there is
64
no longer `DDS` and `BigDDS`. Everything is `DDS`!
75
* `variational_integrator` renamed to `tangent_integrator`.
6+
* `DDS` is made up of 2 fundamental parts: a DiscreteProblem and a
7+
TangentEvolver.
88
## Non-breaking
9-
* Massive performance boost of up to 8x in system evolution.
10-
* `ParallelEvolver` for `DDS`
11-
* `TangentEvolver` for `DDS`
9+
* Massive performance boost of up to 8x in system evolution of continuous systems.
10+
* `ParallelEvolver`
11+
* `TangentEvolver`
1212

1313
# v0.5.0
1414

src/discrete.jl

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -633,8 +633,9 @@ evolve(ds::DDS, u) = evolve(ds.prob, u)
633633
trajectory(ds::DDS, args...) = trajectory(ds.prob, args...)
634634

635635
"""
636-
jacobian(ds::DynamicalSystem, u = state(ds))
637-
Return the Jacobian of the equations of motion at `u`.
636+
jacobian([J, ] ds::DynamicalSystem, u = state(ds))
637+
Return the Jacobian of the equations of motion at `u`, optionally writting the
638+
result in-place in `J`.
638639
"""
639640
function jacobian(ds::DDS{true}, u = state(ds))
640641
ds.tangent.jacobian(ds.tangent.J, u, ds.prob.p)
@@ -643,6 +644,10 @@ end
643644

644645
jacobian(ds::DDS{false}, u = state(ds)) = ds.tangent.jacobian(u, ds.prob.p)
645646

647+
function jacobian(J, ds::DDS, u = state(ds))
648+
ds.tangent.jacobian(J, u, ds.prob.p)
649+
end
650+
646651
#####################################################################################
647652
# Pretty-Printing #
648653
#####################################################################################

src/famous_systems.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ Default values are the ones used in the original paper.
353353
[1] : O. E. Rössler, Phys. Lett. **71A**, pp 155 (1979)
354354
"""
355355
function towel(u0=[0.085, -0.121, 0.075])
356-
return DDS(u0, eom_towel, nothing, jacob_towel)
356+
return DDS(u0, eom_towel, jacob_towel)
357357
end# should result in lyapunovs: [0.432207,0.378834,-3.74638]
358358
@inline function eom_towel(x, p)
359359
@inbounds x1, x2, x3 = x[1], x[2], x[3]
@@ -402,7 +402,7 @@ Nuclear Physics, Novosibirsk (1969)
402402
[2] : J. M. Greene, J. Math. Phys. **20**, pp 1183 (1979)
403403
"""
404404
function standardmap(u0=0.001rand(2); k = 0.971635)
405-
return DDS(u0, standardmap_eom, [k], standardmap_jacob)
405+
return DDS(u0, standardmap_eom, standardmap_jacob; p = [k])
406406
end
407407
@inline @inbounds function standardmap_eom(x, par)
408408
theta = x[1]; p = x[2]
@@ -457,7 +457,7 @@ function coupledstandardmaps(M::Int, u0 = 0.001rand(2M);
457457
J[i+M, i+M] = 1
458458
end
459459

460-
return DDS(u0, csm, [ks, Γ], csm, J)
460+
return DDS(u0, csm, csm, J; p = [ks, Γ])
461461
end
462462
mutable struct CoupledStandardMaps{N}
463463
idxs::UnitRange{Int}
@@ -567,7 +567,7 @@ function's documentation string.
567567
[2] : M. J. Feigenbaum, J. Stat. Phys. **19**, pp 25 (1978)
568568
"""
569569
function logistic(x0=rand(); r = 4.0)
570-
return DDS(x0, logistic_eom, [r], logistic_jacob)
570+
return DDS(x0, logistic_eom, logistic_jacob; p = [r])
571571
end
572572
@inline logistic_eom(x, p) = p[1]*x*(1-x)
573573
@inline logistic_jacob(x, p) = p[1]*(1-2x)
@@ -586,7 +586,7 @@ The parameter container has the parameters in the same order as stated in this
586586
function's documentation string.
587587
"""
588588
function circlemap(x0=rand(); K = 0.99, Ω = 1.0, usemod::Bool = false)
589-
return DDS(x0, circlemap_eom, [Ω, K], circlemap_jacob)
589+
return DDS(x0, circlemap_eom, circlemap_jacob; p = [Ω, K])
590590
end
591591
@inline circlemap_eom(x, p) = x + twopi*p[1] - p[2]*sin(x)
592592
@inline circlemap_jacob(x, p) = -p[2]*cos(x)

test/discrete_systems.jl

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ using Base.Test, StaticArrays
77
@testset "Logistic Map" begin
88

99
d1 = Systems.logistic(0.1)
10-
d2 = DDS(0.1, d1.prob.f, d1.prob.p)
11-
d3 = DDS(big(0.1), d1.prob.f, d1.prob.p, d1.jacobian)
10+
d2 = DDS(0.1, d1.prob.f; p = d1.prob.p)
11+
d3 = DDS(big(0.1), d1.prob.f, d1.tangent.jacobian; p = d1.prob.p)
1212

1313
@testset "Evolution & trajectory" begin
1414
st1 = evolve(d1, 1)
@@ -42,8 +42,8 @@ end
4242
s1 = Systems.henon(0.1ones(N))
4343
end
4444

45-
s2 = DDS(0.1ones(N), s1.prob.f, s1.prob.p)
46-
s4 = DDS(round.(big.(0.1ones(N)),3), s1.prob.f, s1.prob.p, s1.jacobian)
45+
s2 = DDS(0.1ones(N), s1.prob.f; p = s1.prob.p)
46+
s4 = DDS(big.(0.1ones(N)), s1.prob.f, s1.tangent.jacobian; p = s1.prob.p)
4747

4848
@testset "Evolution & trajectory" begin
4949
st1 = evolve(s1, 1)
@@ -82,11 +82,10 @@ end
8282
st1 = evolve(ds, 100)
8383

8484
@test st1 != u0
85-
@test u0 == state(ds)
85+
evolve!(ds, 100)
86+
@test st1 == state(ds)
8687

87-
Jbef = deepcopy(ds.J)
88-
ds.jacobian(ds.J, evolve(ds, 1), ds.prob.p)
89-
@test Jbef != ds.J
90-
ds.jacobian(Jbef, evolve(ds, 1), ds.prob.p)
91-
@test Jbef == ds.J
88+
Jbef = deepcopy(ds.tangent.J)
89+
jacobian(Jbef, ds)
90+
@test Jbef != ds.tangent.J
9291
end

0 commit comments

Comments
 (0)