CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   how to convert to dimensionless scalar in openfoam (https://www.cfd-online.com/Forums/openfoam-programming-development/115838-how-convert-dimensionless-scalar-openfoam.html)

 mehdi kamyabi April 8, 2013 06:40

how to convert to dimensionless scalar in openfoam

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::pow( ((-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.

 cpro April 20, 2013 23:35

Quote:
 Originally Posted by mehdi kamyabi (Post 419049) --> 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::pow( ((-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.

 Lieven April 21, 2013 03:31

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

 mehdi kamyabi May 3, 2013 09:11

Dear cpro & Lieven

 RaghavendraRohith February 25, 2014 07:56

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

Rohith

 Lieven February 25, 2014 08:08

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

 RaghavendraRohith February 25, 2014 08:17

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

 alexeym February 25, 2014 08:37

Hi,

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

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?

 RaghavendraRohith February 25, 2014 08:44

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

 alexeym February 25, 2014 09:03

Well,

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

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.

 RaghavendraRohith February 25, 2014 09:47

Hi

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

Greetings
RR

 All times are GMT -4. The time now is 00:44.