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

User define memory storage

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 1, 2019, 06:51
Default User define memory storage
  #1
New Member
 
Dhiraj Lote
Join Date: Jul 2015
Location: Mumbai, India
Posts: 20
Rep Power: 11
dhiraj.lote@gmail.com is on a distinguished road
Hello,

I have written UDF for the breakage rate of Coulaloglou and Tavlarides model and interpreted in fluent 17.2 (for population balance modeling).

However, I would like to store a memory of breakage rate. For the same I have used syntax C_UDMI (cell, thread, 0)=breakage rate. But, I am getting this stored value zero everywhere in the domain. Please suggest me the solution.

Here is my UDF,

************************************************** **********************

UDF that computes the particle breakage frequency

************************************************** ***********************/

#include "udf.h"

#include "sg_pb.h"

#include "sg_mphase.h"





DEFINE_PB_BREAK_UP_RATE_FREQ(break_up_freq_tav, cell, thread, d_1)

{

real epsi, alpha, f1, f2, rho_d=1.225;

real C1 = 0.00481, C2 = 0.08, sigma = 0.072;

Thread *tm = THREAD_SUPER_THREAD(thread);/*passed thread is phase*/

epsi = C_D(cell, tm);

alpha = C_VOF(cell, thread);

rho_d = C_R(cell, thread);

f1 = C1*pow(epsi, 1./3.)/((1.+alpha)*pow(d_1, 2./3.));

f2 = -(C2*sigma*(1.+alpha)*(1.+alpha))/(rho_d*pow(epsi,2./3.)*pow(d_1, 5./3.));

C_UDMI(cell, thread, 0) = C1*f1*exp(f2);

return C1*f1*exp(f2);

}
dhiraj.lote@gmail.com is offline   Reply With Quote

Old   July 1, 2019, 22:05
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
did you select the name that you specified in the DEFINE macro argument in the appropriate drop-down list under Phenomena in the Population Balance Model dialog box?

udf seems OK, most likely there is some problem with model settings
you may try to put Message macro inside to see what is calculated, but make small mesh for this
Code:
************************************************** **********************

UDF that computes the particle breakage frequency

************************************************** ***********************/

#include "udf.h"

#include "sg_pb.h"

#include "sg_mphase.h"





DEFINE_PB_BREAK_UP_RATE_FREQ(break_up_freq_tav, cell, thread, d_1)

{

real epsi, alpha, f1, f2, rho_d=1.225;

real C1 = 0.00481, C2 = 0.08, sigma = 0.072;

Thread *tm = THREAD_SUPER_THREAD(thread);/*passed thread is phase*/

epsi = C_D(cell, tm);

alpha = C_VOF(cell, thread);

rho_d = C_R(cell, thread);

f1 = C1*pow(epsi, 1./3.)/((1.+alpha)*pow(d_1, 2./3.));

f2 = -(C2*sigma*(1.+alpha)*(1.+alpha))/(rho_d*pow(epsi,2./3.)*pow(d_1, 5./3.));

C_UDMI(cell, thread, 0) = C1*f1*exp(f2);

Message0("epsi = %f | alpha =%f | rho_d =%f | f1 =%f | f2 =%f \n ",alpha,epsi,rho_d,f1,f2);

return C1*f1*exp(f2);

}
best regards
AlexanderZ is offline   Reply With Quote

Old   July 2, 2019, 01:03
Default
  #3
New Member
 
Dhiraj Lote
Join Date: Jul 2015
Location: Mumbai, India
Posts: 20
Rep Power: 11
dhiraj.lote@gmail.com is on a distinguished road
Thank you so much for the reply, AlexanderZ.
By putting message macro inside, in fluent it gives error of "CX_Message0" not found (pc=211).

My mesh is just 60000 elements only.
dhiraj.lote@gmail.com is offline   Reply With Quote

Old   July 2, 2019, 01:05
Default
  #4
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
60000 elements means 60000 messages in console

change message to printf
or compile UDF

best regards
AlexanderZ is offline   Reply With Quote

Old   July 2, 2019, 01:09
Default
  #5
New Member
 
Dhiraj Lote
Join Date: Jul 2015
Location: Mumbai, India
Posts: 20
Rep Power: 11
dhiraj.lote@gmail.com is on a distinguished road
Thank you for the reply,
I am new to UDF, dont know much about UDF.
Can you please tell me how to change message to printf
dhiraj.lote@gmail.com is offline   Reply With Quote

Old   July 2, 2019, 09:35
Default
  #6
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
Put the cursor directly after "Message0", press backspace 8 times, and press 'p' on your keyboard, followed by 'r', 'i', 'n', 't' and 'f'.
pakk is offline   Reply With Quote

Old   July 3, 2019, 07:27
Default
  #7
New Member
 
Dhiraj Lote
Join Date: Jul 2015
Location: Mumbai, India
Posts: 20
Rep Power: 11
dhiraj.lote@gmail.com is on a distinguished road
Thank you pakk,
it worked.
But, still the calculated and stored value is zero everywhere, and lots of values (no. of values are more) are showing in fluent consol. how to tackle this.
dhiraj.lote@gmail.com is offline   Reply With Quote

Old   July 3, 2019, 08:33
Default
  #8
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
All those values are shown on your screen for a reason... Look at them!
pakk is offline   Reply With Quote

Old   July 4, 2019, 00:52
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
this UDF is example from Fluent manual, if it doesn't work, it means you've missed something in settings of your model (not UDF)
did you hook it properly?

best regards
AlexanderZ is offline   Reply With Quote

Old   July 4, 2019, 04:31
Default
  #10
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
I think that dhiraj has no idea what we are trying to do here...


Dhiraj, the problem that you had was that you got zeros as result. AlexanderZ suggested to add some line that would help to know WHY you got zeros as result.


Look at the last line of your code:
Code:
return C1*f1*exp(f2);
When does this return a zero value? It can be in three cases:
  1. C1 = 0
  2. f1 = 0
  3. exp(f2) = 0 (which means f2 = minus infinity)
Which case are you in? The second or the third, but we don't know which. How to find out? Let the program print the values of f1 and f2!


And that is exactly what AlexanderZ suggested: he wanted you to print the values of f1 and f2 (and thinking ahead, he already added some more values to print). You say that you ran the code and saw many values on your screen. Great, look at them! What do they say for f1 and f2? Is f1 zero? Is f2 minus infinity?


If you see (for example) that f1 is always zero, then you have made the problem smaller! Because then you can find out why f1 is zero. Again, look at the place in your code where f1 is defined, see which values it depends on, and print these values. And you might for example find out that the real problem is that epsi is always zero, because you are not running a turbulent simulation. Or it is something else. But you have to look at the values on your screen, we can not do that for you.
pakk 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
udf for source term in UDS equation dkjknobel Fluent UDF and Scheme Programming 12 August 19, 2019 08:57
Segmentation fault error in User defined memory UDF abhi12019 Fluent UDF and Scheme Programming 3 September 13, 2018 04:17
REAL GAS UDF brian FLUENT 6 September 11, 2006 09:23
Free surface boudary conditions with SOLA-VOF Fan Main CFD Forum 10 September 9, 2006 13:24
user define scalar mechmed FLUENT 0 March 29, 2006 11:07


All times are GMT -4. The time now is 13:00.