@@ -623,7 +623,7 @@ def makeEqual_TaTm(mudloads):
623623 else :
624624 mudloads ['method' ] = mudloads ['method' ]
625625
626- return ( self . loads )
626+ return mudloads
627627
628628 def getFS (self , loads = None , acceptance_crit = None ):
629629 '''
@@ -840,7 +840,12 @@ def getSize(self, geom, geomKeys, geomBounds=None, loads=None, minfs={'Ha':1.6,'
840840 # - - - - Objective and Constraint Functions
841841
842842 # Define the objective function: Minimize weight of anchor (cost is dependent on weight)
843- def objective (vars ,geomKeys , input_loads , fix_zlug ):
843+ def objective (vars , args ):
844+
845+ geomKeys = args ['geomKeys' ]
846+ input_loads = args ['input_loads' ]
847+ fix_zlug = args ['fix_zlug' ]
848+
844849 newGeom = dict (zip (geomKeys ,vars ))
845850 self .dd ['design' ].update (newGeom )
846851 if 'suction' in self .dd ['type' ] and not fix_zlug :
@@ -851,8 +856,12 @@ def objective(vars,geomKeys, input_loads, fix_zlug):
851856 return (results ['Weight' ])
852857
853858 # constraint for suction bucket sizing only. May add more constraints for other anchors in the future...
854- def conFun_LD (vars ,LD_con ,geomKeys ):
855- newGeom = dict (zip (geomKeys ,vars ))
859+ def conFun_LD (vars , geomKeys , input_loads , fix_zlug , LD_con , geomBounds , minfs ):
860+ newGeom = dict (zip (geomKeys , vars ))
861+ self .dd ['design' ].update (newGeom )
862+
863+ results = self .getAnchorCapacity (loads = input_loads , plot = False )
864+
856865 convalA = newGeom ['L' ]/ newGeom ['D' ] - LD_con [0 ]
857866 convalB = LD_con [1 ] - newGeom ['L' ]/ newGeom ['D' ]
858867 conval = min ([convalA ,convalB ])
@@ -863,13 +872,22 @@ def conFun_LD(vars,LD_con,geomKeys):
863872
864873 return (conval )
865874 # constraint to ensure unity check > 1 for suction buckets
866- def conFun_Suction (vars ,input_loads ):
867- results = self .getAnchorCapacity (loads = input_loads ,plot = False )
868- conval = results ['UC' ] - 1
875+ def conFun_Suction (vars , geomKeys , input_loads , fix_zlug , LD_con , geomBounds , minfs ):
876+ results = self .getAnchorCapacity (loads = input_loads , plot = False )
877+ #conval = results['UC'] - 1
878+ conval = 1 - results ['UC' ]
869879 # convalB = 1 - results['UC']
870880 return (conval )
881+
882+ def conFun_DandG (vars , geomKeys , input_loads , fix_zlug , LD_con , geomBounds , minfs ):
883+
884+ newGeom = dict (zip (geomKeys , vars ))
885+ self .dd ['design' ].update (newGeom )
886+ results = self .getAnchorCapacity (loads = input_loads , plot = False )
887+
888+ return np .array ([0.05 * newGeom ['D' ] - results ['Lateral displacement' ] , 0.25 - results ['Rotational displacement' ]])
871889
872- def conFunH (vars ,input_loads ):
890+ def conFunH (vars , geomKeys , input_loads , fix_zlug , LD_con , geomBounds , minfs ):
873891 # if 'suction' in self.dd['type']:
874892 # results = self.getAnchorCapacity(plot=False)
875893 # conval = results['UC'] - 1
@@ -885,8 +903,8 @@ def conFunH(vars,input_loads):
885903 # conval = -1*(1-val/minfs[key])
886904 return (conval )
887905
888- def conFunV (vars ,minfs , input_loads ):
889- FS = self .getFS (input_loads )
906+ def conFunV (vars , geomKeys , input_loads , fix_zlug , LD_con , geomBounds , minfs ):
907+ FS = self .getFS (loads = input_loads )
890908 # special case for DEAs
891909 if minfs ['Va' ] == 0 :
892910 conval = 1
@@ -896,6 +914,20 @@ def conFunV(vars,minfs,input_loads):
896914 # print('FS_V',FS['Va'])
897915 return (conval )
898916
917+ def conBounds (vars , geomKeys , input_loads , fix_zlug , LD_con , geomBounds , minfs ):
918+
919+ newGeom = dict (zip (geomKeys , vars ))
920+ self .dd ['design' ].update (newGeom )
921+
922+ results = self .getAnchorCapacity (loads = input_loads , plot = False )
923+
924+ bound_L_lower = newGeom ['L' ] - geomBounds [0 ][0 ]
925+ bound_L_upper = geomBounds [0 ][1 ] - newGeom ['L' ]
926+ bound_D_lower = newGeom ['D' ] - geomBounds [1 ][0 ]
927+ bound_D_upper = geomBounds [1 ][1 ] - newGeom ['D' ]
928+
929+ return np .array ([bound_L_lower , bound_L_upper , bound_D_lower , bound_D_upper ])
930+
899931 # - - - - - Setup & Optimization
900932 from scipy .optimize import minimize
901933 from copy import deepcopy
@@ -940,14 +972,20 @@ def conFunV(vars,minfs,input_loads):
940972 if 'suction' in anchType :
941973 # bounds = [(1, 7), (5, 50),()] # Bounds for D and L
942974 # constraints
943- constraints = [{'type' :'ineq' ,'fun' :conFun_LD ,'args' :(LD_con ,geomKeys )},
944- {'type' :'ineq' ,'fun' :conFun_Suction ,'args' :(input_loads ,)},
945- {'type' :'ineq' ,'fun' :conFunH ,'args' :(input_loads ,)},
946- {'type' :'ineq' ,'fun' :conFunV ,'args' :(minfs ,input_loads )}]
975+
976+ constraints = [{'type' :'ineq' ,'fun' :conFun_LD ,'args' :(geomKeys , input_loads , fix_zlug , LD_con , geomBounds , minfs )},
977+ {'type' :'ineq' ,'fun' :conFun_Suction ,'args' :(geomKeys , input_loads , fix_zlug , LD_con , geomBounds , minfs )},
978+ #{'type':'ineq','fun':conFunH,'args':(geomKeys, input_loads, fix_zlug, LD_con, geomBounds, minfs)},
979+ #{'type':'ineq','fun':conFunV,'args':(geomKeys, input_loads, fix_zlug, LD_con, geomBounds, minfs)},
980+ {'type' :'ineq' ,'fun' :conBounds ,'args' :(geomKeys , input_loads , fix_zlug , LD_con , geomBounds , minfs )}]
981+
947982 else :
948983 # bounds = None
949- constraints = ({'type' :'ineq' ,'fun' :conFunH ,'args' :(input_loads ,)},
950- {'type' :'ineq' ,'fun' :conFunV ,'args' :(minfs ,input_loads )})
984+ constraints = [{'type' :'ineq' ,'fun' :conFun_LD ,'args' :(geomKeys , input_loads , fix_zlug , LD_con , geomBounds , minfs )},
985+ {'type' :'ineq' ,'fun' :conFun_DandG ,'args' :(geomKeys , input_loads , fix_zlug , LD_con , geomBounds , minfs )},
986+ #{'type':'ineq','fun':conFunH,'args':(geomKeys, input_loads, fix_zlug, LD_con, geomBounds, minfs)},
987+ #{'type':'ineq','fun':conFunV,'args':(geomKeys, input_loads, fix_zlug, LD_con, geomBounds, minfs)},
988+ {'type' :'ineq' ,'fun' :conBounds ,'args' :(geomKeys , input_loads , fix_zlug , LD_con , geomBounds , minfs )}]
951989
952990 # Run the optimization to find sizing that satisfy UC close to 1
953991 print ('optimizing anchor size' )
@@ -956,11 +994,11 @@ def conFunV(vars,minfs,input_loads):
956994 solution = minimize (objective , initial_guess , args = (geomKeys , input_loads , fix_zlug ), method = "COBYLA" ,
957995 constraints = constraints , options = {'rhobeg' :0.1 , 'catol' :0.001 })
958996 else :
959- solution = minimize (objective , initial_guess , args = (geomKeys , input_loads , fix_zlug ), method = "COBYLA" ,
960- constraints = constraints , bounds = geomBounds ,
997+ solution = minimize (objective , initial_guess , args = dict (geomKeys = geomKeys , input_loads = input_loads , fix_zlug = fix_zlug , LD_con = LD_con , geomBounds = geomBounds , minfs = minfs ), method = "COBYLA" ,
998+ constraints = constraints ,
961999 options = {'rhobeg' :0.1 , 'catol' :0.001 })
9621000
963- FS , acceptance , FSdiff = self .getFS (acceptance_crit = minfs )
1001+ FS , acceptance , FSdiff = self .getFS (loads = input_loads , acceptance_crit = minfs )
9641002
9651003 # adjust starting value if you're far off from the acceptance criteria (in either direction)
9661004 if FSdiff_max :
@@ -994,7 +1032,7 @@ def conFunV(vars,minfs,input_loads):
9941032 constraints = constraints , bounds = geomBounds ,
9951033 options = {'rhobeg' :0.1 , 'catol' :0.001 ,'maxiter' :400 })
9961034 # re-determine FS and diff from minFS
997- FS , acceptance , FSdiff = self .getFS (acceptance_crit = minfs )
1035+ FS , acceptance , FSdiff = self .getFS (loads = input_loads , acceptance_crit = minfs )
9981036 count += 1
9991037
10001038 # Extract the optimized values of geometry
0 commit comments