Charge and discharge of the supercapacitor
In this example, a supercapacitor is modeled, from which voltage readings are taken during its charging and subsequent discharge. To charge the supercapacitor for 100 seconds, a current of 100 mA is supplied to it from the mains. Then the supercapacitor is not used for one minute. During the next hour, a 50 mA load is connected for one second every 50 seconds to discharge the supercapacitor.
Model diagram:
Defining the function to load and run the model:
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]:
Running the simulation
In [ ]:
start_model_engee();
Writing simulation data to variables:
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]:
Data visualization
In [ ]:
using Plots
In [ ]:
p1 = plot(t, load_current, linewidth=2, label="Нагрузка, мА", ylabel="Ток, мА", lc=2)
p2 = plot(t, supercapacitor_voltage, linewidth=2, label="Напряжение суперконденсатора", xlabel="Время, с", ylabel="Напражение, В")
plot(p1, p2, layout=(2,1))
Out[0]: