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

how to access a variable in DPM within a UDF

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 13, 2009, 04:04
Default how to access a variable in DPM within a UDF
  #1
patrick
Guest
 
Posts: n/a
I'm writing a UDF that should change the position of an Injection in space with every time step (move an Injection in space). The UDF Manual tells me to use the macro DEFINE_INJECTION_INIT but my question is: How can i access the variable "Position (x,y or z)" of an Injection (for example, of an AirBlast-Atomizer)?

Thanks
  Reply With Quote

Old   January 13, 2009, 06:47
Default Re: how to access a variable in DPM within a UDF
  #2
Amine
Guest
 
Posts: n/a
Patrick, You can access all DPM Variables on this page:

http://www.fluentusers.com/fluent/do...udf/node94.htm
  Reply With Quote

Old   January 13, 2009, 08:09
Default Re: how to access a variable in DPM within a UDF
  #3
patrick
Guest
 
Posts: n/a
Amine, I don't have acces to this page... Can i have it as pdf or as screen shot?

Thanks for answering
  Reply With Quote

Old   January 13, 2009, 11:32
Default Re: how to access a variable in DPM within a UDF
  #4
Amine
Guest
 
Posts: n/a
Try this page:

http://web.njit.edu/topics/Prog_Lang...tml/node64.htm

The macro for particle (injection) position: P_POS(p)[i]

with i=0,1 or 2 (for x, y or z direction, respectively).

The macro for particle velocity :

P_VEL(p)[i]

Amine
  Reply With Quote

Old   January 14, 2009, 11:35
Default Re: how to access a variable in DPM within a UDF
  #5
patrick
Guest
 
Posts: n/a
Thanks for answering... here a source: #include "udf.h"

DEFINE_DPM_INJECTION_INIT(Bahn, I) { Particle *p;

loop(p,I->p) { P_Pos(p)[2] = P_Pos(p)[2] + 0.05 P_VEL(p)[0] = P_VEL(p)[0] + 0.05

} }

I gave it a try and when building i get the following: " (system "copy C:\PROGRA~2\Fluent.Inc\fluent6.3.26\src\makefile_n t.udf libudf\win64\3ddp\makefile")

1 file(s) copied. (chdir "libudf")() (chdir "win64\3ddp")() 'nmake' is not recognized as an internal or external command, operable program or batch file. 'nmake' is not recognized as an internal or external command, operable program or batch file.

Done."

and while loading the following: " Opening library "libudf"... Error: open_udf_library: The system cannot find the file specified.

Error Object: ()

Interrupting... Done. "

Is my source wrong....?? As u can see, i simply try to move it horizontally while turning it a bit.

Thanks...
  Reply With Quote

Old   January 14, 2009, 12:16
Default Re: how to access a variable in DPM within a UDF
  #6
Amine
Guest
 
Posts: n/a
Hi Patrick,

I guess you try for the first time to compile on that machine ? I think that is a problem of compilator, I(ve had the same error.

It can't find the libudf file because there were errors on compilation.

The 'nmake' error in the compilation is due to the fact that the visualstudio compilator is not on your machine or you have opened your fluent not in the visual studio command prompt.

Take a look on this page http://university.fluent.com/forum/v...8249af23d2ec05

On this other page you can download the complete UDF Manual in PDF: mariscal.usc.es/manual_fluent63_udf.pdf

Here are steps to compile after setting up Microsoft visual studio 2005 or 2008.

Compiling and Loading User Defined Functions using Microsoft Visual Studio 2005 Standard Edition in Serial

Steps for Building Compiled Windows UDFs using Microsoft Visual Studio 2005 Standard Edition

1. Install Microsoft Visual Studio 2005 Standard Edition (Refer to the Microsoft Visual Studio 2005 Standard Edition Installation Guide for installation instructions.)

2. You will be starting FLUENT from a Command Prompt so you will have to set the FLUENT.INC Environment Variables.

1. Select the Start Menu, Programs, Fluent Inc Products, Fluent 6.3.26, Set Environment. Choose YES to Modify.

3. The installation of Microsoft Visual Studio 2005 Standard Edition does not set environment variables necessary to run from a command line, therefore, in order to compile UDF's within FLUENT you will need to set the Visual Studio environment variables as outlined below in Step 3 depending on the version of Fluent you are using.

FLUENT 6.3.26 32-bit

Select the Start Menu, Programs, Microsoft Visual Studio 2005, Visual Studio, Tools, choose Visual Studio 2005 Command Prompt.

The other solution is to modify the environment variable (it didn't work for me).

  Reply With Quote

Old   January 15, 2009, 05:55
Default Re: how to access a variable in DPM within a UDF
  #7
patrick
Guest
 
Posts: n/a
Thanks for the tip.. I tried to compile it in Linux environment and at least i got a log with some compiling mistakes. The question is: Am i making any didactical mistake in my source code?

#include "udf.h" #include "dpm.h"

DEFINE_DPM_INJECTION_INIT(Bahn, I) { Particle *p;

loop(p,I->p) { P_Pos(p)[2] = P_Pos(p)[2] + 0.05; P_VEL(p)[0] = P_VEL(p)[0] + 0.05;

} }

What do u think?

Thanks

  Reply With Quote

Old   January 15, 2009, 06:11
Default Re: how to access a variable in DPM within a UDF
  #8
Amine
Guest
 
Posts: n/a
When using unsteady particle tracking you must write loop(p, I->p_init) instead of loop(p, I->p)

#include "udf.h"

DEFINE_DPM_INJECTION_INIT(Bahn, I) { Particle *p;

loop(p, I->p_init) { P_Pos(p)[2] = P_Pos(p)[2] + 0.05; P_VEL(p)[0] = P_VEL(p)[0] + 0.05; } }
  Reply With Quote

Old   January 15, 2009, 06:48
Default Re: how to access a variable in DPM within a UDF
  #9
patrick
Guest
 
Posts: n/a
ohh i sent u an older version. In the new one i took it into account but thank you for the tip.. Nevertheless i get the following message after compiling:

Warning: Implicit declaration of function â P_Po. error: subscripted value is neither array nor pointer.

both messages point at line c10 (where i define the new Injector position)

Any idea?

  Reply With Quote

Old   January 15, 2009, 07:09
Default Re: how to access a variable in DPM within a UDF
  #10
Amine
Guest
 
Posts: n/a
I think you canno't write P_POS(p)=P_POS(p)...

The solution perhaps is to define a new variable :

real injposition= ; /* here you must put the initial injector position*/

loop(p, I->p_init) { P_POS(p)= injposition+0.05; injposition=P_POS(p);

}

and Do the same with the velocity in the same loop !!

  Reply With Quote

Old   January 15, 2009, 08:05
Default Re: how to access a variable in DPM within a UDF
  #11
patrick
Guest
 
Posts: n/a
Tried it, but same message for the lines where i define the new Injector position P_Pos and where i write "injposition=P_POS(p)"

Here my code: #include "udf.h" #include "dpm.h"

DEFINE_DPM_INJECTION_INIT(Bahn, I) { Particle *p; real injposition = 0.75; real injvelocity = 0;

loop(p,I->p_init) { P_Pos(p)[2] = injposition + 0.1;

P_VEL(p)[0] = injvelocity + 0.1;

injposition = P_Pos(p)[2]; injvelocity = P_VEL(p)[0];

} }

What means "p->state.pos[2]" (got it from "missile Take off" tutorial). Didn't find any explanations in UDF-Manual..
  Reply With Quote

Old   January 15, 2009, 12:53
Default Re: how to access a variable in DPM within a UDF
  #12
Amine
Guest
 
Posts: n/a
Here is the udf that I just compiled and it works: DEFINE_DPM_INJECTION_INIT(Bahn, I) { Particle *p; real injposition = 0.75; real injvelocity = 0;

loop(p,I->p_init) { P_POS(p)[1] = injposition + 0.1;

P_VEL(p)[0] = injvelocity + 0.1;

injposition = P_POS(p)[1]; injvelocity = P_VEL(p)[0];

} }

You must write P_POS(p) and not P_Pos(p)

Amine
  Reply With Quote

Old   January 16, 2009, 08:21
Default Re: how to access a variable in DPM within a UDF
  #13
patrick
Guest
 
Posts: n/a
Hi Amine... Thanks for u tips. we are making a mistake. But the direction is good. The Looping we're doin is changing the startpostion of each of my particle within an iteration. Let's say we spray 50 Particles at every iteration wit an air-Blast-Atomizer. What we want is to move the atomizer after every 50 particles and not release each particle at different P_POS.

Think I've got a solution. We should define the "CURRENT TIME" (see UDF_Manual, page 2-7) and use it in the P_POS equation and quit updating the injection velocity.

I've got a nice moving spray cone

Tell me what u think of it.

  Reply With Quote

Old   September 15, 2010, 09:38
Default
  #14
New Member
 
Join Date: Sep 2010
Posts: 1
Rep Power: 0
Bubble is on a distinguished road
Quote:
Originally Posted by Amine
;155944
Patrick, You can access all DPM Variables on this page:

http://www.fluentusers.com/fluent/do...udf/node94.htm
Hi, I cant get access to the webpage you wrote. I wish to get the complete list of DPM variables. Do you know another webpage for get it for free? I'm trying to configure a time-dependent injection in two-phase systems. For the moment my best try is: #include "udf.h"

DEFINE_PROFILE(inlet_mf,th,i)
{
face_t f;
begin_f_loop(f,th)
{
if (N_TIME <= 3)
{
F_PROFILE(f,th,i) = 9.83e-05;
}
else if (N_TIME > 3)
{
F_PROFILE(f,th,i) = 1e-01;

}
}
end_f_loop(f,th);
} but isnt working or isnt working well. Can you help me? I need to finish this work very soon for Uni. Best regards
Bubble 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
Error: access: unbound variable Shriram Main CFD Forum 0 June 22, 2007 09:31
Error: access: unbound variable,HELP sudhakar FLUENT 0 January 16, 2007 00:21
Error : access : Unknown variable & Phase-domain MKP FLUENT 0 August 28, 2006 04:40
Error: access: unbound variable vivek FLUENT 0 June 6, 2005 07:05
Error: access: unbound variable cfd-novice FLUENT 0 April 3, 2003 05:53


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