- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试让优化器使用两个储能器进行循环发电和消耗循环。目标是让它在达到满容量时关闭一次储能(在本例中为电池储能),然后先放电直到耗尽。二次存储是在一次存储之后充电,在一次存储之后放电。我希望优化器根据系统进行解决。我试过使用一系列开关,但效果不佳。我知道使用 if 语句对于基于梯度的求解器来说很棘手,所以如果有任何帮助,我将不胜感激!
Capacity = 76.2
EStored = m.SV(value=0,lb=0,ub=Capacity)
batteryeff = .95
batteff = m.if3((Enuc - Cons),1/batteryeff,batteryeff)
#Energy Balance
Cost = m.Var()
eneed = m.sign2(Enuc-Cons) #gives sign of energy need for energy storage or removal from storage
eswitch = m.if3(eneed,0, 1) #Turns eneed into a binary switch
switch = m.if3(eswitch*(Capacity-EStored)+(1-eswitch)*(EStored),0,1) #supposed to charge battery until at capacity and then discharge until EStored is 0. Then use thermal energy second
m.Equation(EStored.dt() == (switch)*batteff*(Enuc - Cons)) #Energy balance for Battery
m.Equation(T.dt() == (1-switch)*thermeff*(Enuc - Cons)/(mass*Cp)) #Energy balance for Thermal Storage
m.Equation(Cost == Enuc*1000 )
m.Obj(Cost)
m.options.IMODE = 5
m.options.SOLVER = 3
m.solve()
这是我正在使用的代码部分,但是如果需要更多详细信息,这里是整个代码的简化版本。
from gekko import GEKKO
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from scipy.integrate import quad
#Set up basic power consumption data
n = 24
t = np.linspace(0,n,n)
def load(t):
return -10*np.sin(2*np.pi*t/24)+40
Load = load(t)
Gen = np.ones(n)*40
def need(t):
return 10*np.sin(2*np.pi*t/24)+10
#Set up Model
m = GEKKO()
m.time = t
Cons = m.Param(value=Load)
Enuc = m.FV(value=45, lb=0) #nuclear power
Enuc.STATUS = 1
#Thermal Energy Storage
T = m.SV(value=300,ub=500,lb=300)
mass = m.FV(value=.0746,lb=0)
mass.STATUS=0
Cp = m.Param(value=5)
thermaleff = .8 #80%efficient
thermeff = m.if3((Enuc - Cons)/(mass*Cp),1/thermaleff,thermaleff)
#Battery Electrical storage
Capacity = 76.2
EStored = m.SV(value=0,lb=0,ub=Capacity)
batteryeff = .95
batteff = m.if3((Enuc - Cons),1/batteryeff,batteryeff)
#Energy Balance
Cost = m.Var()
eneed = m.sign2(Enuc-Cons) #gives sign of energy need for energy storage or removal from storage
eswitch = m.if3(eneed,0, 1) #Turns eneed into a binary switch
switch = m.if3(eswitch*(Capacity-EStored)+(1-eswitch)*(EStored),0,1) #supposed to charge battery until at capacity and then discharge until EStored is 0. Then use thermal energy second
m.Equation(EStored.dt() == (switch)*batteff*(Enuc - Cons)) #Energy balance for Battery
m.Equation(T.dt() == (1-switch)*thermeff*(Enuc - Cons)/(mass*Cp)) #Energy balance for Thermal Storage
m.Equation(Cost == Enuc*1000 )
m.Obj(Cost)
m.options.IMODE = 5
m.options.SOLVER = 3
m.solve()
#plot
plt.subplot(3,1,1)
plt.plot(t,Load)
plt.plot(t,Enuc.value, label=f'Enuc = {Enuc.value[-1]}')
plt.ylabel("Energy")
plt.legend()
plt.subplot(3,1,2)
plt.plot(t,EStored.value, label=f'Capacity = {np.max(EStored.value):.03}')
plt.title("Battery Storage")
plt.ylabel("Energy")
plt.legend()
plt.subplot(3,1,3)
plt.plot(t,T.value,label=f'mass = {mass.value[-1]:.03}')
plt.title("Thermal Storage")
plt.ylabel("Temperature(K)")
plt.legend()
plt.show()```
最佳答案
您可以使用松弛变量代替切换条件。这是一个简单的问题,有两个水箱,总入口流量为 100
。入口流量可以在两个水箱之间分开,但水箱的最大容积分别为 300
和 1000
。 Tank 2 使用起来更昂贵(就像您的热能系统)。
import numpy as np
from gekko import GEKKO
m = GEKKO(remote=False)
m.time = np.linspace(0,10,100)
t = m.Var(0); m.Equation(t.dt()==1) # define time
flow = 100
V1 = m.Var(0,lb=0,ub=300) # tank 1
inlet1 = m.MV(0,lb=0); inlet1.STATUS = 1; inlet1.DCOST = 1e-4
m.Minimize(inlet1)
V2 = m.Var(0,lb=0,ub=1000) # tank 2
inlet2 = m.MV(0,lb=0); inlet2.STATUS = 1; inlet2.DCOST = 1e-4
m.Minimize(10*inlet2) # more expensive
# use tank 2 if tank 1 is projected to be filled
# only one in use, could also use inlet1*inlet2==0 to
# enforce the complementarity condition
m.Minimize(inlet1*inlet2)
# mass balance
m.Equation(flow==inlet1+inlet2)
m.Equations([V1.dt()==inlet1,V2.dt()==inlet2])
m.options.IMODE = 6
m.solve(disp=False)
import matplotlib.pyplot as plt
plt.plot(m.time,inlet1.value,'r--',label='Inlet 1')
plt.plot(m.time,V1.value,'r-',label='Volume 1')
plt.plot(m.time,inlet2.value,'b--',label='Inlet 2')
plt.plot(m.time,V2.value,'b-',label='Volume 2')
plt.grid()
plt.legend()
plt.show()
如果优化器知道电能和热能存储都将被填满,那么何时存储就不一定重要了。如果您确实希望逻辑条件强制执行优先级,则 m.if3()
语句可能更好,但也可能更难解决。如果您可以同时对电能和热能进行充电,那么也不需要互补执行器 m.Minimize(inlet1*inlet2)
,它提供了一个不同但仍然是最佳的解决方案。
在这两种情况下, jar 1 都是更便宜的选择,因此它会达到容量并最大限度地减少 jar 2 的填充。对于您的情况,这可能是更好的解决方案,因为这样您就不需要可能导致问题的切换条件。电池存储将完全充满,但如果预测电池将在夜间需要存储电力时充满,则它可能会在充满热能的同时完成。
关于python - 让优化器根据容量和净负载切换电力存储,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61411129/
我在 iOS 上有一个使用 WebSQL 数据库的 PhoneGap 应用程序。在某些地方,我读到存储容量是 5MB,而在其他地方,我读到它是 50MB,有人可以帮我解决这个问题吗?我还计划在数据库中
我想弄清楚如何更新节点的 pod 容量。我使用文档中概述的 Vagrant/VM 环境进行了简单的集群设置。我尝试使用 kubectl 修补节点的 pod 容量,执行以下操作: 通过以下方式发送补丁所
我想创建一个函数,根据某人系统上的可用 RAM 大小来导入不同批处理的数据。但是如何找到 R 中的可用 RAM 量呢?我可以使用 memory.size() 但这只适用于 Windows。 最佳答案
目前,我正在努力将 Power BI 内容嵌入到我的 Web 应用程序中。我已经通过服务主体实现了它,并且它按预期工作。但是对于产品环境,是否必须为我的报告或工作区添加容量?是否可以在不增加生产环境容
我有一个 3 节点 coros kubernetes 集群启动并运行。 我想使用来自独立 NFS 服务器的 persitentvolumes(pv)。 nfs.yaml apiVersion: v1
我正在学习golang一段时间。我遇到了 channel 问题。 我有两个例子。它们看起来一样,但是其中1个给出了错误。 当我分配 channel 容量(转换为缓冲 channel )时,问题已解决,
我正在尝试创建一个子例程,将一个字符串插入另一个字符串。我想检查主机字符串是否有足够的容量来容纳所有字符,如果没有,则返回错误整数。这需要使用类似 sizeof 的东西,但可以使用指针调用。我的代码如
这个问题在这里已经有了答案: size vs capacity of a vector? (8 个答案) 关闭 7 年前。 在下面的程序中,我只是创建了一个空 vector ,然后将大小调整为 5
免责声明 1 - 我是编程新手免责声明 2 - 我搜索了又搜索,但找不到我正在寻找的帮助。 对于一个项目,我或多或少地以更精简的形式重写了 vector 类。我挂断的部分是编写 push_back 方
我对 BTree 的理解是: if root BTree size is 32, the level 1 have 1024 keys capacity the level 2 can sort 10
我有一个使用 ActionBar 的应用程序,我自己处理方向更改: android:configChanges="keyboard|keyboardHidden|orientation|screenS
如何将 hadoop DFS 的配置容量从默认的 50GB 增加到 100GB? 我目前的设置是在 centOS6 机器上运行的 hadoop 1.2.1,使用了 450GB 中的 120GB。已使用
我的问题是关于 slice 长度和容量。我在这里学习 Go:https://tour.golang.org/moretypes/11 . (我的问题被标记为可能与 this 重复;但是,事实并非如此。
现在尝试从教程中学习 Go,并且有一个非常基本的问题: func main() { a := make([]int, 5) // [0,0,0,0,0] len=5 cap=5 b :=
如何以以下格式获取有关数据库中所有表空间的信息。 TABLESPACE_NAME | FILE_NAME | ALLOCATED_MB | FREE_MB | CAPACITY | 有没有办法自
我想基于每个作业更改群集的减少插槽容量。也就是说, 最初,我为Tasktracker配置了8个reduce插槽,因此对于具有100个reduce任务的作业,将同时运行(8 * datanode数量)r
我正在运行单节点 Hadoop 部署。我知道我的应用程序需要多少数据,我可以设置(和重新设置)HDFS 使用的最大容量吗? 我已经尝试了以下方法,但似乎无法实现。 检查 hdfs-site.xml 和
我安装了 splunk 来监控和分析 hadoop 作业。我在其他节点的Jobtracker、forwarder和TA中安装splunk core和splunk hadoop app后,HDFS ca
vector::operator= 会改变 vector 容量吗?如果有,怎么做? vector的拷贝构造函数是否拷贝容量? 我查看了文档,但找不到具体答案。是否依赖于实现? 最佳答案 您可以保证:
将 SQL 数据库导出到存储时,我们的 DTU 容量已达到,这本质上意味着我们的系统性能受到严重影响。 这对我们来说是一个问题,因为我们使用导出功能来备份和移动数据库。 这个问题有解决办法吗? 最佳答
我是一名优秀的程序员,十分优秀!