Hi there guys
I am an engineering student using python to try and optimize an Abaqus FEA simulation and am having problems using the cobyla, basically I havn't a clue. I was wondering could someone illustrate the many problems with the script below?
Cheers
Dan
import numpy
import os
import scipy.optimize.cobyla
import string
def minimise_mass(mass):
os.system("abq661 cae script=bottlesim2ndstep.py") # Function
myfile=open('totalbottle', 'r')
totalbottle = myfile.readline()
print "Total Bottle",totalbottle,"g"
#myfile=open('topload', 'r')
#topload = myfile.readline()
#print "Topload", topload
myfile=open('mainbody', 'r')
mainbody = myfile.readline()
print "Mainbody",mainbody,"mm"
myfile=open('lid', 'r')
lid = myfile.readline()
print "Lid",lid,"mm"
return totalbottle
def constraint_topload(thickness):
myfile=open('topload', 'r')
topload = myfile.readline()
print "Topload",topload,"N"
return topload-200 # constraint saying topload >=200
def constraint_thickness(thickness):
return thickness-2 # constraint saying thickness >=2
thickness=5 # initial guess for thickness
x_opt=scipy.optimize.fmin_cobyla(minimise_mass, thickness, [constraint_topload,
constraint_thickness], consargs=None, rhobeg=1.0, rhoend=1e-10, iprint=1,
maxfun=1000000)
print "optimised thickness", x_opt
#print x
#print y