|
[Sponsors] |
how to export every data w.r.t time to txt file |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
February 19, 2010, 21:23 |
|
#21 |
New Member
hun
Join Date: May 2009
Posts: 27
Rep Power: 17 |
Hi
it works by change the comma to the semicolon. cheer |
|
April 21, 2010, 14:07 |
|
#22 |
Member
Join Date: Feb 2010
Posts: 33
Rep Power: 16 |
I have a similar problem:
I have a transient simulation with 100 timesteps. I recorded the .trn files for each timestep. Now I want to calculate the time averaged temperature and pressure at a certain plane (with MATLAB). How can I extract data files that contain the x,y,z coordinates and the temperature, pressure at a specific plane? and this for each timestep??? What do I have to do? Which command do I need to write into the comand editor? Where can I find helpers for the command editor language??? Thank you very much!!! |
|
June 3, 2010, 12:05 |
|
#23 |
Member
Join Date: Feb 2010
Posts: 33
Rep Power: 16 |
Hello
For CFD-Post Does anybody have a macro that loads all the timesteps in a loop automatically and gives out a calculation funtion: massflowAve T_tot and P_tot at inlet and outlet.... or even better the total-to-total efficiency of a turbine at each timestep... THANK YOU VERY MUCH I only have a macro where I can export the variables at a plane (at every node).... but i would need to export the results of a macro calculator ar a function calculator... |
|
June 4, 2010, 00:58 |
Hi
|
#24 |
Member
Dynampally Pavitran
Join Date: Mar 2010
Location: India
Posts: 74
Rep Power: 16 |
Sorry, I have posted below to extract variables using function calculator.
Last edited by pavitran; June 4, 2010 at 01:42. Reason: Posted wrong macro so edited it |
|
June 4, 2010, 01:04 |
Hi
|
#25 |
Member
Dynampally Pavitran
Join Date: Mar 2010
Location: India
Posts: 74
Rep Power: 16 |
OK, to use function calculator and extract variables at inlet, out let or some plane
if you have trn files at different time steps lets say, case2_2.trn case2_3.trn # where 2 & 3 refers to time in sec then replace the file name in loadfilename with this and also change the increment in for loop. #************************************************* ********************* ! open(OFH, " >> file.dat"); # writing to a file # for loop start ! for ($i=1; $i <= 3; $i++) { COMMAND FILE: CFX Post Version = 11.0 END DATA READER: Clear All Objects = false Append Results = false Apply X Offset = false Apply Y Offset = false Apply Z Offset = false Keep Camera Position = true Load Particle Tracks = true END > load filename=/home/cfx5run/Ns200/var03_gvo24_full_$i.trn ! $total_temp = areaAve("Total Temperature","inlet"); ! printf (OFH "1.8f\n",$total_temp); !} ! close(OFH); > quit #************************************************* ********* Note: you can execute this in both Windows command line or UNIX command line: eg: cfx5post -batch test.cse Last edited by pavitran; June 4, 2010 at 10:17. |
|
June 4, 2010, 08:38 |
|
#26 |
New Member
Carlos
Join Date: Oct 2009
Posts: 18
Rep Power: 17 |
Dear Blackbody,
Would you mind writing in this forum your macro about exporting variables in several timesteps?.It would be very kind. I've tried to use the code that appears in this threat above but it doesn't work. This macro would make easier my way of working with CFX. Thanks in advance Carlitos |
|
June 4, 2010, 08:43 |
|
#27 |
Member
Join Date: Feb 2010
Posts: 33
Rep Power: 16 |
Hey, i'm currently working on it.... if i manage to let it run i will post it here of course!
cu |
|
June 4, 2010, 10:09 |
|
#28 |
Member
Join Date: Feb 2010
Posts: 33
Rep Power: 16 |
@Carlitos
By the way: What do you need to export? Do you need to export variables (e.g. Temperature) at each node of a plane (e.g. Inlet) including x, y, z coordinates? or do you have the same problem like me that you want to export a functioncalculator value at each timestep? for the first one i have a very nice macro... let me know |
|
June 4, 2010, 10:15 |
Hi
|
#29 | |
Member
Dynampally Pavitran
Join Date: Mar 2010
Location: India
Posts: 74
Rep Power: 16 |
Quote:
! open(OFH, " >> file.dat"); # for loop for time steps lets say 3 time steps ! for ($i=1; $i <= 3; $i++) { COMMAND FILE: CFX Post Version = 12.0 END DATA READER: Clear All Objects = false Append Results = false Edit Case Names = false Open to Compare = false Multi Configuration File Load Option = Last Case Open in New View = true Keep Camera Position = true Load Particle Tracks = true Files to Compare = END DATA READER: Domains to Load = DT, GV, RUN, RUN OUT, SP, SV END > load filename=/home/bpl/RAMPUR/Grid1/GRID1_$i.trn, force_reload=true # "change the path and Result file name" ! $total_temp = areaAve("Total Temperature","inflow"); # "my inlet boundary, I name it as inflow in pre" accordingly call the boundaries as you named it in pre ! printf (OFH "1.8f\n",$total_temp); !} ! close(OFH); > quit Hi carlitos, the first macro which i have posted has been updated with some changes, have a look at that. if you are Executing this and error pops up, can you tell me what error is prompted. |
||
June 4, 2010, 11:05 |
|
#30 |
Member
Join Date: Feb 2010
Posts: 33
Rep Power: 16 |
if I run your programm my outfile looks like following:
1.8f 1.8f 1.8f 1.8f 1.8f ... what shall I do? Thank you! and by the way, how can i modify the sessionfile so that it writes out also AreaAve Temperature at outlet and AreaAve pessure at inlet and outlet.. (total of 4 variables per timestep) is this possible? thanx ps: i'm using version12 my .trn results look like that: 200.trn, 201.trn,... and this is the session file i played: -------------------------------------- ! open(OFH, " >> T_tot_export.csv"); # for loop for time steps lets say 3 time steps ! for ($i=200; $i <= 203; $i++) { COMMAND FILE: CFX Post Version = 12.0 END DATA READER: Clear All Objects = false Append Results = false Edit Case Names = false Open to Compare = false Multi Configuration File Load Option = Last Case Open in New View = true Keep Camera Position = true Load Particle Tracks = true Files to Compare = END DATA READER: Domains to Load = S1, S2 END > load filename=K:\80Efficiency00\Model_trnres_62_001\$i. trn, force_reload=true ! $total_temp = massFlowAve("Total Temperature","Inlet"); ! printf (OFH "1.8f\n",$total_temp); !} ! close(OFH); > quit ---------------------------------------------------- |
|
June 4, 2010, 13:22 |
|
#31 |
Member
Dynampally Pavitran
Join Date: Mar 2010
Location: India
Posts: 74
Rep Power: 16 |
1. we need to write "%1.8f"
2. we can output 4 variables per timestep following is the edited macro -------------------------------------- ! open(OFH, " >> T_tot_export.dat"); # for loop for time steps lets say 3 time steps ! for ($i=200; $i <= 203; $i++) { COMMAND FILE: CFX Post Version = 12.0 END DATA READER: Clear All Objects = false Append Results = false Edit Case Names = false Open to Compare = false Multi Configuration File Load Option = Last Case Open in New View = true Keep Camera Position = true Load Particle Tracks = true Files to Compare = END DATA READER: Domains to Load = S1, S2 END > load filename=K:\80Efficiency00\Model_trnres_62_001\$i. trn, force_reload=true ! print "Case $i\n"; # line 100 ! $tot_temp_in = massFlowAve("Total Temperature","Inlet"); ! $tot_temp_out = massFlowAve("Total Temperature","Outlet"); ! $pr_in = areaAve("Pressure","Inlet"); ! $pr_out = areaAve("Pressure","Outlet"); ! printf (OFH "%1.8f %1.8f %1.8f %1.8f\n",$tot_temp_in,$tot_temp_out,$pr_in,$pr_out ); !} ! close(OFH); > quit ----------------------------------------------------[/QUOTE] # line 100 displays the present case which is in the loop, on the screen you can also do mathematical operations, like calculating Cp, Efficiency. This macro can be made more generic if integrated with Bash scripts in UNIX. |
|
June 4, 2010, 13:38 |
|
#32 |
Member
Join Date: Feb 2010
Posts: 33
Rep Power: 16 |
Thank you, in the meantime i was able to solve it myself
but thanx!!! HERE ARE SOME HELPFUL MACROS: --------------------------------------------------------------------------------------------------------------------------------------------- 1.) If you want to export data of a plane (like "File" -> "Export" in CFD-POST) # A CFX-Post session file for output of Transient Calculation # Results for file export, can be adapted to any other output ## COPY THIS FILE INTO YOUR WORKING DIRECTORY, WHERE YOUR .res FILE is!## ################################################## ###################### #### Name convention ################################################## ###################### ! $PathSeparator = "/"; ! $ResFileName = getValue("DATA READER", "Current Results File"); ! $ResPos = index($ResFileName, ".res"); ! $ResFileLength = length($ResFileName); ! if ($ResPos == ($ResFileLength - 4)){ ! $FileBase = substr($ResFileName, 0, $ResFileLength-4); ! } ! else { ! $FileBase = $ResFileName ; ! } ! $DirName = $FileBase . "_EXPORT1"; ##################### ADJUST THIS ! mkdir ($DirName, 0777); ! $DirName = $DirName . $PathSeparator; ################################################## ###################### #### Start postprocessing loop ################################################## ###################### ! $count = 200; ##################### ADJUST THIS (number of the start imestep) ! @tlistt = (200, 201, 202, 203, 204, 205, 206, …, 300); ##################### ADJUST THIS ! foreach $tlist (@tlistt){ DATA READERATA READER Current Timestep = $tlist END > load ! $dummyfile = $DirName . "t" . $count.".csv"; EXPORT: #ANSYS Export Data = Element Pressure #ANSYS Export Locator = wallmeshcdb #ANSYS Fluid Selection = All Fluids #ANSYS Reference Temperature = 0.0 [C] #ANSYS Specify Reference Temperature = Off Export Type = Generic #BC Profile Type = Inlet Velocity Export Connectivity = Off Export Coord Frame = Global Export File = $dummyfile Export Geometry = On Export Node Numbers = Off Export Null Data = Off Export Units System = Current #Export Variable Type = Hybrid Include File Information = Off Include Header = On Location List = Plane 1 ##################### ADJUST THIS (Inlet, Outlet, Plane1,…) (only one allowed!!!) Null Token = 0 Overwrite = On Precision = 10 Separator = ", " Spatial Variables = X,Y,Z Variable List = Total Temperature, Total Pressure, … ##################### ADJUST THIS (you can specify more than one variable) Vector Brackets = () Vector Display = Scalar END >export ! $count = $count + 1; ############################# ! } # # Ende der Sub-Definition ---------------------------------------------------------------------------------------------------------------- 2.) If you want to give out alculations at a plane, for example massFlowAve value at inlet and outlet.... # A CFX-Post session file for output of Transient Calculation # Results for file export, can be adapted to any other output ## COPY THIS FILE INTO YOUR WORKING DIRECTORY, WHERE YOUR .res FILE is!## ################################################## ###################### #### Name convention ################################################## ###################### ! $PathSeparator = "/"; ! $ResFileName = getValue("DATA READER", "Current Results File"); ! $ResPos = index($ResFileName, ".res"); ! $ResFileLength = length($ResFileName); ! if ($ResPos == ($ResFileLength - 4)){ ! $FileBase = substr($ResFileName, 0, $ResFileLength-4); ! } ! else { ! $FileBase = $ResFileName ; ! } ! $DirName = $FileBase . "_EXPORT2"; ############# ADJUST THIS ! mkdir ($DirName, 0777); ! $DirName = $DirName . $PathSeparator; ! open(OFH, " >> exportfile.csv"); ############# ADJUST THIS ################################################## ###################### #### Start postprocessing loop ################################################## ###################### ! $count = 200; ############# ADJUST THIS ! $Variable1 = "Total Temperature"; ############# ADJUST THIS ! $Variable2 = "Total Pressure"; ############# ADJUST THIS ! $Plane1 = "Inlet"; ############# ADJUST THIS ! $Plane2= "Outlet"; ############# ADJUST THIS ! @tlistt = (200, 201, 202, 203, 204, ..., 300); ! foreach $tlist (@tlistt){ DATA READERATA READER Current Timestep = $tlist END ! $mVariable1 = massFlowAve($Variable1, $Plane1,""); ############# ADJUST THIS ! $mVariable2 = massFlowAve($Variable1, $Plane2,""); ############# ADJUST THIS ! $mVariable3 = massFlowAve($Variable2, $Plane1,""); ############# ADJUST THIS ! $mVariable4 = massFlowAve($Variable2, $Plane2,""); ############# ADJUST THIS !print OFH $tlist," , ",$mVariable1," , ",$mVariable2," , ",$mVariable3," , ",$mVariable4, "\n"; ############# ADJUST THIS ! $count = $count + 1; ! } ############################# # # Ende der Sub-Definition ! close(OFH); --------------------------------------------------------------------------------------------------------------------------------- |
|
June 4, 2010, 13:40 |
|
#33 |
Member
Join Date: Feb 2010
Posts: 33
Rep Power: 16 |
sorry, where this stupid smile is just type:
DATA READER"doublepoint"DATA READER |
|
June 4, 2010, 13:40 |
|
#34 | |
New Member
Carlos
Join Date: Oct 2009
Posts: 18
Rep Power: 17 |
Quote:
Dear Blackbody, yes, that's what i really need: export variables at each node at each timestep including their coordinates. If you could write here the macro...it would be fantastic. Thanks in advance Carlitos |
||
June 4, 2010, 14:33 |
|
#35 |
New Member
Carlos
Join Date: Oct 2009
Posts: 18
Rep Power: 17 |
Thanks for write the macro Blackbody.
I've ran it but, unfortunately, an error pops up and tells me ERROR Too many END statements in CCL. Where's the mistake? I've copied your macro and made the adjust that you suggest. Could you tell anything? Thanks Here is the macro i've ran ################################################## ###################### #### Lecho ################################################## ###################### ! $PathSeparator = "/"; ! $ResFileName = getValue("DATA READER", "Current Results File"); ! $ResPos = index($ResFileName, ".res"); ! $ResFileLength = length($ResFileName); ! if ($ResPos == ($ResFileLength - 4)){ ! $FileBase = substr($ResFileName, 0, $ResFileLength-4); ! } ! else { ! $FileBase = $ResFileName ; ! } ! $DirName = $FileBase . "_EXPORT1"; ##################### ADJUST THIS ! mkdir ($DirName, 0777); ! $DirName = $DirName . $PathSeparator; ################################################## ###################### #### Start postprocessing loop ################################################## ###################### ! $count = 71100; ##################### ADJUST THIS (number of the start imestep) ! @tlistt = (71100, 72000, 72900); ##################### ADJUST THIS ! foreach $tlist (@tlistt){ DATA READER"doublepoint"DATA READER Current Timestep = $tlist END > load ! $dummyfile = $DirName . "t" . $count.".csv"; EXPORT: #ANSYS Export Data = Element Pressure #ANSYS Export Locator = wallmeshcdb #ANSYS Fluid Selection = All Fluids #ANSYS Reference Temperature = 0.0 [C] #ANSYS Specify Reference Temperature = Off Export Type = Generic #BC Profile Type = Inlet Velocity Export Connectivity = Off Export Coord Frame = Global Export File = $dummyfile Export Geometry = On Export Node Numbers = Off Export Null Data = Off Export Units System = Current #Export Variable Type = Hybrid Include File Information = Off Include Header = On Location List = Plane 1 ##################### ADJUST THIS (Inlet, Outlet, Plane1,…) (only one allowed!!!) Null Token = 0 Overwrite = On Precision = 10 Separator = ", " Spatial Variables = X,Y,Z Variable List = Lecho. Volume Fraction ##################### ADJUST THIS (you can specify more than one variable) Vector Brackets = () Vector Display = Scalar END >export ! $count = $count + 1; ############################# ! } # # |
|
June 7, 2010, 07:34 |
Hi Carlitos
|
#36 |
Member
Dynampally Pavitran
Join Date: Mar 2010
Location: India
Posts: 74
Rep Power: 16 |
Ok carlitos try this !
copy the below macro in between hashes #, to some "file.cse" and copy file.cse to the directory where your *.trn files are located. Being in the same directory, at the UNIX or Windows command line just type cfx5post -batch file.cse ####for v11.0 cfx512post -batch file.cse ####for v12.0 As soon as you execute this and if everything is fine, I mean your location name , then on the screen you can see which case is presently in process. eg: :> cfx5post -batch file.cse 71100 72000 72900 :> #################################### COMMAND FILE: CFX Post Version = 11.0 END DATA READER: Clear All Objects = false Append Results = false Apply X Offset = false Apply Y Offset = false Apply Z Offset = false Keep Camera Position = true Load Particle Tracks = true END ! for ($i=71100; $i <= 72900; $i=$i+900) { ! print "$i \n"; > load filename=$i.trn EXPORT: #ANSYS Export Data = Element Heat Flux #ANSYS Reference Temperature = 0.0 [K] #ANSYS Specify Reference Temperature = Off # ANSYS Supplemental HTC = 0.0 [W m^-2 K^-1] # BC Profile Type = Inlet Velocity Export Connectivity = Off Export Coord Frame = Global Export File = $i.csv # Export file name with increment Export Geometry = On Export Node Numbers = Off Export Null Data = Off Export Type = Generic Export Units System = Current Export Variable Type = Current Include File Information = Off Include Header = On Location List = Plane 1 Null Token = 0 Overwrite = Off Precision = 10 Separator = ", " Spatial Variables = X,Y,Z Variable List = Lecho. Volume Fraction Vector Brackets = () Vector Display = Scalar END >export !} ############################################ if your using v12.0 just change the DATA READER and also include Load domains. just see my previous posts. I hope it works this time |
|
June 7, 2010, 12:41 |
|
#37 |
New Member
Carlos
Join Date: Oct 2009
Posts: 18
Rep Power: 17 |
Dear pavitran,
thanks a lot . The macro works perfectly on the command window, but there is a thing that i don't understand...when you comment to run the macro on Lynux you notice me to create a .cse file. How can i get making that kind of file?. I have no idea. And another question, where can i find more information about creating my own macros? Thanks again Carlitos |
|
June 7, 2010, 23:10 |
Hi Carlitos
|
#38 |
Member
Dynampally Pavitran
Join Date: Mar 2010
Location: India
Posts: 74
Rep Power: 16 |
1. To edit or create a file in Linux, one way is using VI editor. so, create a dummy file with extension ".cse" and paste the macro and save the file.
2. Or open Microsoft Word, wordpad or notepad in Windows and paste the macro and then save the file with extension ".cse" and copy this file on to UNIX machine using FTP or winscp. Your next question about creating macros? Look at "Examples of Power Syntax" in CFX help file. It doesn't give much information but for a start it is good. If you get acquainted with creating macros and have some knowledge of bash scripts in Linux, then you can automate your entire postprocessing, which ultimately saves considerable time. Anways all the best! |
|
June 14, 2010, 13:25 |
|
#39 |
New Member
Carlos
Join Date: Oct 2009
Posts: 18
Rep Power: 17 |
Hello Pavitran,
Thanks a lot for your last explanation. Now i'm posting again because i'm working on another macro which is making me get a bit crazy. I would like to calculate the mass flow of different fluids in a multiphase problem. The macro is showed below and the problem is that it calculates the mass flow of all the fluids instead of writing a single fluid. Moreover it appears a error message on the screen explaining to me it's impossible to load the file but actually a file.dat is written... How can i try to fancy with this point? Thanks in advance Carlitos ##################################### ! open(OFH, " >> fileg.dat"); # writing to a file ! for ($i=60030; $i <= 60130; $i=$i+50) { COMMAND FILE: CFX Post Version = 11.0 END DATA READER: Clear All Objects = false Append Results = false Apply X Offset = false Apply Y Offset = false Apply Z Offset = false Keep Camera Position = true Load Particle Tracks = true END > load filename=/carlitos/bis/80_1inhol_005/$i.trn ! $flujo = massFlow("Plane 2","CH4"); ! printf (OFH "%1.8f\n",$flujo); !} ! close(OFH); |
|
June 15, 2010, 02:57 |
Hi Carlitos
|
#40 |
Member
Dynampally Pavitran
Join Date: Mar 2010
Location: India
Posts: 74
Rep Power: 16 |
1. First check --> Open CFX POST GUI and try to calculate mass flow of CH4. If it is working there, then your macro should also work properly, moreover the syntax is fine.
2. Loading file --> Dont use the full path, just be in that directory and call the *.trn file > load filename=$i.trn 3. Are you executing this macro at Command line. Then how your creating "Plane 2". Note: Search for "Function Calculator" in CFX help manual and go to "Direction or Axis Selection" page. There you will find a Note about massFlow. Have a look at that, as it mentions about some Expert control parameters. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[swak4Foam] swak4foam building problem | GGerber | OpenFOAM Community Contributions | 54 | April 24, 2015 17:02 |
Moving mesh | Niklas Wikstrom (Wikstrom) | OpenFOAM Running, Solving & CFD | 122 | June 15, 2014 07:20 |
OpenFOAM on MinGW crosscompiler hosted on Linux | allenzhao | OpenFOAM Installation | 127 | January 30, 2009 20:08 |
DxFoam reader update | hjasak | OpenFOAM Post-Processing | 69 | April 24, 2008 02:24 |
Could anybody help me see this error and give help | liugx212 | OpenFOAM Running, Solving & CFD | 3 | January 4, 2006 19:07 |