Is python a good choice for this task?
Terry Reedy
tjreedy at udel.edu
Mon Nov 11 17:15:10 EST 2002
"Ron Lau" <ral at spongebob.corporate.com> wrote in message
news:pan.2002.11.11.20.29.19.704887.2239 at spongebob.corporate.com...
> Hi,
>
> This IS NOT a request for someone to write a program for me. (But I
won't
> turn it down :) ). The only programming I ever did was FORTRAN >:P
, and short shell
> scripts. I'm just looking for advice.
>
>
> I have a CFD program that takes a text file as input (Q1.1). I run
it on the
> command line as:
>
> phoe Q1.1
>
> which outputs the binary file PH.1
>
>
> I also have a program that gives me a number as the last line of its
> output to the terminal with the command
>
> pointquerey PH.1 TempK 1 1 1 | tail -1
>
>
> What I do now is compare the output of the line above to the value I
want
> it to be, then change a parameter in the Q1.1 file, say T1=500.0
>
> I would like to write something that would Goal Seek this for me.
> (something simple like a newtonian method)
>
> So I would need a program to..
> --------------------------
>
> run the command "phoe Q1.1"
>
> then run the command "pointquery PH.1 TempK 1 1 1 | tail -1"
>
> read the output of the above and compare to the desired value.
>
> calculate a better value of T1.
>
> replace T1=oldvalue in the file Q1.1 with the calculated value from
> above.
>
> loop back to the beginning...
>
> -------------------------
>
>
> My question is, What language is best suited for this? Perl, Python,
or
> shell scripts?
You can run external programs from Python with os.system('command')
(check docs for details). You can easily read, modify, and write a
file (check out file() and file objects). The goal seeking logic can
be programmed in Python as well as anything else. If the other
programs take any sort of time at all, the interpreted speed of the
Python part will not matter. This type of glue job is one of the
things Python was invented for. Good luck.
Terry J. Reedy
More information about the Python-list
mailing list