|
[Sponsors] |
May 21, 2015, 22:05 |
Ansys workbench scripting
|
#1 |
Senior Member
sunil
Join Date: Jul 2012
Location: Bangalore
Posts: 179
Rep Power: 14 |
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() |
|
May 23, 2015, 09:17 |
|
#2 |
Senior Member
Matthias Voß
Join Date: Mar 2009
Location: Berlin, Germany
Posts: 449
Rep Power: 20 |
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.
|
|
November 30, 2017, 09:50 |
|
#3 | |
New Member
Join Date: Nov 2017
Posts: 4
Rep Power: 8 |
Quote:
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 ? |
||
December 4, 2017, 01:00 |
Try this
|
#4 |
New Member
Join Date: Jan 2017
Location: Austria
Posts: 20
Rep Power: 9 |
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. |
|
December 4, 2017, 05:19 |
|
#5 |
New Member
Join Date: Nov 2017
Posts: 4
Rep Power: 8 |
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 |
|
December 4, 2017, 11:35 |
|
#6 |
New Member
Join Date: Nov 2017
Posts: 4
Rep Power: 8 |
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 |
|
December 7, 2017, 06:24 |
Solution
|
#7 |
New Member
Join Date: Nov 2017
Posts: 4
Rep Power: 8 |
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. |
|
January 31, 2018, 06:57 |
|
#8 |
New Member
Roland Blanch
Join Date: Jan 2018
Posts: 2
Rep Power: 0 |
Thanks Fabisch. Very helpful.
|
|
Tags |
workbench scripting |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
ANSYS Workbench on "Uncertified" Linux Distros | hsr | CFX | 289 | April 20, 2023 09:23 |
FLUENT installation on UBUNTU 12.04 (LTS) | teymourj | FLUENT | 2 | March 1, 2017 22:24 |
Macro command combatibility ANSYS workbench | Tassos | CFX | 6 | January 13, 2014 04:19 |
Can't find Ansys workbench in CentOS | idil | ANSYS | 1 | October 11, 2012 08:44 |
Ansys workbench problem | Jonny6001 | ANSYS | 2 | September 30, 2010 12:59 |