POST_SUB
ModelingMotionSolveの結果を抽出するために使用します。
使用
出力ファイルの生成や、プログラムによる結果の処理(リアルタイムアニメーションやプロットなど)に使用します。
<Post_UserAPI
usrsub_param_string = "USER()"
usrsub_dll_name = "ms_csubdll"
usrsub_fnc_name = "POST_SUB"
/>
フォーマット
- Fortranの呼出し構文
-
SUBROUTINE POST_SUB (TIME, IFLAG, INTERPOLATION_FLAG)
- C/C++の呼出し構文
-
void STDCALL POST_SUB (double *time, double *par, int *npar, int *iflag, int *endflag, int *errflg)
- Pythonの呼出し構文
-
def POST_SUB(time, par, npar, iflag, endflag): return errflg
- MATLABの呼出し構文
-
function errflg = POST_SUB(time, par, npar, iflag, endflag)
属性
- TIME
- [倍精度]
- IFLAG
- [論理]
- INTERPOLATION_FLAG
- [論理]
例
次の例は、モデル内の各剛体のX、Y、Z、およびオイラーパラメータを時間ステップごとに結果XMLファイルに書き込みます:
<Post_UserAPI
usrsub_param_string = "USER()"
interpreter = "Python"
script_name = "/post_sub.py"
usrsub_fnc_name = "POST_SUB"
/>
post_sub.pyの内容は次のとおりです:
NULL = 0
fout = NULL
nparts = 0
partids = []
def POST_SUB(time, par, npar, iflag, endflag):
global NULL
global fout
global nparts
if endflag!=0:
# Wrap up
if fout!=NULL:
fout.write("</MultiBodyResults>\n")
fout.close()
del fout
fout = NULL
if partids!=[]:
del partids
partids = []
return 0
if iflag!=0:
outfile = py_gtonam()
outfile += "_res.xml"
fout = open(outfile,"w")
# XML Header
fout.write("<?xml version=\"1.0\"?>\n")
fout.write("<MultiBodyResults>\n")
# Get ID information
nparts = py_getnumid("PART")
if nparts!=0:
[partids, err_flg] = py_getidlist("PART",nparts)
if err_flg <0:
return err_flg
else:
if fout==NULL:
print "Output file was not opened, no results will be written\n"
return -1
fout.write("\t<Results\n")
fout.write("\t\ttime = \"%f\">\n"% time)
# Rigid Body
for i in range(nparts):
[grndflag, info] = py_modfnc("Body_Rigid", partids[i],"IsGround")
if grndflag=="FALSE":
states = py_get_post_states("PART", partids[i])
fout.write("\t\t<RigidBody\n")
fout.write("\t\t\tid = \"%d\"\n"% partids[i])
fout.write("\t\t\tx = \"%-11.8G\"\n"% states[0])
fout.write("\t\t\ty = \"%-11.8G\"\n"% states[1])
fout.write("\t\t\tz = \"%-11.8G\"\n"% states[2])
fout.write("\t\t\te0 = \"%-11.8G\"\n"% states[3])
fout.write("\t\t\te1 = \"%-11.8G\"\n"% states[4])
fout.write("\t\t\te2 = \"%-11.8G\"\n"% states[5])
fout.write("\t\t\te3 = \"%-11.8G\"\n"% states[6])
fout.write("\t\t/>\n")
return 0
コメント
- Post_Subは、シミュレーション中にデータがMRFファイルに書き込まれるのと同じ時間ステップで、MotionSolveから呼び出されます。
Post_Sub内から、MODFNCなどの他の使用可能なユーティリティサブルーチンを呼び出すこともできます。