## Fluids

Topics relate to Fluent, CFX, Turbogrid and more

#### UDF for salinity based on temperature profiles

• soloviev
Subscriber
Hello,I'm trying to write a UDF to implement a temperature based salinity in Fluent, but the temperature in the model is a profile (imported from a .csv). Is this possible? I have a UDF I used previously (see below), but I'm not sure how to implement the salinity based on the variable temperature profile, if even possible.nn#include udf.hnn}nDEFINE_PROPERTY(salinity_dens,c,t)n{ntreal pho_w, sigma_t;ntreal sal = C_UDSI(c,t,salinity); / in promillesntreal temp = C_T(c,t) - 273.15; nn  / complex formula - see www.es.flinders.edu.au/~mattom/IntroOc/lecture03.htmlnn  sigma_t = - 0.157406 + temp*(6.793952E-2 - temp*(9.095290E-3 - temp*(1.001685E-4 - temp*(1.120083E-6 - temp n*6.536332E-9)))) + n    sal*(8.24493E-1 - temp*(4.0899E-3 - temp*(7.6438E-5 - temp*(8.2467E-7 - temp*5.3875E-9))) n    - sqrt(sal)*(5.72466E-3 - temp*(1.0227E-4 - temp*1.6546E-6)) + sal*4.8314E-4);nntpho_w = 1000.0 + sigma_t; ntreturn pho_w;n}Thanks,nAlexnn
• Rob
Ansys Employee
Is salinity a straight mass fraction of salt in water, or is it a % of saturation? n
• soloviev
Subscriber
Mass fraction should be sufficient n
• DrAmine
Ansys Employee
Temperature profile is it a boundary profile or transient one?n
• soloviev
Subscriber
the temperature profile is a boundary profile. we are updating it every 1 minute with real temperature data we collected at the boundaries of the domain. n
• DrAmine
Ansys Employee
Okay and what about the salinity or where /what do you want to customize?n
• soloviev
Subscriber
We'd like to apply a salinity property to the water phase based on the temperature. n
• Rob
Ansys Employee
You want to alter the mass fraction going into the domain based on temperature? Or change the whole domain? I'm a little confused on this one: it's been a long week....n
• DrAmine
Ansys Employee
Yes Rob I am confused too: How is that salinity property defined in your case? Is is specie? Is it an UDS? Is it just a density? Do you want to do that only at entry or in the whole volume?n
• soloviev
Subscriber
We do initialize the temperature in the entire domain, also using a volume profile / fixed value. Then fixed values are turned off after initializing. We did try setting density based on temperature (polynomial) and it gave us stratification, but we'd like to also implement salinity. We previously used salinity as a UDS in other models, but it was set at a specific area in the domain (i.e. a salinity plume that spread due to gravity current). n
• Rob
Ansys Employee
You may want to look at using temperature dependent density and also adding in a second species for the higher salinity liquid plume? Mixture density is then a function of temperature and salinity. nI've seen the mixing of fresh and salt water when diving. It's often accompanied by a temperature change (4C fresh water & 6-8C salt water) and the two streams take a while to fully mix. n
• DrAmine
Ansys Employee
The species approach as mentioned by Rob is better here. You can then make the mixture density as a weighted sum of the density of the components. The density of component can be then set temperature dependent.n