Energy models.

This commit is contained in:
Thomas Lichtenegger
2016-02-27 13:20:09 +01:00
parent 434e3983f6
commit 46111bb4cb
9 changed files with 756 additions and 0 deletions

View File

@ -0,0 +1,64 @@
/*---------------------------------------------------------------------------*\
License
This 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.
This code 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 this code. If not, see <http://www.gnu.org/licenses/>.
Copyright (C) 2015- Thomas Lichtenegger, JKU Linz, Austria
\*---------------------------------------------------------------------------*/
#include "error.H"
#include "energyModel.H"
#include "mathExtra.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(energyModel, 0);
defineRunTimeSelectionTable(energyModel, dictionary);
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
energyModel::energyModel
(
const dictionary& dict,
cfdemCloudEnergy& sm
)
:
dict_(dict),
particleCloud_(sm)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
energyModel::~energyModel()
{}
// * * * * * * * * * * * * * * * * Member Fct * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -0,0 +1,113 @@
/*---------------------------------------------------------------------------*\
License
This 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.
This code 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 this code. If not, see <http://www.gnu.org/licenses/>.
Copyright (C) 2015- Thomas Lichtenegger, JKU Linz, Austria
\*---------------------------------------------------------------------------*/
#ifndef energyModel_H
#define energyModel_H
#include "fvCFD.H"
#include "cfdemCloudEnergy.H"
#include "probeModel.H"
#include "forceModel.H"
#include "interpolationCellPoint.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class energyModel Declaration
\*---------------------------------------------------------------------------*/
class energyModel
{
protected:
// Protected data
const dictionary& dict_;
cfdemCloudEnergy& particleCloud_;
public:
//- Runtime type information
TypeName("energyModel");
// Declare runtime constructor selection table
declareRunTimeSelectionTable
(
autoPtr,
energyModel,
dictionary,
(
const dictionary& dict,
cfdemCloudEnergy& sm
),
(dict,sm)
);
// Constructors
//- Construct from components
energyModel
(
const dictionary& dict,
cfdemCloudEnergy& sm
);
// Destructor
virtual ~energyModel();
// Selector
static autoPtr<energyModel> New
(
const dictionary& dict,
cfdemCloudEnergy& sm,
word energyType
);
// Member Functions
virtual void energyContribution(volScalarField&) const;
virtual void temperatureContribution(volScalarField&) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,67 @@
/*---------------------------------------------------------------------------*\
License
This 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.
This code 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 this code. If not, see <http://www.gnu.org/licenses/>.
Copyright (C) 2015- Thomas Lichtenegger, JKU Linz, Austria
\*---------------------------------------------------------------------------*/
#include "error.H"
#include "energyModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
autoPtr<energyModel> energyModel::New
(
const dictionary& dict,
cfdemCloudEnergy& sm,
word energyType
)
{
Info<< "Selecting energyModel "
<< energyType << endl;
dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(energyType);
if (cstrIter == dictionaryConstructorTablePtr_->end())
{
FatalError
<< "energyModel::New(const dictionary&, const spray&) : "
<< endl
<< " unknown energyModelType type "
<< energyType
<< ", constructor not in hash table" << endl << endl
<< " Valid energyModel types are :"
<< endl;
Info<< dictionaryConstructorTablePtr_->toc()
<< abort(FatalError);
}
return autoPtr<energyModel>(cstrIter()(dict,sm));
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -0,0 +1,77 @@
/*---------------------------------------------------------------------------*\
License
This 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.
This code 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 this code. If not, see <http://www.gnu.org/licenses/>.
Copyright (C) 2015- Thomas Lichtenegger, JKU Linz, Austria
\*---------------------------------------------------------------------------*/
#include "error.H"
#include "heatTransfer.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(heatTransfer, 0);
addToRunTimeSelectionTable(energyModel, heatTransfer, dictionary);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
heatTransfer::heatTransfer
(
const dictionary& dict,
cfdemCloudEnergy& sm
)
:
energyModel(dict,sm),
LaEuScalarTemp(dict,sm),
propsDict_(dict.subDict(typeName + "Props")),
propsLaEuScalarTempDict_(dict.subDict("LaEuScalarTempProps")),
Cp_(readScalar(propsLaEuScalarTempDict_.lookup("Cp")))
{
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
heatTransfer::~heatTransfer()
{}
// * * * * * * * * * * * * * * * * Member Fct * * * * * * * * * * * * * * * //
void heatTransfer::energyContribution(volScalarField& EuField) const
{
const volScalarField& rhoField = forceSubM(0).rhoField();
temperatureContribution(EuField);
EuField.internalField() *= rhoField.internalField()*Cp_;
}
void heatTransfer::temperatureContribution(volScalarField& EuField) const
{
LaEuScalarTemp::manipulateScalarField(EuField);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -0,0 +1,88 @@
/*---------------------------------------------------------------------------*\
License
This 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.
This code 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 this code. If not, see <http://www.gnu.org/licenses/>.
Copyright (C) 2015- Thomas Lichtenegger, JKU Linz, Austria
\*---------------------------------------------------------------------------*/
#ifndef heatTransfer_H
#define heatTransfer_H
#include "fvCFD.H"
#include "cfdemCloudEnergy.H"
#include "energyModel.H"
#include "LaEuScalarTemp.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class heatTransfer Declaration
\*---------------------------------------------------------------------------*/
class heatTransfer
:
public energyModel, public LaEuScalarTemp
{
private:
dictionary propsDict_;
dictionary propsLaEuScalarTempDict_;
scalar Cp_;
public:
//- Runtime type information
TypeName("heatTransfer");
// Constructors
//- Construct from components
heatTransfer
(
const dictionary& dict,
cfdemCloudEnergy& sm
);
// Destructor
virtual ~heatTransfer();
// Member Functions
void energyContribution(volScalarField&) const;
void temperatureContribution(volScalarField&) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,232 @@
/*---------------------------------------------------------------------------*\
License
This 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.
This code 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 this code. If not, see <http://www.gnu.org/licenses/>.
Copyright (C) 2015- Thomas Lichtenegger, JKU Linz, Austria
\*---------------------------------------------------------------------------*/
#include "error.H"
#include "heatTransferGunn.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(heatTransferGunn, 0);
addToRunTimeSelectionTable(energyModel, heatTransferGunn, dictionary);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
heatTransferGunn::heatTransferGunn
(
const dictionary& dict,
cfdemCloudEnergy& sm
)
:
energyModel(dict,sm),
propsDict_(dict.subDict(typeName + "Props")),
tempFieldName_(propsDict_.lookup("tempFieldName")),
tempField_(sm.mesh().lookupObject<volScalarField> (tempFieldName_)),
voidfractionFieldName_(propsDict_.lookup("voidfractionFieldName")),
voidfraction_(sm.mesh().lookupObject<volScalarField> (voidfractionFieldName_)),
maxSource_(1e30),
velFieldName_(propsDict_.lookup("velFieldName")),
U_(sm.mesh().lookupObject<volVectorField> (velFieldName_)),
partTempName_(propsDict_.lookup("partTempName")),
partTemp_(NULL),
partHeatFluxName_(propsDict_.lookup("partHeatFluxName")),
partHeatFlux_(NULL),
lambda_(readScalar(propsDict_.lookup("lambda"))),
Cp_(readScalar(propsDict_.lookup("Cp")))
{
allocateMyArrays();
if (propsDict_.found("maxSource"))
{
maxSource_=readScalar(propsDict_.lookup ("maxSource"));
Info << "limiting eulerian source field to: " << maxSource_ << endl;
}
// init force sub model
setForceSubModels(propsDict_);
// define switches which can be read from dict
forceSubM(0).setSwitchesList(3,true); // activate search for verbose switch
forceSubM(0).setSwitchesList(4,true); // activate search for interpolate switch
forceSubM(0).setSwitchesList(8,true); // activate scalarViscosity switch
// read those switches defined above, if provided in dict
forceSubM(0).readSwitches();
particleCloud_.checkCG(false);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
heatTransferGunn::~heatTransferGunn()
{
delete partTemp_;
delete partHeatFlux_;
}
// * * * * * * * * * * * * * * * private Member Functions * * * * * * * * * * * * * //
void heatTransferGunn::allocateMyArrays() const
{
// get memory for 2d arrays
double initVal=0.0;
particleCloud_.dataExchangeM().allocateArray(partTemp_,initVal,1); // field/initVal/with/lenghtFromLigghts
particleCloud_.dataExchangeM().allocateArray(partHeatFlux_,initVal,1);
}
// * * * * * * * * * * * * * * * * Member Fct * * * * * * * * * * * * * * * //
void heatTransferGunn::temperatureContribution(volScalarField& EuField) const
{
// realloc the arrays
allocateMyArrays();
// reset Scalar field
EuField.internalField() = 0.0;
// get DEM data
particleCloud_.dataExchangeM().getData(partTempName_,"scalar-atom",partTemp_);
const volScalarField& nufField = forceSubM(0).nuField();
const volScalarField& rhoField = forceSubM(0).rhoField();
// calc La based heat flux
scalar voidfraction(1);
vector Ufluid(0,0,0);
scalar Tfluid(0);
label cellI=0;
vector Us(0,0,0);
scalar ds(0);
scalar nuf(0);
scalar magUr(0);
scalar Rep(0);
scalar Pr(0);
scalar Nup(0);
const scalar n = 3.5; // model parameter (found suitable for 3-mm polymer pellets when modelling dilute flows)
interpolationCellPoint<scalar> voidfractionInterpolator_(voidfraction_);
interpolationCellPoint<vector> UInterpolator_(U_);
interpolationCellPoint<scalar> TInterpolator_(tempField_);
for(int index = 0;index < particleCloud_.numberOfParticles(); ++index)
{
//if(particleCloud_.regionM().inRegion()[index][0])
//{
cellI = particleCloud_.cellIDs()[index][0];
if(cellI >= 0)
{
if(forceSubM(0).interpolation())
{
vector position = particleCloud_.position(index);
voidfraction = voidfractionInterpolator_.interpolate(position,cellI);
Ufluid = UInterpolator_.interpolate(position,cellI);
Tfluid = TInterpolator_.interpolate(position,cellI);
}
else
{
voidfraction = voidfraction_[cellI];
Ufluid = U_[cellI];
Tfluid = tempField_[cellI];
}
// calc relative velocity
Us = particleCloud_.velocity(index);
magUr = mag(Ufluid - Us);
ds = 2.*particleCloud_.radius(index);
nuf = nufField[cellI];
Rep = ds * magUr * voidfraction / nuf;
Pr = max(SMALL, Cp_ * nuf * rhoField[cellI] / lambda_);
Nup =
scalar h = lambda_ * Nup / ds;
scalar As = ds * ds * M_PI; // surface area of sphere
// calc convective heat flux [W]
scalar partHeatFlux = h * As * (Tfluid - partTemp_[index][0]);
partHeatFlux_[index][0] = partHeatFlux;
if(forceSubM(0).verbose() && index >=0 && index <2)
{
Info << "partHeatFlux = " << partHeatFlux << endl;
Info << "magUr = " << magUr << endl;
Info << "As = " << As << endl;
Info << "nuf = " << nuf << endl;
Info << "Rep = " << Rep << endl;
Info << "Pr = " << Pr << endl;
Info << "Nup = " << Nup << endl;
Info << "voidfraction = " << voidfraction << endl;
Info << "partTemp_[index][0] = " << partTemp_[index][0] << endl;
Info << "Tfluid = " << Tfluid << endl ;
}
}
//}
}
particleCloud_.averagingM().setScalarSum
(
EuField,
partHeatFlux_,
particleCloud_.particleWeights(),
NULL
);
// scale with -1/(Vcell*rho*Cp)
EuField.internalField() /= -rhoField.internalField()*Cp_*EuField.mesh().V();
// limit source term
forAll(EuField,cellI)
{
scalar EuFieldInCell = EuField[cellI];
if(mag(EuFieldInCell) > maxSource_ )
{
EuField[cellI] = sign(EuFieldInCell) * maxSource_;
}
}
Info << "total convective particle-fluid heat flux [W] (Eulerian) = " << gSum(EuField*rhoField*Cp_*EuField.mesh().V()) << endl;
// give DEM data
particleCloud_.dataExchangeM().giveData(partHeatFluxName_,"scalar-atom", partHeatFlux_);
}
void heatTransferGunn::energyContribution(volScalarField& EuField) const
{
const volScalarField& rhoField = forceSubM(0).rhoField();
temperatureContribution(EuField);
EuField.internalField() *= rhoField.internalField()*Cp_;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -0,0 +1,115 @@
/*---------------------------------------------------------------------------*\
License
This 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.
This code 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 this code. If not, see <http://www.gnu.org/licenses/>.
Copyright (C) 2015- Thomas Lichtenegger, JKU Linz, Austria
Description
Correlation for Nusselt number according to
Gunn, D. J. International Journal of Heat and Mass Transfer 21.4 (1978)
\*---------------------------------------------------------------------------*/
#ifndef heatTransferGunn_H
#define heatTransferGunn_H
#include "fvCFD.H"
#include "cfdemCloudEnergy.H"
#include "energyModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class heatTransferGunn Declaration
\*---------------------------------------------------------------------------*/
class heatTransferGunn
:
public energyModel
{
private:
dictionary propsDict_;
word tempFieldName_;
const volScalarField& tempField_; // ref to temperature field
word voidfractionFieldName_;
const volScalarField& voidfraction_; // ref to voidfraction field
scalar maxSource_; // max (limited) value of src field
word velFieldName_;
const volVectorField& U_;
word partTempName_;
mutable double **partTemp_; // Lagrangian array
word partHeatFluxName_;
mutable double **partHeatFlux_; // Lagrangian array
scalar lambda_; // fluid thermal conductivity [W/(m*K)]
scalar Cp_; // specific heat capacity [W*s/(kg*K)]
void allocateMyArrays() const;
public:
//- Runtime type information
TypeName("heatTransferGunn");
// Constructors
//- Construct from components
heatTransferGunn
(
const dictionary& dict,
cfdemCloudEnergy& sm
);
// Destructor
virtual ~heatTransferGunn();
// Member Functions
void energyContribution(volScalarField&) const;
void temperatureContribution(volScalarField&) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //