# Energy Management of a Multi-Source Power System
## 3 Methodology
### Heuristic Approach  
The developed mathematical model requires a long time to compute the optimal solution; therefore, a heuristic approach was developed to solve the problem under study. The developed heuristic identifies the smallest combination of sources needed to meet the demand of the system. The heuristic algorithm used, assuming two batteries, is shown in Figure 1 and detailed steps are as Algorithm 1:  
The heuristic starts with checking if the demand for power is greater than 200 W. The value of 200 W was chosen because the fuel cell provides 210 W of power at rated conditions. If the power demand is less than or equal to 200 W, the system will move into a charging mode. The system will turn on the fuel cell to meet the demand of the drone and check if there is an output from the photovoltaic cell. If the photovoltaic cell is providing an output, the system will check whether or not the super capacitor is fully charged. If the super capacitor is not fully charged, the photovoltaic cell will charge it. Next, the system will check if the batteries are fully charged; if not, they will be charged by the photovoltaic cell individually. On the other hand, if the photovoltaic cell does not provide an output, the system will take no action and move to the next time instant. If the power demand is greater than 200 W, the system will move to supply mode. First, the system will check if there is a spike in demand. A spike in demand is considered when the demand increases by 30% from a one-time instance to the next. This is done so that the system can discharge the super capacitor during spikes in demand due to the super capacitor's rapid discharge speed [36]. If there is a spike in power demand and the super capacitor is charged, the system will discharge the super capacitor along with other sources to meet the demand of the system. \begin{table}
\begin{tabular}{c c} \hline \hline
**Source** & **Weight** \\ \hline Battery & 0.39 \\ Fuel cell & 0.21 \\ SC & 0.27 \\ PV & 0.13 \\ \hline \hline \end{tabular}
\end{table} 
Table 7: Weights assigned to each of the sources. Figure 1: Demand profile. ```
1:for k = 1:10
2:if (\(P_{k}^{demand}>200\))
3:if\(P_{k}^{demand}<P_{k}^{PC}\)
4:\(S_{k}^{FC}=1\);
5:else if\(P_{k}^{demand}<P_{k}^{FC}+P_{k}^{PV}\)
6:\(S_{k}^{FC}=1\);
7:\(S_{k}^{PV}=1\);
8:else if\(SOC_{k}^{B_{1}}>47\)
9:if\(P_{k}^{demand}<P_{k}^{FC}+P_{k}^{PV}+P_{k}^{B_{1}}\)
10:\(S_{k}^{FC}=1\);
11:\(S_{k}^{PV}=1\);
12:\(S_{k}^{B_{1}}=1\);
13:else if\(SOC_{k}^{B_{2}}>47\). 14:\(S_{k}^{PC}=1\);
15:\(S_{k}^{BV}=1\);
16:\(S_{k}^{B_{1}}=1\);
17:\(S_{k}^{B_{2}}=1\);
18:else if\(SOC_{k}^{C}=100\)
19:\(S_{k}^{FC}=1\);
20:\(S_{k}^{PV}=1\);
21:\(S_{k}^{B_{1}}=1\);
22:\(S_{k}^{C}=1\);
23:end
24:else if\(SOC_{k}^{B_{2}}>47\). 25:\(S_{k}^{FC}=1\);
26:\(S_{k}^{PV}=1\);
27:\(S_{k}^{B_{2}}=1\);
28:else if\(SOC_{k}^{C}=100\)
29:\(S_{k}^{FC}=1\);
30:\(S_{k}^{PV}=1\);
31:\(S_{k}^{B_{2}}=1\);
32:\(S_{k}^{C}=1\);
33:end
34:endif
35:if\(P_{k}^{demand}\leq 200\)
36:if\(SOC_{k}^{C}<99\)
37:\(S_{k}^{PV}=1\);
38:\(S_{k}^{PV}=1\);
39:\(ch_{k}^{C}=1\);
40:else if\(SOC_{k}^{B_{1}}<100\)
41:\(S_{k}^{PV}=1\);
42:\(ch_{k}^{B_{1}}=1\);
43:else if\(SOC_{k}^{B_{2}}<100\)
44:\(S_{k}^{PV}=1\);
45:\(ch_{k}^{B_{2}}=1\);
46:endif
47:endfor
48:return\(S_{k}^{FC},S_{k}^{PV},S_{k}^{B_{1}},S_{k}^{B_{2}},S_{k}^{C},ch_{k}^{C},ch_{k}^{B_{ 1}},ch_{k}^{B_{2}}\)
```  
**Algorithm 1**Energy management Heuristic. On the other hand, if there is no spike in demand, the system will not discharge the super capacitor. Next, the system will check if there is an output from the photovoltaic cell to make use of the photovoltaic cell while it provides an output. Assuming that the photovoltaic cell is providing an output, the system will check which combination of sources along with the photovoltaic cell will be able to meet the demand of the system. For instance, if the photovoltaic cell and fuel cell are not enough to meet the demand, the system will first check the state-of-charge of the first battery.