Step 1: Install visual studio 2017
https://visualstudio.microsoft.com/vs/older-downloads/
Step 2: Set environment variables to link visual studio . Type in System variables and add these three lines to your system variables.
(1) INCLUDE
C:\Program Files (x86)\Microsoft Visual Studio 19.0\VC\include
(2) LIB
C:\Program Files (x86)\Microsoft Visual Studio 19.0\VC\lib\amd64
(3) Path
C:\Program Files (x86)\Microsoft Visual Studio 19.0\VC\bin\amd64
Step 3. Call FLUENT from x86_x64 Cross Tools Command Prompt for VS 2019
Step 4. Finally, compile UDF
I have solved the 'nmake' problem for UDFs in ANSYS Fluent.
The main is to set the environment variables for linking ANSYS Fluent and Visual studio 2012 as follows.
After installing ANSYS Fluent and Visual studio completely, three important environment variables need to add including INCLUDE, LIB and Path.
Firstly, make sure Microsoft SDKs and Microsoft Visual Studio 12.0 installed in the computer.
Then, add three variables in System variables.
(1) INCLUDE
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Include
(2) LIB
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\lib\amd64
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Lib\x64
(3) Path
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\amd64
C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE
Step 2. create c code and wepage code : https://www.youtube.com/watch?v=o_qAFQslASM
need to write a UDF for speed of sound too!
https://studentcommunity.ansys.com/thread/compressible-liquid-density/
/********************************************************************
Density and speed of sound UDFs for compressible liquid flows.
For use with pressure-based solver, for single phase, multiphase mixture
or cavitation models only.
Note that for density function, dp is the difference between a cell
absolute pressure and reference pressure.
*********************************************************************/
#include "udf.h"
#define BMODULUS 2.2e9
#define rho_ref 1000.0
#define p_ref 101325
DEFINE_PROPERTY(superfluid_density, c, t)
{
real rho;
real p, dp;
real p_operating;
p_operating = RP_Get_Real ("operating-pressure");
p = C_P(c,t) + p_operating;
dp = p-p_ref;
rho = rho_ref/(1.0-dp/BMODULUS);
return rho;
}
DEFINE_PROPERTY(sound_speed, c,t)
{
real a;
real p, dp,p_operating;
p_operating = RP_Get_Real ("operating-pressure");
p = C_P(c,t) + p_operating;
dp = p-p_ref;
a = (1.-dp/BMODULUS)*sqrt(BMODULUS/rho_ref);
return a;
}
UDF for density as a function of temperature
Viscous Heating (if enabled) includes the viscous dissipation terms in the energy equation.
Viscous heating plays an important role in the dynamics of fluids with strongly temperature-dependent viscosity because of the coupling between the energy and momentum equations.
The heat generated by viscous friction produces a local temperature increase near the tube walls with a consequent decrease of the viscosity which may dramatically change the temperature and velocity profiles.
/*********************************************************************
UDF for specifying a temperature-dependent viscosity and density property
**********************************************************************/
#include "udf.h"
DEFINE_PROPERTY(cell_viscosity, cell, thread)
{
real mu_lam;
real temp = C_T(cell, thread);
mu_lam = 0.6402+18.9612*exp(-.074*temp) ;
return mu_lam;
}
DEFINE_PROPERTY(cell_density,cell,thread)
{
real rho;
real temp= C_T(cell,thread);
rho=-0.72222*temp+1087.28;
return rho;
}
Execute Command in FLUENT to store pictures
/display/set/contours surfaces cutplane () \n/display/set/contours/coloring n\n/display/set/picture/color-mode color\n/display/contour/acoustic-source-power-db 47 85\n/display/set/contours n-contour 5\n/display/set/contours/filled-contours yes\n/display/views restore-view cutplane\n/display/save-picture "db_contour-%it.png"
This is the link of the combined UDFs to interpret in fluent