Engee documentation
Notebook

Discharge-battery charge

This example demonstrates a simulation of a battery model with a rated voltage of 300 V and a capacity of 100 Ah. This demo example serves as a starting point if you want to simulate:

  • the subsystem of accumulation of SNE
  • Battery Cell Charge Control Unit (BMS)
  • Electric vehicle traction lithium-ion battery

The model uses a realistic DC link load profile, which is determined by the dynamic cycle of the electric vehicle. The total simulation time is 3600 seconds.

General view of the model

The model is based on the Battery library block (https://engee.com/helpcenter/stable/fmod-electricity-sources/battery.html ). In addition to the electrical ports, the Battery unit also has a thermal port for simulating thermal effects. It is important to take them into account when developing control systems, because with a critical increase in temperature, thermal acceleration, spontaneous combustion or explosion may occur. As you can see, the model consists of several networks located in different physical areas — thermal and electrical.

HV_battery.png

The battery is connected to a realistic DC link load profile, which is simulated using the From Workspace unit (https://engee.com/helpcenter/stable/base-lib-sources/from-workspace.html ). This unit transmits a load graph to the model in the form of a signal i = f(t) to a controlled current source.

Implementation of the model launch using software control:

Downloading the necessary libraries to import current versus time:

In [ ]:
Pkg.add(["MAT"])
In [ ]:
using DataFrames
using MAT
gr()
Out[0]:
Plots.GRBackend()

Reading a mat file and converting it to a WorkspaceArray for use in the From Workspace block:

In [ ]:
vars = matread("I_dc_discharge.mat");
data = vars["array"];
t = data[:,1];
current = data[:,2];
df = DataFrame(time=t, value=current);
I_dc = WorkspaceArray(string(rand()), df);
In [ ]:
vars = matread("I_dc_discharge.mat");
data = vars["array"];
t = data[:,1];
current = data[:,2];
df = DataFrame(time=t, value=current);
I_dc = WorkspaceArray(string(rand()), df);

Loading the model:

In [ ]:
model_name = "HV_battery"
model_name in [m.name for m in engee.get_all_models()] ? engee.open(model_name) : engee.load( "$(@__DIR__)/$(model_name).engee");

Launching the uploaded model:

In [ ]:
results = engee.run(model_name)
Out[0]:
Dict{String, DataFrame} with 4 entries:
  "Напряжение, В"          => 360001×2 DataFrame…
  "Температура батареи,°C" => 360001×2 DataFrame…
  "Ток, А"                 => 360001×2 DataFrame…
  "Заряд батареи, %"       => 360001×2 DataFrame

Simulation results

Importing simulation results:

In [ ]:
simulation_time = results["Напряжение, В"].time;
i = results["Ток, А"].value;
v = results["Напряжение, В"].value;
temperature = results["Температура батареи,°C"].value;
charge = results["Заряд батареи, %"].value;

Battery charge for a time interval from 0 to 500 seconds:

In [ ]:
plot(simulation_time[1:50000], charge[1:50000])
plot!(title = "Заряд батареи, %", ylabel = "Заряд батареи, %", xlabel="Время, c")
Out[0]:

Load current at a time interval from 0 to 500 seconds:

In [ ]:
plot(simulation_time[1:50000], i[1:50000])
plot!(title = "Ток, А", ylabel = "Ток, А", xlabel="Время, c")
Out[0]:

During the simulation, the battery is not only discharged, but also charged if the load current is in the opposite direction. This behavior occurs during the operation of the SNE when smoothing load fluctuations or during acceleration and braking of an electric vehicle.

Battery voltage for a time interval from 0 to 500 seconds:

In [ ]:
plot(simulation_time[1:50000], v[1:50000])
plot!(title = "Напряжение, В", ylabel = "Напряжение, В", xlabel="Время, c")
Out[0]:

Battery temperature for a time interval from 0 to 500 seconds:

In [ ]:
plot(simulation_time[1:50000], temperature[1:50000])
plot!(title = "Tемпература,°C", ylabel = "Tемпература,°C", xlabel="Время, c")
Out[0]:

Conclusions:

In this example, tools were used for command control of a battery model with a simulation duration of 1 hour. The battery load profile was imported into the Workspace from a mat file. The simulation results were imported into a script and visualized for a given time interval using interactive graphs from the Plots library.