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

about unsteady uds term

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 26, 2002, 06:25
Default about unsteady uds term
  #1
Frank
Guest
 
Posts: n/a
Hi everybody: I want to write a unsteady uds as a source term to add the mass balance equation. I am a fresh user. I meet many problem when I writting my program. I appreciate if anyboby can post some similar C program codes which can give some instructions.

Thank you very much

Frank
  Reply With Quote

Old   March 26, 2002, 22:25
Default Re: about unsteady uds term
  #2
Greg Perkins
Guest
 
Posts: n/a
have you read the Fluent 6 udf manual? If not start there.

Greg
  Reply With Quote

Old   March 26, 2002, 23:57
Default Re: about unsteady uds term
  #3
Frank
Guest
 
Posts: n/a
Hi: Thank you very much. Acutally I have read the udf mannual in fluent6. But only uds is introduced. I want to know more knowledge about how to write unsteady uds term. Do you have some samples about it?

By the way, my program can be compiled smoothly as a interpreted file. But when I execut it, "SEGMENTATION VIOLATION" is raised. what is the meaning of it? Do you have any advice to solve it?

need your reply promply.

Thank you again

Frank
  Reply With Quote

Old   March 27, 2002, 01:21
Default Re: about unsteady uds term
  #4
Greg Perkins
Guest
 
Posts: n/a
Segmentation fault is most likely caused by you accessing either a UDM or UDS that you haven't yet allocated memory for.

Actually, the udf manual for 6 has an example and a clear explanation of the uds unsteady term - or at least the electronic version I have does.

Have you tried the example....????

Greg
  Reply With Quote

Old   March 27, 2002, 01:25
Default Re: about unsteady uds term
  #5
Frank
Guest
 
Posts: n/a
Hi Greg

Do you think it is helpful for the problem if I compile my program as a compiled program?

Thank you for your reply

Frank
  Reply With Quote

Old   March 27, 2002, 03:46
Default Re: about unsteady uds term
  #6
Frank
Guest
 
Posts: n/a
Hi Greg:

The reason you mentioned may be true. But all uds in my program can be found in my fluent case file after compiling. Could you tell give me some introductions?

By the way, I read the sample of unsteady term in the mannual. The sample just define a derivative dv/dt. But in my case, I want to describe dv/dt=v-v*. How do I write program to describe the equation?

Thank you

Frank
  Reply With Quote

Old   March 27, 2002, 04:58
Default Re: about unsteady uds term
  #7
Greg Perkins
Guest
 
Posts: n/a
What is the exact meaning of dv/dt = v - v* what is v* ??

If this is your pde, then you don't need to write an unsteady uds function since you are using a standard form for the derivative, ie. dv/dt !

In this case, it looks to me like you'll be writing a source term for the v - v* term. Of course, I don't fully know what v* is so it may depend on your answer

Greg
  Reply With Quote

Old   March 27, 2002, 05:03
Default Re: about unsteady uds term
  #8
Frank
Guest
 
Posts: n/a
Hi: v is my uds v* is the function of concentration v*=f(c1,c2) I need the pde dvi/dt=v-v* to calculate v. Yes, you are right. I want to put dvi/dt add mass equation as a source term. Could you give me some advices?

Thank you

Frank
  Reply With Quote

Old   April 16, 2002, 23:29
Default Re: about unsteady uds term
  #9
H.S.Fang
Guest
 
Posts: n/a
I know how to do it. You must use C to write the d(v-v*)/dt,there are C codes I did .Maybe it will be helpful.for it is do d(cl-C_YI)/dt not d(v-v*)/dt. all the same.

(j=0;j<=1400;j++)

{cenx[j]=0.;ceny[j]=0.;ffl[j]=0.;}

thread_loop_c(t,domain) { begin_c_loop(c,t) { C_CENTROID(x,c,t);

cenx[i1]=x[0];ceny[i1]=x[1];

Tl=TM-C_YI(c,t,0)*(TM-TE)/CE;

el=1-(1/(1-KP))*((C_UDSI(c,t,0)-Tl)/(C_UDSI(c,t,0)-TM));

if(el<0.)

el=0.;

else if(el>1.)

el=1.;

cl=(1/(1+(1-el)*(KP-1)+0.0000000000001))*C_YI(c,t,0);

ffl[i1]=cl-C_YI(c,t,0);

i1++; } end_c_loop(c,t); }

thread_loop_c(t,domain) {

begin_c_loop(c,t)

{

totalx2=0.;

totaly2=0.;

totalxy=0.;

totalxf=0.;

totalyf=0.;

/*取出一个网格c(xo,yo,0)及其函数值*/

C_CENTROID(y,c,t);

xo=y[0];yo=y[1];

Tlo=TM-C_YI(c,t,0)*(TM-TE)/CE;

elo=1-(1/(1-KP))*((C_UDSI(c,t,0)-Tlo)/(C_UDSI(c,t,0)-TM));

if(elo<0)

elo=0.;

else if(elo>1.)

elo=1.;

clo=(1/(1+(1-elo)*(KP-1)+0.0000000000001))*C_YI(c,t,0);

fflo=clo-C_YI(c,t,0);

/*寻找该网格的领近各点/

for(j=0;j<=1400;j++)

{

detx=xo-cenx[j];

dety=yo-ceny[j];

if(fabs(detx)<=STEPX && fabs(dety)<=STEPY)

{

ff=fflo-ffl[j];

totalx2=totalx2+detx*detx;

totaly2=totaly2+dety*dety;

totalxy=totalxy+detx*dety;

totalxf=totalxf+detx*ff;

totalyf=totalyf+dety*ff;

}

} undernum=totalx2*totaly2-totalxy*totalxy+0.000000000000001; fix=(totaly2*totalxf-totalxy*totalyf)/undernum; fiy=(totalx2*totalyf-totalxy*totalxf)/undernum; C_UDMI(c,t,0)=fix; C_UDMI(c,t,1)=fiy;

}

end_c_loop(c,t) }
  Reply With Quote

Old   April 17, 2002, 00:32
Default Re: about unsteady uds term
  #10
fank
Guest
 
Posts: n/a
Hi:Friend Thank you for you help. Can I ask you some question urgently by phone? Could you tell me your phone No. and convenient time? Thank you very much again
  Reply With Quote

Old   April 18, 2002, 01:18
Default Re: about unsteady uds term
  #11
Greg Perkins
Guest
 
Posts: n/a
I'm not convinced this is quite what is needed although the code is interesting.

How do you use such code? ie part of an adjust function?

It seems to me that a better way is actually to write the source term for v - v* which is quite easy.

Greg
  Reply With Quote

Old   April 18, 2002, 02:25
Default need help urgently
  #12
Frank
Guest
 
Posts: n/a
Dear Greg: Thank you for your reply. The following is the problem I want to solve: I want to add -Fdv/dt in the mass transfer equation as a source term. dv/dt=k(v*-v); v*=f(c1,c2) v1*=Kc1/(1+bc1+bc2)( here c1, c2 are concentration of one species.I have written a c code.But finally I find that the calculation results cannot be affected by the source term. The source term is zero in the rults. I feel so confused. Could you check my code and refer out the bug inside. Thank you very much!!!! Compilling is no problem.

#include "udf.h" #define F 0.96 #define c0 1000 define time_step 1.0 DEFINE_SOURCE(xmass_source,cell,thread,ds,eqn1) {float K[2]={2.354,3.675}; float b[2]={0.0529,0.0826}; float k[2]={0.9,1.2}; real flow_time, source1,phi1;phi_curr1,phi_old1,phi_balan1,time_di ff1;

phi_balan1=K[0]*c0*C_YI(cell,thread,0)/(1+b[0]*c0*C_YI(cell,thread,0)+b[1]*c0*C_YI(cell,thread,1));

phi_old1=phi1;

phi_curr1=(1-time_step*k[0]*phi_old1+k[0]*time_step*phi_balan1; phi1=phi_curr1; time_diff1=(phi_curr1-phi_old1)/time_step; source1=-F*time_diff1; ds[eqn1]=0.0; return source; }

DEFINE_SOURCE(xmass_source2,cell,thread,ds,eqn2) {similar to the last part }
  Reply With Quote

Old   April 18, 2002, 02:33
Default Re: about unsteady uds term
  #13
Frank
Guest
 
Posts: n/a
I cannot put v-v* as a resouce term directly. Because I need the equation dv/dt=k(v-v*) to solve v. In my code, i use (v_curr-v_old)/time_step to represent dv/dt.

How to write time_step. Can I use RP_Get_Real to describe time step? The the program is a compiled program, right?

Do I need to write a user defined scalar?

need your help.

Thank you very very much
  Reply With Quote

Old   April 18, 2002, 04:14
Default Re: need help urgently
  #14
Greg Perkins
Guest
 
Posts: n/a
I still don't quite get what you want to do exactly. Are you trying to represent some sort of chemical reaction, or mass transfer???

For your udfs, to model mass transfer you need to add a mass source term that is the sum of the species source terms into the continuity eqn.

This seems to have caused some confusion, since I month or so ago I put a post about this - have a look at that.

Its likely, that if you've just added a source term to the species equations you won't see any effect on the total mass flow rate. As I said you need to add the source term to the continuity eqn.

Regarding the other questions, please post a complete description of this dv/dt = v - v*. is v* - a known function or is it some approximation your trying to use ??

Greg
  Reply With Quote

Old   April 18, 2002, 06:24
Default Re: about unsteady uds term
  #15
Greg Perkins
Guest
 
Posts: n/a
This is where we need to be clear on what you're trying to do.

If you want to solve for scalar transport of v in the domain, you will need to solve a scalar transport eqn. (though since its very simple, you may be able to get away with writing just a udf - like an execute on demand).

Assuming you solve a uds, you can set the unsteady term as the defualt, which will be dv/dt.

Then you need to set the flux function to none and the uds diffusivity to zero.

I assume the uds is no. zero and you've allocated memory for it.

Then write a udf source term for the v - v* term you have. I don't exactly undersatdn this term, but this is quite easy:

DEFINE_SOURCE(my_srce,c,t,ds,eqn) {

real srce;

real v_star;

srce = C_UDSI(c,t,0) - v_star;

ds[eqn] = 1.0; }

Now - I have some problem with your definition of the source term. If you use v - v* you are likely to have stability issues, since the derivative of this term wrt v is a positive value. You may need to linearize this term (see the book by Patankar).

Also if v* is a function of v then you'll need to add this to the derivative above. In this case the ds part will be

ds[eqn] = 1.0 + d(v_star)/dv;

Regards

Greg

  Reply With Quote

Old   April 18, 2002, 06:50
Default Re: about unsteady uds term
  #16
Frank
Guest
 
Posts: n/a
Hi: Thank you for your reply! My project is to describe adsorption separation of two specieses. Actually v is adsorption term. v* is balance adsorption term. Because there is no adsorption term dv/dt in the mass transfer equation. I need add this term in it.

dvi/dt=k(vi*-vi)

v=f(c1,c2) c1, c2 is concentration of specieses. for example, v1=Kc1,v2=kc2

COuld you let me know how to write c code.I have already put my code in the last post. COuld you find problem inside. I need you help urgently.

Thank you very much
  Reply With Quote

Old   April 18, 2002, 07:04
Default Re: about unsteady uds term
  #17
Frank
Guest
 
Posts: n/a
Hi: I can not add v*-v as a source term directly, because v must be solved by the mass transfer equation and dv/dt=k(v*-v) and v*=f(c) (c is concentration)

thank you for your consideration
  Reply With Quote

Old   April 18, 2002, 07:08
Default Re: need help urgently
  #18
Frank
Guest
 
Posts: n/a
hi: which equation is continuity equation? I have already add it in the mass transfer equation as source term. In the source term panel, I select source term for different specieses.. COuld you reply to me?

Thank you very much
  Reply With Quote

Old   April 18, 2002, 08:06
Default Re: about unsteady uds term
  #19
Greg Perkins
Guest
 
Posts: n/a
Continuity equation is the one for overall conservation of mass.

I still don't quite understand this v equation. Perhaps somebody else knows this better than I.

At the species level, you have a conservation equation for each species (actuall N-1 equations, we don't solve for last species) and then you have the continuity equation for the conservation of the overall mass.Thus you have N equations for N species mass fractions, concentrations or apparent densities etc - depending on what you prefer you can use any of these.

So for your absorption process, I imagine that you have a source term for each species which models the rate at which the species is "absorbed" and/or desorbed etc. Here I'm using an analogy with chamical reactions since that's what I'm doing.

So have you got the full set of equations you want to solve and have you looked at the conservation of mass issue for the system and all the species?? Is you complete model consistent??

I would think you'll have to write a source term for each species at the very least.

Now back to v - what does it represent in terms of the conservation of mass etc???

If this represents some additional scalar then you'll need to solve it as such, but to be useful I would expect it must have an influence back on the conservation of mass for the species.

Greg

  Reply With Quote

Old   April 18, 2002, 22:58
Default Re: about unsteady uds term
  #20
fank
Guest
 
Posts: n/a
Hi: Thank you for you patient reply: the following is my model:

dc/dt+v*dc/dz=DL*dc^2/dz^2+F*dq/dt dq/dt=k(q*-q) q*=Kc

Where c is concentration of species.q is adsorption term Could you let me know how to write c code for this model?

Thank you very much
  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 of SOURCE term gradient in UDS wind Fluent UDF and Scheme Programming 6 December 1, 2022 15:21
ATTENTION! Reliability problems in CFX 5.7 Joseph CFX 14 April 20, 2010 16:45
Doubts UDS Flux, UDS Unsteady for VOF model kel85uk FLUENT 0 March 17, 2010 09:53
Manipulating the advection term of the UDS Ameya Durve FLUENT 0 February 24, 2009 14:52
[Q] Convection term treatment in UDS Ryan, Lee FLUENT 4 October 18, 2004 11:20


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