Gekko - repeat cycle and oxygen step for wastewater modeling

Viewed 16

I am moving some wastewater metabolic models across to Python, specifically some on polyphosphate accumulating organisms (PAOs). I have managed to move the model into Python and solving using Gekko which is great! (Still a few tweaks in the equations to be implemented).

Anaerobic storage polymer consumption

I can get the change in O2 to wokr and simluate supply of oxygen, however, I don’t quite know how to get it to repeat through multiple cycles to observe the changes in storage polymers over numerous cycles.

This code for a step in Oxygen (O2) worked for the initial cycle:

t = np.linspace(0, 19, 19) m.time = t

O2_step = np.zeros(19)

O2_step[17:] = 0.05

O2 = m.Param(value=O2_step)

I have tried the m.Options.CYCLECOUNT = 3 but it doesn’t seem to do the trick. Is there another way to set this up?

Any help would be greatly appreciated.

1 Answers

Every time m.solve() is called, the solution is time-shifted to the left by m.options.TIME_SHIFT (default=1). The new initial conditions are taken from the next time step and the problem is solved again. Change m.options.TIME_SHIFT=3 to make the 3rd time point the initial condition for the next solve. Set m.options.TIME_SHIFT=0 to have no change in the initial conditions. This allows different O2 profiles to be tested such as:

O2.value = np.ones(19)*0.5; O2.value[15:]=0.7
m.solve()

O2.value = np.ones(19)*0.6; O2.value[15:]=0.7
m.solve()

O2.value = np.ones(19)*0.8; O2.value[15:]=0.7
m.solve()
Related