CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Community Contributions

[PyFoam] Automatic Parameter variation using pyFoam

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 27, 2015, 20:28
Default Automatic Parameter variation using pyFoam
  #1
New Member
 
Join Date: May 2015
Posts: 29
Rep Power: 11
avd28 is on a distinguished road
Hi all,

I've been trying to run a series of test cases on the cavity and pitzDaily tutorials and want to see solution behaviour under 4 different parameters. They are, inlet velocity,minimum mesh side length, timestep, and the inlet Courant number.

It occurred to me that pyFoam would be perfect for this, and thus installed and spent some time getting familiar with it.
I understood that I would need to adapt the parameter code variation given on the wiki page

https://openfoamwiki.net/index.php/C...5_-_2015-06-23

Accordingly I wrote the following script

Code:
from PyFoam.Applications.PlotRunner import PlotRunner
from PyFoam.Execution.UtilityRunner import UtilityRunner
from PyFoam.LogAnalysis.FoamLogAnalyzer import FoamLogAnalyzer
from PyFoam.RunDictionary.SolutionFile import SolutionFile
from PyFoam.RunDictionary.SolutionDirectory import SolutionDirectory

solver = "icoFoam"
case = "cavity"

dire=SolutionDirectory(case,archive="U")
dire.clearResults()
dire.addBackup("PyFoamSolve.logfile")
dire.addBackup("PyFoamSolve.analyzed")

sol=SolutionFile(dire.initialDir(),"U")
 
maximum=1.
nr=10

f=dire.makeFile("InflowVariationResults")

for i in range(nr+1):
    # Set the boundary condition at the inlet
    val=(maximum*pow(10,-nr))
    print "Inlet velocity:",val
    sol.replaceBoundary("inlet","(%f 0 0)" %(val))

run= PlotRunner(FoamLogAnalyzer(),argv=[solver,".",case],silent=True)
run.start()

print "Last Time = ",dire.getLast()

dire.lastToArchive("vel=%g" % (val))
which resulted in the following error when I ran it

Code:
Traceback (most recent call last):
  File "icoFoam_U.py", line 28, in <module>
    run= PlotRunner(FoamLogAnalyzer(),argv=[solver,".",case],silent=True)
  File "/usr/lib/python2.7/site-packages/PyFoam-0.6.5-py2.7.egg/PyFoam/Applications/PlotRunner.py", line 60, in __init__
    **kwargs)
  File "/usr/lib/python2.7/site-packages/PyFoam-0.6.5-py2.7.egg/PyFoam/Applications/PyFoamApplication.py", line 136, in __init__
    interspersed=interspersed)
  File "/usr/lib/python2.7/site-packages/PyFoam-0.6.5-py2.7.egg/PyFoam/Basics/FoamOptionParser.py", line 72, in __init__
    self.argLine=[str(a) for a in args]
TypeError: 'FoamLogAnalyzer' object is not iterable
I had originally tried with BoundingLogAnalyser as is given in the tutorial, but it threw up an identical error, complaining that the object was not iterable.
I'd really appreciate some help understanding this.

P.S I know there is a pyFoam utility, pyFoamRunParameterVariation, which would help vastly in this case but I'm still unsure about the format of its input file. Any help with that would also be appreciated
avd28 is offline   Reply With Quote

Reply

Tags
parameter variation, pyfoam


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
[PyFoam] running pyFoam(Plot)Runner.py in parallel Studi OpenFOAM Community Contributions 10 September 6, 2015 17:38
meshing of a compound volume in GMSH shawn3531 OpenFOAM 4 March 12, 2015 11:45
Force can not converge colopolo CFX 13 October 4, 2011 23:03
[PyFoam] Parameter Variation with Contrib PyFoam tian OpenFOAM Community Contributions 1 May 5, 2011 08:01
Transient Parameter Variation Milanowski FLUENT 3 April 22, 2010 13:37


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