Jump to content
Sign in to follow this  
masuarez1122

Density user defined equation

Recommended Posts

I am learning CFD and I have a problem that has density as a function of Temperature and Pressure.  To start, I wrote a user defined function (usrMyDensity.c) where density is only a function of temperature (linear equation).  I was able to compile the function and call it in my input file, but when i run a simple analysis (internal flow with constant temperature at the walls), i am not able to plot density in FieldView.  I'm assuming that i'm not using the correct problem set up.  

 

I know that it is using the complied user function because initially it was giving me an error of negative density, which i fixed with an if statement in my user function.  

 

Any advice will be greatly appreciated.  

 

thank you for your time and patience  

usrMyDensity.c

Share this post


Link to post
Share on other sites

In order to see contours of density, you'll need to request Derived Quantity Output, which is a separate command in the input file.  The default setting is output_frequency = 0, meaning derived quantity output will not be written.  You'll probably want to change that so the output_frequency is the same as you request for Nodal Output.

Share this post


Link to post
Share on other sites

acupro, 

 

thank you very much, that did it!!!  

 

I have a followup question regarding compiling C files for a Acusolve user defined function.  if you take a look at the attached doc on my original question (usrMyDensity.c), you'll see that it is a very simple linear equation.  I kept it simple so I could get familiar with compiling user defined functions and calling them in the input file.  However, I now want to create a user defined function that interpolates the density between temperature and pressure.  I wrote a very crude C++ program in Visual Studio to open a .txt file, find pressure and temperatures, and interpolate the density.  I run this file using Visual Studio and it works.  in Visual Studio, to open and read a .txt file, i included fstream.h (#include <fstream>). 

 

in Acusolve, I want to start by having the user-defined function open the .txt file and read one value (baby steps), but when i try to compile, it is giving me lots of errors.  in the C code, how do I include the fstream.h needed to open and read text files?   

 

thank you very much

DensityTemperature_Column.txt

fileReader.cpp

 

methane_Density.c

Share this post


Link to post
Share on other sites

Probably better to contact support at hwsupport@altair.com for those details.  By the way, if you're looking for ideal gas density - a function of absolute temperature and pressure - that is already supported in AcuSolve.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
You are posting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...