Skip to main content

Simulation of hydroponic farming

Project description

Project Logo

Coverage Status

Project Hydroponic simulation


This python package aims to provide some basic tools to simulate hydroponic plant growing.🌱 Hydroponics is a farming method where plants grow without soil and instead use a solution containing the required mineral nutriments.👨‍🌾 This technique is already widely used because it is more efficient in water usage and is in development for farming on mars.🪐🚀

In particular, this package allows you to simulate the concentration of minerals and the pH of hydroponic solutions, determine the pH and check the solubility among others. See the "Basic Usage" section below and "example.ipynb" document for further examples and explainantions of the package.

Also see the Githubwebpages associated with this project to see the full documentation: hydroponics.

Learn more about hydropics with the following links:


0. Usage 🔥

import hydroponics as hp

plant_name = "Tomato"
required_nutriments = {"Na+": 0.1, "NO3(-)": 0.5, "K+": 0.2} #minerals needed by the plant
solution = {"Na+": 0.2, "NO3(-)": 0.6, "K+": 0.3} #composition of the solution {"ion_name":conc. [g/L]}
analysed_ions = ["Na+", "NO3(-)", "K+"] #ions for which the conc. will be analysed
volume = 2 #L
growth_time = 20 #days
forbidden_ions = ["Cl-"] #ions you don't want in the solution

# Generate an awsome simulation report (PDF)
hp.generate_report(plant_name, required_nutriments, growth_time, analysed_ions, solution, volume, forbidden_ions = forbidden_ions)

This usage example shows how to quickly use the package's main functionality: generate_report that will provide a lot of essential informations of the simulation. 📝


1. Installation 👩‍💻

Everything is just one pip install away - philippe schwaller


The following pip command can be used to install the python package. The package was made with python 3.10

pip install better-hydroponics==0.1.1

Be aware, the package uses the following dependencies:

  • Numpy (1.26.4)
  • Pandas (2.2.2)
  • matplotlib (3.8.4)
  • sympy (1.12)
  • openpyxl (3.1.2)

Please install the dependencies with their according pip install commands in the right environment.


2. Basic Usage

The package uses python dictionaries to store the concentration of the different salts/ion in the solution. By default concentrations are given in [g/L]. However different functions exist to convert g/L to mol/L and inversly.

Start by importing the package:

import hydroponics as hp

To determine the quantity of each salt to add to the solution to obain the desired concentration of each ion one can use the make_solution function. This function checks the solubility of the salt. 🧑‍🔬

ion_composition = {"K+":0.1, "Cl-": 0.3, "H2PO4(-)":0.5, "Ca(2+)":0.4} #desired concentrations in [g/L]
volume = 10 #L
forbidden_ions = ["Li+", "SO4(2-)"]

salts_to_add = hp.make_solution(ion_composition, volume, forbidden_ions)
print(salts_to_add)

One can visualise the evolution of the concentration of the ions as the plant grows with the plot_graph function.

#Define the variables
solution = {"Na+": 0.2, "NO3(-)": 0.6, "K+": 0.3} #composition of the solution {"ion_name":conc. [g/L]}
required_nutriments = {"Na+": 0.1, "NO3(-)": 0.5, "K+": 0.2} #minerals needed by the plant
growth_time = 20 #days
volume = 5 #L

#plot a figure that shows the concentration of ions as a function of time.
#The figure is directly downloaded in the current directory.
hp.plot_graph(solution, "ion", required_nutriments, growth_time, volume)

One can determine the pH of the solution given the concentration of the ions with the pH_approximation function:

solution = {"K+":0.1, "Cl-": 0.3, "H2PO4(-)":0.5, "Ca(2+)":0.4}
temperature = 25 #°C
pH = hp.pH_approximation(solution, temperature)
print(pH)

See the "tutorial.ipynb" notebook for more complete examples.

Or visit hydroponics to see the full documentation of the package.


3. Datasets

This package uses data from the PRIF17 (link) and the wikipedia page about solubility (wiki).

Accuracy of the results of the package are not guaranteed.

Some solutions and plant compositions are predefined (bell pepper 🫑, cucumber 🥒 and eggplant 🍆), please define a new dict or complete the excel file to use other solutions and new plants.


4. Licence and References

This package is under MIT license.

Please click on the MIT sign for further information

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

better_hydroponics-0.1.1.tar.gz (51.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

better_hydroponics-0.1.1-py3-none-any.whl (23.9 kB view details)

Uploaded Python 3

File details

Details for the file better_hydroponics-0.1.1.tar.gz.

File metadata

  • Download URL: better_hydroponics-0.1.1.tar.gz
  • Upload date:
  • Size: 51.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.10.14

File hashes

Hashes for better_hydroponics-0.1.1.tar.gz
Algorithm Hash digest
SHA256 6e330764664c690f99f848b410ec59ca4f04833671b951878dcb518bfa93755e
MD5 0b40a1a76a8c6c6ae5e5279217c72a91
BLAKE2b-256 7175e7d0a4c77ec8d8b63418715936965c71019da6ff9bbe6208f738d7949ac6

See more details on using hashes here.

File details

Details for the file better_hydroponics-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for better_hydroponics-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1c4bf2920f4156804667df504e9a6f6ad8fa5ea7bfc30b6b1dd8d5871d2712dd
MD5 b1b5f8365e0f683bd2c819f9d95104ba
BLAKE2b-256 e1da18b7dd6b5dd101cb2495208191d1e2edc2edd724086f5e686d74461c0908

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page