|
[Sponsors] |
June 28, 2015, 04:49 |
tutorial problems
|
#1 |
Senior Member
Mehdi Asghari
Join Date: Feb 2010
Posts: 127
Rep Power: 16 |
Hi All Foamers,
I am going to learn PyFoam programming by doInletVariation.py tutorial file. Pyton program for this file has been presented at following link: https://openfoamwiki.net/index.php/C...ter_Variation; However, I executed it into pyton and encountered some errors such as follows: Code:
OSError: [Errno 2] No such file or directory: 'pitzDaily/InletVariation' Code:
run.start() File "<stdin>", line 1 run.start() ^ IndentationError: unexpected indent Code:
/home/myfoam/OpenFOAM/PyFoam-0.6.4/examples/doInletVariation.py: line 3: $'Example for an automatic variation of an inlet-Parameter. Runs the solver\nand after it has finished runs utilies that postprocess the output.\nCollects some results': command not found from: can't read /var/mail/PyFoam.Execution.ConvergenceRunner from: can't read /var/mail/PyFoam.Execution.UtilityRunner from: can't read /var/mail/PyFoam.LogAnalysis.BoundingLogAnalyzer from: can't read /var/mail/PyFoam.RunDictionary.SolutionFile from: can't read /var/mail/PyFoam.RunDictionary.SolutionDirectory /home/myfoam/OpenFOAM/PyFoam-0.6.4/examples/doInletVariation.py: line 16: syntax error near unexpected token `(' /home/myfoam/OpenFOAM/PyFoam-0.6.4/examples/doInletVariation.py: line 16: `dire=SolutionDirectory(case,archive="InletVariation")' Can anyone help me how to overcome these problems?! M.Asghari Last edited by Asghari_M; July 4, 2015 at 17:09. |
|
July 13, 2015, 06:44 |
|
#2 |
Senior Member
Mehdi Asghari
Join Date: Feb 2010
Posts: 127
Rep Power: 16 |
I present the doInletVariation.py code text for all foamers as follows:
Code:
from PyFoam.Execution.ConvergenceRunner import ConvergenceRunner from PyFoam.Execution.UtilityRunner import UtilityRunner from PyFoam.LogAnalysis.BoundingLogAnalyzer import BoundingLogAnalyzer from PyFoam.RunDictionary.SolutionFile import SolutionFile from PyFoam.RunDictionary.SolutionDirectory import SolutionDirectory solver="simpleFoam" case="pitzDaily" pCmd="calcPressureDifference" mCmd="calcMassFlow" dire=SolutionDirectory(case,archive="InletVariation") dire.clearResults() dire.addBackup("PyFoamSolve.logfile") dire.addBackup("PyFoamSolve.analyzed") dire.addBackup("Pressure.analyzed") dire.addBackup("MassFlow.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*i)/nr print "Inlet velocity:",val sol.replaceBoundary("inlet","(%f 0 0)" %(val)) # Run the solver run=ConvergenceRunner(BoundingLogAnalyzer(),argv=[solver,".",case],silent=True) run.start() print "Last Time = ",dire.getLast() # Get the pressure difference (Using an external utility) pUtil=UtilityRunner(argv=[pCmd,".",case],silent=True,logname="Pressure") pUtil.add("deltaP","Pressure at .* Difference .*\] (.+)") pUtil.start() deltaP=pUtil.get("deltaP")[0] # Get the mass flow mUtil=UtilityRunner(argv=[mCmd,".",case,"-latestTime"],silent=True,logname="MassFlow") mUtil.add("mass","Flux at (.+?) .*\] (.+)",idNr=1) mUtil.start() massFlow=mUtil.get("mass",ID="outlet")[0] # Archive the results dire.lastToArchive("vel=%g" % (val)) # Clear results dire.clearResults() # Output current stuff print "Vel: ",val,"DeltaP: ",deltaP,"Mass Flow:",massFlow f.writeLine( (val,deltaP,massFlow) ) sol.purgeFile() solver="simpleFoam" case="pitzDaily" Isn't anyone to help me to find any remedy? Welcome to any view! |
|
May 11, 2016, 00:10 |
|
#3 |
Member
Manoj
Join Date: Jun 2013
Posts: 38
Rep Power: 13 |
Hi, Did you find any solution to this?
Manoj |
|
May 14, 2016, 14:44 |
|
#4 |
Senior Member
Mehdi Asghari
Join Date: Feb 2010
Posts: 127
Rep Power: 16 |
Hi.
In my opinion, it is a little complex. I preferred to use bash scripting instead of it. To me,it is a little simpler. Finally I couldn't find a definite solution by Pyfoam programming. I required it for an inverse problem. Asghari |
|
Tags |
pyfoam tutorial error |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Tutorial for subcooled nucleate boiling | Asghari | FLUENT | 42 | December 10, 2018 12:42 |
Problem on Fluent Tutorial: Horizontal Film Boilig | Feng | FLUENT | 2 | April 13, 2013 06:34 |
Needed Benchmark Problems for FSI | Mechstud | Main CFD Forum | 4 | July 26, 2011 13:13 |
Problems with channelOodles tutorial | alberto | OpenFOAM Running, Solving & CFD | 0 | June 5, 2007 10:08 |
Rotor/stator tutorial, and how to... | gilberto | CFX | 5 | January 21, 2002 10:41 |