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

Ansys workbench scripting

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 21, 2015, 23:05
Smile Ansys workbench scripting
  #1
Senior Member
 
sunilpatil's Avatar
 
sunil
Join Date: Jul 2012
Location: Bangalore
Posts: 179
Rep Power: 14
sunilpatil is on a distinguished road
Hello Everyone,
I am trying to extract results from CFD-Post in workbench environment through script. I have created the workbench script (Ex: saving the velocity contour as a image file). Now i wanted to run it in loop so that i can extract results from multiple results file.
With the script i am able to open different workbench files but i am unable to save the velocity contour i.e i am unable to change Hardcopy Filename in the loop.
please help me to solve this problem
(i already created dp1,dp2,dp3 and dp4 folders in respective path)

# encoding: utf-8
import os

for i in 1,4:
#os.mkdir('dp%s' %i)
Open(FilePath="F:/Workbench_40_dp%s.wbpj" %i) #worked
SetScriptVersion(Version="15.0")
system1 = GetSystem(Name="CFX 11")
results1 = system1.GetContainer(ComponentName="Results")
results1.Edit()
results1.SendCommand(Command="""HARDCOPY:
Antialiasing = On
Hardcopy Filename = "F:/results/temp/dp"str{i}"/velocity.png" #not working
Hardcopy Format = png
Hardcopy Tolerance = 0.0001
Image Height = 600
Image Scale = 100
Image Width = 600
JPEG Image Quality = 80
Screen Capture = Off
Use Screen Size = On
White Background = Off
END
>print""")
results1.Exit()
sunilpatil is offline   Reply With Quote

Old   May 23, 2015, 10:17
Default
  #2
Senior Member
 
Matthias Voß
Join Date: Mar 2009
Location: Berlin, Germany
Posts: 449
Rep Power: 20
mvoss is on a distinguished road
Did it run when providing a name NOT created by a variable?
I would guess that you have to use PERL syntax in order to make this insertion.
  1. put a "!" at the beginning of the perl-like-line in the send-string (in order to have CFX recognize the perl expression)
  2. check the join() command to create the whole string in the beginning instead of stitching it together in-place
mvoss is offline   Reply With Quote

Old   November 30, 2017, 10:50
Default
  #3
New Member
 
Join Date: Nov 2017
Posts: 4
Rep Power: 9
Fabisch is on a distinguished road
Quote:
Originally Posted by sunilpatil View Post
Hello Everyone,
I am trying to extract results from CFD-Post in workbench environment through script. I have created the workbench script (Ex: saving the velocity contour as a image file). Now i wanted to run it in loop so that i can extract results from multiple results file.
With the script i am able to open different workbench files but i am unable to save the velocity contour i.e i am unable to change Hardcopy Filename in the loop.
please help me to solve this problem
(i already created dp1,dp2,dp3 and dp4 folders in respective path)

# encoding: utf-8
import os

for i in 1,4:
#os.mkdir('dp%s' %i)
Open(FilePath="F:/Workbench_40_dp%s.wbpj" %i) #worked
SetScriptVersion(Version="15.0")
system1 = GetSystem(Name="CFX 11")
results1 = system1.GetContainer(ComponentName="Results")
results1.Edit()
results1.SendCommand(Command="""HARDCOPY:
Antialiasing = On
Hardcopy Filename = "F:/results/temp/dp"str{i}"/velocity.png" #not working
Hardcopy Format = png
Hardcopy Tolerance = 0.0001
Image Height = 600
Image Scale = 100
Image Width = 600
JPEG Image Quality = 80
Screen Capture = Off
Use Screen Size = On
White Background = Off
END
>print""")
results1.Exit()
Hey Sunilpatil,
i know it is two years ago, but at the moment i have the same problem to change the the file names. Did you find a solution ?
Fabisch is offline   Reply With Quote

Old   December 4, 2017, 02:00
Default Try this
  #4
New Member
 
Join Date: Jan 2017
Location: Austria
Posts: 20
Rep Power: 9
FluidWarrior is on a distinguished road
Hi,
if you looking for a solution, have a look here:
https://www.researchgate.net/publica...t_and_ParaVIEW

If you have further questions, you are welcome.

Have fun.
FluidWarrior is offline   Reply With Quote

Old   December 4, 2017, 06:19
Default
  #5
New Member
 
Join Date: Nov 2017
Posts: 4
Rep Power: 9
Fabisch is on a distinguished road
Hey FluidWarrior,
thank you for your answer. But unfortunatelly it did not help a lot.
My problem is that i can´t change the name of the exported file during my constructed loop. The loop is working but it always saves the exported files with the same name. But i need to rename the files in every loop.
At the moment i still use the Journal script of workbench. If you have an idea how i can write my own script to get the files exported it will help me a lot.
Thank you for your help
Fabisch is offline   Reply With Quote

Old   December 4, 2017, 12:35
Default
  #6
New Member
 
Join Date: Nov 2017
Posts: 4
Rep Power: 9
Fabisch is on a distinguished road
Thank you for your help so far. In order to find the solution faster, I want to be more specific:

I wrote a Journal to run a sequence of simulations. A part of the journal is to vary the temperature and velocity boundary conditions according to the results of the simulation in the iteration before. I want to save the results of the heat transfer and wall shear stress at a specific boundary for each computed file (see the picture attached). Unfortunately, I don’t know how to change the file name every iteration such that the old data is not overwritten. This is due to the syntax of the commands that starts in line 35.

Do you know how to interrupt the syntax and to include the values for T1, v1 and v2?

Export File = E:/BA/Test/Simulation_files/user_files/Results_T1=443,15_v1=6_v2=0,5.csv

Best regards
Attached Images
File Type: png source_code.PNG (35.4 KB, 46 views)
Fabisch is offline   Reply With Quote

Old   December 7, 2017, 07:24
Default Solution
  #7
New Member
 
Join Date: Nov 2017
Posts: 4
Rep Power: 9
Fabisch is on a distinguished road
Hey everyone,
i have a solution for my own described problem.
The important idea of my the problem is that the command “””EXPORT:…””” is a string. So you can define several substrings and combine them to generate a new name.
Attached you find the improved version of my code.
First, I defined a string called fname_P1 which is the first part of the command to send.
Then, I defined a string called fname_P3 which is the third part of the command to send.
At the beginning of my for-loop i also defined a string with the expression of my variable which i will change. [V1 = str(variable), you can´t see it in the picture below]
Finally I used the command to export the results:

results1.SendCommand(Command=fname_P1 + V1 + fname_P3)

The name of the csv file is E:/BA/Test/Simulation_files/user-files/Results_V1.csv

I hope I can help you, if you have the same problem I had
Best regards.
Attached Images
File Type: png improved_source_code.PNG (43.7 KB, 57 views)
Fabisch is offline   Reply With Quote

Old   January 31, 2018, 07:57
Default
  #8
New Member
 
Roland Blanch
Join Date: Jan 2018
Posts: 2
Rep Power: 0
Polando is on a distinguished road
Thanks Fabisch. Very helpful.
Polando is offline   Reply With Quote

Reply

Tags
workbench scripting


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
ANSYS Workbench on "Uncertified" Linux Distros hsr CFX 289 April 20, 2023 10:23
FLUENT installation on UBUNTU 12.04 (LTS) teymourj FLUENT 2 March 1, 2017 23:24
Macro command combatibility ANSYS workbench Tassos CFX 6 January 13, 2014 05:19
Can't find Ansys workbench in CentOS idil ANSYS 1 October 11, 2012 09:44
Ansys workbench problem Jonny6001 ANSYS 2 September 30, 2010 13:59


All times are GMT -4. The time now is 15:58.