超级电容器的充放电
在本例中,对超级电容器进行建模,在充电和随后的放电过程中,从超级电容器中获取电压读数。 为了给超级电容器充电100秒,从市电向其提供100mA的电流。 然后超级电容器一分钟不使用。 在接下来的一小时内,每50秒连接一个50mA负载一秒钟,以使超级电容器放电。
模型图:
定义加载和运行模型的函数:
In [ ]:
function start_model_engee()
try
engee.close("supercapacitor_charging_and_discharging_behavior", force=true) # 关闭模型
catch err # 如果没有模型关闭和engee。close()不执行,它将在catch之后加载。
m = engee.load("$(@__DIR__)/supercapacitor_charging_and_discharging_behavior.engee") # 加载模型
end;
try
engee.run(m, verbose=true) # 启动模型
catch err # 如果模型没有加载和engee。run()不执行,catch后最下面的两行将被执行。
m = engee.load("$(@__DIR__)/supercapacitor_charging_and_discharging_behavior.engee") # 加载模型
engee.run(m, verbose=true) # 启动模型
end
end
Out[0]:
运行模拟
In [ ]:
start_model_engee();
将仿真数据写入变量:
In [ ]:
t = simout["supercapacitor_charging_and_discharging_behavior/SysOutput_1"].time[:]
load_current = simout["supercapacitor_charging_and_discharging_behavior/SysOutput_1"].value[:]
supercapacitor_voltage = simout["supercapacitor_charging_and_discharging_behavior/SysOutput_2"].value[:]
Out[0]:
数据可视化
In [ ]:
using Plots
In [ ]:
p1 = plot(t, load_current, linewidth=2, label="负载,mA", ylabel="电流,mA", lc=2)
p2 = plot(t, supercapacitor_voltage, linewidth=2, label="超级电容器电压", xlabel="时间,从", ylabel="例如,在")
plot(p1, p2, layout=(2,1))
Out[0]: