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 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
Ejemplo n.º 3
0
        #
        FPD.add_xVertexConstraint(kind='min', value=4.6, index=3)
        #
        #**********************************************************************
        FPD.add_E1(kind='LS', weight=1.)
        FPD.add_E2(kind='LS', weight=1.)
        FPD.add_E3(kind='LS', weight=1.)
        #FPD.add_ArcLength(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)
        vertices = [Lspline.curve.xpts, Lspline.curve.ypts]
        Lspline.compute_lagrangian(vertices, Lspline.Lagrangian)
        Lspline.display(mytitle='initial_basic_curve')

        Lspline.curve.verbose = True
        self = Lspline
        vertices = [self.curve.xpts, self.curve.ypts]

        vertices = Lspline.optimize(vertices,
                                    stop=100,
                                    Lagrangian=self.Lagrangian)
        #Lspline.display(mytitle = 'final basic curve')

        Lspline.curve.plotcurve_detailed()

        print Lspline.curve.vertices
                        key].computed_value
                fini_ans4[Lspline.Lagrangian.obj[key].
                          type] = Lspline.Lagrangian.obj[key].computed_value

            anskeys = fini_ans4.keys()
            for key in anskeys:
                print key, 100. * (fini_ans4[key].value -
                                   ini_ans[key].value) / ini_ans[key].value
            for key in anskeys:
                print key, 100. * (ini_ans[key].value -
                                   fini_ans4[key].value) / ini_ans[key].value
            Lspline.curve.compute_arclength()
            print 'final asymmetric (shifted) flat sac arc length = ', Lspline.curve.AL

            #TLM Sep 3 2017:
            Lspline.display(mytitle='flat_SAC_xcg_16_check_Sep3',
                            closeit_=False)
        if False:
            curve = copy.deepcopy(save2)
            interval_data, small = interval_bounds(curve)
            FPD = FormParameterDict(curve)
            FPD.add_AreaConstraint(kind='equality', value=288.)
            FPD.add_XcConstraint(kind='equality', value=20.)
            FPD.add_AngleConstraint(kind='equality', location=0., value=0.)
            FPD.add_AngleConstraint(kind='equality', location=1., value=0.)
            FPD.add_yPointConstraint(kind='equality',
                                     location=0.3333333333,
                                     value=12.)
            FPD.add_yPointConstraint(kind='equality',
                                     location=0.6666666666,
                                     value=12.)
            FPD.add_xPointConstraint(kind='equality',
Ejemplo n.º 5
0
                                           location=None,
                                           value=2.,
                                           weight=1.0,
                                           index=7,
                                           index2=12,
                                           seperation=2.)
        #"""
        FPD.add_E1(kind='LS', weight=.5)
        FPD.add_E2(kind='LS', weight=.5)
        FPD.add_E3(kind='LS', weight=.5)
        FPD.add_ArcLengthApprox(kind='LS', weight=.5)
        L = Lagrangian(FPD)
        interval_data, small = lagrangian_bounds(L, interval_data, small, 1.e4)
        Lspline = IntervalLagrangeSpline(curve, L, data=interval_data)
        Lspline.optimize(stop=50)
        Lspline.display(mytitle='good_run_9')
        cl.append(copy.deepcopy(Lspline.curve))

        shift_axis = 12.
        color = 'green'
        Lspline.curve.plotcurve_detailed()
        #Lspline.curve.plotCurvature()
        #Lspline.curve.plotCurvature_spines()
        #Lspline.curve.plotCurvature_nospines(alpha=0.)
        Lspline.curve.plotCurvature_expensive(scale=1., nump=2, flip=True)

        plt.fill_between(Lspline.curve.r[:, 0],
                         shift_axis,
                         Lspline.curve.r[:, 1],
                         facecolor=color,
                         alpha=.1,