|
[Sponsors] |
August 15, 2020, 07:03 |
Implementation of sigmoid function
|
#1 |
New Member
Join Date: May 2020
Location: India
Posts: 4
Rep Power: 6 |
Hello Foamers ,
I am trying to implement sigmoid function in OpenFOAM-v1912 using Foam::exp() and Foam::pow(). Code:
volScalarField tmpVar = nGAGR*scalar(-1) + averageGAR; Code:
sigmoidGAGR=Foam::pow((1+Foam::exp(tmpVar)),-1); here nGAGR and averageGAGR both are dimensionless volScalarField. But the code wont work and stops at the second line. What am I doing wrong here, or is there any other way to implement sigmoid function. |
|
August 15, 2020, 16:56 |
|
#2 |
Senior Member
Herpes Free Engineer
Join Date: Sep 2019
Location: The Home Under The Ground with the Lost Boys
Posts: 931
Rep Power: 13 |
Hi,
- What is the error? - Sigmoid function is a generic name, which expression you try to code? - If the value of "tmpVar" becomes very large, the computation of "exp" function may throw floating point overflow error.
__________________
The OpenFOAM community is the biggest contributor to OpenFOAM: User guide/Wiki-1/Wiki-2/Code guide/Code Wiki/Journal Nilsson/Guerrero/Holzinger/Holzmann/Nagy/Santos/Nozaki/Jasak/Primer Governance Bugs/Features: OpenFOAM (ESI-OpenCFD-Trademark) Bugs/Features: FOAM-Extend (Wikki-FSB) Bugs: OpenFOAM.org How to create a MWE New: Forkable OpenFOAM mirror |
|
August 16, 2020, 07:47 |
|
#3 |
New Member
Join Date: May 2020
Location: India
Posts: 4
Rep Power: 6 |
Hi HPE,
- There is no error displayed in the terminal, the simulation just stops after first time-interval. But when I comment out the line the simulation starts running (and does not stops ). - Sigmoid function : The basic idea to use sigmoid function is that to take in some large number and pump out result that is either 0 or 1(or something in between). Here nGAGR is the order of 10^11 and averageGAR is in the order of 10^6. - Value should not be a problem since machine I'm using is a 64-bit one, and the macros DBL_MIN and DBL_MAX give the ranges as 2.22507e-308 and 1.79769e+308 respectively. And the range I'm working with is around 10^-8 to 10^11. The thing I want to do is basically assign 0s and 1s all over my mesh into volScalarField. There are two regions in the mesh one where nGAGR is around 10^11 and other where nGAGR is around 10^-8. Now that could have been easily achieved by looping all over the mesh and using if else. But I have a quite large mesh and deltaT is pretty small 10^-5. And what I learned from scientific computing course is that if/else and loops are lot slower than compared to mathematical statements. So I'm trying to implement sigmoid function PS : I have attached image of the sigmoid function which I want to implement |
|
Tags |
foam::exp, foam::pow, scalar, sigmoid, volscalarfield |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
whats the cause of error? | immortality | OpenFOAM Running, Solving & CFD | 13 | March 24, 2021 08:15 |
is internalField(U) equivalent to zeroGradient? | immortality | OpenFOAM Running, Solving & CFD | 7 | March 29, 2013 02:27 |
channelFoam for a 3D pipe | AlmostSurelyRob | OpenFOAM | 3 | June 24, 2011 14:06 |
latest OpenFOAM-1.6.x from git failed to compile | phsieh2005 | OpenFOAM Bugs | 25 | February 9, 2010 05:37 |
Version 15 on Mac OS X | gschaider | OpenFOAM Installation | 113 | December 2, 2009 11:23 |