|
[Sponsors] |
January 17, 2011, 10:05 |
batch set up for OF 1.7
|
#1 |
Senior Member
Eelco van Vliet
Join Date: Mar 2009
Location: The Netherlands
Posts: 124
Rep Power: 19 |
Dear all
I am trying to use pyFoam to automate my case set up for a series parameter variation. I would like to perform the following: 1: create a basecase OF director with the grid and all the settings, e.g.: run-base 2 Make a pyFoam python script which * read the original base case with SolutionDirectory, * loops over a serie of input parameter, * clones the base case, * modifies a value in on of the fields (e.g. the inlet velocity) * runs the case for a certain time to get a steady state * stops the case, switch on averaging in controlDict * continue case to collect the statistics * go to next case and do the same The problem is that I even don't get the simplest example of PyFoam running. I am using OF 1.7 and pyFoam 0.5.4 with python 2.6 I tried to run the example with the density variation of the dambreak I go to the dambreak directory and now have Code:
import sys,os,subprocess from os import path from PyFoam.Execution.UtilityRunner import UtilityRunner from PyFoam.Execution.BasicRunner import BasicRunner from PyFoam.Infrastructure.ClusterJob import SolverJob from PyFoam.RunDictionary.SolutionDirectory import SolutionDirectory from PyFoam.RunDictionary.ParsedParameterFile import ParsedParameterFile curpath=os.path.abspath('.') #orig=SolutionDirectory(path,archive=None,paraviewLink=False) orig=SolutionDirectory(curpath,archive=None,paraviewLink=False) for density in [10,100]: print "Density: ",density case=orig.cloneCase("damBreakDensity%.0f" % density).name Code:
Density: 10 Traceback (most recent call last): File ".//batchproc.py", line 17, in ? case=orig.cloneCase("damBreakDensity%.0f" % density).name File "/apps/OpenFOAM/local/PyFoam/lib/python2.6/site-packages/PyFoam/RunDictionary/SolutionDirectory.py", line 240, in cloneCase return self.__class__(name,archive=self.archive) File "/apps/OpenFOAM/local/PyFoam/lib/python2.6/site-packages/PyFoam/RunDictionary/SolutionDirectory.py", line 69, in __init__ symlink(path.basename(self.controlDict()),self.controlDict()+".foam") OSError: [Errno 2] No such file or directory also I don't see exactly how this SolutionDirectory works. Does anybody have a working example for me for OF 1.7 use with PyFoam ? Any hints appreciated Regards Eelco |
|
January 17, 2011, 11:51 |
|
#2 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
Bernhard PS: Have you had a look at the two presentations that are available for PyFoam ("Happy foaming with Python" and "Automatization with pyFoam") |
||
January 18, 2011, 04:43 |
pyfoam batching example for qsub system
|
#3 |
Senior Member
Eelco van Vliet
Join Date: Mar 2009
Location: The Netherlands
Posts: 124
Rep Power: 19 |
Hi Bernard,
Thanks for you explanation. I have done some trail and error yesterday (also based on the documents you are referring to). I found indeed that the working directory is considered to be an OpenFOAM case. It is not really what I want, because I want a script in the project directory which reads an OpenFOAM case below it which is the base-case (with the default setting and the grid), clones it into a new one, also below the current directory. I have resolved most problems and it is working now as I want it. For those interested in an extra pyfoam example I have added the python script as an attachment. The script clones a basecase, modifies funkySetFieldsDict based on a varying parameter, decomposes the case and runs it. In order to run the case in a batch queing system working with qsub I make a system call with the appropriate settings to a perlscript which generates the qsub asci file with is piped to qsub. In this way each case can be submitted. I have looked at the example in the Happy Foaming manual, but I could not get this way of submitting running the OF case from the python scripts working. My approach with job.pl works as well, but is a bit less elegant. Regards, Eelco |
|
January 19, 2011, 09:38 |
|
#4 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
- the queuing manager has got to accept python as a valid interpreter for cluster-scipts - PyFoam has to be in the PYTHONPATH The second requirement can be worked around (if you can't/don't want to install PyFoam on the cluster). BEFORE importing any PyFoam-stuff do import sys sys.path.append("/path/to/the/pyfoam/installation/that/is/reachable/from/the/cluster") and it should find the PyFoam-stuff (the SolverJob-class still won't work on other queuing systems that SGE currently, but I accept patches) Bernhard |
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Level set method---reinitiallization and boundary conditions | wenxu | OpenFOAM Running, Solving & CFD | 2 | February 28, 2018 12:43 |
[mesh manipulation] mirrorMesh and undoing the joining of patches | chegdan | OpenFOAM Meshing & Mesh Conversion | 3 | October 21, 2015 09:09 |
OF 1.6 | Ubuntu 9.10 (64bit) | GLIBCXX_3.4.11 not found | piprus | OpenFOAM Installation | 22 | February 25, 2010 14:43 |
Problems with installation of OpenFoam | sheyer | OpenFOAM Installation | 8 | July 28, 2008 04:45 |
Problems with installation | jonititan | OpenFOAM Installation | 4 | November 6, 2005 05:16 |