KK Mothe's Blog
Let’s go be champions, boys
Everytime I watch this video and hear McElroy say "Let's go be champions, boys" it gives me goose bumps. Metallica's no leaf clover makes this video even more awesome.
Getting started with Fluent (6.3) batch files
If you have to do any serious amount of CFD work with Fluent you will probably do a lot of repetitious stuff, especially so in parametric studies with Fluent. E.g. if you have to simulate a flow and get the results for each of the turbulence models (that are available in Fluent) and find out which turbulence model gives better results. Doing this from Fluent GUI repeatedly would be really frustrating, not to mention, time consuming. One way to automate Fluent might be to use the journal files (to record and play back) but the journal files are too fragile. What I mean by that is, it breaks down too easily, like, when one of the models diverges. Then you have to figure out how to continue from there.
Fortunately, to solve these problems, Fluent has a really cool Command Line Interface (CLI). The CLI uses, and is written in a dialect of Lisp called Scheme. Not familiar with Scheme? Don’t sweat it. CLI is simple and inCLItive enough to grok quickly. You can run the CLI commands by opening Fluent and typing them at the command prompt or you can create a script/batch file containing all the CLI commands and run it for repetitive tasks. All right, enough talk, let’s see some examples.
Let’s start by reading a case file into fluent using CLI.
/file/read-case example.cas ‘reads the case file named example.cas
Want to read a case and the associated data file? No problem.
/file/read-case-data example.cas ‘reads example.cas and example.dat
While the above commands work perfectly fine, fluent has a really smart pattern matching in CLI. i.e you can abbreviate the CLI commands and Fluent will try to understand it based on pattern matching, which will be clear in a minute.
/file/rc example.cas
/file/rcd example.cas
/file/rcd example.cas
Or, taking it further,
rc example.cas
rcd example.cas
rcd example.cas
To change the turbulence model to RSM
/define/models/viscous/reynolds-stress-model yes
Or, just,
/def/mod/vis/rsm y
Note that the yes (or y) is an argument for the /def/mod/vis/rsm command, to confirm the enabling of the RSM model. In CLI, each command might have zero, one or multiple command arguments. The arguments might need to be numbers or character strings or Boolean or a list of values. More on this later.
To enable enhanced wall treatment,
/define/models/viscous/near-wall-treatment/enhance-wall-treatment yes
Or, just,
/def/mod/vis/nwt/ewt y
Or, just,
/def/mod/vis/nwt/ewt y
All right, I’ll stop beating the abbreviation hammer now.
To run a 1000 iterations,
/solve/iterate 1000
As you can see from the above examples, the CLI command should be very inCLItive from the way you’d accomplish the same task through the menu bar in the GUI. And you don’t have to remember all these commands and their arguments. You can just explore it by firing up fluent GUI and pressing enter at the command prompt. The character ‘>’ is the command prompt in Fluent GUI. You can see how one could find the command to set the turbulence model in the figure below.

Now that you got your feet wet, let’s see a complete batch file that can be used to run a case file (init.cas in this example) with various turbulence models.
*************************batch.jou******************************
/file/rc init.cas
/solve/initialize/compute-defaults/velocity-inlet inlet
/solve/initialize/initialize-flow
/solve/iterate 5000
/plot/plot yes "Nu1-ske-ewt.xy" yes no no nusselt no no x-over-w bot_wall_1 bot_wall_2 ()
/file/wcd flatplate1-ske-ewt.cas
/define/model/viscous/ke-rng y
/solve/iterate 5000
/plot/plot yes "Nu1-rngke-ewt.xy" yes no no nusselt no no x-over-w bot_wall_1 bot_wall_2 ()
/file/wcd flatplate1-rngke-ewt.cas
/define/model/viscous/ke-realizable y
/solve/iterate 5000
/plot/plot yes "Nu1-realke-ewt.xy" yes no no nusselt no no x-over-w bot_wall_1 bot_wall_2 ()
/file/wcd flatplate1-realke-ewt.cas
/define/model/viscous/kw-standard y
/define/model/viscous/kw-shear-correction y
/solve/iterate 5000
/plot/plot yes "Nu1-skw-sfc.xy" yes no no nusselt no no x-over-w bot_wall_1 bot_wall_2 ()
/file/wcd flatplate1-skw-sfc.cas
/define/model/viscous/kw-sst y
/solve/iterate 5000
/plot/plot yes "Nu1-sst.xy" yes no no nusselt no no x-over-w bot_wall_1 bot_wall_2 ()
/file/wcd flatplate1-sstkw.cas
/define/model/viscous/rsm y
/define/model/viscous/rsmlps y
/define/model/viscous/rsm-solve-tke y
/define/model/viscous/rsm-wall-echo y
/define/model/viscous/nwt/ewt y
/solve/iterate 5000
/plot/plot yes "Nu1-lpsRSM-ewt.xy" yes no no nusselt no no x-over-w bot_wall_1 bot_wall_2 ()
/file/wcd flatplate1-lpsRSM-ewt.cas
/define/model/viscous/rsm-omega-based y
/solve/iterate 5000
/plot/plot yes "Nu1-lrso-sfc.xy" yes no no nusselt no no x-over-w bot_wall_1 bot_wall_2 ()
/file/wcd flatplate1-lrso-sfc.cas
exit
****************************batch.jou******************************
Once you have this file created, you can create a case file init.cas with everything other than turbulence model set. Then all you have to do is run
$ fluent 2d –g -i <batch.jou>output &
$
This will read the init.cas file set the turbulence model, run a few iterations and save the result. This will be repeated for various turbulence models as specified in the batch.jou file.This is only the tip of the iceberg. You can do some funky stuff with the scheme constructs like looping, etc. you can use shell scripting too to generate the fluent batch files. E.g in situations where you want to run all the case files in a specific directory, u can use shell scripting to loop through all the case files in the directory and generate the CLI code for running them in fluent. I’ll try to write another blog post on some advanced scenarios. Hope this helps.
*************************batch.jou******************************
/file/rc init.cas
/solve/initialize/compute-defaults/velocity-inlet inlet
/solve/initialize/initialize-flow
/solve/iterate 5000
/plot/plot yes "Nu1-ske-ewt.xy" yes no no nusselt no no x-over-w bot_wall_1 bot_wall_2 ()
/file/wcd flatplate1-ske-ewt.cas
/define/model/viscous/ke-rng y
/solve/iterate 5000
/plot/plot yes "Nu1-rngke-ewt.xy" yes no no nusselt no no x-over-w bot_wall_1 bot_wall_2 ()
/file/wcd flatplate1-rngke-ewt.cas
/define/model/viscous/ke-realizable y
/solve/iterate 5000
/plot/plot yes "Nu1-realke-ewt.xy" yes no no nusselt no no x-over-w bot_wall_1 bot_wall_2 ()
/file/wcd flatplate1-realke-ewt.cas
/define/model/viscous/kw-standard y
/define/model/viscous/kw-shear-correction y
/solve/iterate 5000
/plot/plot yes "Nu1-skw-sfc.xy" yes no no nusselt no no x-over-w bot_wall_1 bot_wall_2 ()
/file/wcd flatplate1-skw-sfc.cas
/define/model/viscous/kw-sst y
/solve/iterate 5000
/plot/plot yes "Nu1-sst.xy" yes no no nusselt no no x-over-w bot_wall_1 bot_wall_2 ()
/file/wcd flatplate1-sstkw.cas
/define/model/viscous/rsm y
/define/model/viscous/rsmlps y
/define/model/viscous/rsm-solve-tke y
/define/model/viscous/rsm-wall-echo y
/define/model/viscous/nwt/ewt y
/solve/iterate 5000
/plot/plot yes "Nu1-lpsRSM-ewt.xy" yes no no nusselt no no x-over-w bot_wall_1 bot_wall_2 ()
/file/wcd flatplate1-lpsRSM-ewt.cas
/define/model/viscous/rsm-omega-based y
/solve/iterate 5000
/plot/plot yes "Nu1-lrso-sfc.xy" yes no no nusselt no no x-over-w bot_wall_1 bot_wall_2 ()
/file/wcd flatplate1-lrso-sfc.cas
exit
****************************batch.jou******************************
Once you have this file created, you can create a case file init.cas with everything other than turbulence model set. Then all you have to do is run
$ fluent 2d –g -i <batch.jou>
$
This will read the init.cas file set the turbulence model, run a few iterations and save the result. This will be repeated for various turbulence models as specified in the batch.jou file.This is only the tip of the iceberg. You can do some funky stuff with the scheme constructs like looping, etc. you can use shell scripting too to generate the fluent batch files. E.g in situations where you want to run all the case files in a specific directory, u can use shell scripting to loop through all the case files in the directory and generate the CLI code for running them in fluent. I’ll try to write another blog post on some advanced scenarios. Hope this helps.
Some football talk
Folks,
The crimson tide has officially hit the rock bottom, by loosing to some obscure college in Louisina. As huge a bama fan as I'm, it's hard not to criticize the players on the offensive side of the football. The defense didn't look good either. Sure, we didn't have two starters on the offensive line, didn't have the running back that can actually escape tackles, but come on, this is Lousiana Monroe, we lost to. I still think saban is one heck of a coach and I believe in the "process". The only silver bullet as of now is that the 2008 class committed to alabama is ranked third in the nation (courtesy, http://www.rivals.com).
Speaking of football, this college football season has been totally crazy. I can't remember a saturday in this football season without a major upset game somewhere in the nation. I'm guessing that quite a few coaches will get fired/retired at the end of the season.
anyway, I just had to blog today to get the bama loss out my system.
I turn 25
Folks, I've turned 25 yesterday and the only singnificance of it I can think of is the lower auto insurance rates :-). I'm not a big birthyday celebratin' kinda guy and I don't usually take the time to wish someone on their birthday (say, on orkut). So, I certainly appreciate all the b'day wishes pouring in on my scrapbook. Thanks to all those who did take the time to wish me. It sure made me feel good.
Oh my goodness, gracious. This is gonna be huge!
Scott guthrie just blogged here about releasing .net 3.5 base class libraries' source code , along with the release of visual studio 2008. So, now you can download the symbols from the Microsoft's symbols server and step right into the .NET framework source code while debugging. That means, there will be no more of, "Oh, crap. I don't know what the hell is gridview doing internally". This is gonna be a huge improvement in any .NET developer's life. I commend Microsoft for taking such an initiative.
I can't seem to get this song out of my head
If you've seen the recent Nissan Altima ad on the TV, you gotta wonder what the song was in the background. Well, I did, and turns out the song is called "Pride and Joy" by Stevie Ray Vaughn (SRV). Ever since I first heard that song, I've been playing it all week long. if you are curious, go ahead and play the song below and don't forget to blast your speakers with it.
I won ! I won !!
For the non .NET folks out there, there is a podcast called dotNetRocks which is very popular among the .NET community. I'm a huge fan of this podcast and any one who has been a roommate of mine in the last couple of years know that I listen to something (this podcast) as I go to bed.
Anyway, They have an ongoing contest in which they ask some question and you need to submit the answer on their website. So, last week I just registered on their website and answered a question and guess what, Today in show #273 they announced that I won.
So folks, go to http://www.dotnetrocks.com/default.aspx?showNum=273 and listen around 8:00 mins into the show.
P.S.: You'll also hear a silly little joke on tuscaloosa which you probably never heard of.
Subscribe to:
Comments (Atom)