diff --git a/Bio2Py Test/Bio2Py Test.ipynb b/Bio2Py Test/Bio2Py Test.ipynb new file mode 100644 index 0000000..b835265 --- /dev/null +++ b/Bio2Py Test/Bio2Py Test.ipynb @@ -0,0 +1,474 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Bio2Py test" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "import Bio2Py\n", + "import pandas as pd" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "**1. Loading influent data**" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "1.1 Constant influent" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [], + "source": [ + "#Multiple scenarios\n", + "column_names_c = ['Flow','COD (mg-COD/L)','TKN (mg-N/L)','TP (mg-P/L)','TS (mg-S/L)','Nitrate (mg-N/L)','pH','Alkalinity (mmol/L)','ISS total (mg-ISS/L)','Metal soluble - Ca (mg/L)','Metal soluble - Mg (mg/L)', 'Gas - Dissolved O2 (mg/L)']\n", + "inf_c = [[600,500,30,6.5,10,0,7.3,6,45,80,15,0],[700,400,30,5.3,10.2,0,7.2,6,45,80,15,0]]\n", + "inf_c= pd.DataFrame(inf_c, columns=column_names_c)\n", + "inf_c.head()\n", + "\n", + "#Single scenario\n", + "inf_c1 = [[500,500,30,6.5,10,0,7.3,6,45,80,15,0]]\n", + "inf_c1=pd.DataFrame(inf_c1, columns=column_names_c)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "1.2 Variable influent" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [], + "source": [ + "column_names_v = ['Time','Flow','COD (mg-COD/L)','TKN (mg-N/L)','TP (mg-P/L)','TS (mg-S/L)','Nitrate (mg-N/L)','pH','Alkalinity (mmol/L)','ISS total (mg-ISS/L)','Metal soluble - Ca (mg/L)','Metal soluble - Mg (mg/L)', 'Gas - Dissolved O2 (mg/L)']\n", + "\n", + "inf_v0 = [[0,900,500,30,7.2,10,0,7,6,45,80,15,0],[4,1000,400,30,7,10,0,7,6,45,80,15,0],[6,1040,600,30,7,10,0,7,6,45,80,15,0],[10,1200,800,40,7,10,0,7,6,45,80,15,0]]\n", + "inf_v1 = [[0,800,500,30,7.6,10,0,7,6,45,80,15,0],[1,1020,500,30,7,10,0,7,6,45,80,15,0],[3,1100,500,30,7,11,0,7,6,45,80,15,0],[9,1088,500,40,7,10,0,7,6,45,80,15,0]]\n", + "inf_v0= pd.DataFrame(inf_v0, columns=column_names_v)\n", + "inf_v1= pd.DataFrame(inf_v1, columns=column_names_v)\n", + "inf_v= {'inf_v0': inf_v0, 'inf_v1': inf_v1} #each dicctionary key corresponds to a variable influent scenario" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "**2. Getting ready**\n", + "\n", + "Bio2Py automatices the process of loading influent data, changing parameters and running simulations in BioWin. It is necessary to set the system configuration layout, project options, unit system, report options, etc before using Bio2Py. \n", + "\n", + "In order to use Bio2Py, **BioWin simulation window must be fully visible**, placing BioWin window on the left side of the screen is recomended. \n", + "\n", + "**Before using Bio2Py**:\n", + "- Open BioWin simulation file.\n", + "- Set the zoom to 100% on BioWin window.\n", + "- Manually run a single flow balance and steady state/dynamic simulation. Check for any warning messages that could interrupt Bio2Py process. If necessary, the user may consider disabling BioWin alarms to prevent Bio2Py interruption. \n", + "- Choose locations (if applicable): \n", + " - For saving BioWin generated reports with simulation results (File -> Report to Excel (TM) -> Choose directory).\n", + " - From where variable influent data will be loaded (Influent icon -> Open file -> Choose directory)(***). Only necessary if running simulations with variable influent. Choose the same filepath arg .\n", + "- Place BioWin simulation window on the left side of the screen. \n", + "- Make sure influent icon is visible. " + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [], + "source": [ + "filepath=r\"C:\\Users\\Usuario\\OneDrive - Facultad de Ingeniería\\Maestría\\Biowin - python\\bio2py test\\Bio2Py Test\" #replace with chosen filepath (***)" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [], + "source": [ + "simulation_window,influent_window=Bio2Py.setting_the_environment() \n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "**3. Steady state simulations**" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "3.1 Steady state simulation with constant influent" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "17:49:12.402: Flow balance\n", + "17:49:25.351: Steady State\n", + "17:50:01.048: Flow balance\n", + "17:50:13.688: Steady State\n" + ] + } + ], + "source": [ + "Bio2Py.steady_state_simulations('constant',inf_c,'seed','current',600,'table',filepath)" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
ElementsBOD - Total Carbonaceous [mg/L]COD - Total [mg/L]N - Total Kjeldahl Nitrogen [mgN/L]N - Total N [mgN/L]P - Soluble PO4-P [mgP/L]P - Total P [mgP/L]pH []Total suspended solids [mg/L]
0Influent245.21500.0030.0030.003.256.507.30242.71
1Effluent2.6835.661.8816.383.763.916.948.82
2Sludge359.592264.44125.05139.553.7642.696.942261.12
\n", + "
" + ], + "text/plain": [ + " Elements BOD - Total Carbonaceous [mg/L] COD - Total [mg/L] \\\n", + "0 Influent 245.21 500.00 \n", + "1 Effluent 2.68 35.66 \n", + "2 Sludge 359.59 2264.44 \n", + "\n", + " N - Total Kjeldahl Nitrogen [mgN/L] N - Total N [mgN/L] \\\n", + "0 30.00 30.00 \n", + "1 1.88 16.38 \n", + "2 125.05 139.55 \n", + "\n", + " P - Soluble PO4-P [mgP/L] P - Total P [mgP/L] pH [] \\\n", + "0 3.25 6.50 7.30 \n", + "1 3.76 3.91 6.94 \n", + "2 3.76 42.69 6.94 \n", + "\n", + " Total suspended solids [mg/L] \n", + "0 242.71 \n", + "1 8.82 \n", + "2 2261.12 " + ] + }, + "execution_count": 15, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "#Load results for steady state simulation, constant influent, scenario 0 (corresponds to influent=[600,500,30,6.5,10,0,7.3,6,45,80,15,0])\n", + "steady_state_c_0=pd.read_csv('steady_state_c_0.csv')\n", + "steady_state_c_0.head()" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
ElementsBOD - Total Carbonaceous [mg/L]COD - Total [mg/L]N - Total Kjeldahl Nitrogen [mgN/L]N - Total N [mgN/L]P - Soluble PO4-P [mgP/L]P - Total P [mgP/L]pH []Total suspended solids [mg/L]
0Influent196.16400.0030.0030.002.655.307.20203.17
1Effluent2.4628.971.8218.963.073.196.927.57
2Sludge356.712144.61119.25136.393.0740.156.922286.49
\n", + "
" + ], + "text/plain": [ + " Elements BOD - Total Carbonaceous [mg/L] COD - Total [mg/L] \\\n", + "0 Influent 196.16 400.00 \n", + "1 Effluent 2.46 28.97 \n", + "2 Sludge 356.71 2144.61 \n", + "\n", + " N - Total Kjeldahl Nitrogen [mgN/L] N - Total N [mgN/L] \\\n", + "0 30.00 30.00 \n", + "1 1.82 18.96 \n", + "2 119.25 136.39 \n", + "\n", + " P - Soluble PO4-P [mgP/L] P - Total P [mgP/L] pH [] \\\n", + "0 2.65 5.30 7.20 \n", + "1 3.07 3.19 6.92 \n", + "2 3.07 40.15 6.92 \n", + "\n", + " Total suspended solids [mg/L] \n", + "0 203.17 \n", + "1 7.57 \n", + "2 2286.49 " + ] + }, + "execution_count": 16, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "#Load results for steady state simulation, constant influent, scenario 1 (corresponds to influent=[700,400,30,5.3,10.2,0,7.2,6,45,80,15,0])\n", + "steady_state_c_1=pd.read_csv('steady_state_c_1.csv')\n", + "steady_state_c_1.head()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "3.2 Steady state simulation with variable influent" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "18:06:29.340: Flow balance\n", + "18:06:42.248: Steady State\n", + "18:07:12.071: Flow balance\n", + "18:07:25.169: Steady State\n" + ] + } + ], + "source": [ + "Bio2Py.steady_state_simulations('variable',inf_v,'seed','last',200,'none',filepath)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "**4. Dynamic simualtions**" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "4.1 Dynamic simulation with constant influent" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "18:08:16.335: Dynamic simulation\n", + "18:08:59.196: Dynamic simulation\n" + ] + } + ], + "source": [ + "Bio2Py.dynamic_simulations('constant',inf_c,'last',10,120)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "4.2 Dynamic simulation with constant influent" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "18:09:57.250: Dynamic simulation\n", + "18:10:46.904: Dynamic simulation\n" + ] + } + ], + "source": [ + "Bio2Py.dynamic_simulations('variable',inf_v,'last',5,120,filepath)" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "data2", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.12.0" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/Bio2Py Test/Bio2Py test BioWin 6.2.bwc b/Bio2Py Test/Bio2Py test BioWin 6.2.bwc new file mode 100644 index 0000000..4fa8abb Binary files /dev/null and b/Bio2Py Test/Bio2Py test BioWin 6.2.bwc differ