about unsteady uds term
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 
Re: about unsteady uds term
have you read the Fluent 6 udf manual? If not start there.
Greg 
Re: about unsteady uds term
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 
Re: about unsteady uds term
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 
Re: about unsteady uds term
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 
Re: about unsteady uds term
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=vv*. How do I write program to describe the equation? Thank you Frank 
Re: about unsteady uds term
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 
Re: about unsteady uds term
Hi: v is my uds v* is the function of concentration v*=f(c1,c2) I need the pde dvi/dt=vv* 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 
Re: about unsteady uds term
I know how to do it. You must use C to write the d(vv*)/dt,there are C codes I did .Maybe it will be helpful.for it is do d(clC_YI)/dt not d(vv*)/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=TMC_YI(c,t,0)*(TMTE)/CE; el=1(1/(1KP))*((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+(1el)*(KP1)+0.0000000000001))*C_YI(c,t,0); ffl[i1]=clC_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=TMC_YI(c,t,0)*(TMTE)/CE; elo=1(1/(1KP))*((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+(1elo)*(KP1)+0.0000000000001))*C_YI(c,t,0); fflo=cloC_YI(c,t,0); /*寻找该网格的领近各点/ for(j=0;j<=1400;j++) { detx=xocenx[j]; dety=yoceny[j]; if(fabs(detx)<=STEPX && fabs(dety)<=STEPY) { ff=ffloffl[j]; totalx2=totalx2+detx*detx; totaly2=totaly2+dety*dety; totalxy=totalxy+detx*dety; totalxf=totalxf+detx*ff; totalyf=totalyf+dety*ff; } } undernum=totalx2*totaly2totalxy*totalxy+0.000000000000001; fix=(totaly2*totalxftotalxy*totalyf)/undernum; fiy=(totalx2*totalyftotalxy*totalxf)/undernum; C_UDMI(c,t,0)=fix; C_UDMI(c,t,1)=fiy; } end_c_loop(c,t) } 
Re: about unsteady uds term
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

Re: about unsteady uds term
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 
need help urgently
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=(1time_step*k[0]*phi_old1+k[0]*time_step*phi_balan1; phi1=phi_curr1; time_diff1=(phi_curr1phi_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 } 
Re: about unsteady uds term
I cannot put vv* as a resouce term directly. Because I need the equation dv/dt=k(vv*) to solve v. In my code, i use (v_currv_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 
Re: need help urgently
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 
Re: about unsteady uds term
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 
Re: about unsteady uds term
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 
Re: about unsteady uds term
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 
Re: need help urgently
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 
Re: about unsteady uds term
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 N1 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 
Re: about unsteady uds term
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 
All times are GMT 4. The time now is 17:50. 