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

second derivation

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

Reply
 
LinkBack Thread Tools Display Modes
Old   May 9, 2011, 10:15
Default second derivation
  #1
New Member
 
m.reza
Join Date: Apr 2011
Posts: 18
Rep Power: 6
m.reza is on a distinguished road
Hi
How can I define second derivation of temperature and velocity in special direction in udf ???????????????????
m.reza is offline   Reply With Quote

Old   May 10, 2011, 08:38
Default
  #2
Senior Member
 
Amir's Avatar
 
Amir
Join Date: May 2009
Location: Shiraz, Iran
Posts: 739
Blog Entries: 1
Rep Power: 14
Amir is on a distinguished road
Hi,
I guess a tip may work: (do that and inform me)
1)store first gradient of T in a UDS but do not solve a UDS equation.(use that just as a storing position)
2)use C_UDSI_G to compute gradient of gradient

Regards,

Amir
Amir is offline   Reply With Quote

Old   May 10, 2011, 09:14
Default Second Deivation
  #3
New Member
 
m.reza
Join Date: Apr 2011
Posts: 18
Rep Power: 6
m.reza is on a distinguished road
Hi Amir
I did that,but I have a error :
Error:
FLUENT received fatal signal (ACCESS_VIOLATION)
1. Note exact events leading to error.
2. Save case/data under new name.
3. Exit program and restart to continue.
4. Report error to your distributor.
Error Object: ()



And it's my udf for changing the energy Eq.


#include "udf.h"
#include "mem.h"
#define C_teta 0.3
#define P_t 0.85



DEFINE_SOURCE(source_ggdh , c, t, dS, eqn)
{
Domain *domain;
real coord[ND_ND];
real source,y,T,nu_t,S11,S12,S22,A,B,C,D;
real DUDX,DVDY,DVDX,DUDY,D2UDX2,D2UDXY,D2UDY2,D2VDY2,D2 VDYX,D2VDXY,D2VDX2,D2TDX2,D2TDXY,D2TDY2;

C_CENTROID(coord,c, t);
y = coord[1];

nu_t = C_MU_T(c,t)/C_R(c,t);
T = C_K(c, t)/C_D(c, t);

S11 = 0.5*(C_U_G(c,t)[0]+C_U_G(c,t)[0]);
S12 = 0.5*(C_U_G(c,t)[1]+C_V_G(c,t)[0]);
S22 = 0.5*(C_V_G(c,t)[1]+C_V_G(c,t)[1]);





C_UDSI(c,t,0) = (C_U_G(c,t)[0]);
C_UDSI(c,t,1) = (C_V_G(c,t)[1]);
C_UDSI(c,t,2) = (C_U_G(c,t)[1]);
C_UDSI(c,t,3) = (C_V_G(c,t)[0]);
C_UDSI(c,t,4) = C_T_G(c,t)[0];
C_UDSI(c,t,5) = C_T_G(c,t)[1];

DUDX = (C_UDSI(c,t,0));
DVDY = (C_UDSI(c,t,1));
DUDY = (C_UDSI(c,t,2));
DVDX = (C_UDSI(c,t,3));
D2UDX2 =(C_UDSI_G(c,t,0)[0]);
D2UDXY =(C_UDSI_G(c,t,0)[1]);
D2UDY2 =(C_UDSI_G(c,t,2)[1]);
D2VDY2 =(C_UDSI_G(c,t,1)[1]);
D2VDYX =(C_UDSI_G(c,t,1)[0]);
D2VDXY=D2VDYX;
D2VDX2 =(C_UDSI_G(c,t,3)[0]);
D2TDX2=(C_UDSI_G(c,t,4)[0]);
D2TDXY=(C_UDSI_G(c,t,4)[1]);
D2TDY2=(C_UDSI_G(c,t,5)[1]);


A = T*((-2.*nu_t*D2UDX2)*C_UDSI(c,t,4)+(2.*C_K(c, t)/3.-2.*nu_t*S11)*D2TDX2+(-nu_t*(D2UDXY+D2VDX2))*C_UDSI(c,t,5)+(-2.*nu_t*S12)*D2TDXY);
B = T*((-nu_t*(D2UDY2+D2VDXY)*C_UDSI(c,t,4))+(-2.*nu_t*S12)*D2TDXY+(-2.*nu_t*D2VDY2)*C_UDSI(c,t,5)+(2.*C_K(c, t)/3.-2.*nu_t*S22)*D2TDY2);
C = nu_t*C_T_G(c,t)[0]/P_t;
D = nu_t*C_T_G(c,t)[1]/P_t;




source = C_teta*C_R(c,t)*C_CP(c,t)*(A+B-C-D);

dS[eqn] = 0.0;

return source;
}


but I don't know to do.
Do you know where my error is?
m.reza is offline   Reply With Quote

Old   May 10, 2011, 10:56
Default
  #4
Senior Member
 
Amir's Avatar
 
Amir
Join Date: May 2009
Location: Shiraz, Iran
Posts: 739
Blog Entries: 1
Rep Power: 14
Amir is on a distinguished road
Hi,
I compiled and had some iterations with that!
note these comments:
1)activate energy and k-e model
2)you have to prevent the solver from freeing up memory by issuing the text command solve/set/expert and then answering yes to the question Keep temporary solver memory from being freed?
3)use this code:
Quote:
#include "udf.h"
#include "mem.h"
#define C_teta 0.3
#define P_t 0.85



DEFINE_SOURCE(source_ggdh,c,t,dS,eqn)
{
Domain *domain;
real coord[ND_ND];
real source,y,T,nu_t,S11,S12,S22,A,B,C,D;
real DUDX,DVDY,DVDX,DUDY,D2UDX2,D2UDXY,D2UDY2,D2VDY2,D2 VDYX,D2VDXY,D2VDX2,D2TDX2,D2TDXY,D2TDY2;
C_CENTROID(coord,c,t);
y =coord[1];
nu_t = C_MU_T(c,t)/C_R(c,t);
T = C_K(c,t)/C_D(c,t);
S11 = 0.5*(C_U_G(c,t)[0]+C_U_G(c,t)[0]);
S12 = 0.5*(C_U_G(c,t)[1]+C_V_G(c,t)[0]);
S22 = 0.5*(C_V_G(c,t)[1]+C_V_G(c,t)[1]);
C_UDSI(c,t,0) = (C_U_G(c,t)[0]);
C_UDSI(c,t,1) = (C_V_G(c,t)[1]);
C_UDSI(c,t,2) = (C_U_G(c,t)[1]);
C_UDSI(c,t,3) = (C_V_G(c,t)[0]);
C_UDSI(c,t,4) = C_T_G(c,t)[0];
C_UDSI(c,t,5) = C_T_G(c,t)[1];
DUDX = (C_UDSI(c,t,0));
DVDY = (C_UDSI(c,t,1));
DUDY = (C_UDSI(c,t,2));
DVDX = (C_UDSI(c,t,3));
D2UDX2 =(C_UDSI_G(c,t,0)[0]);
D2UDXY =(C_UDSI_G(c,t,0)[1]);
D2UDY2 =(C_UDSI_G(c,t,2)[1]);
D2VDY2 =(C_UDSI_G(c,t,1)[1]);
D2VDYX =(C_UDSI_G(c,t,1)[0]);
D2VDXY=D2VDYX;
D2VDX2 =(C_UDSI_G(c,t,3)[0]);
D2TDX2=(C_UDSI_G(c,t,4)[0]);
D2TDXY=(C_UDSI_G(c,t,4)[1]);
D2TDY2=(C_UDSI_G(c,t,5)[1]);
A = T*((-2.*nu_t*D2UDX2)*C_UDSI(c,t,4)+(2.*C_K(c, t)/3.-2.*nu_t*S11)*D2TDX2+(-nu_t*(D2UDXY+D2VDX2))*C_UDSI(c,t,5)+(-2.*nu_t*S12)*D2TDXY);
B = T*((-nu_t*(D2UDY2+D2VDXY)*C_UDSI(c,t,4))+(-2.*nu_t*S12)*D2TDXY+(-2.*nu_t*D2VDY2)*C_UDSI(c,t,5)+(2.*C_K(c, t)/3.-2.*nu_t*S22)*D2TDY2);
C = nu_t*C_T_G(c,t)[0]/P_t;
D = nu_t*C_T_G(c,t)[1]/P_t;
source = C_teta*C_R(c,t)*C_CP(c,t)*(A+B-C-D);
dS[eqn] = 0.0;
return source;
}
Amir is offline   Reply With Quote

Old   May 11, 2011, 10:17
Default second derivation
  #5
New Member
 
m.reza
Join Date: Apr 2011
Posts: 18
Rep Power: 6
m.reza is on a distinguished road
tnx Amir
I'm trying download C++ and Comile it.
thanks for your help
I'll inform you.
m.reza 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
Derivation of k-e model from momentum equation CFDtoy Main CFD Forum 5 May 10, 2006 16:53
derivation enthalpy Tomik FLUENT 2 March 9, 2006 16:39
derivation of tsunami speed novice Main CFD Forum 3 February 24, 2005 09:43
Derivation d Roh / dt or dT/dt. henry pastohr FLUENT 0 May 17, 2000 03:44
Flux Splitting: Derivation Abhijit Modak Main CFD Forum 5 May 2, 2000 04:13


All times are GMT -4. The time now is 07:21.