[英]How do I run AVL (a binary) from a python script using the subprocess module?
I'm trying to script a series of runs in AVL (Athena Vortex Lattice) , a vortex lattice code for designing wings and other lifting surfaces. 我正在试图在AVL(Athena Vortex Lattice)中编写一系列运行,这是一种用于设计机翼和其他升力表面的涡旋格子代码。
I have the binary stored in ~/bin/. 我把二进制文件存储在〜/ bin /中。 Typically you run AVL within a terminal, and enter commands. 通常,您在终端中运行AVL,然后输入命令。 Typical commands would be: 典型的命令是:
Which, loads a .avl input file, enter the operations menu, sets the angle of attack to 5 degrees, executes the computation, Prints out the forces to an output file, exits the operations menu, and quits the program. 其中,加载.avl输入文件,进入操作菜单,将攻角设置为5度,执行计算,将力打印到输出文件,退出操作菜单,退出程序。
I'm trying to run AVL from a python script using the subprocess module using the following code: 我正在尝试使用以下代码使用子进程模块从python脚本运行AVL:
import subprocess as sp
avl = sp.Popen(['~/bin/avl3.35'],
stdin=sp.PIPE,stdout=None,
stderr=None,
universal_newlines=True)
avl.communicate('LOAD ~/file/avlexamplefile.avl')
This almost works. 这几乎可行。 AVL loads, the first command is executed, but then I get the following error, and won't take any further commands. AVL加载,第一个命令被执行,但后来我得到以下错误,并且不会接受任何进一步的命令。
AVL c> forrtl: severe (24): end-of-file during read, unit -4, file stdin
Image PC Routine Line Source
avl3.35 000000010A00F43B Unknown Unknown Unknown
avl3.35 000000010A00DBFE Unknown Unknown Unknown
avl3.35 0000000109FD5177 Unknown Unknown Unknown
avl3.35 0000000109F8B426 Unknown Unknown Unknown
avl3.35 0000000109F8AA39 Unknown Unknown Unknown
avl3.35 0000000109FB61F3 Unknown Unknown Unknown
avl3.35 0000000109EEECF3 Unknown Unknown Unknown
avl3.35 0000000109E7130F Unknown Unknown Unknown
avl3.35 0000000109E6FC7C Unknown Unknown Unknown
libdyld.dylib 00007FFF8B1D95AD Unknown Unknown Unknown
Can anyone point out what I'm doing wrong? 谁能指出我做错了什么? Eventually, I'd like to place the above inside a for loop for running through multiple variations. 最后,我想将上面的内容置于for循环中以运行多个变体。
Try using avl.stdin.write("your cmd here" +'\\n')
. 尝试使用avl.stdin.write("your cmd here" +'\\n')
。
Working example using xfoil is here (not mine): 使用xfoil的工作示例在这里(不是我的):
https://github.com/Launchpad-McQ/Aileron-design/blob/master/design-aileron.py https://github.com/Launchpad-McQ/Aileron-design/blob/master/design-aileron.py
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.