I am working on an energy system optimization with a storage device. I need the power stored or delivered by the battery to be = 0 when the state of charge is max (>= 100%) or min (<= 0%) respectively. The problem is both the power and the SOC are variables defined at each timestep. The parts of my code related to this are:

Code: Select all

```
Set t hours /t1*t24/;
Scalar PdisN /241.5/; *Discharge power of 1 cell
Scalar PchN /395/; *Charge power of 1 cell
Scalar DSOCdis /-0.01/; *SOC decrease while discharging at max power
Scalar DSOCch /0.01/; *SOC increase while charging at max power
[...]
Variables SOC(t);
Integer variables N_cells;
Positive variables pSTOR_Dis(t), pSTOR_Ch(t), [...];
Binary variable U;
N_cells.lo = 1;
SOC.lo(t) = 0; SOC.up(t) = 1; SOC.l(t) = 0.5;
Equations STORdis, STORch, SOCchange [...];
STORdis(t).. pSTOR_Dis(t) =l= N_cells * PdisN * U(t);
STORch(t).. pSTOR_Ch(t) =l= N_cells * (-PchN) * (U(t) - 1);
SOCchange(t).. SOC(t) =e= SOC(t-1) + (pSTOR_Dis(t) / (PdisN * N_cells)) * DSOCdis - (pSTOR_Ch(t) / (PchN * N_cells)) * DSOCch;
[...]
```

Code: Select all

```
STORfull(t) $ (SOC(t) ge 0.95).. pSTOR_Ch(t) =e= 0;
STORempty(t) $ (SOC(t) le 0.05).. pSTOR_Dis(t) =e= 0;
```

(I am using MINLP solver for now, but I still have to choose the best solver for the problem)

Thank you in advance!