Charge and discharge of a supercapacitor
In this example, a supercapacitor is modelled to take voltage readings when it is charged and then discharged. A current of 100 mA is applied from the mains to charge the supercapacitor for 100 seconds. The supercapacitor is then not used for one minute. For the next hour, a 50 mA load is applied every 50 seconds for one second to discharge the supercapacitor.
Schematic diagram of the model:

Define 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();
Write 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 visualisation
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]: