|
[Sponsors] |
April 7, 2017, 17:11 |
DPM-UDF-Segmentation fault
|
#1 |
Member
yun
Join Date: Jul 2015
Posts: 37
Rep Power: 11 |
hi everyone!
i receive an error while trying to execute a udf, the error message is: "Error: received a fatal signal (Segmentation fault). Error Object: #f" my case is very simple, i would like to get the volume of the cells and flow rate of the particles for now. if i can accomplish it i will change it with more complex problems. i can compile the udf and load it without any problem. in the problem, i do not interact the continuos phase with the discrete phase(one way coupling) because discrete phase has no affect on the continuous phase. so i can display the particle tracks via Results>Graphics and animations>Particle Tracks>Set up. i am not experienced on UDF issue and coding. maybe it is very simple but i could not get any proper answer from the forum or from other code examples. here is the code: #include "udf.h" #include "dpm.h" DEFINE_ON_DEMAND(PSIC) { Domain *d; Thread *t; cell_t c; Tracked_Particle *p; real flowrate; real volume; d = Get_Domain(1); thread_loop_c(t,d) { begin_c_loop(c,t) { volume = C_VOLUME(c,t); /* get cell volume */ flowrate = P_FLOW_RATE(p); /* get flow rate */ C_UDMI(c,t,0) = flowrate/volume; } end_c_loop(c,t) } } |
|
April 10, 2017, 08:02 |
|
#2 |
Member
yun
Join Date: Jul 2015
Posts: 37
Rep Power: 11 |
well i think i found out in the manual that P_FLOW_RATE can only be used with DPM MAcros! so i think, i need to use DEFINE_DPM_OUTPUT somehow. but still stuck here.
i need the particle flow rate (kg/s) in each cell. can anyone have any idea?! i am quite new in UDF and this forum is the only interactive source for me! thanks in advance. |
|
April 10, 2017, 14:46 |
|
#3 | |
New Member
Swapnil Chavanda
Join Date: Jan 2017
Location: Pune
Posts: 19
Rep Power: 9 |
Quote:
Please set number of memory locations in UDF Sent from my Moto G (4) using CFD Online Forum mobile app |
||
April 10, 2017, 14:47 |
|
#4 |
New Member
Swapnil Chavanda
Join Date: Jan 2017
Location: Pune
Posts: 19
Rep Power: 9 |
As 1
Because in your UDF as above it has only one UDMI Sent from my Moto G (4) using CFD Online Forum mobile app |
|
April 10, 2017, 15:01 |
|
#5 |
Member
yun
Join Date: Jul 2015
Posts: 37
Rep Power: 11 |
thank you for the answer Swapnil!
do you mean i need to use one more "c_UDMI(c,t,1)....." after the first one?? can you please be more specific with an example? |
|
April 11, 2017, 09:25 |
|
#6 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
There problems in your code are in the following lines:
Code:
flowrate = P_FLOW_RATE(p); /* get flow rate */ C_UDMI(c,t,0) = flowrate/volume; But what is definitely a problem is the first line above. You ask for the flow rate of "p". What is "p"? Fluent does not know. The compiler only knows that it points to a "Tracked_Particle", but you never specified which particle. You probably mean: the particle in the current cell that I am analyzing. But there might be no particle, or more than one particle. Luckily, Fluent made a macro that finds all particles in a cell. To use it, you can use this code: Code:
flowrate=0; begin_particle_cell_loop(p,c,t) { flowrate += P_FLOW_RATE(p); } end_particle_cell_loop(p,c,t) C_UDMI(c,t,0) = flowrate/volume; A conceptually better solution is probably to stop looping over all cells, but loop over all particles directly, using begin_particle_loop. But this is enough for now. |
|
April 11, 2017, 09:42 |
|
#7 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
And I just realized that you will run into another problem: you say you want to know the flowrate of "the particles". Which particles? At which moment?
Suppose that a particle starts in cell A, moves through cells B and C, and leaves the simulation through cell D, in which cell do you want the flow rate to be counted? It is quite possible that the current UDF chooses something else than you do. (Maybe the UDF even ignores all particles, because in an uncoupled DPM simulation the particles only 'exist' during the DPM calculation. I don't know.) But it start by knowing what YOU want the UDF to do. |
|
April 11, 2017, 10:12 |
|
#8 | |
Member
yun
Join Date: Jul 2015
Posts: 37
Rep Power: 11 |
Quote:
well, what i really want to calculate is the concentration in the each cell. i know it is possible to get concentration values when interaction is enabled. but i dont need interaction of phases. and i should mention that the problem is steady also. so i need to know the flow rate of particle in each cell, particle residence time in that cell and volume of the cell. then i can calculate the concentration via: [flow rate of particles (kg/s) *particle residence time (s) ] / volume of the cell (m3). but unfortunately my coding is just one week old. after the long investigations in the forum and the manual, i think i need to use DEFINE_DPM_OUTPUT rather than on_demand. what do you think? i will try to write and compile a code and inform you accordingly. thank you very much! |
||
April 11, 2017, 10:24 |
|
#9 | |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
I don't know what is best for you, because I don't know what you need.
Quote:
|
||
April 11, 2017, 10:32 |
|
#10 | |
Member
yun
Join Date: Jul 2015
Posts: 37
Rep Power: 11 |
Quote:
i know you dont care but i need your experienced comments! |
||
April 11, 2017, 10:47 |
|
#11 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
Your liquid is in steady state, your particles most likely are not.
Suppose that I throw a ball at you, and you catch it. (In this analogy, the ball is a particle, the throwing is a dpm simulation.) We are standing in a room where there is no wind (so specifically, the gas flows are steady state). If your script would be run on this situation, which cell should get a value? The cell containing my hand? The cell containing your hand? Or the cells along the trajectory of the ball? And if I throw the ball out of a window, so the ball ends up outside the simulation domain. What do you want the script to do with such a ball? (at the end of the simulation, your particles are 'nowhere', unless you have unfinished trajectories) |
|
April 12, 2017, 05:23 |
|
#12 | |
Member
yun
Join Date: Jul 2015
Posts: 37
Rep Power: 11 |
Quote:
all cells should get a value. in your analogy; your hand, my hand and the trajectory also. if you throw the ball out of the window DPM simulation terminates the trajectory at that point. |
||
April 12, 2017, 05:38 |
|
#13 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
But your individual particles are NOT in steady state. They move.
You say all cells along the trajectory should get a value. That is possible (computationally), but then you should make clear what value. What should it physically represent? I can only imagine one thing: the mass of the particles that are on average in this cell volume. (so unit kg) Then you have to use a macro that is called on every DPM timestep, such as DPM_scalar_update. The mass flow rate (P_MASS_FLOW(p)) has units kg/s, so you would need to multiply it with the length of the DPM timestep. |
|
April 12, 2017, 06:26 |
|
#14 | |
Member
yun
Join Date: Jul 2015
Posts: 37
Rep Power: 11 |
Quote:
thanks again, i will follow your comments. |
||
April 13, 2017, 05:19 |
|
#15 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
The difference is that you are not simulating the positions of the individual fluid molecules, but you are simulating the positions of the individual DPM particles.
Good luck! |
|
May 16, 2017, 06:53 |
UFD of DPM
|
#16 |
New Member
Join Date: Jan 2017
Posts: 25
Rep Power: 9 |
Dear sir,
I'm simulating particle in a reactangular domain by using DPM.For that i used a UDF.I'm succesfully complie the UDF but when i'm running it give my e error receive segmental error.Can you help me if ther is a error in my code of where the problem may be: UDF for the Discrete Phase Model solar reactor ************************************************** *********************/ #include "math.h" #include "udf.h" #include "dpm.h" #include "sg_mem.h" #include "surf.h" /* for macros: RP_Cell() & RP_Thread() */ #include "prop.h" #include "pdf_transport.h" /* GLOBAL CONSTANTS */ #define K0 1.07e6 /*1/s */ #define RHO_C_EXP 8.84 /*mol/m^3 */ #define EA 147.0e3 /*J/mol */ #define M_CH4 16.04e-3 /* kg/mol */ #define M_C 12.01e-3 /* kg/mol */ #define M_H2 4.00e-3/* kg/mol */ #define T_REF1 298. /* K */ #define RG 8.31434 /* Universal gas constant J/mol.K */ DEFINE_DPM_LAW(ParticleLaws,p,coupled) { Material *m = P_MATERIAL(p); cell_t c = P_CELL(p); /* Get Cell and Thread from */ cphase_state_t *cell = &(p->cphase); /* cell information of particle location*/ Thread *t = P_CELL_THREAD(p); /* Particle Structure using new macros*/ real dp, Tp, Tg, Vmix, Vp, Ap, rho_CH4, rho_p, theta_r; real r_Cex, r_Cmol, r_C, r_H2mol, r_CH4mol; real h_CH4mol, h_Cmol, h_H2mol, gammadot; real alpha_p, beta_p; real Pr, Nu, U; int CH4 = 0; /* First in list! */ dp= P_DIAM(p);/* Particle diameter */ /*new comment added*/ printf("Content of variable dp is: %d\n", dp); /* \n denotes a new line */ Tp = P_T(p);/* Particle temperature */ Tg = C_T(c,t);/* Gas mixture temperature */ Vmix = C_VOLUME(c,t);/* Gas mixture volume in the cell*/ Vp = M_PI/6.0 * pow(dp,3);/* Particle volume */ Ap = M_PI*pow(dp,2); /* Particle surface */ /* Methane molar density [mol/m^3] */ rho_CH4 = C_YI(c,t,CH4)*C_R(c,t)/M_CH4; /* Carbon particle molar density [mol/m^3] */ rho_p = C_DPMS_CONCENTRATION(c,t)/M_C; /* Experimental law for carbon reaction rate [s^-1] from Maag 2011 pag.7 */ r_Cex = K0 * exp(-EA/(Tp*RG)) * rho_CH4/RHO_C_EXP; /* Molar reaction rates [mol/m^3.s] */ r_Cmol = P_RHO(p)*r_Cex/M_C; r_CH4mol = -r_Cmol; r_H2mol = 2.*r_Cmol; r_C = r_Cmol*M_C; /* Advance particle mass in time using explicit euler */ if(r_C>0.0) { P_MASS(p) = P_MASS(p)/(1-P_DT(p)*r_C/P_RHO(p)); /* P_MASS(p) = P_MASS(p) + P_DT(p) * r_C*Vp;*/ /* Diamter grows, density remans constant */ P_DIAM(p) = pow(6.0*P_MASS(p)/(P_RHO(p)* M_PI), 1./3.); /* Prandtl number */ Pr = cell->sHeat * cell->mu / cell->tCond; /* Nusselt number */ Nu = 2.0 + 0.6 * sqrt(p->Re) * pow(Pr, 1./3.); /* Heat transfer coefficient*/ U = Nu * cell->tCond / dp; /*Radiation temperature*/ theta_r = pow( C_STORAGE_R_XV(c,t,SV_DO_IRRAD,0) / (4. * SIGMA_SBC), 0.25); /*Molar specific enthalpy [J/mol]*/ h_CH4mol = -74900. + 11.93*(Tg-T_REF1)+0.5*7.765e-2*(pow(Tg,2)-pow(T_REF1,2))-1.4e5*(1/Tg-1/T_REF1)-(1.841e-5/3.)*(pow(Tg,3)-pow(T_REF1,3)); h_Cmol = 14.58*(Tp-T_REF1)+0.5*9.957e-3*(pow(Tp,2)-pow(T_REF1,2))+8.5e5*(1/Tp-1/T_REF1)+(2.40e-6/3.)*(pow(Tp,3)-pow(T_REF1,3)); h_H2mol = 26.88*(Tp-T_REF1)+0.5*3.590e-3*(pow(Tp,2)-pow(T_REF1,2))-1.1e5*(1/Tp-1/T_REF1); /* Heat production term due to reactions [W/m^3] */ gammadot =1.*( -r_Cmol*h_Cmol-r_H2mol*h_H2mol-r_CH4mol*h_CH4mol); /*Coefficients for energy equation scheme */ /*alpha_p = (U*cell->temp + DPM_EMISSIVITY(p,m)*SIGMA_SBC*pow(theta_r,4)+dp/6.*gammadot)/(U+DPM_EMISSIVITY(p,m)*SIGMA_SBC*pow(Tp,3));*/ /*beta_p = Ap*(U+DPM_EMISSIVITY(p,m)*SIGMA_SBC*pow(Tp,3))/(P_MASS(p)*MATERIAL_PROP(m,PROP_Cp));*/ /*Energy equation scheme for DPM model */ /*P_T(p) = alpha_p + (P_T(p)-alpha_p)*exp(-beta_p*P_DT(p));*/ P_T(p) = P_T(p)+(P_DT(p)/(P_MASS(p)*MATERIAL_PROP(m,PROP_Cp)))*(U*Ap*(Tg-Tp)+DPM_EMISSIVITY(p,m)*Ap*(pow(theta_r,4)-pow(Tp,4))+Vp*gammadot); } } /* Calculate the cell source term for gas phase */ static real dpm_relax=0.1; /*dpm source relaxation */ |
|
June 30, 2017, 04:06 |
Received a fatal Signal ( Segmentation fault )
|
#17 |
Member
|
Hi everyone !
I hope you are fine. I am using UDF in VOF model in ANSYS FLUENT, although, my VOF model without UDF is running fine. The UDF is written by my friend used it successfully. He has graduated last year after getting the results from same UDF. The UDF was working well on his server. He was using Fluent 6.3 on Linux system. When I am using same case, date and UDF on my laptop the case is not running, although UDF compilation is very fine. I also check it on Linux system too. During or after initialization, Error occurred segmentation fault error. It is very strange that same case and UDF is not working on his office now. Main error occurred when I am hooking ADJUST and EXECUTE-AT-END UDFs. May be there is some problem of writing/calling style is different in Windows and Linux system with 32bit and 64bit. ( this is just my opinion). I hope you can understand the situation and have a try to fix the problem. I would be highly thankful if you guide me that where is the problem. I can send UDF by email if needed.. Thanks in Advance, Regards, M. F. ALi |
|
June 30, 2017, 04:11 |
|
#18 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
Try to initialize without the UDF, then load the UDF, and continue the simulation.
It could be that the UDF tries to access variables that don't exist yet when you do the initialization. If you want more concrete help, you should post the relevant UDF code. I am not going to start email contact. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
fatal signal segmentation fault in a UDF | hares | FLUENT | 6 | January 21, 2017 04:26 |
Parallel UDF Segmentation fault error | KevinZ09 | Fluent UDF and Scheme Programming | 1 | January 9, 2017 06:30 |
UDF with UDM Error: segmentation fault | dj1210 | Fluent UDF and Scheme Programming | 4 | November 24, 2016 10:44 |
segmentation fault when installing OF-2.1.1 on a cluster | Rebecca513 | OpenFOAM Installation | 9 | July 31, 2012 16:06 |
Segmentation Fault | Shawn_A | OpenFOAM Running, Solving & CFD | 6 | October 31, 2011 15:38 |