
[Sponsors] 
December 28, 2013, 09:25 
DEFINE_SOURCE for species

#1 
New Member
M.C.Qin
Join Date: Dec 2013
Posts: 5
Rep Power: 3 
Now, I directly put out my udf problem:
First, I have to describe the physical model: It is about the simulation of SO2 absorbtion by limestone slurry in desulfurization tower. I choose the EulerLagarange model. Of course, the continous phase is gas phase which is put in species transport model, contains two species,one is SO2 and another is air. Limestone slurry droplet is put in DPM modol use droplet particle type. Second, I treat the SO2 absorbtion process as the SO2 negtive mass source, and use the DEFINE_SOURCE macro to deal with it. In order to access the particle phase,I have to use the Particle *p to get the particle thread. The following is the source code: #include "udf.h" #include "dpm.h" #define Drop_density 1087.56 #define E 10. #define surface_intense_force 2.3e2 /* predefine function to calculate the relative velocity */ real urel(Particle *p,cell_t c,Thread *t) { real urelx=abs(C_U(c,t)p>state.V[0]); real urely=abs(C_V(c,t)p>state.V[1]); real urelz=abs(C_W(c,t)p>state.V[2]); real urel=sqrt(urelx*urelx+urely*urely+urelz*urelz); return urel; } DEFINE_SOURCE(de_sox,c,t,dS,eqn) { real S_g_so2=0.; real total_mass=0.,mean_mass=0.; real total_diam=0.,mean_diam=0.; real total_urel=0.,mean_urel=0.; real total_p_temp=0.,mean_p_temp=0.; real Aint=0.; int i=0; real Re,Sc,Sh,k_g_so2,Hso2,D_l_so2,f,k_l_so2,K_G,P_g_so 2; /* particle index for looping over all particles */ Particle *pi; /* loop over all particles in the cell to find their mass and weighted mean velocity and diameter */ begin_particle_cell_loop(pi,c,t) { total_mass+=pi>state.mass; total_diam+=pi>state.diam; total_urel+=urel(pi,c,t); total_p_temp+=pi>state.temp; i=i+1; } end_particle_cell_loop(pi,c,t) /* calculation for the so2 source */ if(i>0) { mean_mass=total_mass/(real)i; mean_diam=total_diam/(real)i; mean_urel=total_urel/(real)i; mean_p_temp=total_p_temp/(real)i; /* calculation for the area of mass transfer in per volume unit */ Aint=6.*(real)i*mean_mass/Drop_density/mean_diam/C_VOLUME(c,t); /* calculation for k_g_so2 */ /* calculation for Re */ Re= /* calculation for Sc */ Sc= /* calculation for Sh */ Sh= /* calculaton for k_g_so2 */ k_g_so2=C_DIFF_EFF(c,t,0)*Sh/UNIVERSAL_GAS_CONSTANT/C_T(c,t)/mean_diam; /* calculation for Herry constant */ Hso2= /* calculation for k_l_so2 */ /* calculation for D_l_so2 */ D_l_so2=mean_p_temp*exp(19.8951800./mean_p_temp); /* calculation for f */ f=sqrt(8.*surface_intense_force/3./M_PI/mean_mass); /* calculation for k_l_so2 */ k_l_so2=0.88*sqrt(f*D_l_so2); /* calculation for K_G */ K_G=1./(1./k_g_so2+1./E/Hso2/k_l_so2); /* calculation for P_g_so2 */ P_g_so2=C_P(c,t)*C_R(c,t)*C_YI(c,t,0)*22.4/64.; /* calculation for S_g_so2 */ S_g_so2=K_G*Aint*P_g_so2; } return S_g_so2; } Third,compiling and loading was successful(and without udf, fluent words well), but when I start to calculate, the problem shows as this: 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: #f I think there are two problems: 1 begin_particle_cell_loop(pi,c,t){}end_particle_cel l_loop(pi,c,t) can not been used in DEFINE_SOURCE. When i delete it, the fluent can calculate but the result may not right,because of the second problem that i noticed next; 2 This is a DEFINE_SOURCE for species, so I think that the thread "t" is a "species_lever"(I don't konw if it is right to call it "species_lever" thread, because there are "mixture_lever"and "phase_lever"thread mentioned in udf manual,but never heared a "species_lever"),if we want to find the C_VOF(c,t,i),thread "t" must be a mixture_lever for multiphase or a phase_lever for a single phase(the contnious phase that i used is single phase contains two species), we konw that we can get the mixture_lever thread from phase_lever thread use THREAD_SUPER_THREAD(phase_lever thread), and get the phase_lever thread from mixture_lever thread use THREAD_SUB_THREAD(mixture_lever thread,phase id),but how can we get a phase_lever thread or mixture_lever thread from the so called "species_lever"thread ? I really really want someone to help me dealing with this problem or providing me some advice or giving me another way and code(like DEFINE_MASS_TRANSTER , DEFINE_VR_RATE and so on) to cope with such process or even sending me a right code if you have ever did the same project, because I shared almost all things that i have studied in the past six month Here is my email:classic1573@163.com; Thinks for help; Last edited by classic1573; December 29, 2013 at 03:15. 

April 24, 2015, 14:54 

#2 
Member
BijanKianoush
Join Date: May 2014
Location: Iran Tehran
Posts: 84
Rep Power: 3 
hi, have you solved your problem ? let me know if you have ,thanks a lot


Tags 
udf 
Thread Tools  
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
turbineSiting tutorial and paraview3.98.0  pajot  OpenFOAM Paraview & paraFoam  4  September 14, 2013 10:19 
Wrong results from motorByke tutorial in OpenFoam 2.1.1  jsc  OpenFOAM Running, Solving & CFD  3  April 16, 2013 07:26 
Wrong oriented faces due to opposite face bends?  Arnoldinho  OpenFOAM  5  August 16, 2012 05:00 
BuoyantBoussinesqSimpleFoam and axialsymmetric results wrong mass flow  Thomas Baumann  OpenFOAM  6  December 21, 2009 11:31 
udf error  srihari  FLUENT  0  February 9, 2009 10:00 