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

UDF problem for Population balance model

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 30, 2018, 09:37
Default UDF problem for Population balance model
  #1
New Member
 
Join Date: Aug 2018
Posts: 16
Rep Power: 8
Amir.11 is on a distinguished road
Hi everyone,

I have some difficulties using Fluent UDF and would like to share them with you, hopefully someone can help me out.

I picked one of the Fluent UDF examples to define particle growth rate in a solid/liquid system where discrete population balance model is considered.

Constant growth rate was already tested without any problem but an error message appears when I try to run a simulation with “Growth rate UDF” which is:


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

Node x: Process xxxx: Received signal SIGSEGV.

================================================== ============================
The fl process could not be started.



My understanding is that something could be wrong between a macro in the UDF and some models in fluent.
The Eulerian multiphase model with mass transfer and granular solid is applied.
The energy equation is on and the memory location is also declared.


Is there any need to turn the species transfer on?


There could be also a parallelizing problem.
I am confused here, and could not figure out how Fluent UDF actually process in parallel.





The UDF is:

/************************************************** **********************
UDF that computes the particle growth rate
************************************************** ***********************/

#include "udf.h"
#include "sg_pb.h"
#include "sg_mphase.h"

DEFINE_PB_GROWTH_RATE(growth_rate, cell, thread,d_1)
{
/* d_1 can be used if size-dependent growth is needed */
/* When using SMM, only size-independent or linear growth is allowed */

real SS;
real G;
real Kg = 2.8e-8; /* growth constant */
real Ng = 1.; /* growth law power index */
real T,solute_mass_frac,solvent_mass_frac, solute_mol_frac,solubility;
real solute_mol_wt, solvent_mol_wt;

Thread *tc = THREAD_SUPER_THREAD(thread); /*obtain mixture thread */
Thread **pt = THREAD_SUB_THREADS(tc); /* pointer to sub_threads */
Thread *tp = pt[P_PHASE]; /* primary phase thread */

solute_mol_wt = 74.55; /* molecular weight of potassium chloride */
solvent_mol_wt = 18.; /* molecular weight of water */
solute_mass_frac = C_YI(cell,tp,0);
/* mass fraction of solute in primary phase (solvent) */

solvent_mass_frac = 1.0 - solute_mass_frac;
solute_mol_frac = (solute_mass_frac/solute_mol_wt)/
((solute_mass_frac/solute_mol_wt)+(solvent_mass_frac/solvent_mol_wt));

T = C_T(cell,tp); /* Temperature of primary phase in Kelvin */

solubility = 0.0005*T-0.0794;
/* Solubility Law relating equilibrium solute mole fraction to Temperature*/

SS = solute_mol_frac/solubility; /* Definition of Supersaturation */

if (SS <= 1.)
{
G = 0.;
}
else
{
G = Kg*pow((SS-1),Ng);
}
return G;
}




Any suggestion or comment is welcome and will be greatly appreciated.

Amir
Amir.11 is offline   Reply With Quote

Old   August 31, 2018, 07:07
Default
  #2
Senior Member
 
Join Date: Aug 2011
Posts: 421
Blog Entries: 1
Rep Power: 22
blackmask will become famous soon enough
The code is modified to handle the situation where a null pointer is encountered. You could use it to pinpoint the unexpected behavior.
Code:
#include "udf.h"
#include "sg_pb.h"
#include "sg_mphase.h"

DEFINE_PB_GROWTH_RATE(growth_rate, cell, thread,d_1)
{
    /* d_1 can be used if size-dependent growth is needed */
    /* When using SMM, only size-independent or linear growth is allowed */

    real SS;
    real G;
    real Kg = 2.8e-8; /* growth constant */
    real Ng = 1.; /* growth law power index */
    real T,solute_mass_frac,solvent_mass_frac, solute_mol_frac,solubility;
    real solute_mol_wt, solvent_mol_wt;



    solute_mol_wt = 74.55; /* molecular weight of potassium chloride */
    solvent_mol_wt = 18.; /* molecular weight of water */

    solute_mass_frac = 0.0; /* in case */
    T = 300.0; /* in case */

    Thread *tc = NULL, **pt = NULL, *tp =NULL;

    tc = THREAD_SUPER_THREAD(thread); /*obtain mixture thread */
    if (NULLP(tc))
    {
        Message("processor [%d]: NULL mixture thread\n");
        goto CALC;
    }
    pt = THREAD_SUB_THREADS(tc); /* pointer to sub_threads */
    if (NULLP(pt))
    {
        Message("processor [%d]: NULL sub_threads\n");
        goto CALC;
    }
    tp = pt[P_PHASE]; /* primary phase thread */
    if (NULLP(tp))
    {
        Message("processor [%d]: NULL primary phase thread\n");
        goto CALC;
    }

    if (NULLP(THREAD_STORAGE(tp, SV_Y)))
    {
        Message("processor [%d]: NULL YI\n");
        goto CALC;
    }
    solute_mass_frac = C_YI(cell,tp,0);
    if (NULLP(THREAD_STORAGE(tp, SV_T)))
    {
        Message("processor [%d]: NULL T\n");
        goto CALC;
    }
    T = C_T(cell,tp); /* Temperature of primary phase in Kelvin */
    /* mass fraction of solute in primary phase (solvent) */

    CALC:solvent_mass_frac = 1.0 - solute_mass_frac;
    solute_mol_frac = (solute_mass_frac/solute_mol_wt)/
            ((solute_mass_frac/solute_mol_wt)+(solvent_mass_frac/solvent_mol_wt));

    solubility = 0.0005*T-0.0794;
    /* Solubility Law relating equilibrium solute mole fraction to Temperature*/

    SS = solute_mol_frac/solubility; /* Definition of Supersaturation */

    if (SS <= 1.)
    {
        G = 0.;
    }
    else
    {
        G = Kg*pow((SS-1),Ng);
    }
    return G;
}
blackmask is offline   Reply With Quote

Old   August 31, 2018, 09:55
Default
  #3
New Member
 
Join Date: Aug 2018
Posts: 16
Rep Power: 8
Amir.11 is on a distinguished road
Thanks for your reply,

Now am pretty sure that is a parallelizing problem.

First I tried to run it in a serial solver and got this warning during compilation:

************************************************** **************************
** WARNING: Automatically switched to run in parallel -t1 mode. **
** Detected non-parallelized UDF usage, enabling parallel usage. **
** If you encounter any issues, please re-run with -t0 flag. **
************************************************** **************************

Then a MPI error appeared when starting the calculation.

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

Node 0: Process 7744: Received signal SIGSEGV.

================================================== ============================
MPI Application rank 0 exited before MPI_Finalize() with status 2
The fl process could not be started.



Seeing this, I tried to configure a parallelizing simulation.
I shared both the main fluent folder (located at: C:\Program Files\AnsysInc\v182\fluent) and my working directory folder. Then use a mapped drive letter to the shared folder.


I Launched Fluent and Set my working directory to the shared and changed the Fluent root path to be UNC.
By clicking ok to launch the program, the launcher disappears and cannot open.


Any comment is appreciated.
Many thanks in advance,
Amir
Amir.11 is offline   Reply With Quote

Old   August 31, 2018, 22:34
Default
  #4
Senior Member
 
Join Date: Aug 2011
Posts: 421
Blog Entries: 1
Rep Power: 22
blackmask will become famous soon enough
Did you use the modified code and still get SIGSEGV?
blackmask is offline   Reply With Quote

Old   September 3, 2018, 10:21
Default
  #5
New Member
 
Join Date: Aug 2018
Posts: 16
Rep Power: 8
Amir.11 is on a distinguished road
Quote:
Originally Posted by blackmask View Post
Did you use the modified code and still get SIGSEGV?


Hello and sorry for this late reply,

Actually I didn't get SIGSEGV by the modified code but couldn't use it either:

The below error message was appeared when interpreting:

Error: C:/Users/ADMINI~1/AppData/Local/Temp/GR.c.5276.7.c: line 25: parse error.
Error: C:/Users/ADMINI~1/AppData/Local/Temp/GR.c.5276.7.c: line 27: tc: undeclared variable


However I was able to compile it but the simulation couldn't get started.

Best,
Amir
Amir.11 is offline   Reply With Quote

Old   September 5, 2018, 12:06
Default
  #6
New Member
 
Join Date: Aug 2018
Posts: 16
Rep Power: 8
Amir.11 is on a distinguished road
I think I know where the problem comes from:

This UDF example (#1) takes ''solute_mass_fraction'' via ''C_YI'' macro.
The thing is, in population balance model and multiphase simulation, Mass fraction isn't declared anywhere, so its value is unknown for the code.

what I think should be used here is rather volume fraction. Because in the boundary conditions for PBM and the multiphase model, the code uses volume fraction and not mass fraction.

Once the volume fraction is defined, mass fraction could be calculated from solute and mixture density.

With this change the simulation could be started but there is also a thing which may cause an error:

The growth rate UDF couldn't be used with Eulerian multiphase model. So you may apply either Mixture or VOF method.

This is the code adding volume fraction:



/************************************************** **********************
UDF that computes the particle growth rate
************************************************** ***********************/

#include "udf.h"
#include "sg_pb.h"
#include "sg_mphase.h"

DEFINE_PB_GROWTH_RATE(growth_rate, cell, thread, d_1)
{
/* d_1 can be used if size-dependent growth is needed */
/* When using SMM, only size-independent or linear growth is allowed */

real SS;
real G;
real Kg = 2.8e-8; /* growth constant */
real Ng = 1.; /* growth law power index */
real T,solute_vol_frac,solvent_vol_frac,solute_mass_fra c,solvent_mass_frac, solute_mol_frac,solubility;
real solute_mol_wt, solvent_mol_wt;

Thread *tc = THREAD_SUPER_THREAD(thread); /*obtain mixture thread */
Thread **st = THREAD_SUB_THREADS(tc); /* pointer to sub_threads */
Thread *ts = st[S_PHASE]; /* secondary phase thread */

solute_mol_wt = 28.086; /* molecular weight of Silicon */
solvent_mol_wt = 18.; /* molecular weight of water */

solute_vol_frac = C_VOF(cell,ts); /* volume fraction of solute */
solvent_vol_frac = 1.0 - solute_vol_frac;

solute_mass_frac = solute_vol_frac*C_R(cell,ts)/C_R(cell,tc);
solvent_mass_frac = 1.0 - solute_mass_frac;

solute_mol_frac = (solute_mass_frac/solute_mol_wt)/
((solute_mass_frac/solute_mol_wt)+(solvent_mass_frac/solvent_mol_wt));

T = C_T(cell,tc); /* Temperature of primary phase in Kelvin */

solubility = 0.0005*T-0.0794;
/* Solubility Law relating equilibrium solute mole fraction to Temperature*/

SS = solute_mol_frac/solubility; /* Definition of Supersaturation */

if (SS <= 1.)
{
G = 0.;
}
else
{
G = Kg*pow((SS-1),Ng);
}
return G;

}


Best,
Amir
Amir.11 is offline   Reply With Quote

Old   May 30, 2022, 05:36
Default UDF of growth rate in population balance
  #7
New Member
 
Mohammadhossein
Join Date: May 2022
Posts: 1
Rep Power: 0
Mohammadhossein is on a distinguished road
Hi dears
I encounter some problems in growth rate udf and I share them.
I hope someone help me out.
I have a growth rate in population balance which depends on the diameter:
G(L)=(Rp*L0*L0*L0)/(3*ro*di*di*di)
Which L0 is initial diameter and di is next diameter due the growth.
I set initial diameter, but next step time initial diameter will change and I don't know how udf can recognize new diameter. Moreover, how I can set di?

bests
Mohammadhossein
Mohammadhossein 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
Problem with DPM simulation with particles injection and EXECUTE_AT_THE_END UDF. Ari Fluent UDF and Scheme Programming 4 May 31, 2016 09:51
problem with UDF for (v2-f) turbulence model in fluent artemiss1984 Fluent UDF and Scheme Programming 6 January 17, 2014 06:50
Problem with population balance model vaibhavraikhare FLUENT 0 January 28, 2012 11:08
The problem of UDF in Non premixed combustion model zhangyuan Main CFD Forum 0 May 25, 2009 10:41
UDF problem in multiphase model Amir Khodabandeh FLUENT 1 March 13, 2009 09:43


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