CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

modifying laplacianFoam - temperature dependent diffusivity

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree1Likes
  • 1 Post By ahmmedshakil

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 17, 2019, 10:32
Default modifying laplacianFoam - temperature dependent diffusivity
  #1
New Member
 
Chris
Join Date: Sep 2017
Posts: 5
Rep Power: 6
kaber is on a distinguished road
Dear Foamers,

I try to modify the laplacianFoam solver to account for a variable thermal diffusivity.

I found the following three threads:

LaplacianFoam with non-constant Diffusion Coefficient

Non-constant Diffusion Coefficient

Thermal conductivity as function of temperature

which deal with this modification. However, I'm not able to implement them.

I added the following code to the createFields.H

Code:
volScalarField Diff
(
    IOobject
    (
        "Diff",
        runTime.timeName(),
        mesh,
        IOobject::NO_READ,
        IOobject::NO_WRITE
    ),
    mesh,
    dimensionedScalar("Diff",dimensionSet(0,2,-1,0,0),0.0)
  );
and added a (simplified linear) equation to the mylaplacianFoamVarDT.C

Code:
while (runTime.loop())
     {
     Diff = 430-0.0785*T;

    fvScalarMatrix TEqn(-fvm::laplacian(Diff, T));
 
    TEqn.solve();

     }
The code compiles without any error, but mylaplacianFoamVarDT complains that the dimensions of
Quote:
Diff = 430-0.0785*T;
are not correct

Code:
--> FOAM FATAL ERROR:
LHS and RHS of '-' have different dimensions
     dimensions : [0 0 0 0 0 0 0] - [0 0 0 1 0 0 0]
Sure, "430" is dimensionless and the "linear equation" part is of dimension K.
Since I'm not yet very familiar with openFOAM, I tried a work around by changing the dimension of Diff (to avoid a similar dimension problem) to K and get rid of the constant "430" first.

Code:
volScalarField Diff
(
    IOobject
    (
        "Diff",
        runTime.timeName(),
        mesh,
        IOobject::NO_READ,
        IOobject::NO_WRITE
    ),
    mesh,
    dimensionedScalar("Diff",dimensionSet(0,0,0,1,0),0.0)
);
Code:
while (runTime.loop())
    {
    Diff = -0.0785*T;

    fvScalarMatrix TEqn(-fvm::laplacian(Diff, T));

    TEqn.solve();

    }
Again, wmake complies, but mylaplacianFoamVarDT shows the following error:


Quote:
/*---------------------------------------------------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1812 |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
Build : v1812 OPENFOAM=1812
Arch : "LSB;label=32;scalar=64"
Exec : mylaplacianFoamVarDT
Date : Nov 17 2019
Time : 13:26:07
Host : kabaer
PID : 13163
I/O : uncollated
Case : /home/XXX/OpenFOAM/XXX-v1812/run/GettingStarted/1DRod-Dirichlet-VariableDT
nProcs : 1
trapFpe: Floating point exception trapping enabled (FOAM_SIGFPE).
fileModificationChecking : Monitoring run-time modified files using timeStampMaster (fileModificationSkew 10)
allowSystemOperations : Allowing user-supplied system call operations

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Create time

Create mesh for time = 0


SIMPLE: no convergence criteria found. Calculations will run for 1 steps.

Reading field T

Creating variable Diffusivity

Reading transportProperties

Reading diffusivity k

No finite volume options present

Calculating temperature distribution

#0 Foam::error:rintStack(Foam::Ostream&) at ??:?
#1 Foam::sigFpe::sigHandler(int) at ??:?
#2 ? in /lib/x86_64-linux-gnu/libc.so.6
#3 Foam::divide(Foam::Field<double>&, double const&, Foam::UList<double> const&) at ??:?
#4 Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > Foamerator/<Foam::fvPatchField, Foam::volMesh>(Foam::dimensioned<double> const&, Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> const&) at ??:?
#5 Foam::harmonic::interpolate(Foam::GeometricField<d ouble, Foam::fvPatchField, Foam::volMesh> const&) const at ??:?
#6 Foam::fv::laplacianScheme<double, double>::fvmLaplacian(Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> const&, Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> const&) at ??:?
#7 Foam::tmp<Foam::fvMatrix<double> > Foam::fvm::laplacian<double, double>(Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> const&, Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> const&) in ~/OpenFOAM/XXX-v1812/platforms/linux64GccDPInt32Opt/bin/mylaplacianFoamVarDT
#8 ? in ~/OpenFOAM/XXX-v1812/platforms/linux64GccDPInt32Opt/bin/mylaplacianFoamVarDT
#9 __libc_start_main in /lib/x86_64-linux-gnu/libc.so.6
#10 ? in ~/OpenFOAM/XXX-v1812/platforms/linux64GccDPInt32Opt/bin/mylaplacianFoamVarDT
I'm grateful for any help....
kaber is offline   Reply With Quote

Old   November 18, 2019, 00:00
Default
  #2
Senior Member
 
Mohammad Shakil Ahmmed
Join Date: Oct 2012
Location: AUS
Posts: 136
Rep Power: 12
ahmmedshakil is on a distinguished road
Hi Chris,
If you look at the error message printed by the OpenFOAM, you may figure out why the error is coming. The error in the first line is showing is a "printStack" type, which means that something is calculating wrong, Please check the parameters as well as the boundary conditions you're using for simulations. Then, check the laplacian scheme you used, as the diffusion term is non-linear, you may use the harmonic interpolation, which may help you to simulate.

-S
kaber likes this.
ahmmedshakil is offline   Reply With Quote

Old   November 18, 2019, 13:08
Default
  #3
New Member
 
Chris
Join Date: Sep 2017
Posts: 5
Rep Power: 6
kaber is on a distinguished road
Dear Mohammed,
thanks for the hint ! I found the problem.
The initial temperature distribution within my domain was set to "zero",
Quote:
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1812 |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
object T;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions [0 0 0 1 0 0 0];

internalField uniform 0;
so the equation
Quote:
Diff=-0.0785*T
results in Diff = 0, which obviously leads to a zero matrix. However, I wonder why this is not leading to the same error with original laplacianFoam and constant conductivity....

In addition, I checked both, "linear" as well as "harmonic" interpolation scheme for "Diff" and also the solver "Conjugate Gradient" as well as "GaussSeidel". All of them give the same result.

But I got another question. In order to get the dimensions of "Diff" right (not the work around with dimension "K" - see above) I would like to know how I can assign the right dimension to the terms within the equation.
Quote:
Diff = 430 - 0.0785*T;
Best regards!
kaber is offline   Reply With Quote

Old   October 19, 2021, 08:06
Default
  #4
New Member
 
Jayabrata Dhar
Join Date: Nov 2018
Posts: 9
Rep Power: 5
jd87 is on a distinguished road
You can name new scalar variables, give them proper dimensions in the transportproperties file, so that Diff has a dimension of thermal diffusivity. This will work well. Or else you have to put dimensionSet to 0 so that OpenFOAM does not check dimensional consistency before running the simulations.
jd87 is offline   Reply With Quote

Old   October 19, 2021, 14:53
Default
  #5
Senior Member
 
Join Date: Sep 2013
Posts: 284
Rep Power: 17
Bloerb will become famous soon enough
Define 430 as a variable with a unit (this is a dimensionedScalar). Something like this with maybe a slightly different syntax.

Code:
 dimensionedScalar Tvalue = ("Tvalue", [0 2 -1 0 0 0 0], 430);
Bloerb is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
OpenFOAM Temperature Dependent Viscosity JR22 OpenFOAM Running, Solving & CFD 0 April 4, 2017 08:45
temperature dependent deviation hebeldebel STAR-CCM+ 7 July 30, 2014 11:44
Temperature dependent material properties stuart230588 CFX 1 November 21, 2013 17:36
temperature dependent heat flux rohinibc Fluent UDF and Scheme Programming 0 December 11, 2012 09:45
Time Dependent Temperature Dependent BC Analysis RP Main CFD Forum 1 March 28, 2008 02:22


All times are GMT -4. The time now is 15:46.