CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

Error SIGSEGV using VOF and UDF

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 28, 2021, 10:06
Default Error SIGSEGV using VOF and UDF
  #1
New Member
 
Jorge Rodríguez
Join Date: Oct 2021
Posts: 10
Rep Power: 4
JERC_UTFSM is on a distinguished road
Hello, I am having a SIGSEGV error when trying to use a UDF that I created for evaporation-condensation limited by the vapor pressure. I am using a gas phase (primary) using the methyl-alcohol-air template with density set up as ideal gas and a liquid phase combine with methyl-alcohol-liquid and water-liquid (with density Volume Weight Mixing Law).

I manage to compile the UDF without any warning and, in order to test the UDF, I decide to work with a closed and small 2D plane with a Pressure Operation around 10 MPa and a temperature of 450 K (which are nearly similar to the operation condition I will work with this UDF).

I design the UDF using the template ANSYS provided in their manual as a template and also have that one in order to discard possible errors. Either, by using my UDF and the one in the manual, I still have the SIGSEGV warning.

================================================== ============================

Node 0: Process 13728: Received signal SIGSEGV.

================================================== ============================

The fl process could not be started.


The UDF I created is the following:

Quote:
#include "udf.h"

/*Constants used in psat_i to calculate saturation pressure using ANTOINE EQUATION*/
/*Provided by NIST*/

#define A_H2O 3.55959
#define B_H2O 643.748
#define C_H2O -198.043

/*user inputs*/

#define MAX_SPE_EQNS_PRIM 5 /*total number of species in primary phase*/
#define index_evap_primary 0 /*evaporating species index in primary phase*/
#define prim_index 0 /*index of primary phase*/

/*end of user inputs*/

/* Computes saturation pressure of vapor pressure */
/* as function of temperature */
/* Equation is taken from ANTOINE EQUATION, */
/* Returns pressure in BAR, given temperature in KELVIN */

DEFINE_HET_RXN_RATE(user_evap_condens_react, c, t, hr, mw, yi, rr, rr_t)
{
Thread **pt = THREAD_SUB_THREADS(t);
Thread *tp = pt[0];
Thread *ts = pt[1];

int i;
real ch2o, csath2o, accum = 0., xh2o, xch3oh, varh2o;

real OP = RP_Get_Float("operating-pressure"); /*OPERATING PRESSURE*/
real P = (OP+C_P(c,tp)); /*PASCAL*/

real T_prim = C_T(c,tp); /*PRIMARY PHASE (gas) temperature*/
real T_sec = C_T(c,ts); /*SECONDARY PHASE (droplet) temperature*/
real diam = C_PHASE_DIAMETER(c,ts); /*secondary phase diameter*/

real Re, Sc, Nu, urel, urelx,urely,urelz=0., mass_coeff, area_density, flux_evap, D_evap_prim;

varh2o = A_H2O - B_H2O / (C_H2O - T_prim);

real psat_h2o = pow(10, varh2o)*1e5; /*VAPOR PRESSURE equation for WATER PASCAL*/

if(Data_Valid_P())
{
urelx = C_U(c,tp) - C_U(c,ts);
urely = C_V(c,tp) - C_V(c,ts);

#if RP_3D
urelz = C_W(c,tp) - C_W(c,ts);
#endif

urel = sqrt(urelx*urelx + urely*urely + urelz*urelz); /*relative velocity*/

Re = urel * diam * C_R(c,tp) / C_MU_L(c,tp);

for (i=0; i < MAX_SPE_EQNS_PRIM ; i++)
{
accum = accum + C_YI(c,tp,i)/mw[i][prim_index];
}

xh2o = C_YI(c,tp,0)/ mw[0][prim_index] / accum;

ch2o = xh2o * P / UNIVERSAL_GAS_CONSTANT / T_prim ;

csath2o = psat_h2o / UNIVERSAL_GAS_CONSTANT / T_sec ;

area_density = 6. * C_VOF(c,ts) / diam ;

D_evap_prim = C_DIFF_EFF(c, tp, 0) - 0.7 * C_MU_T(c, tp) / C_R(c, tp);
Sc = C_MU_L(c, tp) / C_R(c, tp) / D_evap_prim;

Nu = 2. + 0.6 * pow(Re, 0.5) * pow(Sc, 0.333);

mass_coeff = Nu * D_evap_prim / diam;

flux_evap = mass_coeff * (csath2o - ch2o);
*rr = area_density * flux_evap;
}
}
I tried creating a second .cas file, setting the secondary phase like just liquid water, and working with just one core.

Everytime I got the same error.
JERC_UTFSM is offline   Reply With Quote

Old   October 29, 2021, 00:04
Default
  #2
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
you have an equation for 3D case, but running it in 2D

change to
Code:
#if RP_3D
urelz = C_W(c,tp) - C_W(c,ts);
#endif
urel = sqrt(urelx*urelx + urely*urely ); /*relative 
#if RP_3D
urel = sqrt(urelx*urelx + urely*urely + urelz*urelz); /*relative 
#endifvelocity*/
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Old   October 29, 2021, 09:19
Default
  #3
New Member
 
Jorge Rodríguez
Join Date: Oct 2021
Posts: 10
Rep Power: 4
JERC_UTFSM is on a distinguished road
Quote:
Originally Posted by AlexanderZ View Post
you have an equation for a 3D case, but running it in 2D

change to
Code:
#if RP_3D
urelz = C_W(c,tp) - C_W(c,ts);
#endif
urel = sqrt(urelx*urelx + urely*urely ); /*relative 
#if RP_3D
urel = sqrt(urelx*urelx + urely*urely + urelz*urelz); /*relative 
#endifvelocity*/
Thanks for the observation, I tried what you said, but it still gave me the SIGSEGV error. I deleted any 3D equation related to the UDF, but it didn't work.

Thanks anyway for the help. Much appreciate.
JERC_UTFSM is offline   Reply With Quote

Old   October 29, 2021, 09:50
Default
  #4
New Member
 
Jorge Rodríguez
Join Date: Oct 2021
Posts: 10
Rep Power: 4
JERC_UTFSM is on a distinguished road
Quote:
Originally Posted by AlexanderZ View Post
you have an equation for 3D case, but running it in 2D

change to
Code:
#if RP_3D
urelz = C_W(c,tp) - C_W(c,ts);
#endif
urel = sqrt(urelx*urelx + urely*urely ); /*relative 
#if RP_3D
urel = sqrt(urelx*urelx + urely*urely + urelz*urelz); /*relative 
#endifvelocity*/
Can it be the fact I, initially, did not have a secondary phase?

EDIT: I tried with a few if for the secondary phase and it still didn't work.
JERC_UTFSM is offline   Reply With Quote

Old   October 29, 2021, 13:55
Default
  #5
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
Maybe you forgot to enable the energy equation?
__________________
"The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform" is NOT the error after compiling. It is the error after loading. To see compiler errors, look at your screen after you click "build".
pakk is offline   Reply With Quote

Old   October 29, 2021, 14:22
Default
  #6
New Member
 
Jorge Rodríguez
Join Date: Oct 2021
Posts: 10
Rep Power: 4
JERC_UTFSM is on a distinguished road
Quote:
Originally Posted by pakk View Post
Maybe you forgot to enable the energy equation?
It can't be. Energy equation is enable.

EDIT: I just realize Fluent become buggy just after the error is presented. Everywhere I click the text is all over the place.

Captura.jpg
JERC_UTFSM is offline   Reply With Quote

Old   October 31, 2021, 17:42
Default
  #7
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
problem could be here
Code:
real OP = RP_Get_Float("operating-pressure"); /*OPERATING PRESSURE*/
to be
Code:
real OP = RP_Get_Real("operating-pressure"); /*OPERATING PRESSURE*/
its strange, that you have the error while using code from manual, probably something wrong with your case
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Old   November 2, 2021, 10:34
Default
  #8
New Member
 
Jorge Rodríguez
Join Date: Oct 2021
Posts: 10
Rep Power: 4
JERC_UTFSM is on a distinguished road
Quote:
Originally Posted by AlexanderZ View Post
problem could be here
Code:
real OP = RP_Get_Float("operating-pressure"); /*OPERATING PRESSURE*/
to be
Code:
real OP = RP_Get_Real("operating-pressure"); /*OPERATING PRESSURE*/
its strange, that you have the error while using code from manual, probably something wrong with your case
It didn't work. I tried to create another case and I still getting the same SIGSEGV error. I also tried to define the Universal Gas Constant but I am still getting the same error no matter what I try.

I use the Visual Studio compiler because the build-in doesn't work properly, so I doesn't know if it may be related.
JERC_UTFSM is offline   Reply With Quote

Old   November 2, 2021, 22:59
Default
  #9
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
try simplified udf with constant output
Code:
#include "udf.h"

DEFINE_HET_RXN_RATE(user_evap_condens_react, c, t, hr, mw, yi, rr, rr_t)
{
*rr = constant value here;
}
}
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Old   November 3, 2021, 09:36
Default
  #10
New Member
 
Jorge Rodríguez
Join Date: Oct 2021
Posts: 10
Rep Power: 4
JERC_UTFSM is on a distinguished road
Quote:
Originally Posted by AlexanderZ View Post
try simplified udf with constant output
Code:
#include "udf.h"

DEFINE_HET_RXN_RATE(user_evap_condens_react, c, t, hr, mw, yi, rr, rr_t)
{
*rr = constant value here;
}
}
I simplified the UDF. I also specified the diameter of the droplet. I could manage to get rid of the SIGSEGV error, but now I am having trouble with the solver.

This is the UDF:

Quote:
#include "udf.h"

/*Constants used in psat_i to calculate saturation pressure using ANTOINE EQUATION*/
/*Provided by NIST*/

#define A_H2O 3.55959
#define B_H2O 643.748
#define C_H2O -198.043
#define R 8.314

/* Computes saturation pressure of vapor pressure */
/* as function of temperature */
/* Equation is taken from ANTOINE EQUATION, */
/* Returns pressure in PASCAL, given temperature in KELVIN */

DEFINE_HET_RXN_RATE(user_evap_condens_react, c, t, hr, mw, yi, rr, rr_t)
{
Thread** pt = THREAD_SUB_THREADS(t);
Thread* tp = pt[0];
Thread* ts = pt[1];

int i;

real OP = RP_Get_Real("operating-pressure"); /*OPERATING PRESSURE*/
real P = (OP + C_P(c, tp)); /*PASCAL*/

real T_prim = C_T(c, tp); /*PRIMARY PHASE (gas) temperature*/
real T_sec = C_T(c, ts); /*SECONDARY PHASE (droplet) temperature*/

/* Mass fraction from the primary phase. */
real wh2o = C_YI(c, tp, 0);
real wch3oh = C_YI(c, tp, 1);
real wh2 = C_YI(c, tp, 2);
real wco2 = C_YI(c, tp, 3);
real wco = C_YI(c, tp, 4);
real wn2 = C_YI(c, tp, 5);

real mh2o = mw[0][0];
real mch3oh = mw[0][1];
real mh2 = mw[0][2];
real mco2 = mw[0][3];
real mco = mw[0][4];
real mn2 = mw[0][5];

/* Accumulation base from the primary phase. */
real mmix = wh2o / mh2o + wch3oh / mch3oh + wh2 / mh2 + wco2 / mco2 + wn2 / mn2 + wco / mco;

/* Mole fraction from the primary phase. */
real yh2o = (wh2o / mh2o) / mmix;
real ych3oh = (wch3oh / mch3oh) / mmix;
real yh2 = (wh2 / mh2) / mmix;
real yco2 = (wco2 / mco2) / mmix;
real yco = (wco / mco) / mmix;
real yn2 = (wn2 / mn2) / mmix;

real diam = 0.00015; /*secondary phase diameter*/

real Re, Sc, Nu, urel, urelx, urely, mass_coeff, area_density, flux_evap, D_evap_prim;

real varh2o = A_H2O - B_H2O / (C_H2O - T_prim);

real psat_h2o = pow(10., varh2o) * 1e5; /*VAPOR PRESSURE equation for WATER PASCAL*/

if (Data_Valid_P())
{
urelx = C_U(c, tp) - C_U(c, ts);
urely = C_V(c, tp) - C_V(c, ts);

urel = sqrt(urelx * urelx + urely * urely);

Re = urel * diam * C_R(c, tp) / C_MU_L(c, tp);

real ch2o = yh2o * P / R / T_prim;

real csath2o = psat_h2o / R / T_sec;

area_density = 6. * C_VOF(c, ts) / diam;

D_evap_prim = C_DIFF_EFF(c, tp, 0) - 0.7 * C_MU_T(c, tp) / C_R(c, tp);

Sc = C_MU_L(c, tp) / C_R(c, tp) / D_evap_prim;

Nu = 2. + 0.6 * pow(Re, 0.5) * pow(Sc, 0.333);

mass_coeff = Nu * D_evap_prim / diam;

flux_evap = mass_coeff * (csath2o - ch2o);

*rr = area_density * flux_evap;
}
}
Now I am getting errors with the AMG solver, more precisily the temperature.

Stabilizing temperature to enhance linear solver robustness.
Stabilizing temperature using GMRES to enhance linear solver robustness.

Divergence detected in AM
Error at Node 3: floating point exception

Error at Node 1: floating point exception

Error at Node 2: floating point exception

Error at Node 0: floating point exception
G solver: temperature
Divergence detected in AMG solver: temperature
Divergence detected in AMG solver: temperature
Divergence detected in AMG solver: temperature
Error at host: floating point exception

Error: floating point exception
Error Object: #f


Tried with both, stationary and transient model.
JERC_UTFSM is offline   Reply With Quote

Old   November 3, 2021, 22:45
Default
  #11
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
when did you get this error, on the very first time step?

you may try to decrease timestep. make it small enough.
check your mesh quality
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Old   November 4, 2021, 07:56
Default
  #12
New Member
 
Jorge Rodríguez
Join Date: Oct 2021
Posts: 10
Rep Power: 4
JERC_UTFSM is on a distinguished road
Quote:
Originally Posted by AlexanderZ View Post
when did you get this error, on the very first time step?

you may try to decrease timestep. make it small enough.
check your mesh quality
I perform a mesh quality evaluation. I was reading somewhere the best is to keep the minimum orthogonal quality above 0.1, but I don't if there is something wrong with my mesh.

Quote:
Mesh Quality:

Minimum Orthogonal Quality = 1.00000e+00 cell -1 on zone -1 (ID: 0 on partition: 3) at location ( 0.00000e+00 0.00000e+00)
(To improve Orthogonal quality , use "Inverse Orthogonal Quality" in Fluent Meshing,
where Inverse Orthogonal Quality = 1 - Orthogonal Quality)

Maximum Aspect Ratio = 1.41422e+00 cell 262 on zone 2 (ID: 172 on partition: 3) at location ( 1.92500e-02 3.57500e-02)
Decreasing the time step does nothing. I tried with my default 1e-3 and decrease it with a 1e-5 time step and still got the same error.

Btw, the error happens in the first iteration.

EDIT: Tried to refine mesh from 0,5 mm to 0,1 mm element size. It didn't work.
JERC_UTFSM is offline   Reply With Quote

Old   November 5, 2021, 00:22
Default
  #13
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
you may try to run same case but with simplified heating rate

Code:
#include "udf.h"

DEFINE_HET_RXN_RATE(user_evap_condens_react, c, t, hr, mw, yi, rr, rr_t)
{
*rr = constant value here;
}
}
put reasonable value as "constant value here" and run simulation
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Old   November 5, 2021, 09:34
Default
  #14
New Member
 
Jorge Rodríguez
Join Date: Oct 2021
Posts: 10
Rep Power: 4
JERC_UTFSM is on a distinguished road
Quote:
Originally Posted by AlexanderZ View Post
you may try to run same case but with simplified heating rate

Code:
#include "udf.h"

DEFINE_HET_RXN_RATE(user_evap_condens_react, c, t, hr, mw, yi, rr, rr_t)
{
*rr = constant value here;
}
}
put reasonable value as "constant value here" and run simulation
I tried what you suggest but with no success... It gaves me the following errors:

Stabilizing x-momentum to enhance linear solver robustness.
Stabilizing x-momentum using GMRES to enhance linear solver robustness.

Divergence detected in AMG solver: x-momentum Stabilizing y-momentum to enhance linear solver robust
Error at Node 3: floating point exception

Error at Node 1: floating point exception

Error at Node 2: floating point exception

ness.
Error at Node 0: floating point exception
Stabilizing y-momentum using GMRES to enhance linear solver robustness.

Divergence detected in AMG solver: y-momentum Stabilizing pressure correction to enhance linear solver robustness.
Stabilizing pressure correction using GMRES to enhance linear solver robustness.

Divergence detected in AMG solver: pressure correction Stabilizing k to enhance linear solver robustness.
Stabilizing k using GMRES to enhance linear solver robustness.

Divergence detected in AMG solver: k Stabilizing epsilon to enhance linear solver robustness.
Stabilizing epsilon using GMRES to enhance linear solver robustness.

Divergence detected in AMG solver: epsilon Stabilizing vapor-species-0 to enhance linear solver robustness.
Stabilizing vapor-species-0 using GMRES to enhance linear solver robustness.

Divergence detected in AMG solver: vapor-species-0 Stabilizing vapor-species-1 to enhance linear solver robustness.
Stabilizing vapor-species-1 using GMRES to enhance linear solver robustness.

Divergence detected in AMG solver: vapor-species-1 Stabilizing vapor-species-2 to enhance linear solver robustness.
Stabilizing vapor-species-2 using GMRES to enhance linear solver robustness.

Divergence detected in AMG solver: vapor-species-2 Stabilizing vapor-species-3 to enhance linear solver robustness.
Stabilizing vapor-species-3 using GMRES to enhance linear solver robustness.

Divergence detected in AMG solver: vapor-species-3 Stabilizing vapor-species-4 to enhance linear solver robustness.
Stabilizing vapor-species-4 using GMRES to enhance linear solver robustness.

Divergence detected in AMG solver: vapor-species-4 Stabilizing liquid-species-0 to enhance linear solver robustness.
Stabilizing liquid-species-0 using GMRES to enhance linear solver robustness.

Divergence detected in AMG solver: liquid-species-0 Stabilizing temperature to enhance linear solver robustness.
Stabilizing temperature using GMRES to enhance linear solver robustness.

Divergence detected in AMG solver: temperature Stabilizing vof-1 to enhance linear solver robustness.
Stabilizing vof-1 using GMRES to enhance linear solver robustness.

Divergence detected in AMG solver: vof-1
Divergence detected in AMG solver: x-momentum
Divergence detected in AMG solver: y-momentum
Divergence detected in AMG solver: pressure correction
Divergence detected in AMG solver: k
Divergence detected in AMG solver: epsilon
Divergence detected in AMG solver: vapor-species-0
Divergence detected in AMG solver: vapor-species-1
Divergence detected in AMG solver: vapor-species-2
Divergence detected in AMG solver: vapor-species-3
Divergence detected in AMG solver: vapor-species-4
Divergence detected in AMG solver: liquid-species-0
Divergence detected in AMG solver: temperature
Divergence detected in AMG solver: vof-1
Divergence detected in AMG solver: x-momentum
Divergence detected in AMG solver: y-momentum
Divergence detected in AMG solver: pressure correction
Divergence detected in AMG solver: k
Divergence detected in AMG solver: epsilon
Divergence detected in AMG solver: vapor-species-0
Divergence detected in AMG solver: vapor-species-1
Divergence detected in AMG solver: vapor-species-2
Divergence detected in AMG solver: vapor-species-3
Divergence detected in AMG solver: vapor-species-4
Divergence detected in AMG solver: liquid-species-0
Divergence detected in AMG solver: temperature
Divergence detected in AMG solver: vof-1
Divergence detected in AMG solver: x-momentum
Divergence detected in AMG solver: y-momentum
Divergence detected in AMG solver: pressure correction
Divergence detected in AMG solver: k
Divergence detected in AMG solver: epsilon
Divergence detected in AMG solver: vapor-species-0
Divergence detected in AMG solver: vapor-species-1
Divergence detected in AMG solver: vapor-species-2
Divergence detected in AMG solver: vapor-species-3
Divergence detected in AMG solver: vapor-species-4
Divergence detected in AMG solver: liquid-species-0
Divergence detected in AMG solver: temperature
Divergence detected in AMG solver: vof-1
Error at host: floating point exception

Error: floating point exception
Error Object: #f


I define a constant around 1.5*1e(n), varying the n value from -3 to -10.
JERC_UTFSM is offline   Reply With Quote

Old   November 7, 2021, 23:17
Default
  #15
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
I have no experience in condensation/evaporation simulations
but for me this error means, you do probably have problems with case settings (boundary conditions, may be material properties, mesh, others) as you are using simplified UDF.

If you don't have any other thoughts you may try to simplify your case, may be start with just 2 species, find convergence and go step but step to your real case.
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Reply

Tags
udf sigsegv vof


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
UDF for VOF Modeling metafizix Fluent UDF and Scheme Programming 2 September 13, 2019 09:08
UDF Parse Error - Initializing VOF for Multiphase Simulation denbjornen Fluent UDF and Scheme Programming 0 April 25, 2018 02:07
Error during interpreting UDF for VoF vekh Fluent UDF and Scheme Programming 9 March 12, 2018 01:57
HELP! adding a mass source to VOF eqn. by UDF??? ROOZBEH FLUENT 5 December 3, 2016 17:53
UDF Defining VOF Free Surface at Outlet Alex Fluent UDF and Scheme Programming 13 August 8, 2012 16:50


All times are GMT -4. The time now is 02:38.