Skip to content

Commit 62dab1a

Browse files
fix parameter usage
Fixes #594
1 parent 8eb6fa2 commit 62dab1a

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/systems/control/controlsystem.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ function runge_kutta_discretize(sys::ControlSystem,dt,tspan;
140140
states_timeseries = [getindex.(timed_vars,j) for j in 1:n+1]
141141
k_timeseries = [[getindex.(k_vars,i,j) for i in 1:m] for j in 1:n]
142142
control_timeseries = [[[Variable(x.name,i,j)(sys.iv()) for x in controls(sys)] for i in 1:m] for j in 1:n]
143-
ps = parameters(sys)
143+
ps = [p() for p in parameters(sys)]
144144
iv = sys.iv()
145145

146146
# Calculate all of the update and stage equations

test/controlsystem.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
using ModelingToolkit
22

33
@variables t x(t) v(t) u(t)
4+
@parameters p
45
@derivatives D'~t
56

67
loss = (4-x)^2 + 2v^2 + u^2
78
eqs = [
89
D(x) ~ v
9-
D(v) ~ u^3
10+
D(v) ~ p*u^3
1011
]
1112

12-
sys = ControlSystem(loss,eqs,t,[x,v],[u],[])
13+
sys = ControlSystem(loss,eqs,t,[x,v],[u],[p])
1314
dt = 0.1
1415
tspan = (0.0,1.0)
1516
runge_kutta_discretize(sys,dt,tspan)

0 commit comments

Comments
 (0)