|
[Sponsors] |
July 1, 2019, 06:51 |
User define memory storage
|
#1 |
New Member
Dhiraj Lote
Join Date: Jul 2015
Location: Mumbai, India
Posts: 20
Rep Power: 11 |
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); } |
|
July 1, 2019, 22:05 |
|
#2 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
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); } |
|
July 2, 2019, 01:03 |
|
#3 |
New Member
Dhiraj Lote
Join Date: Jul 2015
Location: Mumbai, India
Posts: 20
Rep Power: 11 |
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. |
|
July 2, 2019, 01:05 |
|
#4 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
60000 elements means 60000 messages in console
change message to printf or compile UDF best regards |
|
July 2, 2019, 01:09 |
|
#5 |
New Member
Dhiraj Lote
Join Date: Jul 2015
Location: Mumbai, India
Posts: 20
Rep Power: 11 |
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 |
|
July 2, 2019, 09:35 |
|
#6 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
Put the cursor directly after "Message0", press backspace 8 times, and press 'p' on your keyboard, followed by 'r', 'i', 'n', 't' and 'f'.
|
|
July 3, 2019, 07:27 |
|
#7 |
New Member
Dhiraj Lote
Join Date: Jul 2015
Location: Mumbai, India
Posts: 20
Rep Power: 11 |
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. |
|
July 3, 2019, 08:33 |
|
#8 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
All those values are shown on your screen for a reason... Look at them!
|
|
July 4, 2019, 00:52 |
|
#9 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
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 |
|
July 4, 2019, 04:31 |
|
#10 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
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);
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. |
|
|
|
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 |