Apps
~~*~~ MATLAB Script
~~* ~~Python Script

->Attach:periodic_plot.png

----

A further example demonstrates a more complicated model for energy storage and retrieval. In this case, energy is stored during the first hours of the day when demand is lower. The power generation runs at a constant level while the energy storage is able to follow the cyclical demand. Energy storage is set to a periodic boundary condition to ensure that the beginning and end of the day have at least 100 units of stored energy. Scripts are available in both MATLAB and Python.

[[Attach:periodic_storage.zip|Periodic Energy Storage Script Files (periodic_storage.zip)]]
~~(:table border=1 width=100%~~:~~)~~

(:cell:) MATLAB

(:cell:)Python

~~(:cellnr:)~~ Attach:periodic_script_~~matlab~~.~~png~~

(:cell:) Attach:periodic_script_python.png

(:tableend:)

## Periodic Boundary Conditions

## Apps.PeriodicBoundaryConditions History

Hide minor edits - Show changes to output

Changed line 27 from:

[[Attach:periodic_storage.zip|Periodic Energy Storage Script Files (periodic_storage.zip)]]

to:

[[Attach:periodic_energy_storage.zip|Periodic Energy Storage Script Files (periodic_energy_storage.zip)]]

Changed lines 9-10 from:

The following example illustrates the use of the boundary condition. Scripts in MATLAB and Python are available below to recreate this solution.

to:

The following example illustrates the use of the boundary condition. Scripts in MATLAB and Python are available below to recreate this solution along with the model equations in APMonitor. Both MATLAB and Python scripts produce equivalent results.

Changed lines 13-16 from:

to:

APMonitor Model

->Attach:periodic_model.png

MATLAB Script

->Attach:periodic_model.png

MATLAB Script

Changed line 19 from:

to:

Python Script

Added lines 21-27:

->Attach:periodic_plot.png

----

A further example demonstrates a more complicated model for energy storage and retrieval. In this case, energy is stored during the first hours of the day when demand is lower. The power generation runs at a constant level while the energy storage is able to follow the cyclical demand. Energy storage is set to a periodic boundary condition to ensure that the beginning and end of the day have at least 100 units of stored energy. Scripts are available in both MATLAB and Python.

[[Attach:periodic_storage.zip|Periodic Energy Storage Script Files (periodic_storage.zip)]]

Changed lines 13-18 from:

(:cell:) MATLAB

(:cell:)

(:cell:) Attach:periodic_script_python.png

(:tableend:)

to:

* MATLAB Script

->Attach:periodic_script_matlab.png

* Python Script

->Attach:periodic_script_python.png

->Attach:periodic_script_matlab.png

* Python Script

->Attach:periodic_script_python.png

Changed lines 16-17 from:

(:cellnr~~:)~~

(:cell:) Attach:periodic_script_matlab.png

(:cell

to:

(:cellnr:) Attach:periodic_script_matlab.png

Added lines 1-19:

(:title Periodic Boundary Conditions:)

(:keywords periodic, Circadian rhythm, differential, algebraic, modeling language, numerical, boundary condition:)

(:description Solve dynamic estimation and optimization problems with periodic boundary conditions.:)

Periodic boundary conditions arise in any situation where the end point must be equal to the beginning point. This type of boundary condition is typical where something is repeating many times but the optimization or simulation only needs to take place over one cycle of that sequence. An examples of a repeating process is the body's natural [[https://en.wikipedia.org/wiki/Circadian_rhythm|Circadian rhythm]] or a power plant that produces power to follow daily demand cycles. Examples of periodic boundary conditions in natural cycles or in manufacturing processes give importance to these conditions in numerical simulation.

In the APMonitor software, boundary conditions are added for select variables with the use of a periodic object declaration. Linking this periodic object to a variable in the model enforces the periodic condition by adding an additional equation that the end point must be equal to the beginning point in the horizon.

The following example illustrates the use of the boundary condition. Scripts in MATLAB and Python are available below to recreate this solution.

[[Attach:periodic_example.zip|Periodic Example Script Files (periodic_example.zip)]]

(:table border=1 width=100%:)

(:cell:) MATLAB

(:cell:) Python

(:cellnr:)

(:cell:) Attach:periodic_script_matlab.png

(:cell:) Attach:periodic_script_python.png

(:tableend:)

(:keywords periodic, Circadian rhythm, differential, algebraic, modeling language, numerical, boundary condition:)

(:description Solve dynamic estimation and optimization problems with periodic boundary conditions.:)

Periodic boundary conditions arise in any situation where the end point must be equal to the beginning point. This type of boundary condition is typical where something is repeating many times but the optimization or simulation only needs to take place over one cycle of that sequence. An examples of a repeating process is the body's natural [[https://en.wikipedia.org/wiki/Circadian_rhythm|Circadian rhythm]] or a power plant that produces power to follow daily demand cycles. Examples of periodic boundary conditions in natural cycles or in manufacturing processes give importance to these conditions in numerical simulation.

In the APMonitor software, boundary conditions are added for select variables with the use of a periodic object declaration. Linking this periodic object to a variable in the model enforces the periodic condition by adding an additional equation that the end point must be equal to the beginning point in the horizon.

The following example illustrates the use of the boundary condition. Scripts in MATLAB and Python are available below to recreate this solution.

[[Attach:periodic_example.zip|Periodic Example Script Files (periodic_example.zip)]]

(:table border=1 width=100%:)

(:cell:) MATLAB

(:cell:) Python

(:cellnr:)

(:cell:) Attach:periodic_script_matlab.png

(:cell:) Attach:periodic_script_python.png

(:tableend:)