Closed lyhybrid closed 1 month ago
Adding additional time points improves accuracy, but 2,000,000
time points is generally not required. If a large number of time points are required, consider switching to IMODE=7
(sequential simulation). Otherwise the problem may take a while to solve with IMODE=4
(simultaneous simulation). The issue that you've encountered is that this number of time points is not allowed on the remote server. Try switching to a local solve with remote=False
.
m = GEKKO(remote=False)
Here is a complete script that adds additional points and uses NODES=3
to increase accuracy.
from gekko import GEKKO
import numpy as np
import matplotlib.pyplot as plt
m = GEKKO(remote=False)
m.time = np.linspace(0,20,2000)
k = 10
y = m.Var(value=5.0)
t = m.Param(value=m.time)
m.Equation(k*y.dt()==-t*y)
m.options.NODES = 3 # 2-6, 2=default
m.options.IMODE = 4
m.solve(disp=False)
plt.plot(m.time,y.value)
plt.xlabel('time')
plt.ylabel('y')
plt.show()
Please ask future questions on StackOverflow: https://stackoverflow.com/questions/tagged/gekko
Thank you so much for your help!
I am using an example from gekko document to do a dynamic simulation:
when I change from
m.time = np.linspace(0,20,100)
tom.time = np.linspace(0,20,2000000)
, i.e. increase the time scale, I will encounter a warning as below, and the dimension of the variabley
will become 2 which does not match withm.time
. I am wondering why is it happening? ,SincerelyWith error: