def plot(self): X1, X2 = t.get_2d_grid(100, [-1.0, -1.0], [1.0, 1.0]) X = t.get_ffd_2d(100, [-1.0, -1.0], [1.0, 1.0]) Ym1 = np.array([self.modelCL(xi) for xi in X]) Ym1 = np.reshape(Ym1,X1.shape) Ym2 = np.array([self.modelCD(xi) for xi in X]) Ym2 = np.reshape(Ym2,X1.shape) Ym3 = np.array([self.modelCM(xi) for xi in X]) Ym3 = np.reshape(Ym3,X1.shape) fig1 = plt.figure(1) ax1 = fig1.add_subplot(111, projection='3d') ax1.hold(True) ax1.plot_wireframe(X1,X2,Ym1,color='b') ax1.plot(self.x[:,0],self.x[:,1],self.data[:,2],'bs') ax1.set_xlabel('X1') ax1.set_ylabel('X2') fig2 = plt.figure(2) ax2 = fig2.add_subplot(111, projection='3d') ax2.hold(True) ax2.plot_wireframe(X1,X2,Ym2,color='b') ax2.plot(self.x[:,0],self.x[:,1],self.data[:,3],'bs') ax2.set_xlabel('X1') ax2.set_ylabel('X2') fig3 = plt.figure(3) ax3 = fig3.add_subplot(111, projection='3d') ax3.hold(True) ax3.plot_wireframe(X1,X2,Ym3,color='b') ax3.plot(self.x[:,0],self.x[:,1],self.data[:,4],'bs') ax3.set_xlabel('X1') ax3.set_ylabel('X2') plt.show()
def run_test1(): fh = ForresterND(0.75, 0.0, 0.0) fl = ForresterND(0.8, 5.0, 2.0) xl = np.array([0.0, 0.0]) xu = np.array([1.0, 1.0]) sigmaX = 0.05 # -- plot X1, X2 = t.get_2d_grid(50, xl, xu) X = t.get_ffd_2d(50, xl, xu) yh = np.array([fh(xi) for xi in X]) yl = np.array([fl(xi) for xi in X]) yh = np.reshape(yh,X1.shape) yl = np.reshape(yl,X1.shape) fig1 = plt.figure(1) ax1 = fig1.add_subplot(111, projection='3d') ax1.hold(True) ax1.plot_wireframe(X1,X2,yh,color='r') ax1.plot_wireframe(X1,X2,yl,color='b') ax1.set_xlabel('X1') ax1.set_ylabel('X2') plt.show()
def run_test1(): fhigh = tf.ForresterND(0.65, 0.9, 2.0) flow = tf.ForresterND(0.7, 1.0, 0.0) xl = np.array([0,0],dtype=float) xu = np.array([1,1],dtype=float) xDOE = get_DOE_data() npts = 50 # for plot nprobes = 5 #FFD level for probe jnTarget = 0.1 dTarget = 0.2 minDistance = 0.02 X1, X2 = t.get_2d_grid(npts, xl, xu) X = t.get_ffd_2d(npts, xl, xu) xprobe = t.get_ffd_2d(nprobes, xl, xu) # --------------------- yl = np.array([flow(xi) for xi in xDOE]) model = mt.RbfMod(xDOE, yl) Yl = np.array([flow(xi) for xi in X]) Yl = np.reshape(Yl,X1.shape) model = mt.RbfMod(xDOE, yl) Ym = np.array([model(xi) for xi in X]) Ym = np.reshape(Ym,X1.shape) Yobj = np.array([objective(xi, xDOE, yl, jnTarget, dTarget) for xi in X]) Yobj = np.reshape(Yobj,X1.shape) yobj = np.array([objective(xi, xDOE, yl, jnTarget, dTarget) for xi in xDOE]) fig1 = plt.figure(1) ax1 = fig1.add_subplot(111, projection='3d') ax1.hold(True) ax1.plot_wireframe(X1,X2,Yl,color='r') ax1.plot_wireframe(X1,X2,Ym,color='b') ax1.plot(xDOE[:,0],xDOE[:,1],yl,'ro') ax1.set_xlabel('X1') fig2 = plt.figure(2) ax2 = fig2.add_subplot(111, projection='3d') ax2.hold(True) ax2.plot_surface(X1,X2,Yobj,cmap=cm.jet,rstride=1, cstride=1,linewidth=0) ax2.plot(xDOE[:,0],xDOE[:,1],yobj,'ro') ax2.set_xlabel('X1') plt.show()
def run_test1(): fhigh = tf.ForresterND(0.65, 0.9, 2.0) flow = tf.ForresterND(0.7, 1.0, 0.0) xl = np.array([0,0],dtype=float) xu = np.array([1,1],dtype=float) xDOE = get_DOE_data() npts = 50 # for plot nprobes = 5 #FFD level for probe jnTarget = 0.1 dTarget = 0.2 minDistance = 0.02 X1, X2 = t.get_2d_grid(npts, xl, xu) X = t.get_ffd_2d(npts, xl, xu) xprobe = t.get_ffd_2d(nprobes, xl, xu) # --------------------- yl = np.array([flow(xi) for xi in xDOE]) model = mt.RbfMod(xDOE, yl) Yl = np.array([flow(xi) for xi in X]) Yl = np.reshape(Yl,X1.shape) bnds = np.array([[-0.01,0.01],[1.01,1.01]]) for i in range(25): yprobe = np.array([objective(xi, xDOE, yl, jnTarget, dTarget) for xi in xprobe]) match = True idx = 0 while match: x0idx = np.argsort(yprobe)[idx] x0 = xprobe[x0idx] rslt = minimize(objective,x0,method='SLSQP',bounds=bnds,args=(xDOE,yl,jnTarget, dTarget,)) xnew = t.move_pt_to_bounds(rslt.x,xl,xu) fnew = objective(xnew, xDOE,yl,jnTarget, dTarget) for xx in xDOE: if (xx==xnew).all(): match = True idx += 1 break else: match = False print '%.4f\t%.4f\t%.4f\t%d'%(xnew[0],xnew[1],fnew, idx) xDOE = np.vstack([xDOE,xnew]) yl = np.array([flow(xi) for xi in xDOE]) model = mt.RbfMod(xDOE, yl) Ym = np.array([model(xi) for xi in X]) Ym = np.reshape(Ym,X1.shape) Yobj = np.array([objective(xi, xDOE, yl, jnTarget, dTarget) for xi in X]) Yobj = np.reshape(Yobj,X1.shape) yobj = np.array([objective(xi, xDOE, yl, jnTarget, dTarget) for xi in xDOE]) fig1 = plt.figure(1) ax1 = fig1.add_subplot(111, projection='3d') ax1.hold(True) ax1.plot_wireframe(X1,X2,Yl,color='r') ax1.plot_wireframe(X1,X2,Ym,color='b') ax1.plot(xDOE[:,0],xDOE[:,1],yl,'ro') ax1.set_xlabel('X1') fig2 = plt.figure(2) ax2 = fig2.add_subplot(111, projection='3d') ax2.hold(True) ax2.plot_wireframe(X1,X2,Yobj,color='r') ax2.plot(xDOE[:,0],xDOE[:,1],yobj,'ro') ax2.set_xlabel('X1') plt.show()
def results(): path1 = 'ClarkY-C81.txt' path2 = 'ClarkY-ad.txt' path3 = 'aDOE_results.txt' n = 50 data1 = mt.read_tabulated_data_without_header(path1,1) data2 = mt.read_tabulated_data_without_header(path2) data3 = mt.read_tabulated_data_without_header(path3) xl = np.array([0.2, -20.0]) #Mach, alpha xu = np.array([0.8, 20.0]) norm = mt.Normalization(xl, xu,-1.0,1.0) x1 = norm.normalize(data1[:,:2]) modelCL1 = mt.RbfMod(x1, data1[:,2],f='cubic') modelCD1 = mt.RbfMod(x1, data1[:,3],f='cubic') modelCM1 = mt.RbfMod(x1, data1[:,4],f='cubic') x2 = norm.normalize(data2[:,:2]) modelCL2 = mt.RbfMod(x2, data2[:,2],f='cubic') modelCD2 = mt.RbfMod(x2, data2[:,3],f='cubic') modelCM2 = mt.RbfMod(x2, data2[:,4],f='cubic') X1, X2 = t.get_2d_grid(n, [-1.0, -1.0], [1.0, 1.0]) X1r,X2r = t.get_2d_grid(n, xl, xu) X = t.get_ffd_2d(n, [-1.0, -1.0], [1.0, 1.0]) Ym11d = np.array([modelCL1(xi) for xi in X]) Ym11 = np.reshape(Ym11d,X1.shape) Ym21d = np.array([modelCD1(xi) for xi in X]) Ym21 = np.reshape(Ym21d,X1.shape) Ym31d = np.array([modelCM1(xi) for xi in X]) Ym31 = np.reshape(Ym31d,X1.shape) Ym12d = np.array([modelCL2(xi) for xi in X]) Ym12 = np.reshape(Ym12d,X1.shape) Ym22d = np.array([modelCD2(xi) for xi in X]) Ym22 = np.reshape(Ym22d,X1.shape) Ym32d = np.array([modelCM2(xi) for xi in X]) Ym32 = np.reshape(Ym32d,X1.shape) fig1 = plt.figure(1) ax1 = fig1.add_subplot(111, projection='3d') ax1.hold(True) #ax1.plot_wireframe(X1,X2,Ym11,color='b') ax1.plot_surface(X1r,X2r,Ym12,cmap=cm.jet, rstride=1, cstride=1) ax1.plot(data2[:,0],data2[:,1],data2[:,2],'rs') ax1.set_xlabel('Mach') ax1.set_ylabel('Angle of attack, deg') ax1.set_zlabel('Lift coefficient') #ax1.legend(['Sample points','Exact function','Approximation']) fig2 = plt.figure(2) ax2 = fig2.add_subplot(111, projection='3d') ax2.hold(True) #ax2.plot_wireframe(X1,X2,Ym21,color='b') ax2.plot_surface(X1r,X2r,Ym22,cmap=cm.jet, rstride=1, cstride=1) ax2.plot(data2[:,0],data2[:,1],data2[:,3],'rs') ax2.set_xlabel('Mach') ax2.set_ylabel('Angle of attack, deg') ax2.set_zlabel('Drag coefficient') fig3 = plt.figure(3) ax3 = fig3.add_subplot(111, projection='3d') ax3.hold(True) #ax3.plot_wireframe(X1,X2,Ym31,color='b') ax3.plot_surface(X1r,X2r,Ym32,cmap=cm.jet, rstride=1, cstride=1) ax3.plot(data2[:,0],data2[:,1],data2[:,4],'rs') ax3.set_xlabel('Mach') ax3.set_ylabel('Angle of attack, deg') ax3.set_zlabel('Moment coefficient') fig4 = plt.figure(4) ax4 = fig4.add_subplot(111) ax4.plot(data2[:,0],data2[:,1],'ro') ax4.set_xlabel('Mach') ax4.set_ylabel('Angle of attack, deg') plt.show()
def main(): #flow = tf.ForresterND(1.0, 0.9, 2.0) flow = tf.stybtang #flow = tf.ForresterND(0.7, 1.0, 0.0) xDOEinit = get_DOE_data('LHS30.txt') xDOEinit = xDOEinit*10.0-5.0 xDOE0 = t.get_ffd_2d(11, [-5.0,-5.0], [5.0, 5.0]) nTry = 10 nFoldSamples = 1 k = 10 #xDOE0 = get_DOE_data('LHS11.txt') # xDOE0 = np.vstack([xDOE0,[[0,0],[0,1],[1,0],[1,1]]]) xl = np.array([-5.0,-5],dtype=float) xu = np.array([5,5.0],dtype=float) minDistance = 0.1 tol = 0.01 runBudget = 75 npts = 50 # for plot only # larger design space: slsqp bug xDOE = xDOEinit # plot only ylinit = np.array([flow(xi) for xi in xDOEinit]) X1, X2 = t.get_2d_grid(npts, xl, xu) X = t.get_ffd_2d(npts, xl, xu) yl = np.array([flow(xi) for xi in xDOE]) model = mt.RbfMod(xDOE, yl) Ym0 = np.array([model(xi) for xi in X]) Ym0 = np.reshape(Ym0,X1.shape) # main body err = tol+1 itr = 0 yl = np.array([flow(xi) for xi in xDOE]) bnds = np.array([[-0.005,-0.005],[1.005,1.005]]) #for zz in range(10): npts = len(xDOE) while err>tol and runBudget>npts: itr += 1 jn0 = np.array([objective(xi, xDOE, yl, None, nFoldSamples) for xi in xDOE0]) xsort = xDOE0[np.argsort(jn0)] xopt = np.zeros([nTry,xDOE.shape[1]]) pointFound = False i = 0 while not pointFound: x0 = xsort[i] i += 1 rslt = minimize(objective,x0,method='SLSQP',bounds=bnds,args=(xDOE,yl,None,nFoldSamples,k,minDistance,)) xopt = t.move_pt_to_bounds(rslt.x,xl,xu) #SLSQP bugfix #fopt = get_jn(xopt, xDOE,yl,None,nFoldSamples) pointFound = check_point(xopt, xDOE, minDistance) #xopt = filter_results(xopt,fopt,0.1) xDOE = mt.remove_duplicates(np.vstack([xopt,xDOE])) npts = len(xDOE) yl = np.array([flow(xi) for xi in xDOE]) err = t.RRMSE(xDOE,yl) #err = np.average(np.array([get_jn(xi, xDOE, yl,None,nFoldSamples) for xi in xDOE])) print '%d\t%d\t%.4e'%(itr, len(xDOE), err) yl = np.array([flow(xi) for xi in xDOE]) model = mt.RbfMod(xDOE, yl) Ym1 = np.array([model(xi) for xi in X]) Ym1 = np.reshape(Ym1,X1.shape) Yl = np.array([flow(xi) for xi in X]) Yl = np.reshape(Yl,X1.shape) Yobj = np.array([objective(xi, xDOE, yl,None,nFoldSamples) for xi in X]) Yobj = np.reshape(Yobj,X1.shape) yobj = np.array([get_jn(xi, xDOE, yl,None,nFoldSamples) for xi in xDOE]) Yobj2 = np.array([get_jn(xi, xDOE, yl,None,nFoldSamples) for xi in X]) Yobj2 = np.reshape(Yobj2,X1.shape) fig1 = plt.figure(1) ax1 = fig1.add_subplot(111, projection='3d') ax1.hold(True) ax1.plot_wireframe(X1,X2,Yl,color='r') #ax1.plot_wireframe(X1,X2,Ym0,color='b') ax1.plot_wireframe(X1,X2,Ym1,color='b') ax1.plot(xDOE[:,0],xDOE[:,1],yl,'ro') ax1.plot(xDOEinit[:,0],xDOEinit[:,1],ylinit,'bs') ax1.set_xlabel('X1') ax1.set_ylabel('X2') fig2 = plt.figure(2) ax2 = fig2.add_subplot(111, projection='3d') ax2.hold(True) ax2.plot_wireframe(X1,X2,Yobj,color='r') ax2.plot(xDOE[:,0],xDOE[:,1],yobj,'ro') ax2.plot_wireframe(X1,X2,Yobj2,color='b') ax2.set_xlabel('X1') #ax2.set_zlim([0,16]) lvls = np.linspace(-100,250,20) fig3 = plt.figure(3) ax3 = fig3.add_subplot(111) ax3.hold(True) ax3.plot(xDOE[:,0],xDOE[:,1],'ro') ax3.plot(xDOEinit[:,0],xDOEinit[:,1],'bs') CS = ax3.contourf(X1,X2, Yl, levels=lvls) plt.colorbar(CS, ticks=lvls, format='%.4f') ax3.set_xlabel('X1') ax3.set_ylabel('X2') fig4 = plt.figure(4) ax4 = fig4.add_subplot(111) ax4.hold(True) ax4.plot(xDOE[:,0],xDOE[:,1],'ro') ax4.plot(xDOEinit[:,0],xDOEinit[:,1],'bs') CS1 = ax4.contourf(X1,X2, Ym1, levels=lvls) plt.colorbar(CS1, ticks=lvls, format='%.4f') ax4.set_xlabel('X1') ax4.set_ylabel('X2') #ax3.clabel(CS, inline=1, fontsize=10) plt.show()
def run_test1(): flow = tf.ForresterND(0.7, 1.0, 0.0) xl = np.array([0,0],dtype=float) xu = np.array([1,1],dtype=float) xDOE = get_DOE_data() xDOEinit = get_DOE_data() npts = 50 # for plot nprobes = 7 #FFD level for probe jnTarget = 0.1 # for normalization minDistance = 0.05 maxDistance = 0.50 X1, X2 = t.get_2d_grid(npts, xl, xu) X = t.get_ffd_2d(npts, xl, xu) xprobe = t.get_ffd_2d(nprobes, xl, xu) # --------------------- yl = np.array([flow(xi) for xi in xDOE]) model = mt.RbfMod(xDOE, yl) Yl = np.array([flow(xi) for xi in X]) Yl = np.reshape(Yl,X1.shape) bnds = np.array([[-0.01,0.01],[1.01,1.01]]) tol = 0.5 err = tol+1.0 while err>=tol: yprobe = np.array([objective(xi, xDOE, yl) for xi in xprobe]) x0idx = np.argsort(yprobe)[0] x0 = xprobe[x0idx] rslt = minimize(objective,x0,method='SLSQP',bounds=bnds,args=(xDOE,yl,)) xnew = t.move_pt_to_bounds(rslt.x,xl,xu) #SLSQP bugfix fnew = objective(xnew, xDOE,yl) match = True jnbest = 0 while match: for xx in xDOE: if (xx==xnew).all(): match = True for xi in xDOE: d = np.linalg.norm(xi-xnew) if minDistance<= d <=maxDistance: if objective(xi, xDOE, yl)<=jnbest: xmove = xi xnew = move_pt_dir(xnew, xmove) break else: match = False print '%d\t%.4f\t%.4f\t%.4f\t%.4f'%(len(xDOE),xnew[0],xnew[1],-fnew,err) xDOE = np.vstack([xDOE,xnew]) yl = np.array([flow(xi) for xi in xDOE]) jnavg = np.array([objective(xi, xDOE, yl) for xi in xDOE]) err = -np.average(jnavg) ylinit = np.array([flow(xi) for xi in xDOEinit]) model = mt.RbfMod(xDOE, yl) Ym = np.array([model(xi) for xi in X]) Ym = np.reshape(Ym,X1.shape) Yobj = np.array([objective(xi, xDOE, yl) for xi in X]) Yobj = np.reshape(Yobj,X1.shape) yobj = np.array([objective(xi, xDOE, yl) for xi in xDOE]) fig1 = plt.figure(1) ax1 = fig1.add_subplot(111, projection='3d') ax1.hold(True) ax1.plot_wireframe(X1,X2,Yl,color='r') ax1.plot_wireframe(X1,X2,Ym,color='b') ax1.plot(xDOE[:,0],xDOE[:,1],yl,'ro') ax1.plot(xDOEinit[:,0],xDOEinit[:,1],ylinit,'bs') ax1.set_xlabel('X1') fig2 = plt.figure(2) ax2 = fig2.add_subplot(111, projection='3d') ax2.hold(True) ax2.plot_wireframe(X1,X2,Yobj,color='r') ax2.plot(xDOE[:,0],xDOE[:,1],yobj,'ro') ax2.set_xlabel('X1') plt.show()
def create_aero_db(): af = MyTools.airfoil.airfoil.Airfoil() af.read_txt('Clark-Y.txt') #af.create_naca4() # flow = AeroModel('ClarkY-adaptive.txt') flow.plot() # fhigh = AeroModel('aero_data_jfoil.txt') #flow.plot() #fhigh.plot() #fhigh = CFDrun(af) #fhigh.modelCL.rbf.epsilon = 1e-8 #flow.plot() #fhigh.plot() # def func(x): # cl0, cd0, cm0 = flow(x) # cl1, cd1, cm1 = fhigh(x) # return cl1-cl0, cd1-cd0, cm1-cm0 func = CFDrun(af) func.path = 'ClarkY-adaptive.txt' # func = AeroModel('ClarkY-C81.txt') # func.plot() # fhigh = AeroModel('ClarkY-adaptive.txt') # fhigh.plot() Mach = np.array([0.2, 0.8]) alpha = np.array([-20.0, 20.0]) DOEpath = 'LHS30.txt' tol = np.array([0.05, 0.001, 0.01]) runBudget = 100 minDistance = 0.025 kFold = 1 pOut = 5 xDOE0 = t.get_ffd_2d(51, [-1.0, -1], [1.,1.]) # trial initial points nptsPlot = 50 # --- --- bnds = np.array([[-0.0001,-0.0001],[1.0001,1.0001]]) _xl = np.array([-1.0, -1.0]) _xu = np.array([1.0, 1.0]) xl = np.array([Mach[0], alpha[0]]) xu = np.array([Mach[1], alpha[1]]) norm = mt.Normalization(xl, xu) xDOE = mt.read_tabulated_data_without_header(DOEpath) #xDOE = t.get_ffd_2d(3,[-1.0, -1], [1.,1.]) #get_aero_data(xDOE[10], af, norm) data = np.zeros([len(xDOE),3]) dataNew = np.zeros(3) for i,xx in enumerate(xDOE): data[i,0], data[i,1], data[i,2] = func(xx) xreal = func.norm.denormalize(xx) out2 = '%.6f\t%.6f\t%.8f\t%.8f\t%.8f\n'%(xreal[0],xreal[1],data[i,0],data[i,1],data[i,2]) fid2 = open('ClarkY-ad.txt','at') fid2.write(out2) fid2.close() # data = mt.read_tabulated_data_without_header(func.path)[:,2:] itr = 0 err = tol+1.0 npts = len(xDOE) while np.all(err>tol) and runBudget>npts: itr += 1 dataSetIdx = itr%3 ds = data[:,dataSetIdx] jn0 = np.array([objective(xi, xDOE, ds, None, pOut, kFold) for xi in xDOE0]) xsort = xDOE0[np.argsort(jn0)] #xopt = np.zeros([nTrial,xDOE.shape[1]]) pointFound = False i = 0 while not pointFound: x0 = xsort[i] i += 0 rslt = minimize(objective,x0,method='SLSQP',bounds=bnds, args=(xDOE,ds,None,pOut, kFold,minDistance,)) xopt = t.move_pt_to_bounds(rslt.x,_xl,_xu) #SLSQP bugfix pointFound = check_point(xopt, xDOE, minDistance) xDOE = mt.remove_duplicates(np.vstack([xopt,xDOE])) npts = len(xDOE) dataNew[0], dataNew[1], dataNew[2] = func(xopt) data = np.vstack([dataNew, data]) err1 = t.RRMSE(xDOE,data[:,0]) err2 = t.RRMSE(xDOE,data[:,1]) err3 = t.RRMSE(xDOE,data[:,2]) # err1 = np.average(np.array([get_jn(xi, xDOE, data[:,0],None, pOut, kFold) for xi in xDOE])) # err2 = np.average(np.array([get_jn(xi, xDOE, data[:,1],None, pOut, kFold) for xi in xDOE])) # err3 = np.average(np.array([get_jn(xi, xDOE, data[:,2],None, pOut, kFold) for xi in xDOE])) err = np.array([err1,err2,err3]) out = '%d\t%d\t%.4e\t%.4e\t%.4e\n'%(itr, len(xDOE), err[0], err[1], err[2]) xreal = func.norm.denormalize(xDOE[0]) out2 = '%.6f\t%.6f\t%.8f\t%.8f\t%.8f\n'%(xreal[0],xreal[1],dataNew[0],dataNew[1],dataNew[2]) print out fid1 = open('aDOE_results.txt','at') fid1.write(out) fid1.close() fid2 = open('ClarkY-ad.txt','at') fid2.write(out2) fid2.close() #--- plot area iz = 0 X1, X2 = t.get_2d_grid(nptsPlot, [-1.0, -1.0], [1.0, 1.0]) X = t.get_ffd_2d(nptsPlot, [-1.0, -1.0], [1.0, 1.0]) X1r, X2r = t.get_2d_grid(nptsPlot, xl, xu) #Yl = np.array([func(xi)[iz] for xi in X]) #Yl = np.reshape(Yl,X1.shape) xDOEreal = np.zeros(xDOE.shape) for i,xd in enumerate(xDOE): xDOEreal[i] = norm.denormalize(xd) Yobj = np.array([objective(xi, xDOE, data[:,iz],None,1, kFold) for xi in X]) Yobj = np.reshape(Yobj,X1.shape) yobj = np.array([objective(xi, xDOE, data[:,iz],None,1, kFold) for xi in xDOE]) model = mt.RbfMod(xDOE, data[:,iz]) Ym1 = np.array([model(xi) for xi in X]) Ym1 = np.reshape(Ym1,X1.shape) fig1 = plt.figure(1) ax1 = fig1.add_subplot(111, projection='3d') ax1.hold(True) #.plot_wireframe(X1r,X2r,Yl,color='r') #ax1.plot_wireframe(X1,X2,Ym0,color='b') ax1.plot_wireframe(X1r,X2r,Ym1,color='b') ax1.plot(xDOEreal[:,0],xDOEreal[:,1],data[:,iz],'ro') #ax1.plot(xDOEinit[:,0],xDOEinit[:,1],ylinit,'bs') ax1.set_xlabel('X1') ax1.set_ylabel('X2') ax1.set_zlim([-1,1]) fig2 = plt.figure(2) ax2 = fig2.add_subplot(111, projection='3d') ax2.hold(True) ax2.plot_wireframe(X1,X2,Yobj,color='r') ax2.plot(xDOE[:,0],xDOE[:,1],yobj,'ro') ax2.set_xlabel('X1') #lvls = np.linspace(-30,20,20) fig3 = plt.figure(3) ax3 = fig3.add_subplot(111) ax3.hold(True) ax3.plot(xDOE[:,0],xDOE[:,1],'ro') #ax3.plot(xDOEinit[:,0],xDOEinit[:,1],'bs') #CS = ax3.contourf(X1,X2, Yl, levels=lvls) #plt.colorbar(CS, ticks=lvls, format='%.4f') ax3.set_xlabel('X1') ax3.set_ylabel('X2') fig4 = plt.figure(4) ax4 = fig4.add_subplot(111) ax4.hold(True) ax4.plot(xDOE[:,0],xDOE[:,1],'ro') #ax4.plot(xDOEinit[:,0],xDOEinit[:,1],'bs') #CS1 = ax4.contourf(X1,X2, Ym1, levels=lvls) #plt.colorbar(CS1, ticks=lvls, format='%.4f') ax4.set_xlabel('X1') ax4.set_ylabel('X2') #ax3.clabel(CS, inline=1, fontsize=10) plt.show()