해당 스크립트를 아바쿠스에서 run script로 실행
아바쿠스에서 실행하면 환경변수 문제가 발생해서 job-submit과정에서 에러가 발생한다.
따로 아바쿠스 인터프리터를 가져와서 해당 스크립트를 실행하는 방식으로 변경하였다.
# -*- coding: utf-8 -*-
import Tkinter as tk
import tkFileDialog as filedialog
def select_file():
root = tk.Tk()
root.withdraw()
file_path = filedialog.askopenfilename(
filetypes=[("Abaqus ODB files", "*.odb")]
)
print("Selected file:", file_path)
return file_path
file_name = str(select_file())
odb = openOdb(path=file_name)
r =session.openOdb(name=file_name)
all_txt = 'Eigenvalues:\n\n'
for step_name, step in odb.steps.items():
print("Step name:", step_name)
Frames = r.steps[step_name].frames
f = len(Frames)
all_txt += "Step name:"+step_name+'\n'
results_text = 'Eigenvalues:\n'
for i in range (1,f):
EigenV = Frames[i].description
list = EigenV.split()
Load = float(list[-1])
results_text += 'Mode {0}: {1}\n'.format(i, Load)
all_txt= all_txt+results_text+'\n'
result_name = file_name[:-4]+'Eigen_Value.txt'
with open(result_name, 'w') as file:
file.write(all_txt)
해당 코드는 python2용이라서 python3에서는 안돌아갈수도 있다.
아바쿠스에서만 사용하자.
# -*- coding: utf-8 -*-
import Tkinter as tk
import tkFileDialog as filedialog
file_name = str(select_file())
results_text += 'Mode {0}: {1}\n'.format(i, Load)
특히 이부분들은 python2용으로 작성됬다.
다음 스크립트로 위에 스크립트를 실행하는 방식
import subprocess
# 스크립트 파일 이름
script_name = 'abaqus_save_eigen_value.py'
# 현재 디렉토리에서 Abaqus Python 인터프리터를 사용하여 스크립트 실행
subprocess.run(['abaqus', 'python', script_name], shell=True)