CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   FLUENT (http://www.cfd-online.com/Forums/fluent/)
-   -   how to access a variable in DPM within a UDF (http://www.cfd-online.com/Forums/fluent/50272-how-access-variable-dpm-within-udf.html)

patrick January 13, 2009 04:04

how to access a variable in DPM within a UDF
 
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

Amine January 13, 2009 06:47

Re: how to access a variable in DPM within a UDF
 
Patrick, You can access all DPM Variables on this page:

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

patrick January 13, 2009 08:09

Re: how to access a variable in DPM within a UDF
 
Amine, I don't have acces to this page... Can i have it as pdf or as screen shot?

Thanks for answering

Amine January 13, 2009 11:32

Re: how to access a variable in DPM within a UDF
 
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

patrick January 14, 2009 11:35

Re: how to access a variable in DPM within a UDF
 
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...

Amine January 14, 2009 12:16

Re: how to access a variable in DPM within a UDF
 
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).


patrick January 15, 2009 05:55

Re: how to access a variable in DPM within a UDF
 
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


Amine January 15, 2009 06:11

Re: how to access a variable in DPM within a UDF
 
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; } }

patrick January 15, 2009 06:48

Re: how to access a variable in DPM within a UDF
 
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?


Amine January 15, 2009 07:09

Re: how to access a variable in DPM within a UDF
 
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 !!


patrick January 15, 2009 08:05

Re: how to access a variable in DPM within a UDF
 
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..

Amine January 15, 2009 12:53

Re: how to access a variable in DPM within a UDF
 
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

patrick January 16, 2009 08:21

Re: how to access a variable in DPM within a UDF
 
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.


Bubble September 15, 2010 08:38

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


All times are GMT -4. The time now is 21:38.