Modeling Effluent Disposal Mixing Zone into the Ocean with OpenFOAM - Tutorial
/The use of advanced tools in the environmental impact assessment of common industrial process is a key factor that assures a correct design and the most realistic impact scenarios. Effluent disposal into the ocean is an important part of a coastal water treatment plant, if the disposal procedure is designed on a conservative approach, most probably the use of a diffuser plus hundreds of meters of pipeline would be required; however, the pipeline length and the difusser number would not prevent us to understand how the effluent is mixing with the ocean.
A right assessment of the effluent mixing zone would require a baseline of sea currents, discharge flows, seawater and effluent density, bathymetry, waves, infraestructure geometry and a tool that can analyse the interaction of the mentioned factors. OpenFOAM is a numerical model for Computational Fluid Dynamics (CFD) modeling capable of modeling fluids with complex geometries, conditions and requirements; with OpenFOAM one can model compressible/uncompressible, single phase / multiphase, flows that mix, non-newtonian flows, etc. OpenFOAM comes with build-in tools for model construction and visualization, and there is Salome Platform for advanced mesh generation.
This tutorial show the entire procedure for the simulation of a effluent of 40 l/s into the ocean that has a current of 0.05 m/s. The model is on transient conditions, model simulation were done under uniform discharge rates, the development of the mixing zone was analyzed with paraView tools and a water chemistry component was introduced into the simulation with some Python scripts.
Model Geometry
This is the layout of the model geometry with the vertex coordinates
Tutorial
First Part - Mesh generation
Second Part - Model Construction
Third Part - Output representation
Input data
You can download the input data for this tutorial here.
Python code
This is the code for the water chemistry component calculation
import os, tarfile, re, gzip os.chdir('C:\\OpenFOAM\\18.02\\USER-dev\\run\\effluentMixingZone') listaarchivos = os.listdir(os.getcwd()) listaarchivos[:5] # Hallamos el mayor valor de tiempo listatiempos = [] for tiempo in listaarchivos: try: listatiempos.append(int(tiempo)) except ValueError: pass tiemposimulacion = max(listatiempos) print('La simulacion tiene una longitud de ' + str(tiemposimulacion)) # Aqui definimos las concentraciones iniciales Conc_Agua=0.0001 Conc_Efluente=0.2 footer = ''' boundaryField { inlet { type zeroGradient; } outlet { type zeroGradient; } effluent { type inletOutlet; inletValue uniform 0.2; value uniform 0.2; } modelWall { type zeroGradient; } atmosphere { type zeroGradient; } ''' # Desempacamos los archivos zipeados de water y other for archivo in listatiempos: os.chdir(str(archivo)) #unpack and convert gzip files with gzip.open('alpha.water.gz', 'rb') as f: with open('alpha.water', 'w') as g: g.write(f.read().decode('utf-8')) with gzip.open('alpha.other.gz', 'rb') as f: with open('alpha.other', 'w') as g: g.write(f.read().decode('utf-8')) #read the text files with open('alpha.water', 'r') as f: lin_alphawater = f.readlines() with open('alpha.other', 'r') as f: lin_alphaother = f.readlines() #find the start and end of element sequence limTexto = [] for i, texto in enumerate(lin_alphawater): #print(texto) if 'internal' in texto: limTexto.append(i) if 'boundary' in texto: limTexto.append(i) print('This is the element length: ' + str(limTexto[1]-3-limTexto[0]-3)) #Empezamos el archivo de alpha.componente with open('alpha.componente', 'w') as componente: for linea in lin_alphawater[:limTexto[0]+3]: linea = re.sub('alpha.water','alpha.componente',linea) componente.write(linea) #Ahora hacemos la conversion for elemento in range(limTexto[0]+3,limTexto[1]-3): concMezcla = float(lin_alphawater[elemento])*Conc_Agua+float(lin_alphaother[elemento])*Conc_Efluente if concMezcla > 0.5: print(elemento) componente.write("%.6f" % concMezcla+'\n') componente.write(');\n') componente.write(footer) #os.system('gzip -f alpha.water alpha.other alpha.componente') with gzip.open('alpha.componente.gz', 'wb') as f: with open('alpha.componente', 'r') as g: f.write(g.read().encode('utf-8')) os.remove('alpha.water') os.remove('alpha.other') os.remove('alpha.componente') os.chdir(os.pardir)