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

how to convert to dimensionless scalar in openfoam

Register Blogs Community New Posts Updated Threads Search

Like Tree13Likes
  • 9 Post By Lieven
  • 1 Post By Lieven
  • 3 Post By alexeym

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 8, 2013, 07:40
Default how to convert to dimensionless scalar in openfoam
  #1
New Member
 
mehdi
Join Date: Nov 2010
Location: Tehran
Posts: 16
Rep Power: 16
mehdi kamyabi is on a distinguished road
Dear OpenFoamers

I'm already trying to write a code for simulating conformational rheological problems.
my code is complied well but when I try to use it this error appears:

--> FOAM FATAL ERROR:
Argument of trancendental function not dimensionless

From function trans(const dimensionSet&)
in file dimensionSet/dimensionSet.C at line 480.


I found the source of error may exist in these lines of my code:

//size of shear rate tensor (which is dimensioned scalar)
volScalarField sizegamadot = Foam::sqrt ( 0.5 * (twoD && twoD) );

//ci is a non-dimensioned variable which is calculated by this
//formula : ci = ((-0.0076*ln(sizegamadot) + 0.0385)/0.1876)^1.998

volScalarField ci = Foam:ow( ((-0.0076 * Foam::log (sizegamadot)) + 0.0385) / 0.1876 ) ,1.998 );

// solving equation for a.
tmp<fvSymmTensorMatrix> aEqn
(
fvm::ddt(a_)
== keisi * ( (twoD & a_) + (a_ & twoD) ) + 4 * ci * sizegamadot * (I_ - 3*a_)
);

aEqn().relax();
solve(aEqn);


where keisi is a dimensionless scalar ,a_ is dimensionless tensor , twoD is shear rate tensor ( dimesnion = grad velocity = 1/s ) and I_ is identity tensor(dimensionless)

although ci is dimensionless in real world but this formula makes openFoam to consider it as a dimensioned scalar.(I don't know really why it happens?!! )

however, my question is how i should convert ci in to a dimensionless scalar which can be use in the aEqn?
any help would be appreciated.
mehdi kamyabi is offline   Reply With Quote

Old   April 21, 2013, 00:35
Default
  #2
New Member
 
Chris Prohoda
Join Date: Mar 2013
Posts: 6
Rep Power: 13
cpro is on a distinguished road
Quote:
Originally Posted by mehdi kamyabi View Post
--> FOAM FATAL ERROR:
Argument of transcendental function not dimensionless

//size of shear rate tensor (which is dimensioned scalar)
volScalarField sizegamadot = Foam::sqrt ( 0.5 * (twoD && twoD) );

//ci is a non-dimensioned variable which is calculated by this
//formula : ci = ((-0.0076*ln(sizegamadot) + 0.0385)/0.1876)^1.998

volScalarField ci = Foam:ow( ((-0.0076 * Foam::log (sizegamadot)) + 0.0385) / 0.1876 ) ,1.998 );
The formula for ci looks like it should be dimensionless. However, it looks like sizegamadot has dimensions of 1/s, which means it isn't a valid argument for log. That may be what the error message means. Hope that helps.
cpro is offline   Reply With Quote

Old   April 21, 2013, 04:31
Default
  #3
Senior Member
 
Lieven
Join Date: Dec 2011
Location: Leuven, Belgium
Posts: 299
Rep Power: 22
Lieven will become famous soon enough
Cpro is right, sizegamadot is not dimless and this is causing the problem.

The easiest way of solving this, is by writing something as
Code:
volScalarField sizegamadot =  Foam::sqrt ( 0.5 * (twoD && twoD) );

dimensionedScalar one = ("one",1/sizegamadot.dimensions(),1.0);

volScalarField ci = Foam::pow( ((-0.0076 * Foam::log (one*sizegamadot)) + 0.0385) / 0.1876 ) ,1.998 );
Normally however, correlations are usually set up such that the transcendental functions arguments are dimensionless. Before applying the fix above, make sure this is not the case for you (cause the fix is basically bypassing the dimensions check in OF).

Cheers,

L
Lieven is offline   Reply With Quote

Old   May 3, 2013, 10:11
Default
  #4
New Member
 
mehdi
Join Date: Nov 2010
Location: Tehran
Posts: 16
Rep Power: 16
mehdi kamyabi is on a distinguished road
Dear cpro & Lieven

thank you so for your valuable answers...it helped me so much.
mehdi kamyabi is offline   Reply With Quote

Old   February 25, 2014, 07:56
Default
  #5
Member
 
Rohith
Join Date: Oct 2012
Location: Germany
Posts: 57
Rep Power: 14
RaghavendraRohith is on a distinguished road
I am trying to implement an additional source term in energy equation, please suggest me the bug in my code.


Required Source term: 0.5*(1-tanh^2((Tm-T)/epsilon))/epsilon

I have placed a code

Code:
{

dimensionedScalar epsilon
(
    "epsilon",
    dimensionSet(0, 0, 0, 0, 0, 0 ,0),
    0.05
);


dimensionedScalar half
(
    "half",
    dimensionSet(0, 0, 0, 0, 0, 0 ,0),
    0.5
);


dimensionedScalar one
(
    "one",
    dimensionSet(0, 0, 0, 0, 0, 0 ,0),
    1
);


dimensionedScalar forty
(
    "forty",
    dimensionSet(0, 0, 0, 0, 0, 0 ,0),
    40
);


  = half*(one-Foam::pow(Foam::tanh((Tmelt-T)/epsilon),2))

How can i get it in a better way, i thought writing tanhx in exponential form but the same bug

HTML Code:
FOAM FATAL ERROR: 
Argument of trancendental function not dimensionles
s surrounds it

Thanks in Advance
Rohith
RaghavendraRohith is offline   Reply With Quote

Old   February 25, 2014, 08:08
Default
  #6
Senior Member
 
Lieven
Join Date: Dec 2011
Location: Leuven, Belgium
Posts: 299
Rep Power: 22
Lieven will become famous soon enough
Hi Rohith,

The error is related the remark I give above:
Quote:
correlations are usually set up such that the transcendental functions arguments are dimensionless
Although the variables you create are dimensionless, variables Tm and T are probably not. This is the reason OpenFOAM is complaining since he cannot compute the tanh of a dimensioned variable.

Also, I think you mean
Code:
(tanh((Tm-T)/epsilon)))^2
but still I don't see how (Tm-T)/epsilon can become dimensionless... Easy workaround is (Tm.value()-T.value())/epsilon.value() but this kind of ugly if you ask me.

Cheers,

L
Luttappy likes this.
Lieven is offline   Reply With Quote

Old   February 25, 2014, 08:17
Default
  #7
Member
 
Rohith
Join Date: Oct 2012
Location: Germany
Posts: 57
Rep Power: 14
RaghavendraRohith is on a distinguished road
Hi Lieven

I even don't want the (Tm-T)/epsilon to become dimensionless, however by using T.value(), it says that this scalar field doesn't have a member of this kind. how about converting the hyperbolic function into exponential and writing it? what do you think, i have tried it but the exp (temperature) must work, but theoretically it is not working for me



Greetings
Rohith
RaghavendraRohith is offline   Reply With Quote

Old   February 25, 2014, 08:37
Default
  #8
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,938
Rep Power: 39
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
Hi,

value is a method of dimensionedScalar, volScalarField has field method (http://foam.sourceforge.net/docs/cpp...873157f6ed35c3).

Also instead of
Code:
dimensionSet(0, 0, 0, 0, 0, 0 ,0)
you can use predefined constant dimness, i.e.

Code:
dimensionedScalar epsilon
(
    "epsilon",
    dimless
    0.05
);
But if all your constants in the code you've provided do not have dimensions why do you even bother to use dimensionedScalar instead of just scalar?
alexeym is offline   Reply With Quote

Old   February 25, 2014, 08:44
Default
  #9
Member
 
Rohith
Join Date: Oct 2012
Location: Germany
Posts: 57
Rep Power: 14
RaghavendraRohith is on a distinguished road
Hi

Ya it is not a big question here, i may be have used scalar(0.05) or dimless you are right, i will refine it. But the main issue concerns to the implementation of the equation described above


Ideas?

Greetings
RR
RaghavendraRohith is offline   Reply With Quote

Old   February 25, 2014, 09:03
Default
  #10
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,938
Rep Power: 39
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
Well,

First of all OpenFOAM is right and there's no such thing as exponent of kelvins. Argument of transcendent function should be dimensionless.

Concerning your equation, you can

1. Set dimension of epsilon to the temperature, as (I guess) it is the melting temperature range. So (Tm - T)/epsilon will be dimensionless.

2. Use T.field(), Tm.value() and epsilon.value() if you insist on them being dimensioned. Though it was suggested by Lieven.
jai manik, Luttappy and Kummi like this.
alexeym is offline   Reply With Quote

Old   February 25, 2014, 09:47
Default
  #11
Member
 
Rohith
Join Date: Oct 2012
Location: Germany
Posts: 57
Rep Power: 14
RaghavendraRohith is on a distinguished road
Hi

The second one doesnt work, but first one can be used with some more alterations.

Greetings
RR
RaghavendraRohith is offline   Reply With Quote

Reply


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
Solving for an additional species CO in coalChemistryFoam N. A. OpenFOAM Programming & Development 3 February 18, 2019 06:58
dieselFoam problem!! trying to introduce a new heat transfer model vivek070176 OpenFOAM Programming & Development 10 December 24, 2014 00:48
Specifying nonuniform boundary condition maka OpenFOAM Running, Solving & CFD 59 October 22, 2014 15:52
To convert Mesh from OpenFoam to GMSH gara1988 OpenFOAM Running, Solving & CFD 1 October 12, 2012 10:43
[Other] How to convert a mesh into openfoam format jr33 OpenFOAM Meshing & Mesh Conversion 1 October 2, 2012 18:20


All times are GMT -4. The time now is 06:59.