Skip to content

Commit

Permalink
commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
Keivan-A-Gh committed Sep 30, 2021
0 parents commit 63b1143
Show file tree
Hide file tree
Showing 289 changed files with 46,406 additions and 0 deletions.
Binary file added Documents/Master's Thesis - Final Edition.pdf
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
10 changes: 10 additions & 0 deletions Documents/Visualization of the Results/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Visualized Results
**By Keivan A.Gh.**

## Details
These four video clips are created based on the results of the initial OpenFOAM simulation for [temperature](./Temperature%20Contour.avi), [pressure](./Pressure%20Contour.avi), [mass fraction](./Mass%20Fraction%20Contour.avi), and [density](./Density%20Contour.avi) contours in the center of the flow field.


| Temperature [<img width="460" height="128" src="https://user-images.githubusercontent.com/44712667/135472329-80e3e9dc-ac24-4dc3-8fc2-0326b8da5576.gif">](./Temperature%20Contour.avi) | Pressure [<img width="460" height="128" src="https://user-images.githubusercontent.com/44712667/135472497-a896e69b-1abe-411c-b175-0f0a79d4117f.gif">](./Pressure%20Contour.avi) |
| :---: | :---: |
| **Mass Fraction** [<img width="460" height="128" src="https://user-images.githubusercontent.com/44712667/135472564-00cdd8e6-e4e8-4394-ba8c-0714e1fca1fc.gif">](./Mass%20Fraction%20Contour.avi) | **Density** [<img width="460" height="128" src="https://user-images.githubusercontent.com/44712667/135472709-ab2ab0e0-0517-4887-bb88-b6c85152b31e.gif">](./Density%20Contour.avi) |
Binary file not shown.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 Keivan-A-Gh

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
35 changes: 35 additions & 0 deletions OpenFOAM v.7/New Solver and Thermophysical Models/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Solver and Thermophysical Models
**By Keivan A.Gh.**

This folder contains all the required OpenFOAM utilities that have been used in [this master's thesis](https://github.com/Keivan-A-Gh/Master_Thesis/blob/main/Documents/Master's%20Thesis%20-%20Final%20Edition.pdf).


## Main Files
### 1. rhoReactingCentralFoam Solver
The [utilized solver](https://github.com/Keivan-A-Gh/Master_Thesis/tree/main/OpenFOAM%20v.7/New%20Solver%20and%20Thermophysical%20Models/applications/solvers/compressible/rhoReactingCentralFoam) in this thesis is generally based on [rhoReactingCentralFoam](https://github.com/duncanam/thesis) solver written by Duncan A. McGough at the University of Colorado Boulder, although there are some minor changes and additions in this version to make the original solver compatible with our needs and also the version of the utilized OpenFOAM.

### 2. New Thermodynamic and Transport Models
In this project, for calculating thermodynamic properties (C<sub>p</sub>, H, S, and etc.) a new thermodynamic model called [nasa9poly](https://github.com/Keivan-A-Gh/Master_Thesis/tree/main/OpenFOAM%20v.7/New%20Solver%20and%20Thermophysical%20Models/src/thermophysicalModels/specie/thermo/nasa9Poly) has been implemented which is based on [NASA-9](https://github.com/Keivan-A-Gh/Master_Thesis/blob/main/OpenFOAM%20v.7/New%20Thermophysical%20Coefficients/2002_(NASA%209)_McBride%2C%20Gordon_NASA%20Glenn%20Coefficients%20for%20Calculating%20Thermodynamic%20Properties%20of%20Individual%20Species.pdf) polynomials for individual species. Furthermore, for calculating transport properties (κ, μ, and etc.) a new transport model called [nasaPoly](https://github.com/Keivan-A-Gh/Master_Thesis/tree/main/OpenFOAM%20v.7/New%20Solver%20and%20Thermophysical%20Models/src/thermophysicalModels/specie/transport/nasaPoly) has been implemented which is based on [NASA-7](https://github.com/Keivan-A-Gh/Master_Thesis/blob/main/OpenFOAM%20v.7/New%20Thermophysical%20Coefficients/1993_(NASA%207)_McBride%2C%20Gordon_Coefficients%20for%20Calculating%20Thermodynamic%20and%20Transport%20Properties%20of%20Individual%20Species.pdf) transport polynomial for individual species.

### 3. New Thermophysical Models
As discussed in the [report](https://github.com/Keivan-A-Gh/Master_Thesis/blob/main/Documents/Master's%20Thesis%20-%20Final%20Edition.pdf), two new thermophysical models have been implemented for this project to enable OpenFOAM to use a non-ideal-gas equation of state along with the new solver as well as the new thermodynamic and transport models to simulate the main scenario. All the required entries that have been added to the specific paths in *basic*, *reactionThermo*, and *specie* libraries are explained in *Chapter 4.3* of the [report](https://github.com/Keivan-A-Gh/Master_Thesis/blob/main/Documents/Master's%20Thesis%20-%20Final%20Edition.pdf). Generally, these two thermophysical models are as follows:

Entries |Initial Model|Final Model
| :--- | :---: | :---:
**`type`** | `hePsiThermo` | `hePsiThermo`
**`mixture`** | `reactingMixture` | `reactingMixture`
**`transport`** | `sutherland` | `nasaPoly`
**`thermo`** | `janaf` | `nasa9Poly`
**`equationOfState`** | `PengRobinsonGas` | `PengRobinsonGas`
**`specie`** | `specie` | `specie`
**`energy`** | `sensibleInternalEnergy` | `sensibleInternalEnergy`


## Manual
In order to use the solver, you need to download the [applications](https://github.com/Keivan-A-Gh/Master_Thesis/tree/main/OpenFOAM%20v.7/New%20Solver%20and%20Thermophysical%20Models/applications) folder and merge it to the *applications* folder in your OpenFOAM user working directory (your working directory is located under this path: ``` $WM_PROJECT_USER_DIR ```). After that, you can simply go to the [rhoReactingCentralFoam](https://github.com/Keivan-A-Gh/Master_Thesis/tree/main/OpenFOAM%20v.7/New%20Solver%20and%20Thermophysical%20Models/applications/solvers/compressible/rhoReactingCentralFoam) folder and compile the solver by using the `wmake` command.

Also, for using the new thermodynamic and transport models as well as the new thermophysical models, you just need to download the [src](https://github.com/Keivan-A-Gh/Master_Thesis/tree/main/OpenFOAM%20v.7/New%20Solver%20and%20Thermophysical%20Models/src) folder and as before move it to your OpenFOAM user working directory. This time, first you need to compile the [basic](https://github.com/Keivan-A-Gh/Master_Thesis/tree/main/OpenFOAM%20v.7/New%20Solver%20and%20Thermophysical%20Models/src/thermophysicalModels/basic) library, then the [reactionThermo](https://github.com/Keivan-A-Gh/Master_Thesis/tree/main/OpenFOAM%20v.7/New%20Solver%20and%20Thermophysical%20Models/src/thermophysicalModels/reactionThermo) and [specie](https://github.com/Keivan-A-Gh/Master_Thesis/tree/main/OpenFOAM%20v.7/New%20Solver%20and%20Thermophysical%20Models/src/thermophysicalModels/specie) libraries; failure to follow this sequence will lead to an error in the compilation.


## Citation
For citation, please refer to the [README](https://github.com/Keivan-A-Gh/Master_Thesis/blob/main/README.md) file in the main folder.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory
set -x

#wclean libso BCs
wclean

# ----------------------------------------------------------------- end-of-file
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory
set -x

#(wmake libso BCs && wmake)
wmake

# ----------------------------------------------------------------- end-of-file
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Global
centralCourantNo
Description
Calculates the mean and maximum wave speed based Courant Numbers.
\*---------------------------------------------------------------------------*/

if (mesh.nInternalFaces())
{
scalarField sumAmaxSf(fvc::surfaceSum(amaxSf)().internalField());

CoNum = 0.5*gMax(sumAmaxSf/mesh.V().field())*runTime.deltaTValue();

meanCoNum =
0.5*(gSum(sumAmaxSf)/gSum(mesh.V().field()))*runTime.deltaTValue();

acousticCoNum = 0.5*gMax
(
fvc::surfaceSum
(
fvc::interpolate(scalar(1)/sqrt(psi))*mesh.magSf()
)().primitiveField()/mesh.V().field()
)*runTime.deltaTValue();
}

Info<< "Central Courant Number mean: " << meanCoNum
<< " max: " << CoNum
<< " acoustic max: " << acousticCoNum
<< endl;
// ************************************************************************* //
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
rhoReactingCentralFoam.C

EXE = $(FOAM_USER_APPBIN)/rhoReactingCentralFoam
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
EXE_INC = \
-I$(FOAM_SOLVERS)/compressible/rhoCentralFoam/BCs/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(WM_PROJECT_USER_DIR)/src/thermophysicalModels/basic/lnInclude \
-I$(WM_PROJECT_USER_DIR)/src/thermophysicalModels/specie/lnInclude \
-I$(LIB_SRC)/transportModels/compressible/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/compressible/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude \
-I$(WM_PROJECT_USER_DIR)/src/thermophysicalModels/reactionThermo/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/chemistryModel/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/fvOptions/lnInclude \
-I$(LIB_SRC)/ODE/lnInclude \
-I$(LIB_SRC)/combustionModels/lnInclude \
-I$(LIB_SRC)/dynamicFvMesh/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude

EXE_LIBS = \
-L$(FOAM_USER_LIBBIN) \
-lfiniteVolume \
-lcompressibleTransportModels \
-lfluidThermophysicalModels \
-lspecie \
-lrhoCentralFoam \
-lturbulenceModels \
-lcompressibleTurbulenceModels \
-lmeshTools \
-lfvOptions \
-lchemistryModel \
-lreactionThermophysicalModels \
-lODE \
-lcombustionModels \
-ldynamicFvMesh \
-ltopoChangerFvMesh \
-lmeshTools
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
bool useAcousticCo = runTime.controlDict().lookupOrDefault<Switch>("useAcousticCo",false);

scalar maxAcousticCo
(
readScalar(runTime.controlDict().lookup("maxAcousticCo"))
);

#include "createTimeControls.H"
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
volScalarField& p = thermo.p();
const volScalarField& T = thermo.T();
const volScalarField& psi = thermo.psi();
const volScalarField& mu = thermo.mu();

bool inviscid(true);
if (max(mu.primitiveField()) > 0.0)
{
inviscid = false;
}

const label inertIndex(composition.species()[inertSpecie]);
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
#include "createRDeltaT.H"

Info<< "Reading thermophysical properties\n" << endl;

autoPtr<psiReactionThermo> pThermo(psiReactionThermo::New(mesh));
psiReactionThermo& thermo = pThermo();
thermo.validate(args.executable(), "h", "e");

basicMultiComponentMixture& composition = thermo.composition();
PtrList<volScalarField>& Y = composition.Y();

const word inertSpecie(thermo.lookup("inertSpecie"));
if (!composition.species().found(inertSpecie))
{
FatalIOErrorIn(args.executable().c_str(), thermo)
<< "Inert specie " << inertSpecie << " not found in available species "
<< composition.species() << exit(FatalIOError);
}

volScalarField& e = thermo.he();

volVectorField U
(
IOobject
(
"U",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);

volScalarField rho
(
IOobject
(
"rho",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
thermo.rho()
);

volVectorField rhoU
(
IOobject
(
"rhoU",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
rho*U
);

volScalarField rhoE
(
IOobject
(
"rhoE",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
rho*(e + 0.5*magSqr(U))
);

surfaceScalarField pos
(
IOobject
(
"pos",
runTime.timeName(),
mesh
),
mesh,
dimensionedScalar("pos", dimless, 1.0)
);

surfaceScalarField neg
(
IOobject
(
"neg",
runTime.timeName(),
mesh
),
mesh,
dimensionedScalar("neg", dimless, -1.0)
);

surfaceScalarField phi("phi", mesh.Sf() & fvc::interpolate(rhoU));

autoPtr<compressible::turbulenceModel> turbulence
(
compressible::turbulenceModel::New
(
rho,
U,
phi,
thermo
)
);

Info<< "Creating reaction model\n" << endl;
autoPtr<CombustionModel<psiReactionThermo>> reaction
(
CombustionModel<psiReactionThermo>::New(thermo, turbulence())
);

multivariateSurfaceInterpolationScheme<scalar>::fieldTable fields;

forAll (Y, i)
{
fields.add(Y[i]);
}
fields.add(thermo.he());

volScalarField Qdot
(
IOobject
(
"Qdot",
runTime.timeName(),
mesh,
IOobject::READ_IF_PRESENT,
IOobject::AUTO_WRITE
),
mesh,
dimensionedScalar("Qdot", dimEnergy/dimVolume/dimTime, 0.0)
);

Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
namespace Foam
{

//- Interpolate field vf according to direction dir
template<class Type>
tmp<GeometricField<Type, fvsPatchField, surfaceMesh> > interpolate
(
const GeometricField<Type, fvPatchField, volMesh>& vf,
const surfaceScalarField& dir,
const word& reconFieldName = word::null
)
{
tmp<GeometricField<Type, fvsPatchField, surfaceMesh> > tsf
(
fvc::interpolate
(
vf,
dir,
"reconstruct("
+ (reconFieldName != word::null ? reconFieldName : vf.name())
+ ')'
)
);

GeometricField<Type, fvsPatchField, surfaceMesh>& sf = tsf.ref();

sf.rename(vf.name() + '_' + dir.name());

return tsf;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

if (useAcousticCo)
{
maxAcousticCo = readScalar(runTime.controlDict().lookup("maxAcousticCo"));
}

#include "readTimeControls.H"
Loading

0 comments on commit 63b1143

Please sign in to comment.