def make_box(self): c1 = spline.Bspline(np.asarray([self.pts[0],self.pts[1]]),self.k,self.nump) c2 = spline.Bspline(np.asarray([self.pts[1],self.pts[2]]),self.k,self.nump) c3 = spline.Bspline(np.asarray([self.pts[2],self.pts[3]]),self.k,self.nump) c4 = spline.Bspline(np.asarray([self.pts[3],self.pts[0]]),self.k,self.nump) self.curves = [c1,c2,c3,c4] return
def test_algo(): k = 4 p = k-1 nump = 60 correction = -1 cfac = correction verts = spline.linear_vertices([0.,0.],[12.,12.],7) verts[:,1] = np.cos(verts[:,1]) self = spline.Bspline(verts,k,nump) lself = lespline(verts,k,nump) p = self.p TAU = self.t tpi = np.sort(list(set(TAU))) TP = np.zeros((p+2+cfac),float) for i in range(len(TP)): TP[i] = (tpi[i]+tpi[i+1])*.5 ith = 0 actv_knots = self.active_knots(ith) #tp_insert = knot_union2(actv_knots,TP) #intersection instead?? tau = actv_knots tp = TP#tp_insert W = subdivide_basis_not_SABIN(p,tau,tp) for i in range(0,self.n-1): tau = self.active_knots(i) print subdivide_basis_not_SABIN(p,tau,tp) return
def compute_entrance_SAC(self): k = SAC.k nump = SAC.nump nCV = 7 xb = SAC.xb xe = xb + self.Lr yb = self.Amax ye = 0. yap = self.Aap Xc = self.Xr ab = 0. ae = 0. ini_v = InitializeControlVertices(xb, yb, xe, ye, alphae=ae, alphab=ab, Cab_given=0., Cae_given=0., nCV=7, slope='down') curve = spline.Bspline(ini_v.vertices, k, nump) interval_data, small = interval_bounds(curve) FPD = FormParameterDict(curve) #FPD.add_AreaConstraint(kind='equality', value = curve_area) FPD.add_AngleConstraint(kind='equality', value=0., location=0.) FPD.add_AngleConstraint(kind='equality', value=0., location=1.) FPD.add_CurvatureConstraint(kind='equality', value=0., location=0.) FPD.add_CurvatureConstraint(kind='equality', value=0., location=1.) FPD.add_XcConstraint(kind='equality', value=3.5) FPD.add_E1(kind='LS', weight=1.) FPD.add_E2(kind='LS', weight=1.) FPD.add_E3(kind='LS', weight=1.) FPD.add_ArcLengthApprox(kind='LS', weight=1.) L = Lagrangian(FPD) interval_data, small = lagrangian_bounds(L, interval_data, small, 1.e4) Lspline = IntervalLagrangeSpline(curve, L, data=interval_data) Lspline.compute_lagrangian() Lspline.display(mytitle='SAC_fwd_ini', x_axis_name='x', y_axis_name='z') Lspline.optimize() Lspline.display(mytitle='SAC_fwd', x_axis_name='x', y_axis_name='z') return Lspline
def aggregate_SAC_curves_Small(self): """put fwd, mid, and run into one SAC curve """ n1 = self.run.curve.n n2 = self.midbody.curve.n n3 = self.entrance.curve.n self.midbody.translate(self.Le + SAC.xb) self.entrance.translate(self.Lm + self.Le + SAC.xb) nv = n1 + n2 - 2 + n3 Cv = np.zeros((nv, 2), float) Cv[0:n1, :] = self.run.curve.vertices Cv[n1:n1 + n2 - 2, :] = self.midbody.curve.vertices[1:-1] Cv[n1 + n2 - 2:n1 + n2 + n3, :] = self.entrance.curve.vertices self.SAC = spline.Bspline(Cv, SAC.k, nump=SAC.nump * 3) return
def compute_midbody_SAC(self): k = SAC.k nump = SAC.nump n = 7 xb = SAC.xb xe = xb + self.Lm yb = self.Amax ye = self.Amax Xc = self.Xm ab = 0. ae = 0. vertices = linear_vertices([xb, yb], [xe, ye], num=n) curve = spline.Bspline(vertices, k, nump) interval_data, small = interval_bounds(curve) FPD = FormParameterDict(curve) #FPD.add_AreaConstraint(kind='equality', value = curve_area) FPD.add_AngleConstraint(kind='equality', value=0., location=0.) FPD.add_AngleConstraint(kind='equality', value=0., location=1.) FPD.add_CurvatureConstraint(kind='equality', value=0., location=0.) FPD.add_CurvatureConstraint(kind='equality', value=0., location=1.) #FPD.add_XcConstraint(kind = 'equality', value = 6.) FPD.add_E1(kind='LS', weight=1.) FPD.add_E2(kind='LS', weight=1.) FPD.add_E3(kind='LS', weight=1.) FPD.add_ArcLengthApprox(kind='LS', weight=1.) L = Lagrangian(FPD) interval_data, small = lagrangian_bounds(L, interval_data, small, 1.e4) Lspline = IntervalLagrangeSpline(curve, L, data=interval_data) Lspline.compute_lagrangian() Lspline.display(mytitle='SAC_mid_ini', x_axis_name='x', y_axis_name='z') Lspline.optimize() Lspline.display(mytitle='SAC_mid', x_axis_name='x', y_axis_name='z') return Lspline
alphab = 0.#-5. alphae = 0.#-15. Cab_given = 0. Cae_given = 0. xc = 4. yc = 4. curve_area = 72.#84.# slope = 'down' ae = alphae ab = alphab ini_v = InitializeControlVertices(alphae=ae, alphab=ab, Cab_given=0.,Cae_given=0., nCV = 7) curve = spline.Bspline(ini_v.vertices, k, nump) wi = 3.5 #2.5# w = .5 #.65 ep = 1.e-10 sp = 1.e-4 x = ini_v.vertices[:,0] y = ini_v.vertices[:,1] interval_data={} #interval_data, small = interval_bounds(curve) # Max March 2015 ultimate test -Mod used August 2015 """ interval_data['xmin'] = [ 0.0, 0.01, 0.1, 0.2, 0.000000001, 0.000000001, 11.999999999 ] interval_data['xmax'] = [ 0.0000000001, 11.9, 11.9, 11.9, 11.99, 11.99, 12.0000000001 ] interval_data['ymin'] = [11.9999999999, 0.01, 0.01, 0.0, 0.,0.,0.]# -0.000000001, -0.000000001, -0.000000001 ] # interval_data['ymax'] = [12.0000000001, 12.0, 12., 12., 12., 11., 0.00000000001] #"""
def initial_curve(start=(0., 12.), end=(12., 0.), num=7, k=4, nump=50): vertices = linear_vertices(start, end, num) k = 4 nump = 50 curve = spline.Bspline(vertices, k, nump) return curve
Cae_given = 0. xc = 4. yc = 4. curve_area = 72. #84.# slope = 'down' ae = alphae ab = alphab numcv = 8 #7 ini_v = InitializeControlVertices(alphae=ae, alphab=ab, Cab_given=0., Cae_given=0., nCV=numcv) curve = spline.Bspline(ini_v.vertices, k, nump) wi = 3.5 #2.5# w = .5 #.65 ep = 1.e-10 sp = 1.e-4 x = ini_v.vertices[:, 0] y = ini_v.vertices[:, 1] interval_data, small = interval_bounds(curve) if test == 'SAC_4': print test if True: print '\n\n\n\n CURVE 1' curve = initial_curve((0., 0.), (36., 0.), num=12, k=4, nump=30) v = copy.deepcopy(curve.vertices) v[4:7, 1] = 15.
self.SplineHierarchy = splines return if __name__ == '__main__': basic = False interactive = True if False: k = 4 nump = 30 start = [0., 12.] end = [12., 0.] num = 10 vv = spline.curvalinear_vertices(start, end, num) vb = spline.Bspline(vv, k, nump) h0spline = LevelSpline(vv, k, nump) h1spline = h0spline.bounds_refinement([.75, .8]) h0spline.plotcurve_detailed() h1spline.plotcurve_detailed() self = h1spline a = h0spline b = h1spline print self.active_knots() print self.active_Bik_interval(u=.75) print self.active_Bik_interval(u=.8) av = copy.deepcopy(a.vertices) av[3] = [5., 5.]
Cae = 0. xc = 4. yc = 4. curve_area = 72. slope = 'up' ae = alphae ab = alphab numcv = 9 #8 #10 ini_v = InitializeControlVertices(xb,yb,xe,ye,alphae=ae, alphab=ab, Cab_given=Cab,Cae_given=Cae, nCV = numcv, slope = 'up') curve = spline.Bspline(ini_v.vertices, k, nump) curve.knot_insertion(knot=.55) curve.knot_insertion(knot=.55) curve.knot_insertion(knot=.55) curve.knot_insertion(knot=.55) curve.knot_insertion(knot=.55) curve.knot_insertion(knot=.55) curve.knot_insertion(knot=.55) curve.knot_insertion(knot=.55) curve.knot_insertion(knot=.55) c = spline.Bspline(curve.vertices, k, 3*nump) curve.plotcurve_detailed() if do_all: test = 'smart_section' if test == 'smart_section':
alphae = 0. alphab = 0. Cab_given = 0. Cae_given = 0 xc = 4. yc = 4. curve_area = 72. slope = 'down' ini_v = InitializeControlVertices(alphae=0., alphab=0., Cab_given=0., Cae_given=0.) curve = spline.Bspline(ini_v.vertices, k, nump) ae = alphae ab = alphab ini_v = InitializeControlVertices(alphae=ae, alphab=ab, Cab_given=0., Cae_given=0., nCV=7) curve = spline.Bspline(ini_v.vertices, k, nump) wi = 3.5 #2.5# w = .5 #.65 ep = 1.e-10 sp = 1.e-4 x = ini_v.vertices[:, 0] y = ini_v.vertices[:, 1]
Alpha = 1 - Beta b[j] = Alpha * b[j] + Beta * b[j + 1] return b if __name__ == '__main__': green = 'green' red = 'red' blue = 'blue' k = 4 nump = 60 correction = -1 cfac = correction verts = spline.linear_vertices([0.,0.],[12.,12.],7) verts[:,1] = np.cos(verts[:,1]) self = spline.Bspline(verts,k,nump) lself = lespline(verts,k,nump) time0=time.clock() lself = lself.dyadic_refinement() time1=time.clock() print 'refined Basis calc time method 1 = {} s'.format(time1-time0) #self.plotcurve_detailed() p = self.p tau = self.t tpi = np.sort(list(set(tau))) tp = np.zeros((p+2+cfac),float) for i in range(len(tp)): tp[i] = (tpi[i]+tpi[i+1])*.5