|
[Sponsors] |
November 4, 2015, 04:45 |
Adding new model to transportProperties
|
#1 | |
Senior Member
Agustín Villa
Join Date: Apr 2013
Location: Alcorcón
Posts: 314
Rep Power: 15 |
Hello everyone
I want to create a model to include inside the transportModel the thermal diffusivity, as it is already done with the viscosity (nu) for incompressible solvers. I have modified the viscosityModel files in order to create the new model, but when I compile, I get this error: Quote:
Did you guys face this problem before? Thank you! |
||
November 4, 2015, 11:16 |
|
#2 |
Senior Member
Agustín Villa
Join Date: Apr 2013
Location: Alcorcón
Posts: 314
Rep Power: 15 |
Hi, I was able to solve it, there was a mistake inside the code.
Now I have to link it to one solver and try it. |
|
November 5, 2015, 03:21 |
|
#3 |
Senior Member
Anton Kidess
Join Date: May 2009
Location: Germany
Posts: 1,377
Rep Power: 30 |
Why not make this thread useful and share how you solved your problem? Someone in the future will thank you for it.
__________________
*On twitter @akidTwit *Spend as much time formulating your questions as you expect people to spend on their answer. |
|
November 5, 2015, 03:35 |
|
#4 |
Senior Member
Agustín Villa
Join Date: Apr 2013
Location: Alcorcón
Posts: 314
Rep Power: 15 |
Hello,
the error was a typing one, so the rest of the code was ok. But you are right in the fact I could explain a bit my procedure for other people who wanted to implement it. The idea was to replace any term related with viscosity with the thermal diffusivity. Instead of creating the function "nu" you should type "alpha", "kappa"... I defined as well a transport thermal model (transportModel) and a singlePhaseTransportModel, where "alpha" is used instead the kinematic viscosity. In the solver, in yout readTransportProperties, you should add: Code:
singlePhaseTransportThermalModel laminarTransportThermal(U, phi); Code:
transportThermalModel Newtonian; alpha alpha [ 0 2 -1 0 0 0 0 ] 1.75048355e-007; EDIT: now, in order to integrate your new transportModel in your turbulence models, you have to create a new turbulenceModel library. In my case it is an incompressible one. If you copy & paste the already existing one, you have to do some modifications: Code:
autoPtr<turbulenceThermalModel> turbulenceThermalModel::New ( const volVectorField& U, const surfaceScalarField& phi, const volScalarField& T, transportModel& transport, transportThermalModel& transportThermal, const word& turbulenceThermalModelName ) In this other declaration you have to do similarly: Code:
(U, phi, T, transport, transportThermal, turbulenceThermalModelName) Ok. Now the turbulent thermal models are there, but RAS models must be created as well to use them in our simulations. Other library RASModel must be created. Copying the existing one, applying the second replacement I explained, and modifying a bit the RASModels.C and .H it should be ok. After that you have to implement your own turbulence RAS thermal models. Passing throught the first library (models for nut) to the thermal one (alphat) is quite straightforward, in the sense there are already some terms that need a little modification (ie, change nu for alpha, U for T ...). If further explanation is required, please make me know. Even this could be considered to create another thread . Last edited by agustinvo; November 5, 2015 at 07:12. Reason: Adding modifications in turbulence libraries |
|
November 5, 2015, 07:15 |
|
#5 |
Senior Member
Agustín Villa
Join Date: Apr 2013
Location: Alcorcón
Posts: 314
Rep Power: 15 |
I have modified my second post in order to include the use of the new transport model in the turbulence models.
Maybe for C++ users and programmers, it is quite obvious the way to do it, but for people like me, it can be very helpful. |
|
November 6, 2015, 12:07 |
|
#6 | |
Senior Member
Agustín Villa
Join Date: Apr 2013
Location: Alcorcón
Posts: 314
Rep Power: 15 |
Hello,
once this library is working, I want to implement a polynomial expression for alpha, in the same way I did it already for nu. It was just a copy and paste, and replacements of nu, viscosity ... for their equivalents. But I get this error when I compile: Code:
Making dependency list for source file thermalDiffusivityModels/TempPolyLaw/TempPolyLaw.C thermalDiffusivityModels/TempPolyLaw/TempPolyLaw.dep:489: warning: overriding recipe for target `Make/linux64Gcc48DPOpt/TempPolyLaw.o' viscosityModels/TempPolyLaw/TempPolyLaw.dep:489: warning: ignoring old recipe for target `Make/linux64Gcc48DPOpt/TempPolyLaw.o' SOURCE=thermalDiffusivityModels/TempPolyLaw/TempPolyLaw.C ; g++ -m64 -Dlinux64 -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -O3 -DNoRepository -ftemplate-depth-100 -I/software/alternate/openfoam/fc20/2.3.1/OpenFOAM-2.3.1/src/transportModels/incompressible/lnInclude -I/software/alternate/openfoam/fc20/2.3.1/OpenFOAM-2.3.1/src/transportModels/incompressible/twoPhaseMixture/lnInclude -I/software/alternate/openfoam/fc20/2.3.1/OpenFOAM-2.3.1/src/finiteVolume/lnInclude -IlnInclude -I. -I/software/alternate/openfoam/fc20/2.3.1/OpenFOAM-2.3.1/src/OpenFOAM/lnInclude -I/software/alternate/openfoam/fc20/2.3.1/OpenFOAM-2.3.1/src/OSspecific/POSIX/lnInclude -fPIC -c $SOURCE -o Make/linux64Gcc48DPOpt/TempPolyLaw.o TempPolyLaw.o:(.bss+0x18): multiple definition of `Foam::thermalDiffusivityModels::TempPolyLaw::typeName' TempPolyLaw.o:(.bss+0x18): first defined here TempPolyLaw.o:(.bss+0x10): multiple definition of `Foam::thermalDiffusivityModels::TempPolyLaw::debug' TempPolyLaw.o:(.bss+0x10): first defined here TempPolyLaw.o:(.bss+0x8): multiple definition of `Foam::thermalDiffusivityModels::addTempPolyLawToDebug_' TempPolyLaw.o:(.bss+0x8): first defined here TempPolyLaw.o:(.bss+0x0): multiple definition of `Foam::thermalDiffusivityModels::addTempPolyLawdictionaryConstructorTothermalDiffusivityModelTable_' TempPolyLaw.o:(.bss+0x0): first defined here TempPolyLaw.o: In function `Foam::thermalDiffusivityModels::TempPolyLaw::calcAlpha() const': TempPolyLaw.C:(.text+0x880): multiple definition of `Foam::thermalDiffusivityModels::TempPolyLaw::calcAlpha() const' TempPolyLaw.o:TempPolyLaw.C:(.text+0x880): first defined here TempPolyLaw.o: In function `Foam::thermalDiffusivityModels::TempPolyLaw::TempPolyLaw(Foam::word const&, Foam::dictionary const&, Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> const&, Foam::GeometricField<double, Foam::fvsPatchField, Foam::surfaceMesh> const&)': TempPolyLaw.C:(.text+0xb60): multiple definition of `Foam::thermalDiffusivityModels::TempPolyLaw::TempPolyLaw(Foam::word const&, Foam::dictionary const&, Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> const&, Foam::GeometricField<double, Foam::fvsPatchField, Foam::surfaceMesh> const&)' TempPolyLaw.o:TempPolyLaw.C:(.text+0xb60): first defined here TempPolyLaw.o: In function `Foam::thermalDiffusivityModels::TempPolyLaw::TempPolyLaw(Foam::word const&, Foam::dictionary const&, Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> const&, Foam::GeometricField<double, Foam::fvsPatchField, Foam::surfaceMesh> const&)': TempPolyLaw.C:(.text+0xb60): multiple definition of `Foam::thermalDiffusivityModels::TempPolyLaw::TempPolyLaw(Foam::word const&, Foam::dictionary const&, Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> const&, Foam::GeometricField<double, Foam::fvsPatchField, Foam::surfaceMesh> const&)' TempPolyLaw.o:TempPolyLaw.C:(.text+0xb60): first defined here TempPolyLaw.o: In function `Foam::thermalDiffusivityModels::TempPolyLaw::read(Foam::dictionary const&)': TempPolyLaw.C:(.text+0x1100): multiple definition of `Foam::thermalDiffusivityModels::TempPolyLaw::read(Foam::dictionary const&)' TempPolyLaw.o:TempPolyLaw.C:(.text+0x1100): first defined here collect2: error: ld returned 1 exit status make: *** [/students/phd_ea/villaortiz/OpenFOAM/villaortiz-2.3.1/platforms/linux64Gcc48DPOpt/lib/libmyIncompressibleTransportModels.so] Error 1 file.C Code:
/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011 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/>. \*---------------------------------------------------------------------------*/ #include "TempPolyLaw.H" #include "addToRunTimeSelectionTable.H" #include "surfaceFields.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // namespace Foam { namespace thermalDiffusivityModels { defineTypeNameAndDebug(TempPolyLaw, 0); addToRunTimeSelectionTable ( thermalDiffusivityModel, TempPolyLaw, dictionary ); } } // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // Foam::tmp<Foam::volScalarField> Foam::thermalDiffusivityModels::TempPolyLaw::calcAlpha() const { const volScalarField& T= U_.mesh().lookupObject<volScalarField>("T"); //const volScalarField& rho= U_.mesh().lookupObject<volScalarField>("rho"); return (base_+slope_*T+slope2_*pow(T,2.0)+slope3_*pow(T,3.0)); } // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::thermalDiffusivityModels::TempPolyLaw::TempPolyLaw ( const word& name, const dictionary& thermalDiffusivityProperties, const volVectorField& U, const surfaceScalarField& phi ) : thermalDiffusivityModel(name, thermalDiffusivityProperties, U, phi), TempPolyLawCoeffs_(thermalDiffusivityProperties.subDict(typeName + "Coeffs")), base_(TempPolyLawCoeffs_.lookup("base")), slope_(TempPolyLawCoeffs_.lookup("slope")), slope2_(TempPolyLawCoeffs_.lookup("slope2")), slope3_(TempPolyLawCoeffs_.lookup("slope3")), alpha_ ( IOobject ( name, U_.time().timeName(), U_.db(), IOobject::NO_READ, IOobject::AUTO_WRITE ), calcAlpha() ) {} // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // bool Foam::thermalDiffusivityModels::TempPolyLaw::read ( const dictionary& thermalDiffusivityProperties ) { thermalDiffusivityModel::read(thermalDiffusivityProperties); TempPolyLawCoeffs_ = thermalDiffusivityProperties.subDict(typeName + "Coeffs"); TempPolyLawCoeffs_.lookup("base") >> base_; TempPolyLawCoeffs_.lookup("slope") >> slope_; TempPolyLawCoeffs_.lookup("slope2") >> slope2_; TempPolyLawCoeffs_.lookup("slope3") >> slope3_; return true; } // ************************************************************************* // Code:
/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011 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/>. Class Foam::viscosityModels::TempPolyLaw Description Standard polynomial-law non-Newtonian viscosity model. mu=a0+a1*T+a2*T2+... SourceFiles TempPolyLaw.C \*---------------------------------------------------------------------------*/ #ifndef TempPolyLaw_H #define TempPolyLaw_H #include "thermalDiffusivityModel.H" #include "dimensionedScalar.H" #include "volFields.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { namespace thermalDiffusivityModels { /*---------------------------------------------------------------------------*\ Class TempPolyLaw Declaration \*---------------------------------------------------------------------------*/ class TempPolyLaw : public thermalDiffusivityModel { // Private data dictionary TempPolyLawCoeffs_; dimensionedScalar base_; dimensionedScalar slope_; dimensionedScalar slope2_; dimensionedScalar slope3_; volScalarField alpha_; // Private Member Functions //- Calculate and return the laminar viscosity tmp<volScalarField> calcAlpha() const; public: //- Runtime type information TypeName("TempPolyLaw"); // Constructors //- Construct from components TempPolyLaw ( const word& name, const dictionary& thermalDiffusivityProperties, const volVectorField& U, const surfaceScalarField& phi ); //- Destructor ~TempPolyLaw() {} // Member Functions //- Return the laminar viscosity tmp<volScalarField> alpha() const { return alpha_; } //- Return the laminar viscosity for patch tmp<scalarField> alpha(const label patchi) const { return alpha_.boundaryField()[patchi]; } //- Correct the laminar viscosity void correct() { alpha_ = calcAlpha(); } //- Read transportProperties dictionary bool read(const dictionary& thermalDiffusivityProperties); }; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace viscosityModels } // End namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #endif // ************************************************************************* // I was using the same fileName.C for the polynomial of nu() and alpha, so there was a conflict with the internal functions (the only difference between both files are the viscosity and thermal diffusivity references, not the C++ and functions ones). I changed the names, so I have Quote:
Now it is possible to implement the same functions for each diffusion term (nu and alpha), just be sure the names are different! Last edited by agustinvo; November 9, 2015 at 06:57. |
||
November 9, 2015, 06:59 |
|
#7 |
Senior Member
Agustín Villa
Join Date: Apr 2013
Location: Alcorcón
Posts: 314
Rep Power: 15 |
The previous problem was solved. It is explained on its post.
I think it would be interesting to create a post of "How to implement a new transport model library", in a nicer way than the one here. |
|
December 5, 2016, 08:34 |
|
#8 |
Member
Hasan Celik
Join Date: Sep 2016
Posts: 64
Rep Power: 10 |
Dear agustinvo, thank you so much for this post. I try to do the exactly the same thing with you and your post helped me a lot to understand where I should start. In your code, these lines below refer to viscosity or thermal conductivity? I am little bit confused.
Code:
//- Calculate and return the laminar viscosity tmp<volScalarField> calcAlpha() const; And my other question is, how did you compile it? Did you add these models to src folder or did you compile them individually using usr libbin? Thanks a lot for your answer and time. |
|
December 5, 2016, 09:47 |
|
#9 | |
Senior Member
Agustín Villa
Join Date: Apr 2013
Location: Alcorcón
Posts: 314
Rep Power: 15 |
Quote:
for me, alpha is the thermal diffusivity, it is . Since I have other libraries, I put them in USER_LIBBIN, so I don't mess up the installation folder with all my implementations. What you can use to know how to implement different models is this PDF, more or less they explain what to do in each part. My implementations are done in OF 2.3.1, but I don't know if it changed a lot or not for OF 3.0.x or OF 4.x |
||
December 5, 2016, 18:01 |
|
#10 |
Member
Hasan Celik
Join Date: Sep 2016
Posts: 64
Rep Power: 10 |
Thank you so much!
|
|
Tags |
thermal diffusivity, transportproperties |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Adding new temperature dependent viscosity model | vabishek | OpenFOAM Programming & Development | 3 | May 15, 2016 22:05 |
Adding different properties to Thermophysical Model | DanAndrea87 | OpenFOAM Programming & Development | 9 | May 1, 2014 11:37 |
adding lift model to twoPhaseEulerFoam | mehrdad_kbg | OpenFOAM Programming & Development | 8 | September 17, 2013 17:08 |
An error has occurred in cfx5solve: | volo87 | CFX | 5 | June 14, 2013 18:44 |
K - epsilon VS SST turbulence model | Maicol | Main CFD Forum | 0 | November 30, 2012 17:25 |