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

Periodic BC in ANSYS DDPM, UDF

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 12, 2016, 10:56
Thumbs up Periodic BC in ANSYS DDPM, UDF
  #1
Member
 
Rupesh Verma
Join Date: Jun 2013
Posts: 64
Rep Power: 13
roopesh99 is on a distinguished road
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!!!
roopesh99 is offline   Reply With Quote

Old   January 12, 2016, 18:33
Default
  #2
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
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?
`e` is offline   Reply With Quote

Old   January 13, 2016, 00:02
Default
  #3
Member
 
Rupesh Verma
Join Date: Jun 2013
Posts: 64
Rep Power: 13
roopesh99 is on a distinguished road
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!!!
roopesh99 is offline   Reply With Quote

Old   January 13, 2016, 20:14
Default
  #4
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
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.
`e` is offline   Reply With Quote

Old   January 27, 2016, 09:21
Default DDPM with particle recycle
  #5
Member
 
Rupesh Verma
Join Date: Jun 2013
Posts: 64
Rep Power: 13
roopesh99 is on a distinguished road
Quote:
Originally Posted by `e` View Post
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
roopesh99 is offline   Reply With Quote

Old   January 27, 2016, 18:01
Default
  #6
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
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).
`e` is offline   Reply With Quote

Old   January 29, 2016, 04:22
Default
  #7
Member
 
Rupesh Verma
Join Date: Jun 2013
Posts: 64
Rep Power: 13
roopesh99 is on a distinguished road
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.
roopesh99 is offline   Reply With Quote

Old   January 31, 2016, 22:56
Default
  #8
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
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.
`e` is offline   Reply With Quote

Old   February 1, 2016, 23:39
Default
  #9
Member
 
Rupesh Verma
Join Date: Jun 2013
Posts: 64
Rep Power: 13
roopesh99 is on a distinguished road
Quote:
Originally Posted by `e` View Post
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.
roopesh99 is offline   Reply With Quote

Old   February 2, 2016, 17:15
Default
  #10
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
Quote:
Originally Posted by roopesh99 View Post
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 View Post
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 View Post
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 View Post
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 View Post
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"
`e` is offline   Reply With Quote

Old   February 3, 2016, 04:39
Default
  #11
Member
 
Rupesh Verma
Join Date: Jun 2013
Posts: 64
Rep Power: 13
roopesh99 is on a distinguished road
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.
roopesh99 is offline   Reply With Quote

Old   February 5, 2016, 17:14
Default
  #12
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
The UDF probably requires compiling instead of interpreting. It's good practice to compile all UDFs to avoid these types of errors.
`e` is offline   Reply With Quote

Old   February 5, 2016, 23:47
Default
  #13
Member
 
Rupesh Verma
Join Date: Jun 2013
Posts: 64
Rep Power: 13
roopesh99 is on a distinguished road
Quote:
Originally Posted by `e` View Post
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"
roopesh99 is offline   Reply With Quote

Old   February 6, 2016, 00:35
Default
  #14
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
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;
`e` is offline   Reply With Quote

Old   February 6, 2016, 00:54
Default
  #15
Member
 
Rupesh Verma
Join Date: Jun 2013
Posts: 64
Rep Power: 13
roopesh99 is on a distinguished road
Thanks for nice help, now udf is compiling but i am unable to see this UDF in HOOK or outlet BC.
roopesh99 is offline   Reply With Quote

Old   February 6, 2016, 00:58
Default
  #16
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
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).
`e` is offline   Reply With Quote

Old   February 6, 2016, 02:25
Default
  #17
Member
 
Rupesh Verma
Join Date: Jun 2013
Posts: 64
Rep Power: 13
roopesh99 is on a distinguished road
Quote:
Originally Posted by `e` View Post
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.
roopesh99 is offline   Reply With Quote

Old   February 6, 2016, 02:39
Default
  #18
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
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.
`e` is offline   Reply With Quote

Old   February 6, 2016, 03:09
Default
  #19
Member
 
Rupesh Verma
Join Date: Jun 2013
Posts: 64
Rep Power: 13
roopesh99 is on a distinguished road
Quote:
Originally Posted by `e` View Post
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
}
roopesh99 is offline   Reply With Quote

Old   February 6, 2016, 03:51
Default
  #20
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
Quote:
Originally Posted by roopesh99 View Post
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 View Post
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).
`e` is offline   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
UDF for periodic boundary condition Angeline Fluent UDF and Scheme Programming 6 November 7, 2015 01:08
Periodic model for ansys cfx jayendrajpatel CFX 3 January 21, 2015 17:44
Ansys FLUENT UDF - Velocity profile (of known values) across edge / surface emmkell FLUENT 0 October 20, 2011 08:37
Compiling UDF in Ansys Fluent12 Vishu Fluent UDF and Scheme Programming 2 October 5, 2011 10:09
Ansys meshing of two-phase periodic domain kcsmith ANSYS Meshing & Geometry 11 March 9, 2011 22:08


All times are GMT -4. The time now is 19:22.