CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   Multiphase UDF : How to specify velocities for different phases (https://www.cfd-online.com/Forums/fluent-udf/153548-multiphase-udf-how-specify-velocities-different-phases.html)

iamadz May 28, 2015 07:51

Multiphase UDF : How to specify velocities for different phases
 
3 Attachment(s)
Hello

I have a 3D 2-phase flow in a cylindrical column being simulated in FLUENT 14.0 . I want to specify different velocity inlets for both air and water. I figured that by making 2 different UDFs, I can specify the respective UDFs for the corresponding phase velocity boundary condition. However, whenever I interpret the 2nd UDF, the UDF interpreted earlier disappears i.e. I am unable to specify multiple velocity UDFs. Can someone please suggest how to tackle this problem?

I had thought of somehow using phase_domain_index but I cannot find the way of using it. I am attaching my codes for reference.

Thanks in advance

P.S. While interpreting codes, I don't get any error, but when I try to compile the codes I get the errors as shown in the jpeg file

Kokemoor May 28, 2015 11:07

Try putting both macros in one file, i.e.

Code:

#include "udf.h"

DEFINE_PROFILE(gas_z_velocity, thread, nv)
{
  ...
}

DEFINE_PROFILE(liquid_z_velocity, thread, nv)
{
  ...
}

Then they should both appear as options for your profiles, and you can set each phase to its appropriate profile.

`e` May 29, 2015 01:15

Compiling your UDFs would be a more robust and reliable method compared with interpreting your UDFs.

Are there any other lines of errors reported before or after those shown in your screenshot? It appears the problem might be with data types: are you running your simulations in single or double precision? Use the 'real' data type to declare your variables because then Fluent will either use float or long data types accordingly for single and double precision modes, respectively.

Lastly, add a trailing period to your zeros and integers for example "0." instead of "0" to avoid incorrect assignments (again, be careful of data types).

iamadz May 29, 2015 01:20

1 Attachment(s)
Thank you Kokemoor, it worked like a charm.

Dear 'e', there are no other errors apart from those mentioned in the screenshot. I have defined the variable type as float (as mentioned in the code). and running the simulations on double precision. I interpreted the UDF and am currently running the simulation, will there be any difference if I define the data type as Real and then compile and run it? Thanks

UPDATE :

When I try to compile the file, I get the error as shown in the png file. The 'Done' statement is when I Build the file, the error afterwards is when I try to 'Load' it.

`e` May 29, 2015 01:36

If it's running successfully now then that's fine; but you could ensure the data types are assigned correctly and check that the results are equal. Sometimes code will compile (or "interpret") fine but not execute quite how you'd expect.

iamadz May 29, 2015 01:39

Okay, I'll run another case after compiling it. But as mentioned in my just-updated-previous-reply, I'm encountering an error. Please have a look. Thanks

`e` May 29, 2015 06:26

Perhaps Fluent is getting caught up with the UDF version, try my compiling process for Fluent UDFs with an existing library loaded.

iamadz May 29, 2015 06:36

1 Attachment(s)
There are no existing libraries to unload.

Regarding the compilation error for libudf, I looked up on the forums and found the attached pdf for solving this error. However, after installing both Visual C++ Studio and Microsoft SDK 7.0, I am now getting the following error while Build :
"'nmake' is not recognized as an internal or external command, operable program or batch file"

I found on the internet that this error relates to registering environment variables, but having followed whatever tips I could find, the error still does not go. Can you please advise what I should do now?

Many thanks for your help again

`e` May 29, 2015 06:56

The Fluent FAQ Wiki has a section on compiling issues here. I use Microsoft Visual Studio Express (freely available). Have you managed to compile any UDFs in the past?

iamadz May 29, 2015 07:11

No, I haven't compiled any UDFs in the past.

I have already read that wiki. They mention that I have to select the option for 'Setting environment variables' during installation. Unfortunately, I found no such option during the installation. I have reinstalled both Visual C++ Express 2010 and SDK but to no avail

`e` May 29, 2015 07:26

Strange, I don't remember having these issues. Try uninstalling all of the software you've tried compiling with and reinstall Microsoft Visual Studio Express. If that still doesn't work, perhaps stay with interpreting UDFs for the meantime.

iamadz May 29, 2015 08:25

Its working now, I had not changed the values for Path environment variable

Thanks a lot 'e' for your help :)

Kokemoor May 29, 2015 10:19

Quote:

Originally Posted by `e` (Post 548164)
The Fluent FAQ Wiki has a section on compiling issues here. I use Microsoft Visual Studio Express (freely available). Have you managed to compile any UDFs in the past?

What version of Visual Studio Express do you use, `e`? I use 2010 and the Windows SDK, but I'm told 2012 has a 64 bit compiler in the free version, so you don't need the SDK.

`e` May 29, 2015 19:39

I use Microsoft Visual Studio Express 2012 for Windows Desktop. That's right, I don't use an SDK or any other programs for compiling within Fluent and compiling works well in all cases I've come across.

sircorp June 4, 2015 01:16

Quote:

Originally Posted by Kokemoor (Post 548041)
Try putting both macros in one file, i.e.

Code:

#include "udf.h"

DEFINE_PROFILE(gas_z_velocity, thread, nv)
{
  ...
}

DEFINE_PROFILE(liquid_z_velocity, thread, nv)
{
  ...
}

Then they should both appear as options for your profiles, and you can set each phase to its appropriate profile.

Once interpreted or compiled, macro does not Disappear. If you have already loaded it. then don't worry. It is not visible, that's all. Loading new macro does not mean old disappear.

Best way as advised by Kokemoor. Put as many macro as possible in single file, compile or interpret, then and "variable" will be visible all the time. Make life easy.

Shane


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