# how to convert to dimensionless scalar in openfoam

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

 April 8, 2013, 06:40 how to convert to dimensionless scalar in openfoam #1 New Member   mehdi Join Date: Nov 2010 Location: Tehran Posts: 16 Rep Power: 7 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 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.

April 20, 2013, 23:35
#2
New Member

Chris Prohoda
Join Date: Mar 2013
Posts: 6
Rep Power: 5
Quote:
 Originally Posted by mehdi kamyabi --> 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.

 April 21, 2013, 03:31 #3 Senior Member   Lieven Join Date: Dec 2011 Location: Leuven, Belgium Posts: 297 Rep Power: 14 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 Tushar@cfd, sharonyue and Pirlu like this.

 May 3, 2013, 09:11 #4 New Member   mehdi Join Date: Nov 2010 Location: Tehran Posts: 16 Rep Power: 7 Dear cpro & Lieven thank you so for your valuable answers...it helped me so much.

 February 25, 2014, 07:56 #5 Member   Rohith Join Date: Oct 2012 Location: Germany Posts: 57 Rep Power: 6 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

February 25, 2014, 08:08
#6
Senior Member

Lieven
Join Date: Dec 2011
Location: Leuven, Belgium
Posts: 297
Rep Power: 14
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

 February 25, 2014, 08:17 #7 Member   Rohith Join Date: Oct 2012 Location: Germany Posts: 57 Rep Power: 6 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

 February 25, 2014, 08:37 #8 Senior Member   Alexey Matveichev Join Date: Aug 2011 Location: Nancy, France Posts: 1,423 Rep Power: 25 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?

 February 25, 2014, 08:44 #9 Member   Rohith Join Date: Oct 2012 Location: Germany Posts: 57 Rep Power: 6 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

 February 25, 2014, 09:03 #10 Senior Member   Alexey Matveichev Join Date: Aug 2011 Location: Nancy, France Posts: 1,423 Rep Power: 25 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.

 February 25, 2014, 09:47 #11 Member   Rohith Join Date: Oct 2012 Location: Germany Posts: 57 Rep Power: 6 Hi The second one doesnt work, but first one can be used with some more alterations. Greetings RR

 Thread Tools Display Modes Linear Mode

 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 OffTrackbacks are On Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post vivek070176 OpenFOAM Programming & Development 10 December 24, 2014 00:48 N. A. OpenFOAM Programming & Development 2 November 13, 2014 09:43 maka OpenFOAM Running, Solving & CFD 59 October 22, 2014 14:52 gara1988 OpenFOAM Running, Solving & CFD 1 October 12, 2012 09:43 jr33 OpenFOAM Meshing & Mesh Conversion 1 October 2, 2012 17:20

All times are GMT -4. The time now is 23:11.