# Periodic BC in ANSYS DDPM, UDF

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

 January 12, 2016, 10:56 Periodic BC in ANSYS DDPM, UDF #1 Member   Rupesh Verma Join Date: Jun 2013 Posts: 64 Rep Power: 6 Dear Friend, I am using, DDPM simulation using ANSYS 14.5, for a simple system. I used inlet as periodic and outlet as shadow in ANSYS for making it periodic but after making periodic I have no control on the inlet (I am unable to specify mass flow rate inlet), it is showing option to specify pressure gradient. Thanks for helping in advance!!!

 January 12, 2016, 18:33 #2 Senior Member   Join Date: Mar 2015 Posts: 800 Rep Power: 11 Are you having a problem with the fluid or discrete phase? Are you using a UDF with the boundary condition? Are you sure you want to use a periodic boundary condition for the inlet and outlet?

 January 13, 2016, 00:02 #3 Member   Rupesh Verma Join Date: Jun 2013 Posts: 64 Rep Power: 6 I have not facing problem in defining fluid or discrete phase. Simply, I have 3D rectangular domain and i used udf for filling the particle in that, having diameter 1 cm (1000 particles), now i want to recycle the particles from the outlet to inlet, may be there will be so may method but up to now i am unable to do that. I am using ddpm-Dem in ANSYS 14.5. Thanks!!!

 January 13, 2016, 20:14 #4 Senior Member   Join Date: Mar 2015 Posts: 800 Rep Power: 11 I've not used the Dense Discrete Phase Model (DDPM) but it appears Fluent uses the same DPM model with modifications to the mass and momentum conservation equations in the Eulerian model (to overcome the limitation of the small volume fraction assumption). One method of recycling the particles from the outlet to the inlet boundary is to modify the position when the particle reaches the outlet. Modify the x-position (assuming the outlet is in the Y-Z plane) using the DEFINE_DPM_BC macro and hook this macro to the outlet boundary for the DPM. An (incomplete) example with the key lines of code: Code: ```DEFINE_DPM_BC(recycle_particles,...) { ... P_POS(p)[0] = 0.; // move particle to inlet (at origin, x=0) return PATH_ACTIVE; // allows the solver to continue tracking this parcel }``` Note: be careful with the number of tracked particle steps because the particle may never escape the domain.

January 27, 2016, 09:21
DDPM with particle recycle
#5
Member

Rupesh Verma
Join Date: Jun 2013
Posts: 64
Rep Power: 6
Quote:
 Originally Posted by `e` I've not used the Dense Discrete Phase Model (DDPM) but it appears Fluent uses the same DPM model with modifications to the mass and momentum conservation equations in the Eulerian model (to overcome the limitation of the small volume fraction assumption). One method of recycling the particles from the outlet to the inlet boundary is to modify the position when the particle reaches the outlet. Modify the x-position (assuming the outlet is in the Y-Z plane) using the DEFINE_DPM_BC macro and hook this macro to the outlet boundary for the DPM. An (incomplete) example with the key lines of code: Code: ```DEFINE_DPM_BC(recycle_particles,...) { ... P_POS(p)[0] = 0.; // move particle to inlet (at origin, x=0) return PATH_ACTIVE; // allows the solver to continue tracking this parcel }``` Note: be careful with the number of tracked particle steps because the particle may never escape the domain.
Dear Friends,
I am using, DDPM simulation using ANSYS 14.5, for a simple system. Domain is a rectangular column, having dimensions 0.2X0.15X1.5 m3. Also, there is one outlet and one inlet of 0.025X0.025X0.2 m3. In the column there are 1000 balls having diameter 0.02 m. I want to balls continuous recycle back in a countable way.
[some body told me in circulating fluidized bed mostly people used this, outlet recycle back, using smaller domain, but i didn't get any thing by google search]
Thanks

 January 27, 2016, 18:01 #6 Senior Member   Join Date: Mar 2015 Posts: 800 Rep Power: 11 Starting with the code I've provided above, add in commands to save the number of particles cycled either to a text file (could include details of flow time or particle residence time) or global variable (simply an integer of the number of recycled particles). Code: ```static int recycledParticles=0; // global variable accessible only within this file DEFINE_DPM_BC(recycle_particles,...) { ... // open a data file // save data to a text file, you could include times or location of particle // close the data file recycledParticles = recycledParticles + 1; // update number of particles P_POS(p)[0] = 0.; // move particle to inlet (at origin, x=0) return PATH_ACTIVE; // allows the solver to continue tracking this parcel }``` Let us know if you're stuck with the coding, but it should be straightforward (there are code snippets online for opening and writing to files etc).

 January 29, 2016, 04:22 #7 Member   Rupesh Verma Join Date: Jun 2013 Posts: 64 Rep Power: 6 Thanks for nice reply, Is such type of UDF will work in ANSYS ( also which version of ANSYS is comfortable with such type UDF etc. My Second question: i am unable to the understand how to apply the step "// save data to a text file, you could include times or location of particle" pls explain in detail. My email is roopesh99@gmail.com if you have some issues. Thanking You.. Last edited by roopesh99; January 29, 2016 at 09:55.

 January 31, 2016, 22:56 #8 Senior Member   Join Date: Mar 2015 Posts: 800 Rep Power: 11 I'm unsure of your first question but ANSYS bought Fluent and it's now called ANSYS Fluent but the code is the same (has been updated / developed since acquisition); the UDF I posted above should work on any Fluent version you're working with. There are many examples online for saving data to a text file so I won't repeat here but check this post for starters.

February 1, 2016, 23:39
#9
Member

Rupesh Verma
Join Date: Jun 2013
Posts: 64
Rep Power: 6
Quote:
 Originally Posted by `e` I'm unsure of your first question but ANSYS bought Fluent and it's now called ANSYS Fluent but the code is the same (has been updated / developed since acquisition); the UDF I posted above should work on any Fluent version you're working with. There are many examples online for saving data to a text file so I won't repeat here but check this post for starters.
Thanks, I saw the linked UDF, I have question, what is 'a' symbol in the 6th row of UDF "fp = fopen ("Motion.txt", "a"); /* Open a file to add data to the end */
Second question: in the 8,9 and 10th row UDF is calling CURRENT_TIME, DT_CG (dt)[0],DT_CG(dt)[1], DT_CG(dt)[2]) etc, But how UDF will understand that in the running simulation that is current time and that is DT_CG...
Thanks

Also I have written one UDF based on your guidance, pls correct because i am not expert
DEFINE_DPM_BC(recycle_particle)
{
FILE *fp;
fp=fopen("recycleparticles.txt", "a"); //”w” or “a”
fprintf(particles, " fp \n"); //ck (pebbles, " fp \n") or (fp, “%E”, particles)
fclose(fp);
recycledparticles = recycledparticles + 1; // update number of particles
P_POS(p)[0] = 0.0; // inlet at x=0 origin
return PATH_ACTIVE; // it will continue tracking this parcel
}

Can we use "*P" and * t, i saw this information in UDF manual-2015 heading 2.5.1.2 and 2.5.1.4
Also need to specify DPM.h????, at the start of the UDF???

Last edited by roopesh99; February 2, 2016 at 01:04.

February 2, 2016, 17:15
#10
Senior Member

Join Date: Mar 2015
Posts: 800
Rep Power: 11
Quote:
 Originally Posted by roopesh99 Thanks, I saw the linked UDF, I have question, what is 'a' symbol in the 6th row of UDF "fp = fopen ("Motion.txt", "a"); /* Open a file to add data to the end */
The 'a' is for appending the opened file, more details and options are available here.

Quote:
 Originally Posted by roopesh99 Second question: in the 8,9 and 10th row UDF is calling CURRENT_TIME, DT_CG (dt)[0],DT_CG(dt)[1], DT_CG(dt)[2]) etc, But how UDF will understand that in the running simulation that is current time and that is DT_CG...
That post was about writing a data file for the moving/deforming mesh, don't worry about the macros associated with grid motions. The CURRENT_TIME solver macro returns the real current flow time (included in the Fluent code, you don't need to calculate this macro).

Quote:
 Originally Posted by roopesh99 Also I have written one UDF based on your guidance, pls correct because i am not expert DEFINE_DPM_BC(recycle_particle) { FILE *fp; fp=fopen("recycleparticles.txt", "a"); //”w” or “a” fprintf(particles, " fp \n"); //ck (pebbles, " fp \n") or (fp, “%E”, particles) fclose(fp); recycledparticles = recycledparticles + 1; // update number of particles P_POS(p)[0] = 0.0; // inlet at x=0 origin return PATH_ACTIVE; // it will continue tracking this parcel }
Modify your fprintf line (order, and to include a particle y-position):

Code:
`fprintf(fp,"%e\n",P_POS(p)[1]);`
Note: by default the text file will be saved in the working directory. You can save it elsewhere by specifying the full path; for example "C:\\a_folder\\recycleparticles.txt" using the double backslash.

Quote:
 Originally Posted by roopesh99 Can we use "*P" and * t, i saw this information in UDF manual-2015 heading 2.5.1.2 and 2.5.1.4
Yes, you should include the other arguments (my code above was an incomplete example):

Code:
`DEFINE_DPM_BC(recycle_particle,p,t,f,f_normal,dim)`
Quote:
 Originally Posted by roopesh99 Also need to specify DPM.h????, at the start of the UDF???
The dpm.h header file is included in the udf.h file (which should be included):

Code:
`#include "udf.h"`

 February 3, 2016, 04:39 #11 Member   Rupesh Verma Join Date: Jun 2013 Posts: 64 Rep Power: 6 First of all, thanks for this nice help. Pls see the following UDF. Is it o.k. or need to modify. #include "udf.h" DEFINE_DPM_BC(recycle_particle,p,t,f,f_normal,dim) { FILE *fp; fp=fopen("recycleparticles.txt", "a"); //”w” or “a” fprintf(fp,"%e\n",P_POS(p)[1]); //or can use (pebbles, " fp \n") or (fp, “%E”, particles) fclose(fp); recycledparticles = recycledparticles + 1; // update number of particles P_POS(p)[0] = 0.0; // inlet at x=0 origin return PATH_ACTIVE; // it will continue tracking this parcel } Thanks when i am interpreted this UDF then it is showing the error in the 6th line which is "line 6: P_POS: undeclared variable", in the UDF 6th line is "fprintf(fp,"%e\n",P_POS(p)[1])" , i am taking x-axis as length, y as width and z as the height. Last edited by roopesh99; February 4, 2016 at 08:38.

 February 5, 2016, 17:14 #12 Senior Member   Join Date: Mar 2015 Posts: 800 Rep Power: 11 The UDF probably requires compiling instead of interpreting. It's good practice to compile all UDFs to avoid these types of errors.

February 5, 2016, 23:47
#13
Member

Rupesh Verma
Join Date: Jun 2013
Posts: 64
Rep Power: 6
Quote:
 Originally Posted by `e` The UDF probably requires compiling instead of interpreting. It's good practice to compile all UDFs to avoid these types of errors.
Even compiling is not working it is showing error, i tried both......on compiling the error is "error C2065: 'recycledparticles' : undeclared identifier"

 February 6, 2016, 00:35 #14 Senior Member   Join Date: Mar 2015 Posts: 800 Rep Power: 11 The variable recycledparticles needs to be declared and initialised at the start of the code block (before or after FILE *fp;): Code: `int recycledparticles = 0;`

 February 6, 2016, 00:54 #15 Member   Rupesh Verma Join Date: Jun 2013 Posts: 64 Rep Power: 6 Thanks for nice help, now udf is compiling but i am unable to see this UDF in HOOK or outlet BC.

 February 6, 2016, 00:58 #16 Senior Member   Join Date: Mar 2015 Posts: 800 Rep Power: 11 You're posting across several threads and have different versions in each one. You have this line of code from another thread: Code: `Tracked_Particle *p` which should have a semicolon terminating the line. However, the pointer to the particle p is already passed to the DEFINE_DBM_BC macro and shouldn't be altered here (remove that line of code).

February 6, 2016, 02:25
#17
Member

Rupesh Verma
Join Date: Jun 2013
Posts: 64
Rep Power: 6
Quote:
 Originally Posted by `e` You're posting across several threads and have different versions in each one. You have this line of code from another thread: Code: `Tracked_Particle *p` which should have a semicolon terminating the line. However, the pointer to the particle p is already passed to the DEFINE_DBM_BC macro and shouldn't be altered here (remove that line of code).
I already removed but the question is same as i asked above "now udf is compiling but i am unable to see this UDF in HOOK or outlet BC."

Last edited by roopesh99; February 6, 2016 at 03:36.

 February 6, 2016, 02:39 #18 Senior Member   Join Date: Mar 2015 Posts: 800 Rep Power: 11 Have you loaded the UDF after compiling? If you've modified the UDF then check my compiling process for Fluent UDFs with an existing library loaded.

February 6, 2016, 03:09
#19
Member

Rupesh Verma
Join Date: Jun 2013
Posts: 64
Rep Power: 6
Quote:
 Originally Posted by `e` Have you loaded the UDF after compiling? If you've modified the UDF then check my compiling process for Fluent UDFs with an existing library loaded.
i am not facing problem in compiling also i used this UDF at the outlet DPM. Also, i run the simulation for longer time it is not creating the recycleparticles.txt as mentioned in the UDF.
Thanks a lot for helping..

This is the UDF which i am compiling successful as well as able to define at the outlet, but why recycleparticles.txt file not creating, i am running it in the 3D geometry
#include "udf.h"
DEFINE_DPM_BC(recycle_particle,p,t,f,f_normal,dim)
{
int recycledparticles = 0;
FILE *fp;
//Tracked_Particle *p;
fp=fopen("recycleparticles.txt", "a"); //”w” or “a”
fprintf(fp,"%e\n",P_POS(p)[1]); //or can use (pebbles, " fp \n") or (fp, “%E”, particles)
fclose(fp);
recycledparticles = recycledparticles + 1; // update number of particles
P_POS(p)[0] = 0.0; // inlet at x=0 origin
return PATH_ACTIVE; // it will continue tracking this parcel
}

February 6, 2016, 03:51
#20
Senior Member

Join Date: Mar 2015
Posts: 800
Rep Power: 11
Quote:
 Originally Posted by roopesh99 I already removed but the question is same as i asked above "now udf is compiling but i am unable to see this UDF in HOOK or outlet BC."
As above, you said you couldn't find the UDF to hook in the boundary conditions settings. A possible cause of this problem could be if you hadn't loaded the UDF after compiling. Have you tried using a UDF boundary condition from the UDF manual, to check your workflow?

Quote:
 Originally Posted by roopesh99 i am not facing problem in compiling also i used this UDF at the outlet DPM. Also, i run the simulation for longer time it is not creating the recycleparticles.txt as mentioned in the UDF. Thanks a lot for helping..
Now it sounds like you have compiled and hooked the UDF but the data file is not being created. Perhaps, for debugging purposes, print a messge to the screen each time this macro is called. If this message isn't printed to the screen then the macro isn't called at all. For example:

Code:
```#include "udf.h"

static int recycledParticles=0; // global variable accessible only within this file

DEFINE_DPM_BC(recycle_particle,p,t,f,f_normal,dim)
{
FILE *fp;
Message("The outlet boundary UDF is being called...\n");
fp=fopen("recycleparticles.txt", "a"); //”w” or “a”
fprintf(fp,"%e\n",P_POS(p)[1]); //or can use (pebbles, " fp \n") or (fp, “%E”, particles)
fclose(fp);
recycledparticles = recycledparticles + 1; // update number of particles
P_POS(p)[0] = 0.0; // inlet at x=0 origin
return PATH_ACTIVE; // it will continue tracking this parcel
}```
Note: also looking back on my previous post, the recycledparticles variable is for storing the global number of particles recycled and should be defined outside the DEFINE_DPM_BC macro (fixed in the code above).

 Thread Tools Display Modes Linear Mode

 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 OffTrackbacks are On Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post Angeline Fluent UDF and Scheme Programming 6 November 7, 2015 01:08 jayendrajpatel CFX 3 January 21, 2015 17:44 emmkell FLUENT 0 October 20, 2011 07:37 Vishu Fluent UDF and Scheme Programming 2 October 5, 2011 09:09 kcsmith ANSYS Meshing & Geometry 11 March 9, 2011 22:08

All times are GMT -4. The time now is 11:10.