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

Derivative of a scalar or a variable through UDF

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   August 3, 2012, 16:42
Default Derivative of a scalar or a variable through UDF
  #1
Member
 
Fer Villa
Join Date: Apr 2012
Posts: 35
Rep Power: 6
fevi84 is on a distinguished road
Hi,

I need help!!!

I need calculate of derivative of a scalar, in my case, the derivative of the volume fraction.

Anyone knows how I can calculate this derivative through UDF??? because I only know the macros for the derivative of the velocity (C_DUDX(c,t), C_DUDY(c,t), C_DUDZ(c,t),...).

is there a way to calculate the derivative of a scalar or a variable other than velocity?

Thanks!!!
fevi84 is offline   Reply With Quote

Old   August 5, 2012, 11:29
Default
  #2
Senior Member
 
Amir's Avatar
 
Amir
Join Date: May 2009
Location: Montreal, QC
Posts: 739
Blog Entries: 1
Rep Power: 15
Amir is on a distinguished road
Hi,

You can store it in a UDS and retrieve its derivation.

Bests,
__________________
Amir
Amir is offline   Reply With Quote

Old   August 6, 2012, 01:41
Default
  #3
Senior Member
 
Ji Junjie
Join Date: Feb 2010
Location: Shanghai, China
Posts: 109
Rep Power: 8
gearboy is on a distinguished road
As Amir said, store the volume fraction into a UDSI and do not solve the equation of this UDSI. Then achieve the derivative by C_UDSI_G.
Use the following code to get the volume fraction.


Material *mix_mat = mixture_material(Get_Domain(1));
Material *spe_mat = NULL;
real all_mass_fracts[MAX_SPE_EQNS];
real all_mole_fracts[MAX_SPE_EQNS];
int i = -1;
mixture_species_loop(mix_mat, spe_mat, i)
{
all_mass_fracts[i] = C_YI(c,t,i);
}
Mole_Fraction(mix_mat, all_mass_fracts, all_mole_fracts);



After this, the mole fractions of all species can be found in the array "all_mole_fracts".





Quote:
Originally Posted by fevi84 View Post
Hi,

I need help!!!

I need calculate of derivative of a scalar, in my case, the derivative of the volume fraction.

Anyone knows how I can calculate this derivative through UDF??? because I only know the macros for the derivative of the velocity (C_DUDX(c,t), C_DUDY(c,t), C_DUDZ(c,t),...).

is there a way to calculate the derivative of a scalar or a variable other than velocity?

Thanks!!!
gearboy is offline   Reply With Quote

Old   August 6, 2012, 09:07
Default
  #4
Member
 
Fer Villa
Join Date: Apr 2012
Posts: 35
Rep Power: 6
fevi84 is on a distinguished road
Thank you very much for their replies.

I don't understand how store the volume fraction in a UDS without solving this UDS. I have to create a UDS through the graphical interface?

Can you please explain more.

Thanks!!!

Last edited by fevi84; August 6, 2012 at 09:38.
fevi84 is offline   Reply With Quote

Old   August 6, 2012, 10:40
Default
  #5
Senior Member
 
Ji Junjie
Join Date: Feb 2010
Location: Shanghai, China
Posts: 109
Rep Power: 8
gearboy is on a distinguished road
无命名.jpg

As to the usage, see chapter "Example UDF that Utilizes UDM and UDS Variables" in Fluent 6.3 UDF pdf manual(page 3-43).




Quote:
Originally Posted by fevi84 View Post
Thank you very much for their replies.

I don't understand how store the volume fraction in a UDS without solving this UDS. I have to create a UDS through the graphical interface?

Can you please explain more.

Thanks!!!
gearboy is offline   Reply With Quote

Old   August 6, 2012, 13:20
Default
  #6
Member
 
Fer Villa
Join Date: Apr 2012
Posts: 35
Rep Power: 6
fevi84 is on a distinguished road
Thank you very much again, your reply was very useful.


Quote:
Originally Posted by gearboy View Post
Attachment 15027

As to the usage, see chapter "Example UDF that Utilizes UDM and UDS Variables" in Fluent 6.3 UDF pdf manual(page 3-43).
fevi84 is offline   Reply With Quote

Old   February 3, 2015, 19:28
Default
  #7
Member
 
Join Date: Dec 2014
Posts: 38
Rep Power: 3
Harry321 is on a distinguished road
Hello,

Could one of you tell me difference between gradient and derivative in fluent. I used code:

fprintf(fp2, "DWDZ %f ", C_DWDZ(c, t));
fprintf(fp2, "CWG %lf \n", C_W_G(c, t)[2]);

but the values are different.
Harry321 is offline   Reply With Quote

Old   February 3, 2015, 22:39
Default
  #8
Member
 
Join Date: Dec 2014
Posts: 38
Rep Power: 3
Harry321 is on a distinguished road
Dear colleagues,

I don't know why in previous version of a code, fluent plotted wrong values but after I add:

fprintf(fp2, "DWDZ %f ", C_DWDZ(c, t));
fprintf(fp2, "CWG[0] %lf \n", C_W_G(c, t)[0]);
fprintf(fp2, "CWG[1] %lf \n", C_W_G(c, t)[1]);
fprintf(fp2, "CWG[2] %lf \n", C_W_G(c, t)[2]);

fluent plotted the same values for derivative of a velocity and for C_W_G(c, t)[2], I cannot see difference between this and previous one, but it works and the results are the same so it means that gradient and derivative are the same.
Harry321 is offline   Reply With Quote

Reply

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
UDF derivative libia87 Fluent UDF and Scheme Programming 0 March 30, 2012 04:14
can i get pressure derivative in UDF? ruirui389 Fluent UDF and Scheme Programming 4 April 8, 2011 04:12
UDF - accessing face variable problem argeus FLUENT 2 February 9, 2011 05:08
UDF extern variable - mean time moment coefficient enry Fluent UDF and Scheme Programming 0 November 14, 2009 07:56
Env variable not set gruber2 OpenFOAM Installation 5 December 30, 2005 05:27


All times are GMT -4. The time now is 06:37.