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.
addRow()[source]

Add a row to the list of components.

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.
runModel()[source]

Run the actual model.

showErrorMessage(message)[source]

Popup a message box with an error message.

Parameters:message (str) – The message to display.
updateModelComponent()[source]

Action to perform when the component type dropbox changes.

It removes all parameter widgets for the respective row and adds the parameter widgets for the new component type.

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:

list

AquaponicsModeler.app.get_parameter_widget(name, type)[source]

Map a tuple with model parameter type information into a QtWidget set.

Parameters:
  • name (str) – The name of the parameter
  • type (tuple) – A tuple with parameter information. The first item is always the the second is the label to display and subsequent items might be needed to create the widget
Returns:

A list with QtWidgets.QtWidget for all widgets for this parameter.

Return type:

list

AquaponicsModeler.app.main()[source]

Run the actual application.

AquaponicsModeler.interface module

class AquaponicsModeler.interface.Ui_MainWindow[source]

Bases: object

retranslateUi(MainWindow)[source]
setupUi(MainWindow)[source]

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 for Containers 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
get_state()[source]

Get the current contents of this container.

Returns:current state value
Return type:float
step()[source]

Step into the next iteration of the model.

class AquaponicsModeler.model.Container(previous, outflow, threshold, start_content=0)[source]

Bases: AquaponicsModeler.model.SimpleContainer

Parameters:
  • previous (Container) – The previous Container in the chain.
  • outflow (float) – The outflow speed of this container.
  • threshold (int) – The threshold contents after which the container outflow speed starts.
  • start_content (int) – The starting contents of the container.
get_current_outflow_speed()[source]

Determine the current flow speed of water from this container.

Returns:The current outflow speed.
Return type:float
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.

get_current_outflow_speed()[source]

Return the current outlflow speed.

Outflow starts when self.threshold has been reached and will continue at self.outflow speed until the container is empty.

Returns:The outflow speed of this Container
Return type:float
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.
get_current_outflow_speed()[source]

Return the pump speed of this pump.

Returns:The outflow speed of this pump in L/min.
Return type:float
step(time=10)[source]

Go through the next step of the pump state and return that state.

Parameters:time (int) – The time in seconds for which the pump state should be returned.
Returns:The state of the pump. 1=on 0=off.
Return type:int
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:
  • ontime (float) – The time in minutes the pump spends pumping.
  • offtime (float) – The time in minutes the pump is off.
  • outflow (float) – The speed at which the pump pumps in L/min.
get_current_outflow_speed()[source]

Return the current outflow (pump) speed.

It is determined by a timed switch that toggles the pump on and off.

Returns:The outflow speed in L/min
Return type:float
step(time=10)[source]

Go through the next step of the pump state and return that state.

Parameters:time (int) – The time in seconds for which the pump state should be returned.
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:
  • r1 (int) – The value in Ohm of resistor 1 for the 555 timer.
  • r2 (int) – The value in Ohm of resistor 2 for the 555 timer.
  • c (int) – The value of the capacitor in uF for the 555 timer
  • outflow (float) – The speed at which the pump pumps in L/min.
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:
  • r1 (int) – The value in Ohm of resistor 1 for the 555 timer.
  • r2 (int) – The value in Ohm of resistor 2 for the 555 timer.
  • c (int) – The value of the capacitor in uF for the 555 timer
  • outflow (float) – The speed at which the pump pumps in L/min.
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.
get_current_outflow_speed()[source]

Return the pump speed of this pump.

Returns:The outflow speed of this source in L/min.
Return type:float
step(time=10)[source]

Go through the next step of the source.

Parameters:time (int) – The time in seconds for which the pump state should be returned.
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:
  • previous (Container) – The previous Container in the chain.
  • outflow (float) – The outflow speed of this container.
  • threshold (int) – The threshold contents after which the container outflow speed starts.
  • start_content (int) – The starting contents of the container.
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
get_current_outflow_speed()[source]

Determine the current flow speed of water from this container.

Returns:The current outflow speed.
Return type:float
step(time=10)[source]

Go through the next step of the simulation of this container.

Parameters:time (int) – The length of the next step in seconds.
AquaponicsModeler.model.get_components()[source]

Get all available component types.

Returns:Return a list of all component classes.
Return type:list

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.

addFigure()[source]

Add a new figure to the canvas, plotList and toolbar widgets.

delFigure()[source]

Remove the current figure form the canvas and toolbar widgets.

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.
restoreFigure(item)[source]

Restore a previously created plot to the canvas and toolbar widgets.

Parameters:item (QListWidgetItem) – The item that was clicked in self.plotList.

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:
  • title (string) – The title to be used in the legend.
  • values (list) – A list of y-axis values to for this line.
  • params (list) – A list of model parameters containing (title, value)
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:
  • x_title (string) – The title for the x-axis
  • y_title (string) – The title for the y-axis
  • x_values (list) – A list of values for the x-axis.
  • dataItems (list) – A list of DataItem objects, one for each line.
class AquaponicsModeler.plotdata.PlotData(dataSeries, description)[source]

Bases: object

PlotData contains data necessary to create plots from a model run.

Init the Plot Data.

Parameters:
  • dataSeries (list) – A list of DataSeries items for this plot.
  • description (string) – A description to display below the plot.

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.