SkillAgentSearch skills...

OpenWasteWater

OpenModelica Wastewater library

Install / Use

/learn @jobehrendt/OpenWasteWater
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

OpenWasteWater (OpenModelica library)

with Openmodelica (www.openmodelica.org)

Main Author:
Joachim Behrendt
Hamburg University of Technology
Institute of Wastewater Management and Water Protection
Eissendorfer Str. 42
21073 Hamburg, Germany
email: j.behrendt@tuhh.de

Motivation

This package is developed manly for teaching purposed at TUHH. The students should learn process modelling features and the complexity of the wastewater treatment system. The modelica language was a very fruitful approach, because the students can develop a complex model and don’t have to worry about the numerical methods to solve their equation. To give the student a sustainable tool, open source software was required. Thank’s to Lund University to publish the OpenModelica platform (www.openmodelica.org) that included the modelica library. The basic constructs are working perfectly but many libraries (as well as third party libraries) are leading to frustration, because they have a limited documentation and have bugs in OpenModelica. The Open Modelica User’s Guide is available in the newest version (“OpenModelica User’s Guide” n.d.) at https://www.openmodelica.org/doc/OpenModelicaUsersGuide/OpenModelicaUsersGuide-latest.pdf

The Wastewater package, originally developed by Gerald Reichl ((Reichl et al. 2006)) were adopted to Dymola, (C) Dassault Systèmes(R), where the free version is not able to solve these amount on equations. In Modelica a concept of “connector” exist that is relaxed in Dymola. Another argument is to develop a wastewater library for wastewater professional/student to make use in practise and education. The original approach was more adopted to control engineering and matlab/simulik.

Gerald Reichl took a lot of work to make nice icons, that are recycled in this approach. He made modells for ASM 1,2d, and 3 and different clarifier models. Here we are focusing on the ASM1 only and a simplified clarifier model and the model of Takács (1991) only. The clarifier model have a minor effect to the result and one model gives a good base for further development. In addition, a sludge treatment in involved, with thickener und centrifuge as well as anaerobic digester. The Anaerobic digester model ADM is mainly developed for sludge digestion. The implementation was mainly done by Moritz Liedke (Liedke, Moritz 2017) in the frame of his master thesis at TUHH.

In the frame of this documentation the wastewater models are not explained. Please refer following references: (Henze 2007), ((Batstone et al. 2002)),(Copp, John B. 2001) and (Copp et al. 2002)

Basic concept of the Wastewater Model

This library offers tools to make an advanced model for a wastewater treatment plant including sludge treatment. As modelling base the ASM1 and the ADM1 were chosen and can be adapted to the individual needs. The library can be used in teaching, research and as well in optimisation of existing WWTP. The model starts always with a source, where the concentrations, the flow rate and the temperature are defined. The flow is directed to the wastewater sink(s). All internal flows like recirculation, or dividing has to be realised with pumps to fulfil the requirements of a flow variables in modelica.

For every flow variable in modelca, a potential variable is required. For a flow this should be the pressure, but we don’t make hydrodynamic modelling. Therefore, the temperature is chosen to be the potential variable an in declared in the inflow. The stream variables are not declared as stream variables, because the our wastewater components are grouped in form of records. For stream variables don’t work with records. It is not possible to add variables we have to use the prefix input or output. This explications may confuses, but you are getting it while reading the part where the connectors are explained.

The modelling can be done graphically. You can create a new model and place the sub-model via mouse to the new model. The model without icons are not intended for the direct use. Now you can connect the model with the mouse clicking on a output connector, moving the mouse to an input connector and clicking here again. Then a line should be sketched. You can click on the way as well to achieve a better looking line. If the model is complete, please save it. If no error occurs, you can run the model and have fun.

Description of the model

Data types

Beside of common data types like (Real, Integer, Boolean…) data are combined in a special class record. Record of Soluble and Particulate are defined, where the components are representing the dissolved or particulate components.

record Soluble
  Real O2 "gO2/m3 dissolved oxygen";
  Real I "gCOD/m3 inert soluble organic material";
  Real S "gCOD/m3 readily biodegradable organic substances";
  Real NH "gN/m3 ammonium + ammonia N";
  Real NO "gN/m3 nitrite + nitrate N";
  Real ND "gN/m3 dissolved organic N";
  Real ALK "mol/m3 alkalinity";
end Soluble;

record Particulate
  Real H "gCOD/m3 heterotrophic bacteria";
  Real A "gCOD/m3 autotrophic bacteria";
  Real S "gCOD/m3 particulate slowly degradable substrates";
  Real I "gCOD/m3 inert particulate organic material";
  Real P "gCOD/m3 inert particulate organic matter resulting from decay";
  Real ND "gN/m3 particulate organic nitrogen";
end Particulate;

The use of this records makes the formulation of connectors easier. The data type record can used as component references in expressions

Sini =  Soluble(I = 30, S = 1.15, O2 = 4.0, NH = 0.2, NO = 10.9, ND = 0.9, ALK = 3.54);

Sini can be used as initial condition in the initial equation block.

Functions

Only few functions are formulated. These functions has to adapt to your specified needs.

1. Calculation of the saturation concentration of oxygen

function fS_O2sat
  input Real T;
  output Real S_O2sat;
algorithm
  S_O2sat := exp(7.7117 - 1.31403 * log(T + 45.93));
  annotation(
    defaultComponentName = "fS_O2sat",
    Documentation(info = "<html>
    <H1 style=\"font-size:20px\">Saturation concnetration of oygen </H1>
    <p style=\"font-size:20px\">
    This function determines the saturation concentration of
    oxygen in water aerated with air as function
    of the temperature<br />
    (T in °C S_O2sat in g/m3 at a pressure of 1013 hPa)<br />
    from Mortimer, 1981
    </p>
  </html>"));
end fS_O2sat;

A correlation of the saturation concentration with the temperature is used. The empirical equation has been adopted from ((Mortimer 1981, eq. 6 page 13)). Additionally a ß-value can be introduces. The ß-value is the relation between the saturation concentration in the wastewater and the saturation concentration in pure water. For municipal wastewater ß is in the range of 0.95 - 1.

2. Calculating the volumetric mass transfer coefficient for oxygen

function fkLa
  output Real kLa "specific mass transfer coefficient, 1/d";
  input Real Q "air flow rate, m³/d";
  input Real V_R = 1333 "reactor volume, m³";
  input Real H = 4.5 "fluid height, m";
protected
  Real kLa_stern "-";
  Real v = 10 ^ (-6) "kinematic viscosity of water, m²/s";
  Real g = 9.81 "gravity, m/s²";
  Real w "m/d";
  Real w_stern "-";
algorithm
  w := Q * H / V_R;
  w_stern := w / (84600 * (g * v) ^ (1 / 3));
  kLa_stern := 1.17 * 10 ^ (-4) * w_stern ^ (-0.1);
  kLa := kLa_stern * w / (v ^ 2 / g) ^ (1 / 3);
  annotation(
    defaultComponentName = "klacalc",
    Documentation(info = "<html>
<H1 style=\"font-size:20px\">kLa calculation</H1>
<p style=\"font-size:20px\">
This function calculates the specific mass transfer coefficient kLa in '1/d' for a defined air flow rate Q_air.
The division by 84600 in the term 'w_stern' is the conversion from m/d to m/s in order to fit with the units of gravity [m/s²] and viscosity [m²/s].
The equations are valid for a gas distribution systems with perforated bottom, sintered plate or frit.
Based on
'M. Zlokarnik. Verfahrenstechnische Grundlagen der reaktorgestaltung. Acta Biotechnologica 1, 1981.'
</p> </html>"));
end fkLa;

The main input is the Air flow rate in m<sup>3</sup>/d. The reactor volume in the depth is required as well for the geometry of the reactor. In these case a correlation of Zlokarnik ((Zlokarnik 1981)) is used, but you may modify this for your need. As well the α value should be considered in this function. The α value is the relation of the mass transfer coefficient for wastewater and pure water. For municipal wastewater α is in the range 0.6 — 1.

3. Sedimentation flux

The sedimentation flux is needed in the secondary clarifier model. The sedimentation flux is the product of the particle concentration and the sedimentation velocity. Because the ASM1 is a COD-based model, the solid concentration is given as COD as well. The sedimentation velocity is calculated as suggested by (Takács 1991). As transformation factor between TSS and COD 0.75 is chosen. For model modification another model for calculation the sedimentation flux can be introduced.

function fJS "Sedimentation velocity function"
  input Real X "g/m3";
  output Real JS "g/(m2 d)";
protected
  Real v0str, v0 "maximum settling velocity";
  Real nv "exponent as part of the Vesilind equation";
  Real XTSS;
  Real rh, rp;
algorithm
  v0 := 474.0 "m/d";
  v0str := 250.0 "m/d";
  rh := 0.000576 "m3/(g SS)";
  rp := 0.00286 "m3/(g SS)";
  XTSS := X * 0.75;
  JS := min(v0str, v0 * exp(-rh * XTSS) - v0 * exp(-rp * XTSS)) * XTSS / 0.75 "g/(m2 d)";
  annotation(
    defaultComponentName = "fJS",
    Documentation(info = "<html>
    <H1 style=\"font-size:20px\">Sludge Sedimentation Flux </H1>
View on GitHub
GitHub Stars19
CategoryDevelopment
Updated11h ago
Forks8

Languages

Modelica

Security Score

90/100

Audited on Apr 2, 2026

No findings