我正在尝试建立这个生理模型。我想模拟运动员的恢复,这类似于电动汽车的充电状态。我不确定如何限制100%的SoC。
我遇到的问题是,这个问题变得非常大,因为我需要获取以前的Soc来测量当前的SoC。此外,我不确定如何对放电速率与充电速率不同的事实进行建模。谢谢
#discharging
W'Exp = (P - CP) * dt
soc = soc - W'Exp
#If the Power for the data point is below CP or CV, W' is reconstituted:
W'Rec = (CP - P) * dt
Rate = (W' - W'Bal) / W'
soc = soc + W'Rec * Rate发布于 2021-03-26 11:14:01
查看简单能量存储模型的Gekko实现,发现here是一个example problem。您可以为运动员修改此模型。

import numpy as np
import matplotlib.pyplot as plt
import matplotlib.ticker as mtick
from gekko import GEKKO
m = GEKKO(remote=False)
t = np.linspace(0, 24, 24*3+1)
m.time = t
m.options.SOLVER = 1
m.options.IMODE = 6
m.options.NODES = 3
m.options.CV_TYPE = 1
m.options.MAX_ITER = 300
p = m.FV() # production
p.STATUS = 1
s = m.Var(100, lb=0) # storage inventory
store = m.SV() # store energy rate
vy = m.SV(lb=0) # store slack variable
recover = m.SV() # recover energy rate
vx = m.SV(lb=0) # recover slack variable
eps = 0.7
d = m.MV(-20*np.sin(np.pi*t/12)+100)
m.periodic(s)
m.Equations([p + recover/eps - store >= d,
p - d == vx - vy,
store == p - d + vy,
recover == d - p + vx,
s.dt() == store - recover/eps,
store * recover <= 0])
m.Minimize(p)
m.solve(disp=True)
#%% Visualize results
fig, axes = plt.subplots(4, 1, sharex=True)
ax = axes[0]
ax.plot(t, store, 'C3-', label='Store Rate')
ax.plot(t, recover, 'C0-.', label='Recover Rate')
ax = axes[1]
ax.plot(t, d, 'k-', label='Electricity Demand')
ax.plot(t, p, 'C3--', label='Power Production')
ax = axes[2]
ax.plot(t, s, 'C2-', label='Energy Inventory')
ax = axes[3]
ax.plot(t, vx, 'C2-', label='$S_1$')
ax.plot(t, vy, 'C3--', label='$S_2$')
ax.set_xlabel('Time (hr)')
for ax in axes:
ax.legend(bbox_to_anchor=(1.01, 0.5), \
loc='center left', frameon=False)
ax.grid()
ax.set_xlim(0, 24)
loc = mtick.MultipleLocator(base=6)
ax.xaxis.set_major_locator(loc)
plt.tight_layout()
plt.show()发布于 2021-03-26 07:06:07
对于第一个问题,我猜SOC是一个变量。变量的上下限设置如下:
m = GEKKO()
SOC = m.Var(10, lb=0, ub=100)10是SOC的初始值。对于您的第二个问题,是否提供了P, CP, W'Bal?
https://stackoverflow.com/questions/66766375
复制相似问题