【微电网】并网微电网运行经济性研究(Python代码实现)

简介: 【微电网】并网微电网运行经济性研究(Python代码实现)

👨‍🎓个人主页:研学社的博客

💥💥💞💞欢迎来到本博客❤️❤️💥💥



🏆博主优势:🌞🌞🌞博客内容尽量做到思维缜密,逻辑清晰,为了方便读者。



⛳️座右铭:行百里者,半于九十。


📋📋📋本文目录如下:🎁🎁🎁

目录

💥1 概述

📚2 运行结果

🎉3 参考文献

🌈4 Python代码、数据、详细文章讲解



💥1 概述

image.gif

在本文中,我们提出了我们的策略和算法来管理微电网中的能量,更具体地说,在考虑消费者负荷、太阳能发电和动态电价的情况下,每小时与主电网的能量交易。

该算法的主要目标是在用户负荷、太阳能发电和电价波动的情况下,优化储能系统( ESS )的运行,最大化微电网的货币效益。除了货币收益外,该算法还考虑了需要保留的最小能量,因为这对于确保微电网中关键任务操作的连续性至关重要。研究分析了两种能量管理算法的性能:1 )具有预测未来知识的模型预测控制线性规划( MPCLPF );2 )不具有未来知识的强化学习。在MPCLPF中,分析了不同的预测算法,并对最优预测算法进行了整合。下面是文章目录:

image.gif

image.gif

详细文章见第4部分。

📚2 运行结果

fig, ax = plt.subplots(1, 1, figsize = (7.5,5))

ax2 = ax.twinx()

PV_plot = ax.step(np.arange(24), df.iloc[0:24,0], 'ro-', label = "PV")

load_plot = ax.step(np.arange(24), df.iloc[0:24,1], 'b*-', label = "Load")

price_plot = ax2.step(np.arange(24), df.iloc[0:24,2], 'k.-', label = "RTP")


# Display all label in one box

plots = PV_plot + load_plot + price_plot

labels = [plot.get_label() for plot in plots]

ax.legend(plots, labels, loc = 0)

ax.set_xlabel("Hour")

ax.set_ylabel("Power (kW)")

ax2.set_ylabel("Price ($/ kWh)")


plt.show()

fig, ax = plt.subplots(3, 2, figsize = (15, 15))


ax[0, 0].step(np.arange(len(x[:,0])), x[:,0])

ax[0, 0].set_xlabel("Hour")

ax[0, 0].set_ylabel("PV (kW)")

ax[0, 1].step(np.arange(len(x[0:24,0])), x[0:24,0])

ax[0, 1].set_xlabel("Hour")

ax[0, 1].set_ylabel("PV (pu)")


ax[1, 0].step(np.arange(len(x[:,1])), x[:,1])

ax[1, 0].set_xlabel("Hour")

ax[1, 0].set_ylabel("Load (kW)")

ax[1, 1].step(np.arange(len(x[0:24,1])), x[0:24,1])

ax[1, 1].set_xlabel("Hour")

ax[1, 1].set_ylabel("Load (pu)")


ax[2, 0].step(np.arange(len(x[:,2])), x[:,2])

ax[2, 0].set_xlabel("Hour")

ax[2, 0].set_ylabel("Price ($/kWh)")

ax[2, 1].step(np.arange(len(x[0:24,2])), x[0:24,2])

ax[2, 1].set_xlabel("Hour")

ax[2, 1].set_ylabel("Price (pu)")


plt.show()

 

plt.plot(lstm.history.history["loss"], "-*", label="training")

plt.plot(lstm.history.history["val_loss"], "-o", label="validation")

plt.xticks(np.arange(0, 20, 2), np.arange(0, 20, 2))

plt.xlabel("Epoch")

plt.ylabel("MAE")

plt.legend()

plt.show()

encoder.load_weights(encoder.weights_dir)

decoder.load_weights(decoder.weights_dir)


y_train_pred, attentions = predict(x_train, y_train)

print ("Training MAE: {:.4f} pu\n".format(mae(y_train[:, :, 0], y_train_pred[:, :, 0])))


fig = plt.figure(figsize=(24, 5))

for idx, i in enumerate([0, 1000, 2000, 3000]):

 ax = fig.add_subplot(1, 4, idx+1)

 ax.plot(y_train_pred[i], "-*", label="prediction")

 ax.plot(y_train[i, :, 0], "-o", label="actual")

 ax.set_xlabel("Hour")

 ax.set_ylabel("Power (pu)")

 ax.legend(loc=2)

plt.show()

 

image.gif

plt.plot(lstm.history.history["loss"], "-*", label="training")

plt.plot(lstm.history.history["val_loss"], "-o", label="validation")

plt.xticks(np.arange(0, 20, 2), np.arange(0, 20, 2))

plt.xlabel("Epoch")

plt.ylabel("MAE")

plt.legend()

plt.show()

image.gif

 

idx = -10


num_steps_display = timesteps_in


attention = attention_weights

attention = tf.squeeze(attention["decoder_layer1_block2"][idx:idx+1], axis=0)


for head in range(0, num_heads):

 fig = plt.figure(figsize=(32,8))

 spec = gridspec.GridSpec(ncols=90, nrows=100)

 

 top_ax = fig.add_subplot(spec[0:15, 15:75])

 left_ax = fig.add_subplot(spec[25:, 0:10])

 right_ax = fig.add_subplot(spec[25:, 15:])

 

 top_ax.plot(x_train[idx, :num_steps_display, 0])

 top_ax.set_xlim([0, num_steps_display])

 top_ax.set_xticks(range(0, num_steps_display, 4))

 top_ax.set_xticklabels(range(0, num_steps_display, 4))


 left_ax.plot(decoder_input[idx, :, 0], range(0, timesteps_out))

 left_ax.set_yticks(range(0, timesteps_out, 4))

 left_ax.set_yticklabels(range(0, timesteps_out, 4))

 left_ax.invert_yaxis()


 sns.heatmap(attention[head][:, :num_steps_display], cmap="viridis", ax=right_ax)

 right_ax.set_xticks(range(0, num_steps_display, 4))

 right_ax.set_xticklabels(range(0, num_steps_display, 4))

 right_ax.set_yticks(range(0, timesteps_out, 4))

 right_ax.set_yticklabels(range(0, timesteps_out, 4))


 plt.title("Head {}".format(head+1))

 plt.show()

image.gif

def get_resultplot(SOC_list, action_list, x, start_idx, end_idx):

 hours = end_idx - start_idx

 if hours == 24:

   plt.figure(figsize = (8,7))

   plt.xticks(range(0, 24), range(1, 25))

 else:

   plt.figure(figsize = (25,5))

   plt.xticks(range(0, end_idx-start_idx, 24), range(1, end_idx-start_idx+1, 24))

 plt.step(range(0, hours), SOC_list[start_idx:end_idx], "ro-", label = "SOC")

 plt.step(range(0, hours), x[start_idx:end_idx, 2], "bs-", label = "price")

 plt.step(range(0, hours), x[start_idx:end_idx, 0], "g*-", label = "pv")

 plt.step(range(0, hours), x[start_idx:end_idx, 1], "m--", label = "load")

 plt.bar(range(0, hours), action_list[start_idx:end_idx],

         facecolor = "w", edgecolor = "k", label = "action")

 plt.ylabel("SOC/ Normalized Price")

 plt.xlabel("Hour")

 plt.legend(loc=2)

 plt.show()  

image.gif

# Case 1 - Charged with PV not with grid to contain excess PV even the price is higher than average

# Use the spare capacity to store PV

# Not below the target SOC

start_idx = len(SOC_list) - 192

end_idx = len(SOC_list) - 168

get_resultplot(SOC_list, action_list, x, start_idx, end_idx)

 

image.gif

 

# Zoom of case 3


fig, ax = plt.subplots(1, 1, figsize = (8,6))

#ax2 = ax.twinx()

ln1 = ax.step(range(0, 24), SOC_list[13079:13103], "ro-", label = "SOC")

ln2 = ax.bar(range(0, 24), action_list[13079:13103],

            facecolor = "w", edgecolor = "k", label = "action")

ln3 = ax.axhline(y  = 0.5, linestyle = "--", label = "target SOC")

ax.set_xlabel("Hour")

ax.set_ylabel("SOC")

lns = ln1 + [ln2] + [ln3]

labs = [l.get_label() for l in lns]

ax.legend(lns, labs, loc = 3)

plt.xticks(range(0, 24), range(1, 25))

plt.show()

image.gif

其余详细部分见第4部分。

🎉3 参考文献

部分理论来源于网络,如有侵权请联系删除。

image.gif编辑

 

🌈4 Python代码、数据、详细文章讲解

https://ttaozhi.com/t/p.html?id=2YA7W3RDkr

相关文章
|
7天前
|
监控 算法 安全
内网桌面监控软件深度解析:基于 Python 实现的 K-Means 算法研究
内网桌面监控软件通过实时监测员工操作,保障企业信息安全并提升效率。本文深入探讨K-Means聚类算法在该软件中的应用,解析其原理与实现。K-Means通过迭代更新簇中心,将数据划分为K个簇类,适用于行为分析、异常检测、资源优化及安全威胁识别等场景。文中提供了Python代码示例,展示如何实现K-Means算法,并模拟内网监控数据进行聚类分析。
28 10
|
23天前
|
存储 缓存 Java
Python高性能编程:五种核心优化技术的原理与Python代码
Python在高性能应用场景中常因执行速度不及C、C++等编译型语言而受质疑,但通过合理利用标准库的优化特性,如`__slots__`机制、列表推导式、`@lru_cache`装饰器和生成器等,可以显著提升代码效率。本文详细介绍了这些实用的性能优化技术,帮助开发者在不牺牲代码质量的前提下提高程序性能。实验数据表明,这些优化方法能在内存使用和计算效率方面带来显著改进,适用于大规模数据处理、递归计算等场景。
58 5
Python高性能编程:五种核心优化技术的原理与Python代码
|
28天前
|
数据采集 数据可视化 数据挖掘
金融波动率的多模型建模研究:GARCH族与HAR模型的Python实现与对比分析
本文探讨了金融资产波动率建模中的三种主流方法:GARCH、GJR-GARCH和HAR模型,基于SPY的实际交易数据进行实证分析。GARCH模型捕捉波动率聚类特征,GJR-GARCH引入杠杆效应,HAR整合多时间尺度波动率信息。通过Python实现模型估计与性能比较,展示了各模型在风险管理、衍生品定价等领域的应用优势。
251 66
金融波动率的多模型建模研究:GARCH族与HAR模型的Python实现与对比分析
|
2月前
|
Python
课程设计项目之基于Python实现围棋游戏代码
游戏进去默认为九路玩法,当然也可以选择十三路或是十九路玩法 使用pycharam打开项目,pip安装模块并引用,然后运行即可, 代码每行都有详细的注释,可以做课程设计或者毕业设计项目参考
78 33
|
2月前
|
JavaScript API C#
【Azure Developer】Python代码调用Graph API将外部用户添加到组,结果无效,也无错误信息
根据Graph API文档,在单个请求中将多个成员添加到组时,Python代码示例中的`members@odata.bind`被错误写为`members@odata_bind`,导致用户未成功添加。
52 10
|
2月前
|
Shell 开发工具 Python
如何在vim里直接运行python程序
如何在vim里直接运行python程序
|
2月前
|
数据挖掘 vr&ar C++
让UE自动运行Python脚本:实现与实例解析
本文介绍如何配置Unreal Engine(UE)以自动运行Python脚本,提高开发效率。通过安装Python、配置UE环境及使用第三方插件,实现Python与UE的集成。结合蓝图和C++示例,展示自动化任务处理、关卡生成及数据分析等应用场景。
178 5
|
文字识别 算法 前端开发
100行Python代码实现一款高精度免费OCR工具
近期Github开源了一款基于Python开发、名为Textshot的截图工具,刚开源不到半个月已经500+Star。
|
2月前
|
Python
[oeasy]python055_python编程_容易出现的问题_函数名的重新赋值_print_int
本文介绍了Python编程中容易出现的问题,特别是函数名、类名和模块名的重新赋值。通过具体示例展示了将内建函数(如`print`、`int`、`max`)或模块名(如`os`)重新赋值为其他类型后,会导致原有功能失效。例如,将`print`赋值为整数后,无法再用其输出内容;将`int`赋值为整数后,无法再进行类型转换。重新赋值后,这些名称失去了原有的功能,可能导致程序错误。总结指出,已有的函数名、类名和模块名不适合覆盖赋新值,否则会失去原有功能。如果需要使用类似的变量名,建议采用其他命名方式以避免冲突。
52 14
|
2月前
|
分布式计算 大数据 数据处理
技术评测:MaxCompute MaxFrame——阿里云自研分布式计算框架的Python编程接口
随着大数据和人工智能技术的发展,数据处理的需求日益增长。阿里云推出的MaxCompute MaxFrame(简称“MaxFrame”)是一个专为Python开发者设计的分布式计算框架,它不仅支持Python编程接口,还能直接利用MaxCompute的云原生大数据计算资源和服务。本文将通过一系列最佳实践测评,探讨MaxFrame在分布式Pandas处理以及大语言模型数据处理场景中的表现,并分析其在实际工作中的应用潜力。
116 2

热门文章

最新文章

推荐镜像

更多