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

Defining expressions

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By Micael

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 14, 2020, 17:26
Question Defining expressions
  #1
New Member
 
Simar Sethi
Join Date: Jun 2020
Posts: 5
Rep Power: 6
alpha2rock is on a distinguished road
I am working on a precipitation problem, and for that I need to define an expression:
f=sqrt(C1*C2)-sqrt(Ksp)

where C1 and C2 are molar concentrations for 2 species.

How can I define f?

Also, Ksp is a constant that I need to define with units i.e.
Ksp=1.1*10^-11[kmol^2/m^-6]

How can I define Ksp?

Do I need to use UDF or is it possible using fluent alone?
Also I need to use this expression (f) in a UDF.
So, how to go about it?
alpha2rock is offline   Reply With Quote

Old   June 15, 2020, 05:54
Default
  #2
Senior Member
 
Micael
Join Date: Mar 2009
Location: Canada
Posts: 157
Rep Power: 18
Micael is on a distinguished road
When you say you "also" need it in UDF, what is the first use then? Visualization?

As for the UDF purpose, that should be easy to do. Below is not a complet UDF and it assumes you use it in a macro that passes c and t, but might be useful as a starting point.

Code:
int species_1_index; species_2_index;
real Ksp;
real y1, y2;
real mw1, mw2;
real rho;
real f;

Ksp = 1.1e-11;

/* you got to figure out index for your species */
/* I arbitrary put 0 and 1 as index */
species_1_index = 0;
species_2_index = 1;

/* species molecular weight [kg/kmol] */
/* I put some arbitrary values */
mw1 = 18.;
mw2 = 32.;

/* Get species mass fraction */
y1 = C_YI(c,t,species_1_index);
y2 = C_YI(c,t,species_2_index);

/* mixture density */
rho = C_R(c,t);

/* molar concentration [kmol/m3] */
C1 = y1*rho/mw1;
C2 = y2*rho/mw2;

f = sqrt(C1*C2)-sqrt(Ksp);
alpha2rock likes this.
Micael is offline   Reply With Quote

Old   June 22, 2020, 04:39
Default
  #3
New Member
 
Simar Sethi
Join Date: Jun 2020
Posts: 5
Rep Power: 6
alpha2rock is on a distinguished road
Thank you for your reply Michael.

Yes, defining the parameters/expressions directly into the UDF as variables can be done.
But, alternatively I wanted to call parameters defined in defined as "Named Expressions" in the Fluent interface, which gives me an option to mark them as "use in UDF". Can you help me on how to call these while writing my udf?
alpha2rock is offline   Reply With Quote

Reply

Tags
constant, expressions, parameters, udf, units


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
CFX Command Language to Modify Expressions cfd seeker CFX 5 February 6, 2019 17:23
[cfMesh] Regular expressions in cfMesh rama13 OpenFOAM Community Contributions 6 June 7, 2015 18:01
Grouping expressions in CEL foo7 CFX 4 September 21, 2011 10:15
defining new expressions iperten CFX 4 April 6, 2009 06:36
Cel expressions for trasient problem Jervds CFX 0 March 4, 2008 11:03


All times are GMT -4. The time now is 16:11.