Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - william

Pages: [1] 2 3 ... 11
1
Fluent / Re: What is the macro to access the level-set function in a UDF?
« on: December 27, 2020, 05:23:29 PM »
The Level-set function can be accessed using the C_LSF(c,t) macro, where 't' is the phase thread pointer in Fluent.


2
Fluent / Re: Error: "ST_Create_Store: out of memory" in out file.
« on: December 27, 2020, 05:18:33 PM »
I am getting the following Error: "ST_Create_Store: out of memory" in out file.

Please tell me how to fix this error.

Thank you.

This error arises because of the system configuration. It also arises when the problem is more complex geometry and complex physics like reacting flows, multiphase, CHT etc.
In case of heat transfer when the user tries to solve convection then the simulation will work fine but if radiation is also involved then this error arises.
Hence it is recommended to use high end configuration system.

3
Ansys Fluent has inbuilt compiler in 2020R2. Instead of Visual studio compiler, you can select "Use Built-In Compiler" after selecting the UDF file and then click the build button.

4
Hi,

How can I get the number of faces in a boundary zone to use it in a variable in Fluent?

Thanks.

Create a variable, then use the following Scheme code snippet

(define (ncf ct_id) (car (%inquire-faces-and-nodes-on-thread ct_id)))

Then just use

(ncf 4)

to get the number of faces in thread with ID 4.

5
You can use a UDF for this purpose, here is a sample code. You can modify it to suite your requirements for any variable you like to monitor:

Code: [Select]
#include "udf.h"
static real global_max_pressure;
static real global_coordinates_max_pressure[ND_ND];
static int global_print_output = 1;
DEFINE_ON_DEMAND(get_max_pressure)
{
 Domain *d = Get_Domain(1);
 Thread *t;
 cell_t c;
 real max_pressure = -REAL_MAX;
 real max_pressure_node;
 real iwork[ND_ND], coordinates_max_pressure[ND_ND];

#if !RP_HOST
 /* Calculate the maximum pressure */
 thread_loop_c(t, d)
 {
 if (FLUID_THREAD_P(t)) {
 begin_c_loop_int(c, t)
 {
 if (C_P(c,t) > max_pressure) {
 max_pressure = C_P(c,t);
 C_CENTROID(coordinates_max_pressure, c, t);
 }
 }
 end_c_loop_int(c, t)
 }
 }
 max_pressure_node = max_pressure;

 /* Global reduction */
 max_pressure = PRF_GRHIGH1(max_pressure);

/* Verify on each compute node, consider numerical round-off errors */
 if (max_pressure_node < max_pressure-max_pressure*1e-16) {
 NV_S(coordinates_max_pressure,=,-REAL_MAX);
 }
 PRF_GRHIGH(coordinates_max_pressure,ND_ND,iwork);

 /* Output */
 global_max_pressure = max_pressure;
 NV_V(global_coordinates_max_pressure,=,coordinates_max_pressure);

 if (global_print_output) {
#if RP_2D
 Message0("Max pressure %e at %e | %e\n", max_pressure,
coordinates_max_pressure[0], coordinates_max_pressure[1]);
#else

Message0("Max pressure %e at %e | %e | %e\n", max_pressure,
coordinates_max_pressure[0], coordinates_max_pressure[1],
coordinates_max_pressure[2]);
#endif
 }
#endif
}
DEFINE_ON_DEMAND(activate_console_output)
{
 global_print_output = 1;
}
DEFINE_ON_DEMAND(deactivate_console_output)
{
 global_print_output = 0;
}
DEFINE_EXECUTE_AT_END(run_max_pressure)
{
 get_max_pressure();
 node_to_host_real_1(global_max_pressure);
 node_to_host_real(global_coordinates_max_pressure, ND_ND);
}
DEFINE_REPORT_DEFINITION_FN(max_pressure_location_x)
{
 return global_coordinates_max_pressure[0];
}
DEFINE_REPORT_DEFINITION_FN(max_pressure_location_y)
{
 return global_coordinates_max_pressure[1];
}

DEFINE_REPORT_DEFINITION_FN(max_pressure_location_z)
{
#if RP_2D
 return 0.0;
#else
 return global_coordinates_max_pressure[2];
#endif
}


6
Fluent / Re: Global maximum value of a variable in Fluent using UDF
« on: September 24, 2020, 05:14:20 PM »
Hi,

The Global Maximum Value of a certain variable can be obtained through the User Defined Functions in Fluent using Global Maximum Macro PRF_GRHIGH1(x). This can be used to obtain the Global Minimum as well.

Here is the implementation that outputs the global maximum temperature in the domain:

Code: [Select]
#include "udf.h"
DEFINE_ON_DEMAND(MaxTemp)
{
Domain *d;
d = Get_Domain(1); /* Get the domain using Fluent utility */
Thread *t;
cell_t c;
real T_maxx = 0;
real T_max = 0;
#if RP_NODE
{
thread_loop_c(t,d)
{
if (FLUID_THREAD_P(t))
{
begin_c_loop(c,t)
{
T_maxx = MAX(C_T(c,t), T_maxx);
}
end_c_loop(c,t)
}
}
}
#endif
 T_max = PRF_GRHIGH1(T_maxx);
Message("\n T_maxx %0.14f", T_maxx);
Message("\n T_max %0.14f", T_max);
}

7
Fluent / Re: Is there any UDF to access inter-phase mass transfer rate
« on: September 24, 2020, 04:50:32 PM »
Hi,
You can access the interphase mass transfer rate using the following macro:

C_STORAGE_R_XV(cell,mixture_thread,SV_MASS_TRANSFER,k-1)

k in the above macro is the mass transfer mechanism number, which can be found from phase interaction panel in fluent. The number in the mass transfer mechanism before the 'From Phase', 'To Phase' option is the mass transfer mechanism number.

And if you are looking for a UDF, the following code illustrates the example:

The UDF is used to store the cavitation mass transfer rates in a UDM location.

#include "udf.h"
#define k 1
DEFINE_ADJUST(mass_transfer_access,d)
{
cell_t c;
Thread *t;
thread_loop_c(t,d)
begin_c_loop(c,t)
C_UDMI(c,t,0) = C_STORAGE_R_XV(c,t,SV_MASS_TRANSFER,k-1);
end_c_loop(c,t)
}


8
You can access the Level-set function using the C_LSF(c,t) macro, where 't' is the phase thread pointer.
Let me know if you have any trouble.


9
Fluent / Partially premixed combustion
« on: November 13, 2016, 02:55:36 PM »
If I run a partially premixed combustion solution and want to post-process NOx, I have the option to use a Mixture fraction or Temperature NOx PDF. Which is better and why?

The Mixture Fraction PDF is better.

1. It uses the same variance as was solved during the combustion calculation, which is superior to the approximate variance transport equation used for the NOX Temperature PDF

2. Both the number and distribution of the variance points in the NOx PDF, and the variance itself, align exactly with what is used in the combustion calculations, so turbulence interaction treatment is consistent across the calculations.

10
How to restart a run, allowing the solver to read the values from a previous results file, but giving own values for certain variables on domains?

Example1:
The first simulation has been carried out, then simulation1.res is restarted using all variables, except some variables are overwritten with new values.

Example2;
A simulation with two domains D1 and D2. The first simulation has been carried out, then simulation1.res is restarted with the initial values for D1 from simulation1.res and the initial values for D2 are specified manually.

In these situations Initialization with "Automatic" or "Automatic with Value" in CFX Pre will not work, as it will
read the variables from the results file.

In order to achieve this:
1. Create a def file with "Automatic with Value" initialization (for Example2, do not use global initialization
in CFX-Pre, but initialization per domain) and give desired value of variables which you would want solver
to use.
2. In Solver Manager, go to Tools -> Edit CFX-Solver File Edit Definition file and switch the initialization of
the desired variable to be "Value" instead of "Automatic with Value". See Figure 1. This value will be used
for the restart instead results from previous run even if a result file exists.
The same can be done for Example2, letting D1 initialization as "Automatic", and switching D2 initialization
to "Value" entering the desired value.

11
Fluent / How to create a Wall Boundary between Solid Zones in FLUENT?
« on: November 13, 2016, 02:44:47 PM »
Walls between Fluid - Solid zones are created automatically when imported into FLUENT even if not set in the geometry software, but interfaces between two solids are treated as interior zones by default.
The boundary between two solid zones is treated as interior surface by default. In the boundary conditions panel, boundary type can be changed from interior type to wall.
 :D

12
When using a mass-flow-inlet boundary condition, if more than one region is contained within the same
boundary condition zone, the value of the Mass Flow Rate that should be defined is the sum of the individual
mass flow rates, as showed on images attached.
Using this strategy, the resulted inlet velocity will be proportional to face areas.
This can be useful if you have several inlets, once you need to set only one named selection for all inlet
regions and one boundary condition definition.


13
Fluent / How to extrude a face zone in Fluent
« on: November 13, 2016, 02:31:37 PM »
The ability to extrude a boundary face zone allows you to extend the solution domain without having to exit Fluent. A typical application of the extrusion capability is to extend the solution domain when recirculating flow is impinging on a flow outlet. The current extrusion capability creates prismatic or hexahedral layers based on the shape of the face and normal vectors computed by averaging the face normals to the face zones node.
You can define the extrusion process by specifying a list of displacements (in SI units) or by specifying a total distance (in SI units) and parametric coordinates.

mesh/modify-zones/extrude-face-zone-para
mesh/modify-zones/extrude-face-zone-delta

Note: This text command is not available in the parallel version of ANSYS Fluent.

14
CFX / Re: Combustor efficiency
« on: November 12, 2016, 06:20:29 PM »
The ccl below uses the CEL expression CombEff to adjust the heating values:

LIBRARY:
MATERIAL: Methane Air WD1
Option = Variable Composition Mixture
Reactions List = Methane Air WD1
END # MATERIAL Methane Air WD1
MATERIAL : CH4 # Methane
Option = Pure Substance
PROPERTIES :
Option = Ideal Gas
Molar Mass = 16.04 [kg kmol^-1]
Dynamic Viscosity = 11.1E-06 [kg m^-1 s^-1]
Thermal Conductivity = 343E-04 [W m^-1 K^-1]
Thermal Expansivity = 3.35E-03 [K^-1]
Refractive Index = 1.
Reference Pressure = 1. [atm]
Reference Temperature = 25 [C]
Reference Specific Enthalpy = -74.87310 [kJ mol^-1] / 16.04 [kg kmol^-1]
Reference Specific Entropy = 186.2 [J mol^-1 K^-1] / 16.04 [kg kmol^-1]
SPECIFIC HEAT CAPACITY:
Option = NASA Format
Temperature Limit List = 300 [K], 5000 [K], 1000 [K]
NASA Coefficient List =
NASACoeff21, NASACoeff22, NASACoeff23,
NASACoeff24, NASACoeff25, NASACoeff26,
NASACoeff27,
NASACoeff11, NASACoeff12, NASACoeff13,
NASACoeff14, NASACoeff15, NASACoeff16,
NASACoeff17
END #SPECIFIC HEAT CAPACITY
#
# Boiling point (1 atm) = 111.66 [K]
# Critical Temperature = 190.58 [K]
# Critical Pressure = 4.604E+06 [Pa]
#
END #PROPERTIES
END #MATERIAL


CEL:
EXPRESSIONS:
#
# Combustion of methane: CH4 + 2O2 -> CO2 + 2H2O
#
Rgas = 8314.41 [J kmol^-1]
CombEff = 0.95
HoFCO2 = -393.5224 [kJ mol^-1]
HoFH2O = -241.8264 [kJ mol^-1]
HoFCH4 = -74.8731 [kJ mol^-1]
HeatofProducts = HoFCO2+2*HoFH2O
HeatofReaction = HeatofProducts-HoFCH4
#
# Modify heat of formation ofmethane to account for a
# combustion efficiency of less than 100% using Gordon
# & McBride (NASA) format for enthalpy polynomial
#
HoFCH4Mod = HeatofProducts-CombEff*HeatofReaction
#
NASACoeff11 = 0.07787415E+01
NASACoeff12 = 0.01747668E+00
NASACoeff13 = -0.02783409E-03
NASACoeff14 = 0.03049708E-06
NASACoeff15 = -0.01223931E-09
NASACoeff17 = 0.01372219E+03
Tref1 = 298.15
DHTref11 = NASACoeff11*Tref1 + NASACoeff12*Tref1^2/2 +
NASACoeff13*Tref1^3/3 + NASACoeff14*Tref1^4/4 + NASACoeff15*Tref1^5/5
Tref2 = 1000.0
DHTref12 = NASACoeff11*Tref2 + NASACoeff12*Tref2^2/2 +
NASACoeff13*Tref2^3/3 + NASACoeff14*Tref2^4/4 +
NASACoeff15*Tref2^5/5
NASACoeff16 = HoFCH4Mod/Rgas-DHTref11
# NASACoeff16 = -0.09825229E+05
#
# High temperature polynomial
#
NASACoeff21 = 0.01683479E+02
NASACoeff22 = 0.01023724E+00
NASACoeff23 = -0.03875129E-04
NASACoeff24 = 0.06785585E-08
NASACoeff25 = -0.04503423E-12
NASACoeff27 = 0.09623395E+02
DHTref22 = NASACoeff21*Tref2 + NASACoeff22*Tref2^2/2 +
NASACoeff23*Tref2^3/3 + NASACoeff24*Tref2^4/4 +
NASACoeff25*Tref2^5/5
# Ensure high T and low T polynomials match at Tref2
NASACoeff26 = DHTref12 + NASACoeff16 - DHTref22
# NASACoeff26 = -0.01008079E+06
#
END # EXPRESSIONS
END # CEL
END # LIBRARY


FLOW:

DOMAIN: Combustor
Location = Combustor
Coord Frame = Coord 0
Fluids List = Methane Air WD1
DOMAIN MODELS:
DOMAIN MOTION:
Option = Stationary
END # DOMAIN MOTION
BUOYANCY MODEL:
Option = Non Buoyant
END # BUOYANCY MODEL
REFERENCE PRESSURE:
Reference Pressure = 1.0133E5 [Pa]
END # REFERENCE PRESSURE
END # DOMAIN MODELS

FLUID MODELS:
TURBULENCE MODEL:
Option = k epsilon
END # TURBULENCE MODEL
TURBULENT WALL FUNCTIONS:
Option = Scalable
END # TURBULENT WALL FUNCTIONS
HEAT TRANSFER MODEL:
Option = Thermal Energy
END # HEAT TRANSFER MODEL
COMBUSTION MODEL:
Option = Eddy Dissipation
END # COMBUSTION MODEL
COMPONENT: CH4
Option = Transport Equation
END # COMPONENT CH4
COMPONENT: O2
Option = Transport EquationEND # COMPONENT O2
COMPONENT: CO2
Option = Transport Equation
END # COMPONENT CO2
COMPONENT: H2O
Option = Transport Equation
END # COMPONENT H2O
COMPONENT: N2
Option = Constraint
END # COMPONENT N2
THERMAL RADIATION MODEL:
Option = None
END # THERMAL RADIATION MODEL
END # FLUID MODELS

END # DOMAIN Combustor
END #FLOW

15
Suppose you have a multiphase VOF problem in ANSYS Fluent and you wish to calculate the gradient of the volume of fluid variable (VOF). One application would be to determine the local interfacial area of a cell, which is given by the product of the magnitude of the cell VOF gradient and the cell volume.

A User-Defined Function (UDF) can be written (see below) to calculate gradient of a flow variable using User Defined Scalars (UDS) and User Defined Memory locations (UDM). For any UDS, ANSYS Fluent can calculate the gradient using an available macro. Hence, passing the variable to a UDS permits the cell-centered gradient of any flow variable to be calculated. This vector result can then be stored in UDM arrays. The steps for doing this are as follows:
1. Read in the converged case and data
2. Compile the UDF listed below in the Interpreted mode (Define->User Defined->Functions->Intepreted). You may also Compile the UDF for your platform if desired (Define->User Defined->Functions->Compiled).
3. Hook up the DEFINE_ADJUST function (Define->User Defined->Function Hooks->Adjust Function)
4. Define UDM (Define->User Defined->Memory 1)
5. Define UDS (Define->User Defined->Scalars 1)
6. Turn off all equations (Solve->Controls->Solution)
7. Do one solver iteration
8. Execute the UDF store_gradient (Define->User Defined->Execute On Demand)

/* VOF gradient UDF */
# include ʺudf.hʺ
# define domain_ID 2
DEFINE_ADJUST(adjust_gradient, domain)
{
Thread *t;
cell_t c;
face_t f;
domain = Get_Domain(domain_ID);
/* Fill UDS with the variable. */
thread_loop_c (t,domain)
{ begin_c_loop (c,t)
{ C_UDSI(c,t,0) = C_VOF(c,t); }
end_c_loop (c,t) }
thread_loop_f (t,domain)
{ if (THREAD_STORAGE(t,SV_UDS_I(0))!=NULL)
begin_f_loop (f,t)
{F_UDSI(f,t,0) = F_VOF(f,t); }
end_f_loop (f,t) }
}
DEFINE_ON_DEMAND(store_gradient)
{
Domain *domain;
cell_t c;
Thread *t;
domain=Get_Domain(1); /* Fill the UDM with magnitude of gradient. */
thread_loop_c (t,domain)
{
begin_c_loop (c,t)
{C_UDMI(c,t,0) = NV_MAG(C_UDSI_G(c,t,0)); }
end_c_loop (c,t)
}
}

Pages: [1] 2 3 ... 11