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

how to export every data w.r.t time to txt file

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree6Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 19, 2010, 20:23
Default
  #21
New Member
 
hun
Join Date: May 2009
Posts: 27
Rep Power: 16
hung is on a distinguished road
Hi
it works by change the comma to the semicolon.
cheer
hung is offline   Reply With Quote

Old   April 21, 2010, 13:07
Default
  #22
Member
 
Join Date: Feb 2010
Posts: 33
Rep Power: 16
blackbody is on a distinguished road
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!!!
blackbody is offline   Reply With Quote

Old   June 3, 2010, 11:05
Default
  #23
Member
 
Join Date: Feb 2010
Posts: 33
Rep Power: 16
blackbody is on a distinguished road
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...
blackbody is offline   Reply With Quote

Old   June 3, 2010, 23:58
Default Hi
  #24
Member
 
Dynampally Pavitran
Join Date: Mar 2010
Location: India
Posts: 74
Rep Power: 16
pavitran is on a distinguished road
Sorry, I have posted below to extract variables using function calculator.

Last edited by pavitran; June 4, 2010 at 00:42. Reason: Posted wrong macro so edited it
pavitran is offline   Reply With Quote

Old   June 4, 2010, 00:04
Default Hi
  #25
Member
 
Dynampally Pavitran
Join Date: Mar 2010
Location: India
Posts: 74
Rep Power: 16
pavitran is on a distinguished road
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 09:17.
pavitran is offline   Reply With Quote

Old   June 4, 2010, 07:38
Default
  #26
New Member
 
Carlos
Join Date: Oct 2009
Posts: 18
Rep Power: 16
Carlitos is on a distinguished road
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
Carlitos is offline   Reply With Quote

Old   June 4, 2010, 07:43
Default
  #27
Member
 
Join Date: Feb 2010
Posts: 33
Rep Power: 16
blackbody is on a distinguished road
Hey, i'm currently working on it.... if i manage to let it run i will post it here of course!
cu
blackbody is offline   Reply With Quote

Old   June 4, 2010, 09:09
Default
  #28
Member
 
Join Date: Feb 2010
Posts: 33
Rep Power: 16
blackbody is on a distinguished road
@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
blackbody is offline   Reply With Quote

Old   June 4, 2010, 09:15
Default Hi
  #29
Member
 
Dynampally Pavitran
Join Date: Mar 2010
Location: India
Posts: 74
Rep Power: 16
pavitran is on a distinguished road
Quote:
Originally Posted by Carlitos View Post
I've tried to use the code that appears in this threat above but it doesn't work.
Carlitos
For CFX v12.0 the start should be

! 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.
pavitran is offline   Reply With Quote

Old   June 4, 2010, 10:05
Default
  #30
Member
 
Join Date: Feb 2010
Posts: 33
Rep Power: 16
blackbody is on a distinguished road
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
----------------------------------------------------
blackbody is offline   Reply With Quote

Old   June 4, 2010, 12:22
Default
  #31
Member
 
Dynampally Pavitran
Join Date: Mar 2010
Location: India
Posts: 74
Rep Power: 16
pavitran is on a distinguished road
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.
pavitran is offline   Reply With Quote

Old   June 4, 2010, 12:38
Default
  #32
Member
 
Join Date: Feb 2010
Posts: 33
Rep Power: 16
blackbody is on a distinguished road
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);

---------------------------------------------------------------------------------------------------------------------------------
holzkiste and aadicfd like this.
blackbody is offline   Reply With Quote

Old   June 4, 2010, 12:40
Default
  #33
Member
 
Join Date: Feb 2010
Posts: 33
Rep Power: 16
blackbody is on a distinguished road
sorry, where this stupid smile is just type:

DATA READER"doublepoint"DATA READER
blackbody is offline   Reply With Quote

Old   June 4, 2010, 12:40
Default
  #34
New Member
 
Carlos
Join Date: Oct 2009
Posts: 18
Rep Power: 16
Carlitos is on a distinguished road
Quote:
Originally Posted by blackbody View Post
@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?

for the first one i have a very nice macro...
let me know

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
Carlitos is offline   Reply With Quote

Old   June 4, 2010, 13:33
Default
  #35
New Member
 
Carlos
Join Date: Oct 2009
Posts: 18
Rep Power: 16
Carlitos is on a distinguished road
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;

#############################
! }
#
#
Carlitos is offline   Reply With Quote

Old   June 7, 2010, 06:34
Default Hi Carlitos
  #36
Member
 
Dynampally Pavitran
Join Date: Mar 2010
Location: India
Posts: 74
Rep Power: 16
pavitran is on a distinguished road
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
holzkiste likes this.
pavitran is offline   Reply With Quote

Old   June 7, 2010, 11:41
Smile
  #37
New Member
 
Carlos
Join Date: Oct 2009
Posts: 18
Rep Power: 16
Carlitos is on a distinguished road
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
Carlitos is offline   Reply With Quote

Old   June 7, 2010, 22:10
Default Hi Carlitos
  #38
Member
 
Dynampally Pavitran
Join Date: Mar 2010
Location: India
Posts: 74
Rep Power: 16
pavitran is on a distinguished road
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!
pavitran is offline   Reply With Quote

Old   June 14, 2010, 12:25
Exclamation
  #39
New Member
 
Carlos
Join Date: Oct 2009
Posts: 18
Rep Power: 16
Carlitos is on a distinguished road
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);
Carlitos is offline   Reply With Quote

Old   June 15, 2010, 01:57
Default Hi Carlitos
  #40
Member
 
Dynampally Pavitran
Join Date: Mar 2010
Location: India
Posts: 74
Rep Power: 16
pavitran is on a distinguished road
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.
pavitran is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
[swak4Foam] swak4foam building problem GGerber OpenFOAM Community Contributions 54 April 24, 2015 16:02
Moving mesh Niklas Wikstrom (Wikstrom) OpenFOAM Running, Solving & CFD 122 June 15, 2014 06:20
OpenFOAM on MinGW crosscompiler hosted on Linux allenzhao OpenFOAM Installation 127 January 30, 2009 19:08
DxFoam reader update hjasak OpenFOAM Post-Processing 69 April 24, 2008 01:24
Could anybody help me see this error and give help liugx212 OpenFOAM Running, Solving & CFD 3 January 4, 2006 18:07


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