AquaponicsModeler package¶
Submodules¶
AquaponicsModeler.app module¶
This module contains the actual Qt app.
-
class
AquaponicsModeler.app.
AquaponicsModeler
(log, parent=None)[source]¶ Bases:
PyQt5.QtWidgets.QMainWindow
,AquaponicsModeler.interface.Ui_MainWindow
The graphical interface to the aquaponics modeler.
Instantiate the application.
Parameters: - log (logging.Logger) – The logger to send log messages to.
- parent (PyQt5.Qt.QWidget) – The parent widget.
-
deleteSelectedRows
()[source]¶ Action to perform when the remove row button is clicked.
All component rows for which the checkbox was clicked are removed.
-
plotResults
(results, chain)[source]¶ Plot the results of a model run with matplotlib.
- results (list): A list of lists. The first item is the x-axis
- (time component). Subsequent items are series for each model component in the order in which they are in the chain. Each of these lists contains the state values of the component for each step through the model.
- chain (list): The model chain, which is a list of instances
- inheriting from
model.BaseModelClass
.
-
AquaponicsModeler.app.
run_model
(chain, timestep, runtime, log)[source]¶ Run the actual model and return the data series.
Parameters: - timestep (int) – The time steps (seconds) for the model Minimum is 1 second, max is 3600s (1 hour)
- runtime (int) – The total time (hours) the model should run for Minimum is 1 hour, maximum is 23 hours
- chain (list) – A list of model in the order they are
connected in the model. The componets should be instances of
classes inheriting from
<model.BaseModelCompontent>
- log (logging.Logger) – The logger to use for logging
Returns: - A list with an item for the time axis plus an item for
each model component in chain, with the data series for that component.
Return type:
AquaponicsModeler.interface module¶
AquaponicsModeler.model module¶
The AquaponicsModeler.model
module contains all components to be used in
models.
All model components are classes that should inherit from
BaseModelClass
. So far there are two groups of component types:
containers and pumps.
Containers
are compents that contain water and have water
flowing in or out. They need to have another component before them in the
model, so water can flow from one container to the other.
As Containers
always need a source of water, the first
component in the model is a Pump
. There are several types of pumps,
but they all assume an infinite water source that they can pump from, and they
pump into a Container
.
-
class
AquaponicsModeler.model.
BaseModelClass
[source]¶ Bases:
object
A base class for the model that other objects inherit from.
The BaseModelClass doesn’t implement much except for general methods to get the parameters for a component and to manage the state while stepping through the model. The state is the main variable manipulated by the model. For
Pump
it contains the on/off state, while forContainers
it contains the water volume of the container.-
classmethod
getParameters
()[source]¶ Return the model parameters.
Returns: The parameters for this class. Return type: collections.OrderedDict
-
classmethod
-
class
AquaponicsModeler.model.
Container
(previous, outflow, threshold, start_content=0)[source]¶ Bases:
AquaponicsModeler.model.SimpleContainer
Parameters:
-
class
AquaponicsModeler.model.
FloodDrainContainer
(*args, **kwargs)[source]¶ Bases:
AquaponicsModeler.model.Container
This
Container
will drain fully when the threshold has been reached.In other respects it works like other
Containers
but for the way it drains. A container with a U-siphon or bell siphon at the end will only start draining when the waterlevel has reached a maximum. When that happens, suction makes sure that all water is drained from the container at the speed specified in outflow.
-
class
AquaponicsModeler.model.
Pump
(outflow)[source]¶ Bases:
AquaponicsModeler.model.BaseModelClass
A general Pump object.
It pumps water into the system (from an unlimited source) and has a constant outflow speed. It doesn’t have contents (unlike containers for instance). The state attribute contains the on (1) or off (0) state of the pump, which is also what is plotted in the resulting graphs.
Parameters: outflow (float) – The speed at which the pump pumps.
-
class
AquaponicsModeler.model.
TimedPump
(ontime, offtime, outflow)[source]¶ Bases:
AquaponicsModeler.model.Pump
A pump like the Pump object.
This pump has timing parameters which periodically switch it on and off. This way the outflow speed of the pump is controlled. If it is on, it equals the outflow speed parameter, else it is 0.
Parameters:
-
class
AquaponicsModeler.model.
Timed555Pump
(r1, r2, c, outflow)[source]¶ Bases:
AquaponicsModeler.model.TimedPump
A pump like the
TimedPump
object.This pump gets resistor and capacitor values as input parameters instead of the actual ontime and offtime. This object assumes a 555 timer circuit in a-stable mode is used to switch the pump on and off. A relay is used for the actual switching which is on when the timer is high. The resistor values of the timer determine the on and off time.
Parameters:
-
class
AquaponicsModeler.model.
InvTimed555Pump
(r1, r2, c, outflow)[source]¶ Bases:
AquaponicsModeler.model.TimedPump
An inverted version of the
Timed555Pump
object.It works very similar, but the relay is inverted. The normally-off side of the relay is used to switch the pump off when the timer is high.
Parameters:
-
class
AquaponicsModeler.model.
WaterSource
(outflow)[source]¶ Bases:
AquaponicsModeler.model.BaseModelClass
A general Water Source object.
Water flows at a static speed from a source (spring or other source). It doesn’t have contents (unlike containers for instance).
Parameters: outflow (float) – The speed at which the watersource flows.
-
class
AquaponicsModeler.model.
SimpleContainer
(previous, outflow, start_content=0)[source]¶ Bases:
AquaponicsModeler.model.BaseModelClass
A container in the aquaponics loop.
Each container is a container/tank/basin/growbed/etc containing a volume of water, with possibly water flowing out into the next component and flowing into it from the previous container in the loop. The inflow speed of each container is determined by the outflow speed of the previous container. The outflow of each container only starts when in the treshold has been reached, and only if the contents of the container > 0 liters.
Parameters: -
get_current_inflow_speed
()[source]¶ Determine the current speed of water flowing into this container.
This is determined by the outflow speed of the previous container.
Returns: The current inflow speed. Return type: float
-
AquaponicsModeler.plotcanvas module¶
This module contains the plot window for the application.
-
class
AquaponicsModeler.plotcanvas.
PlotWindow
[source]¶ Bases:
PyQt5.QtWidgets.QWidget
The main plot window.
Init the plot window.
-
plot
(data, restore=False)[source]¶ Plot data on the canvas using Matplotlib.
Parameters: - data (PlotData) – A PlotData instance with the data to be plotted. It contains a list of DataSeries items with one instance for each subplot (only 2 supported now). Each subplot has a constant x-axis and y-axis scale but can contain multiple dataItems, each resulting in a separate line in the plot.
- restore (bool) – This tells the plot function whether we are restoring an old figure or adding a new one. In the first case the figure is not added to self.plotList as it is there already.
-
AquaponicsModeler.plotdata module¶
This module contais classes to package the model data necessary for plotting.
DataSeries is the main class of interest.
-
class
AquaponicsModeler.plotdata.
DataItem
(title, values, params)[source]¶ Bases:
object
One line in a plot. It contains y-axis values and a title.
Init the DataItem.
Parameters:
-
class
AquaponicsModeler.plotdata.
DataSeries
(x_title, y_title, x_values, dataItems)[source]¶ Bases:
object
DataSeries contains series of data to plot in a single plot.
The y-axis and x-axis scales should be identical for each dataItem. Each dataItem is represented by a line in the plot and legend.
Init the Data Series.
Parameters:
Module contents¶
Aquaponics Modeler is a graphical modeling tool for aquaponics water flow.
It allow you to model waterflow between different containers with different drain speeds and methods, in combination with different types of pumps. By creating your own chain of consecutive components, you can model how water flow between them in nice graphs.