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

Scripting in Solver Manager

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 20, 2015, 10:13
Post Scripting in Solver Manager
  #1
Member
 
Join Date: Oct 2014
Posts: 44
Rep Power: 12
kar.coep is on a distinguished road
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
kar.coep is offline   Reply With Quote

Old   May 20, 2015, 15:12
Default
  #2
Senior Member
 
Matthias Voß
Join Date: Mar 2009
Location: Berlin, Germany
Posts: 449
Rep Power: 20
mvoss is on a distinguished road
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.
mvoss is offline   Reply With Quote

Old   May 20, 2015, 15:34
Post
  #3
Member
 
Join Date: Oct 2014
Posts: 44
Rep Power: 12
kar.coep is on a distinguished road
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?
kar.coep is offline   Reply With Quote

Old   May 20, 2015, 15:59
Default
  #4
Senior Member
 
Matthias Voß
Join Date: Mar 2009
Location: Berlin, Germany
Posts: 449
Rep Power: 20
mvoss is on a distinguished road
The file is stored in the run-directory of the solver and is a "how-ever" formatted plain text-file.
mvoss is offline   Reply With Quote

Old   May 20, 2015, 21:46
Default
  #5
Senior Member
 
Join Date: Jun 2009
Posts: 1,880
Rep Power: 33
Opaque will become famous soon enough
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.
Opaque is offline   Reply With Quote

Old   May 21, 2015, 01:36
Post
  #6
Member
 
Join Date: Oct 2014
Posts: 44
Rep Power: 12
kar.coep is on a distinguished road
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.
kar.coep is offline   Reply With Quote

Old   May 21, 2015, 11:59
Default
  #7
Senior Member
 
Join Date: Jun 2009
Posts: 1,880
Rep Power: 33
Opaque will become famous soon enough
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.
Opaque is offline   Reply With Quote

Old   May 21, 2015, 12:33
Post
  #8
Member
 
Join Date: Oct 2014
Posts: 44
Rep Power: 12
kar.coep is on a distinguished road
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?
kar.coep is offline   Reply With Quote

Old   May 27, 2015, 10:56
Post
  #9
Member
 
Join Date: Oct 2014
Posts: 44
Rep Power: 12
kar.coep is on a distinguished road
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)
before starting the solution update, I am trying to set an excel cell value to start, saying that the mon file reading code should start when this cell is changed.

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
but whenever the cell value is changed, excel and ansys goes 'not responding' mode. Even though i am changing excel cell value from python file, shouldn't it go on with updating the solution component even if excel goes in infinite loop?

Please help.
kar.coep is offline   Reply With Quote

Old   May 28, 2015, 05:49
Default
  #10
Senior Member
 
Matthias Voß
Join Date: Mar 2009
Location: Berlin, Germany
Posts: 449
Rep Power: 20
mvoss is on a distinguished road
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.
mvoss is offline   Reply With Quote

Reply

Tags
ccl, cfx, solver manager


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
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


All times are GMT -4. The time now is 14:45.