Skip to content

Commit 55b9a29

Browse files
committed
jacobian function
plus duffing fix
1 parent 60309a0 commit 55b9a29

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

src/continuous.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ dimension(ds::ContinuousDS) = length(ds.prob.u0)
103103
Base.eltype(ds::ContinuousDS{T,F,J}) where {T, F, J} = T
104104
state(ds::ContinuousDS) = ds.prob.u0
105105

106+
jacobian(ds::ContinuousDynamicalSystem) = (ds.jacob!(0, state(ds), ds.J); ds.J)
107+
106108
#######################################################################################
107109
# Interface to DifferentialEquations #
108110
#######################################################################################

src/discrete.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using StaticArrays, ForwardDiff, Requires
22

3-
export DiscreteDS, DiscreteDS1D, evolve, trajectory, dimension, state
3+
export DiscreteDS, DiscreteDS1D, evolve, trajectory, dimension, state, jacobian
44
export BigDiscreteDS, DiscreteDynamicalSystem
55

66
#####################################################################################
@@ -135,14 +135,14 @@ dimension(::DiscreteDS1D) = 1
135135
dimension(ds::BigDiscreteDS) = length(state(ds))
136136

137137
"""
138-
jacobian(ds::DynamicalSystem)
138+
jacobian(ds::DynamicalSystem) -> J
139139
Return the Jacobian matrix of the equations of motion at the system's state.
140140
"""
141-
jacobian(ds::DynamicalSystem) = (ds.jacob!(ds.J, state(ds)), ds.J)
141+
jacobian(ds::DynamicalSystem) = (ds.jacob!(ds.J, state(ds)); ds.J)
142142
jacobian(ds::DiscreteDS) = ds.jacob(state(ds))
143143

144144
"""
145-
state(ds::DynamicalSystem)
145+
state(ds::DynamicalSystem) -> u
146146
Return the state of the system.
147147
"""
148148
state(ds::DynamicalSystem) = ds.state

src/famous_systems.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ end
272272
end
273273
@inbounds function (duf::Duffing)(t, u::AbstractVector, J::AbstractMatrix)
274274
J[2,1] = -duf.β - 3u[1]^2
275-
J[2,2] = -duf.d*u[2]
275+
J[2,2] = -duf.d
276276
end
277277

278278

0 commit comments

Comments
 (0)