#######################################################################################
## Run Parametric Studies in PyCharm
#######################################################################################
import numpy as np
import subprocess
from os import path
from numpy import floor
import os
curr_dir = os.getcwd()
if not os.path.exists(curr_dir + '\\FEModelFiles'):
os.mkdir(curr_dir + '\\FEModelFiles')
TR = np.array([0.8, 1.0, 1.2])
WR = np.array([1.0, 1.5, 2.0, 2.5])
for i in range(len(TR)):
for j in range(len(WR)):
DirName = 'ThicknessRatio_' + str(TR[i]) + '_WidthRatio_' + str(WR[j])
if path.exists(curr_dir + '\\FEModelFiles\\' + DirName) == True:
print(curr_dir + '\\FEModelFiles\\' + DirName + "already exists!")
elif path.exists(curr_dir + '\\FEModelFiles\\' + DirName) == False:
f = open("Parameters_for_MetaBeam.py", "w")
f.write("ThickRatio = " + str(TR[i]) + '\n')
f.write("WidthRatio = " + str(WR[j]) + '\n')
f.close()
print(curr_dir + '\\FEModelFiles\\' + DirName + 'is running!!')
try:
subprocess.call([r'runPython.bat'])
except:
print("unexpected error!!!!!")
#######################################################################################
## Add the following code to Abaqus python script
#######################################################################################
DirName = 'ThicknessRatio_' + str(ThickRatio) + '_WidthRatio_' + str(WidthRatio)
curr_dir = os.getcwd()
if not os.path.exists(curr_dir + '\\FEModelFiles\\' + DirName):
os.mkdir(curr_dir + '\\FEModelFiles\\' + DirName)
os.chdir(curr_dir + '\\FEModelFiles\\' + DirName)