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

Issue with logarithm function in OpenFOAM

Register Blogs Community New Posts Updated Threads Search

Like Tree4Likes
  • 1 Post By fluidflowsteel
  • 1 Post By alexeym
  • 2 Post By alexeym

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 15, 2017, 13:08
Default Issue with logarithm function in OpenFOAM
  #1
New Member
 
fluidflowsteel
Join Date: Jun 2016
Posts: 21
Rep Power: 10
fluidflowsteel is on a distinguished road
Hi ,

I am able to solve the following PDE successfully in OpenFOAM

fvm::ddt(X) == fvc::div(Y1*Y2*fvc::grad(X1/(1-X1))) where X,X1, Y1 and Y2 are scalar field variables

but when I modify the PDE in the following form

fvm::ddt(X) == fvc::div(Y1*Y2*fvc::grad(log(X1/(1-X1)))) where X1 is 0.09 (i.e less than 1)

I am getting the following error

#0 Foam::error:rintStack(Foam::Ostream&) at ??:?
#1 Foam::sigFpe::sigHandler(int) at ??:?
#2 ? in "/lib/x86_64-linux-gnu/libc.so.6"
#3 log in "/lib/x86_64-linux-gnu/libm.so.6"
#4 Foam::log(Foam::Field<double>&, Foam::UList<double> const&) at ??:?
#5 ? at ??:?
#6 ? at ??:?
#7 __libc_start_main in "/lib/x86_64-linux-gnu/libc.so.6"
#8 ? at ??:?

Can anyone help me how can get rid of the error ?


With regards
fluidflowsteel is offline   Reply With Quote

Old   February 15, 2017, 16:51
Default
  #2
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,

Is X1 constant? Can it be 0? Can it be negative? Just use X1.writeMinMax(Info) to see the range of X1.
alexeym is offline   Reply With Quote

Old   February 16, 2017, 05:05
Default
  #3
New Member
 
fluidflowsteel
Join Date: Jun 2016
Posts: 21
Rep Power: 10
fluidflowsteel is on a distinguished road
Hi,

NO X1 is not a constant. X1, Y1 and Y2 are volume scalar field variables. The initial value of X1 is 0.09. I think because of this value (which is very close to 0), the program is showing the error.

With regards
Kummi likes this.
fluidflowsteel is offline   Reply With Quote

Old   February 16, 2017, 05:21
Default
  #4
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
Quote:
Originally Posted by fluidflowsteel View Post
The initial value of X1 is 0.09. I think because of this value (which is very close to 0), the program is showing the error.
Well, this is nonsense-like sentence. If we assume that X1 = 0.09 EVERYWHERE, X1/(1 - X1) == 0.(098901), which is rather far from 0. But if we suppose, that SOMEWHERE X1 == 0 or X1 < 0, then it is a valid reason for FPE.

The error happens on the first solver iteration?
Tobi likes this.
alexeym is offline   Reply With Quote

Old   February 16, 2017, 05:31
Default
  #5
New Member
 
fluidflowsteel
Join Date: Jun 2016
Posts: 21
Rep Power: 10
fluidflowsteel is on a distinguished road
yes the error happens on first solver iteration. Look grad (logX1) = (1/X1)*grad(X1). since X1 initial value is 0.09 i think because of 1/0.09, the error is coming
fluidflowsteel is offline   Reply With Quote

Old   February 16, 2017, 06:14
Default
  #6
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
And you really think, compiler use chain rule for gradient? Instead of GUESSING, you can:

1. Just CHECK values of X1.
2. Use debug build of OpenFOAM to see exact line number, where error is located.

Or if this thread is psychoanalytic one, yes, we can continue to discuss, your thoughts. Next step is to talk about your feelings about this error. Did you have particular problems with logarithms in childhood?

Also, if I did not make a mistake

\vec\nabla\left(\log\frac{X1}{1 - X1}\right) = \vec\nabla\left(\log\left(X1\right) - \log\left(1 - X1\right)\right) =

= \frac{1}{X1}\vec\nabla{X1} - \frac{1}{1 - X1}\vec\nabla\left(1 - X1\right) = \frac{1}{X1}\vec\nabla{X1} + \frac{1}{1 - X1}\vec\nabla{X1} = \frac{1}{X1\left(1 - X1\right)}\vec\nabla{X1}
Tobi and Kummi like this.
alexeym is offline   Reply With Quote

Old   February 17, 2017, 09:14
Default
  #7
nsf
Senior Member
 
Nicolas Edh
Join Date: Mar 2010
Location: Uppsala, Sweden
Posts: 123
Rep Power: 18
nsf is on a distinguished road
Another possible cause is that X1 is zero on one of the boundaries.

/N
nsf 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
Map of the OpenFOAM Forum - Understanding where to post your questions! wyldckat OpenFOAM 10 September 2, 2021 06:29
issue compiling new turbulence model perplexed user OpenFOAM Programming & Development 1 January 13, 2012 04:40
New OpenFOAM Forum Structure jola OpenFOAM 2 October 19, 2011 07:55
[swak4Foam] wmake groovyBC in OpenFOAM 1.7 ? randomid OpenFOAM Community Contributions 1 August 27, 2010 06:15
Problem with compile the setParabolicInlet ivanyao OpenFOAM Running, Solving & CFD 6 September 5, 2008 21:50


All times are GMT -4. The time now is 12:42.