|
[Sponsors] |
May 20, 2015, 10:13 |
Scripting in Solver Manager
|
#1 |
Member
Join Date: Oct 2014
Posts: 44
Rep Power: 12 |
Hello,
my first question is if Workbench records Solver manager commands (if solver manager is linked with CFX Case file in workbench project)? I need to figure out how to export user point for each iteration in csv format while solution is running. Since Solver Manager cannot be scripted, can we export these monitor points with any python commands? I need to achieve this through a .py file that is executing in workbench environment. I am really new to this. So any help would be appreciated. Thanks |
|
May 20, 2015, 15:12 |
|
#2 |
Senior Member
Matthias Voß
Join Date: Mar 2009
Location: Berlin, Germany
Posts: 449
Rep Power: 20 |
No. It doesnt.... actually wb only remembers stuff on the wb-schematic.
Try looking for the "send"-command ... this is how you can talk from the wb-schematic to underlying code (DM, ICEM, CFX). You can definitely pull out the Monitor Points via cfx5mondata .... and since everthing is stored in the mon-file DURING solution you can regexp this file on-the-fly for sure... but i have no idea about the underlying syntax within the mon-file.I would guess with some arm grease you can crawl through the mon-file via. the *.py-script IF you know how to pick out the correct numbers. |
|
May 20, 2015, 15:34 |
|
#3 |
Member
Join Date: Oct 2014
Posts: 44
Rep Power: 12 |
Thanks for the info. It would be really helpful to get me started on right path.
Do you know where this monitor file is stored and in what format it would be? |
|
May 20, 2015, 15:59 |
|
#4 |
Senior Member
Matthias Voß
Join Date: Mar 2009
Location: Berlin, Germany
Posts: 449
Rep Power: 20 |
The file is stored in the run-directory of the solver and is a "how-ever" formatted plain text-file.
|
|
May 20, 2015, 21:46 |
|
#5 |
Senior Member
Join Date: Jun 2009
Posts: 1,880
Rep Power: 33 |
You do not describe if you want to do such export inline (while the simulation is proceeding), or offline (once the simulation has finished), neither what is your objective.
Sometimes a high level description of what your final goal is may allow others to contribute their experiences instead of answering a very specific low level detail, and not taking advantage of perhaps already existing solutions. For example, there is command to read data from the monitor file. Nothing dark, or reinventing the wheel. cfx5mondata -res <file> | -dir <directory> | -mon <file> [-showvars] [-nocoeffloops] [-lastvalueonly] [-varlist <variables>] [-varrule <rule>] [-out <file>] [-help] [-v] you can use cfx5mondata -help for the syntax details. |
|
May 21, 2015, 01:36 |
|
#6 |
Member
Join Date: Oct 2014
Posts: 44
Rep Power: 12 |
Hi Opaque,
Thanks for the info!!! I want to get the monitor data while the run is going on and simultaneously plot it in excel. Provide 1 command button in excel spreadsheet to allow user to stop the run at any point of time (if he wants to) and 1 command button to rerun solution for specified number of iterations after run has completed(in case user thinks that the solution is not converged looking at the graph). if CFX5mondata used to get values in real time (while the run is going on)? I tried to start this command from cmd.exe in windows 8. But no luck. I found an option under setup>output control>backup which gives liberty to store data points at some interval of iterations. But not sure how to use it.. Any Advice please Last edited by kar.coep; May 21, 2015 at 09:54. |
|
May 21, 2015, 11:59 |
|
#7 |
Senior Member
Join Date: Jun 2009
Posts: 1,880
Rep Power: 33 |
You are trying to wrap ANSYS CFX under another user interface to manage the runs.
I wonder what is missing in the customization tools from ANSYS to achieve your end goal. You will be repeating a lot of the effort you already paid for, and later add some value to it. cfx5mondata is a one shot command, you may need to execute it for every iteration to get up to date information. If you want to execute the command outside the ANSYS CFX environment, I guess you must use the full path for the command, and perhaps some environment variables. |
|
May 21, 2015, 12:33 |
|
#8 |
Member
Join Date: Oct 2014
Posts: 44
Rep Power: 12 |
Can you please more elaborate on using full path of command?
I am really new to this and it would be really difficult for me to start with this coding. Can please explain the flow how and from where this command should be executed? Would it be directly from cmd.exe in windows 8? If yes then what code to run? |
|
May 27, 2015, 10:56 |
|
#9 |
Member
Join Date: Oct 2014
Posts: 44
Rep Power: 12 |
Hi mvoss and opaque,
I started with the coding. this is what i have in python file which starts and updates setup and other modules. Code:
solution1.SetExecutionControl(CCL=cfxcmd) component1 = system1.GetComponent(Name="Solution") solutionSettings1 = solution1.GetSolutionSettings() solutionSettings1.UpdateOption = "Foreground" worksheetcon.range["J5"].value = "start" component1.Update(Force=True) this is my excel vba code. Code:
Private Sub Worksheet_Change(ByVal Target As Range) If Target.Row = 5 And Target.Column = 10 Then If Target.Value = "start" Then path = Sheets("Input").Cells(4, 6).Value + "\" + Sheets("Input").Cells(5, 3).Value + "_files\dp0\CFX\CFX\Fluid Flow_Case CFX_001.dir" Application.Wait (Now + TimeValue("0:00:10")) Do While (Dir(path, vbDirectory) = vbNullString) ' do nothing Loop If Not Dir(path, vbDirectory) = vbNullString Then If Dir(path + "\mon") Then timewalafunc End If End If End If End Sub Code:
Sub timewalafunc() timetorun = Now + TimeValue("00:00:01") Application.OnTime timetorun, "doitagain" End Sub Code:
Sub doitagain() Dim path, fromcopy, tocopy, filepath As String MsgBox ("Reached Here") 'Path = Sheets("Input").Cells(4, 6).Value + "\" + Sheets("Input").Cells(5, 3).Value + "_files\dp0\CFX\CFX\Fluid Flow_Case CFX_001.dir" fromcopy = path + "\mon" tocopy = path + "\mon.csv" FileCopy fromcopy, tocopy filepath = path + "\mon.csv" Set wtarget = Workbooks.Open(filepath) Dim i, j, k, m, lastcol As Integer i = 1 Do While wtarget.Worksheets("mon").Cells(i, 1).Value <> 1 i = i + 1 Loop j = i Do While wtarget.Worksheets("mon").Cells(j, 1).Value <> "" j = j + 1 Loop j = j - 1 m = 0 For k = i To j Sheets("Convergence_Plot").Cells(6 + m, 1).Value = wtarget.Cells(k, 1).Value Next lastcol = 1 Do While wtarget.Cells(i, lastcol).Value <> "" lastcol = lastcol + 1 Loop lastcol = lastcol - 1 m = 0 For k = i To j Sheets("Convergence_Plot").Cells(6 + m, 4).Value = wtarget.Cells(k, lastcol).Value Next m = 0 For k = i To j Sheets("Convergence_Plot").Cells(6 + m, 3).Value = wtarget.Cells(k, lastcol - 1).Value Next m = 0 For k = i To j Sheets("Convergence_Plot").Cells(6 + m, 2).Value = wtarget.Cells(k, lastcol - 2).Value Next Workbooks("mon.csv").Close savechanges = False i = 6 Do While Worksheets("Convergence Plot").Cells(i, 1).Value <> "" i = i + 1 Loop i = i - 1 ActiveSheet.ChartObjects("Chart 1").Activate ActiveChart.PlotArea.Select ActiveChart.FullSeriesCollection(1).Values = "=Convergence_Plot!$B$6:$B$" & i ActiveChart.FullSeriesCollection(2).Values = "=Convergence_Plot!$C$6:$C$" & i ActiveChart.FullSeriesCollection(3).Values = "=Convergence_Plot!$D$6:$D$" & i End Sub Please help. |
|
May 28, 2015, 05:49 |
|
#10 |
Senior Member
Matthias Voß
Join Date: Mar 2009
Location: Berlin, Germany
Posts: 449
Rep Power: 20 |
Sorry but this is basically a coding/programming question and we cannot debug your code remotely. If both programs freeze one the "doitagain" then this is where the error raises up. Are the graphs shown properly when reading in the mon.csv? Try to throw a print line or an errorbox or whatever after every line of code and work through the whole script to pinpoint the line causing the freeze.
|
|
Tags |
ccl, cfx, solver manager |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Creating New Solver: For particle-laden compressible jets | sankarv | OpenFOAM Running, Solving & CFD | 17 | December 3, 2014 20:41 |
Quarter Burner mesh with periosic condition | SamCanuck | FLUENT | 2 | August 31, 2011 12:34 |
Working directory via command line | Luiz | CFX | 4 | March 6, 2011 21:02 |
Creating New Solver: For particle-laden compressible jets | sankarv | OpenFOAM | 0 | April 4, 2010 19:06 |
why the solver reject it? Anyone with experience? | bearcat | CFX | 6 | April 28, 2008 15:08 |