Esempio n. 1
0
 def ADILS_optiization(self,curve,yval,xval,x2,y2,
                tanb=0.,tane=0.,cvb=0.,cve=0.,area=72.):
     interval_data, small = interval_bounds(curve)        
     FPD = FormParameterDict(curve) 
     #---box constraint
     FPD.add_yPointConstraint(kind= 'max', value=4., location=xval[0] )
     FPD.add_xPointConstraint(kind= 'min', value=6., location=xval[0] )
     #FPD.add_yPointConstraint(kind= 'LS', value=4., location=yval[0], weight=-100. )
     #FPD.add_xPointConstraint(kind= 'LS', value=6., location=xval[0], weight=-100. )
     #---
     #---box constraint
     FPD.add_yPointConstraint(kind= 'max', value=8., location=y2[0] )
     FPD.add_xPointConstraint(kind= 'min', value=6., location=x2[0] )
     #FPD.add_yPointConstraint(kind= 'LS', value=8., location=y2[0], weight=-100. )
     #FPD.add_xPointConstraint(kind= 'LS', value=6., location=x2[0], weight=-100. )
     #---
     FPD.add_AreaConstraint(kind='LS',value=area)
     FPD.add_AngleConstraint(kind='equality',location=0.,value=tanb)
     FPD.add_AngleConstraint(kind='equality',location=1.,value=tane)
     FPD.add_CurvatureConstraint(kind='equality',location=0.,value=cvb)
     FPD.add_CurvatureConstraint(kind='equality',location=1.,value=cve)
     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)
     print 'in the loop'
     Lspline.optimize(stop = 50)
     return Lspline
    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 fini_lagrangian(FPD, this_kind='equality'):
    curve = FPD.curve
    interval_data, small = interval_bounds(curve)
    L = Lagrangian(FPD)
    interval_data, small = lagrangian_bounds(L, interval_data, small, 1.e4)
    Lspline = IntervalLagrangeSpline(curve, L, data=interval_data)
    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
Esempio n. 5
0
    def done(self):
        if self.verbose: print 'Done'
        interval_data, small = interval_bounds(self.Lspline.curve)
        self.FPD.add_E1(kind='LS', weight=1.)
        self.FPD.add_E2(kind='LS', weight=.5)
        self.FPD.add_E3(kind='LS', weight=.5)
        #self.FPD.add_ArcLength(kind='LS', weight = 1.)
        self.FPD.add_ArcLengthApprox(kind='LS', weight=1.)
        L = Lagrangian(self.FPD)
        interval_data, small = lagrangian_bounds(L, interval_data, small, 1.e4)

        self.Lspline = IntervalLagrangeSpline(self.Lspline.curve,
                                              L,
                                              data=interval_data)
        #self.Lspline = IntervalLagrangeSpline(curve, L, data = interval_data)
        plt.close(3)
        return
Esempio n. 6
0
def init_Lspline(thbcurve, FPD):
    """setup THBcurve Lspline solver
    parameters
    ----------
    thbcurve : a myspline.rbspline THB curve
    FRP : form parameter design constraint object
    
    dev
    ----------
    thbcurve = curve
    """
    interval_data, small = interval_bounds(thbcurve)

    L = Lagrangian(FPD)
    interval_data, small = lagrangian_bounds(L, 
                        interval_data, small, 1.e4)
    Lspline = IntervalLagrangeSpline(thbcurve, L, 
                                     data = interval_data)
    return Lspline
        #interval_data, small = lagrangian_bounds(L, interval_data, small, 1.e4)
        #"""
        interval_data['lmin'] = [-500.,-100000.,-100000.,-200000.,-200000.,-200000.]
        interval_data['lmax'] = [500.,100000.,100000.,200000.,200000.,200000.]
        #"""
        
        
        FPD = FormParameterDict(curve) 
        FPD.add_AreaConstraint(kind='equality', value = curve_area)#value = AF.fuzzyNumber(60.,70.,80.) )#
        FPD.add_AngleConstraint(kind='equality', location = 0., value = alphab)#AF.fuzzyNumber(-5.,-2.,0.))#
        FPD.add_AngleConstraint(kind='equality', location = 1., value = alphae)
        FPD.add_CurvatureConstraint(kind='equality', location = 0., value = Cab_given)
        FPD.add_CurvatureConstraint(kind='equality', location = 1., value = Cae_given)
        #"""
        FPD.add_E1(kind='LS', weight = 1.0)
        FPD.add_E2(kind='LS', weight = 0.5)
        FPD.add_E3(kind='LS', weight = 0.5)
        FPD.add_ArcLengthApprox(kind='LS', weight = 1.)
        
        L = Lagrangian(FPD)
        Lspline = IntervalLagrangeSpline(curve, L, data = interval_data)
        
#        Lspline.check_IA_correctness = True
#        self = Lspline
#        self.contract_constraints()
        
        Lspline.contract_constraints()
        sp1 = CurvePaver(Lspline)
        self = sp1
        print sp1.ntboxes
        #self.compute_subpaving()
Esempio n. 8
0
 #"""
 #"""
 FPD.add_AreaConstraint(kind='equality',value=curve_area)
 FPD.add_AngleConstraint(kind='equality',location=0.,value=alphab)
 FPD.add_AngleConstraint(kind='equality',location=1.,value=alphae)
 FPD.add_CurvatureConstraint(kind='equality',location=0.,value=Cab)
 FPD.add_CurvatureConstraint(kind='equality',location=1.,value=Cae)
 #"""
 #"""
 #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)
 ini = copy.deepcopy(Lspline)
 #"""
 #ini.curve.plotcurve_detailed() #TLM Sep 4 2017
 #ini.curve.plotCurvature_spines()
 #ini.curve.plotCurvature_nospines(alpha=0.)
 box1.plot()
 #"""
 
 
 print 'doing first one'
 Lspline.optimize(stop = 50)
 curve = Lspline.curve
 Lspline.curve.plotcurve_detailed()
 Lspline.curve.plotCurvature_expensive(scale=3.5,
                                      nump=5,
            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_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.curve.compute_arclength()
            print 'initial Initial sac arc length = ', Lspline.curve.AL
            save_ini_al = copy.deepcopy(Lspline.curve.AL)

            Lspline.compute_lagrangian()
            save_ini_curve = copy.deepcopy(Lspline)
            keys = Lspline.Lagrangian.obj.keys()
            #Lspline.Lagrangian.obj
            ini_ans = {}
            for key in keys:
                print Lspline.Lagrangian.obj[
                    key].type, key, ' : ', Lspline.Lagrangian.obj[
                        key].computed_value
                ini_ans[Lspline.Lagrangian.obj[key].
Esempio n. 10
0
        #                                  index = 3)
        #
        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()
def setup_interpolation_solver(thbcurve, vtinterp, this_kind='equality'):
    #                           this_kind='equality'):
    #                           this_kind='LS'):
    """setup THBcurve Lspline vertex interpolation solver
    
    
    inputs
    ----------
        thbcurve    = starting base level THB curve (n=4)
        vinterp     = the transverse vertices to be interpolated
                                        (including the endpoints!)
                                        
    dev
    ----------
    Lspline = setup_interpolation_solver(thbcurve,
                                         vtinterp)
    this_kind = 'equality'
    """
    big = 100000.
    interval_data, small = interval_bounds(thbcurve)
    FPD = FormParameterDict(thbcurve)

    FPD.add_E1(kind='LS', weight=1.)
    FPD.add_E2(kind='LS', weight=.5)
    FPD.add_E3(kind='LS', weight=.05)
    FPD.add_ArcLength(kind='LS', weight=big)
    ntinterp = len(vtinterp)
    ukbar = np.linspace(0., 1., ntinterp)[1:-1]
    nth = 1

    start = vtinterp[3]
    end = vtinterp[6]
    dx = np.linalg.norm(end - start)
    for pt, loc in zip(vtinterp[1:-1], ukbar):
        FPD.add_xPointConstraint(kind=this_kind,
                                 value=pt[0],
                                 location=loc,
                                 weight=big)
        FPD.add_yPointConstraint(kind=this_kind,
                                 value=pt[1],
                                 location=loc,
                                 weight=big)
        FPD.add_zPointConstraint(kind=this_kind,
                                 value=pt[2],
                                 location=loc,
                                 weight=big)
        #*********************************************
        # X Fixing
        #        if nth in [4,5,6,7]:
        #            FPD.add_xFixity(index=nth,
        #                            value=pt[0])
        #        else:
        #            FPD.add_xPointConstraint(kind= this_kind,
        #                                 value=pt[0],
        #                                 location=loc,
        #                                 weight = big )
        #        #*********************************************
        #        # Y Fixing
        #        if nth in [3,4,5,6]:
        #            FPD.add_xFixity(index=nth,
        #                            value=pt[1])
        #        else:
        #            FPD.add_yPointConstraint(kind= this_kind,
        #                                 value=pt[1],
        #                                 location=loc,
        #                                 weight = big  )
        #        #*********************************************
        #        # Z Fixing
        #        if nth in [3,4,5,6,7]:
        #            if nth == 4:
        #                #assert(pt[2]==start[2]),'You got START wrong!'
        #                FPD.add_zFixity(index=nth,
        #                                value=start[2]-.1*dx)
        #            elif nth == 5:
        #                FPD.add_zFixity(index=nth,
        #                                value=start[2]-.05*dx)
        #
        #            elif nth == 6:
        #                FPD.add_zFixity(index=nth,
        #                                value=end[2]+.05*dx)
        #            elif nth == 7:
        #                #assert(pt[2]==end[2]),'You got END wrong!'
        #                FPD.add_zFixity(index=nth,
        #                                value=end[2]+.1*dx)
        #            #else:
        #                #assert(1==0),'Logic Failure'
        #        else:
        #            FPD.add_zPointConstraint(kind= this_kind,
        #                                 value=pt[2],
        #                                 location=loc,
        #                                 weight = big  )
        #*********************************************
        #        if nth in [3,4,5,6]:
        #            FPD.add_CurvatureXoverZConstraint(value=0.,
        #                                        location=loc,
        #                                        weight=big)
        #*********************************************
        #        if nth == 1:
        #            FPD.add_zFixity(index=nth,
        #                            value=0.)
        #        else:
        #            FPD.add_zPointConstraint(kind= this_kind,
        #                                 value=pt[2],
        #                                 location=loc,
        #                                 weight = big  )

        #*********************************************
        if nth == 3:
            FPD.add_CurvatureXoverZConstraint(kind=this_kind,
                                              location=loc,
                                              value=0.,
                                              weight=big)
            FPD.add_AngleXoverZConstraint(kind=this_kind,
                                          location=loc,
                                          value=loc,
                                          weight=big)


#        if nth ==4:
#            FPD.add_CurvatureXoverZConstraint(kind=this_kind,
#                                        location=loc+.01,
#                                        value = 0.,
#                                        weight =big)
#        if nth ==5:
#            FPD.add_CurvatureXoverZConstraint(kind=this_kind,
#                                        location=loc-.01,
#                                        value = 0.,
#                                        weight =big)
#            FPD.add_CurvatureXoverZConstraint(kind=this_kind,
#                                        location=loc,
#                                        value = 0.,
#                                        weight =big)
        if nth == 4:
            #            FPD.add_CurvatureXoverZConstraint(kind=this_kind,
            #                                        location=loc,
            #                                        value = 0.,
            #                                        weight =big)
            #-----------------------------
            #            test = FPD.curve.greville_abscissa(7)
            #            FPD.add_CurvatureXoverZConstraint(kind=this_kind,
            #                                        location=loc-.1,
            #                                        value = 0.,
            #                                        weight =big)
            #            FPD.add_CurvatureXoverZConstraint(kind=this_kind,
            #                                        location=loc,
            #                                        value = 0.,
            #                                        weight =big)
            FPD.add_CurvatureXoverZConstraint(kind=this_kind,
                                              location=loc,
                                              value=0.,
                                              weight=big)
            #            FPD.add_CurvatureXoverZConstraint(kind=this_kind,
            #                                        location=test,
            #                                        value = 0.,
            #                                        weight =big)
            #---- --- --- --
            #            FPD.add_AngleXoverZConstraint(kind=this_kind,
            #                                            location = loc,
            #                                            value = 0.,
            #                                            weight=big)
            #            FPD.add_AngleXoverZConstraint(kind=this_kind,
            #                                            location = loc-.01,
            #                                            value = 0.,
            #                                            weight=big)
            FPD.add_AngleXoverZConstraint(kind=this_kind,
                                          location=loc,
                                          value=0.,
                                          weight=big)
        nth += 1
    FPD.add_verticalXoverZAngleConstraint(kind=this_kind,
                                          location=0.,
                                          value=0.,
                                          weight=big)

    #    FPD.add_AngleXoverZConstraint(kind      = this_kind,
    #                                 location   = 0.,
    #                                 value      = 90.,
    #                                 weight     = 10*big)
    L = Lagrangian(FPD)
    interval_data, small = lagrangian_bounds(L, interval_data, small, 1.e4)
    Lspline = IntervalLagrangeSpline(thbcurve, L, data=interval_data)
    return Lspline
    def OSV_bbow(curve):
        """Lspline solver 
        
            for the 
            
            CProfile keel curve
            
         (intended for a transom sterned hull)
        with bulbous bow
        
        dev
        ----------
        
        elevation = self.MaxDraft
        k           = self.k
        nump        = self.nump
        xb          = 0.
        yb          = 0.
        xe          = self.LengthDWL
        ye          = 0.+self.MaxDraft*drop_aft
        #alphab     = 85.##35
        #alphae     = -85.##-35
        Cab_given   = 0.
        Cae_given   = 0.
        slope       = 'down'

        Dmax = self.MaxDraft
        area = self.CLarea

        ab = alphab
        ae = alphae
        """
        print 'OSV_bbow solver Oct 14, 2018'
        #            #
        #            #**********************************************************************
        #            # get weights
        #            if Lspline is not None:
        #                norms = package_norms(Lspline)
        #                E1_0 = norms[0]
        #                E2_0 = norms[1]
        #                E3_0 = norms[2]
        #                S_0  = norms[3]
        #                curve = Lspline.curve
        #            else:
        #                E1_0 = 1.
        #                E2_0 = 1.
        #                E3_0 = 1.
        #                S_0  = 1.
        # CPK
        #**********************************************************************
        # initialize
        interval_data, small = interval_bounds(curve)
        FPD = FormParameterDict(curve)
        #
        #**********************************************************************
        # area  CPKeelProfile stage 1
        FPD.add_AreaConstraint(kind='equality', value=area)
        #
        #**********************************************************************
        # Xc CPKeelProfile
        if Xc is None:
            print 'CPK OSV bbow, equality LCG'
            FPD.add_XcConstraint(kind='LS', value=LCG * .75,
                                 weight=100.)  #cLProfile flat to bulb...
            #FPD.add_XcConstraint(kind='max',
            #                     value=self.LCG*.95)
            #FPD.add_XcConstraint(kind='min',
            #                     value=self.LCG*0.8)
        else:
            print 'Centerplane setting Xc constraint to ', Xc
            FPD.add_XcConstraint(kind='LS', value=Xc)
        #                                     value = 0.)
        #
        ##**************************************************************
        # CPkeelProfile
        #print 'Adding x - fixity!'
        #-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
        # TLM, straight flat stem
#            FPD.add_xFixity(index=1,
#                            value=xb)
#            FPD.add_xFixity(index=2,
#                            value=xb)
#-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
# Dr. Birk, flat stem
#            FPD.add_AngleConstraint(
#                                    kind        = 'equality',
#                                    location    = 0.,
#                                    value       = 75.)
        FPD.add_CurvatureConstraint(kind='equality',
                                    location=0.,
                                    value=0.,
                                    weight=100.)
        #--------------------------------------
        # +++
        #-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
        # TLM, straight flat stem
        #FPD.add_xVertexConstraint(kind='LS',
        #                         index = 3,
        #                         value = 0.)
        FPD.add_xFixity(
            index=3,  #5,
            value=0.)
        FPD.add_relative_xVertexConstraint(kind='equality',
                                           value=0.,
                                           index=3,
                                           index2=4,
                                           seperation=0.)
        #-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
        #--------------------------------------
        # ++
        #            FPD.add_xVertexConstraint(kind='LS',
        #                                     index = 8,
        #                                     value = xe)
        #            FPD.add_xVertexConstraint(kind='LS',
        #                                     index = 9,
        #                                     value = xe)
        #--------------------------------------
        ##**************************************************************
        # CPkeelProfile
        #print 'Adding x - fixity!'
        #tlmOct 14 2018 tweak this:
        FPD.add_xFixity(
            index=5,  #5,
            value=FOCP0)
        FPD.add_xFixity(
            index=6,  #6,
            value=FOCP1)
        #
        #------------------------------- #tlmOct 14 2018 tweak this:
        #print 'Adding y - fixity!'
        #FPD.add_yFixity(index=3,
        #                value=Dmax)
        FPD.add_yFixity(index=4, value=Dmax)
        FPD.add_yFixity(index=5, value=Dmax)
        FPD.add_yFixity(index=6, value=Dmax)
        FPD.add_yFixity(index=7, value=Dmax)
        #-------------------------------
        FPD.add_yFixity(index=8, value=Dmax)
        #FPD.add_yFixity(index=9,
        #                value=Dmax)
        #?-------------------------------?
        #            FPD.add_yVertexConstraint(kind='max',
        #                                     index = 8,
        #                                     value = Dmax)
        #            FPD.add_yVertexConstraint(kind='max',
        #                                     index = 9,
        #                                     value = Dmax)
        #?-------------------------------?
        #
        #
        #**********************************************************************
        # CPkeelProfile Fairness
        FPD.add_E1(kind='LS', weight=.5)
        FPD.add_E2(kind='LS', weight=.5)
        FPD.add_E3(kind='LS', weight=.001)
        FPD.add_ArcLengthApprox(kind='LS', weight=1.5)
        #
        #**********************************************************************
        #Setup and Solve:
        #
        L = Lagrangian(FPD)
        interval_data, small = lagrangian_bounds(L, interval_data, small, 1.e4)
        Lspline = IntervalLagrangeSpline(curve, L, data=interval_data)
        print 'Doing first stage CPkeel solve (include bbow weighting)'
        Lspline.optimize(stop=50)
        return Lspline
Esempio n. 13
0
                                    location=0.,
                                    value=Cab_given)
        FPD.add_CurvatureConstraint(kind='equality',
                                    location=1.,
                                    value=Cae_given)
        #"""
        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)
        Lspline.curve.verbose = True
        self = Lspline

    if interactive == True:
        assert (Lspline != None)
        #self = setup_optimization(Lspline)
        self = BsplineInteractor(Lspline)

        setconstraints = plt.axes([0.50, 0.05, 0.1, 0.075])
        sconstraints = Button(setconstraints, 'SET')
        sconstraints.on_clicked(self.set_contraints)

        axconstraints = plt.axes([0.61, 0.05, 0.1, 0.075])
        bconstraints = Button(axconstraints, 'Form Parm')
        bconstraints.on_clicked(self.add_constraints)
    def stage2(self, Lspline, FPD):
        #
        #******************************************************************
        # SAC
        # NOW Entering Solver Stage 2
        norms = package_norms(Lspline)
        E1_0 = norms[0]
        E2_0 = norms[1]
        E3_0 = norms[2]
        S_0 = norms[3]
        curve = Lspline.curve
        #
        #**********************************************************************
        #
        interval_data, small = interval_bounds(curve)
        FPD = FormParameterDict(curve)
        #
        #******************************************************************
        # Integral Parameters
        FPD.add_AreaConstraint(kind='equality', value=self.BareHullVolume)
        FPD.add_XcConstraint(kind='equality', value=self.LCG)

        #FPD.add_xPointConstraint(kind='max',
        #                         value=0.1,
        #                         location=.001)
        #FPD.add_yPointConstraint(kind='min',
        #                         value=10.,
        #                         location=.001)
        #
        #******************************************************************
        #  FLATS
        #
        #******************************************************************
        # X FLAT SAC
        #
        #print 'using x - fixity'
        #        FPD.add_xFixity(index=5,
        #                        value=self.stations.FOSAC[0])
        #        FPD.add_xFixity(index=6,
        #                        value=self.stations.FOSAC[1])
        #
        FPD.add_relative_xVertexConstraint(kind='equality',
                                           location=None,
                                           value=self.lfsac,
                                           weight=1.0,
                                           index=5,
                                           index2=6,
                                           seperation=-self.lfsac)
        #        FPD.add_relative_xVertexConstraint(kind = 'min', location=None,
        #                                           value = 0., weight = 1.0,
        #                                           index = 5, index2 = 6,
        #                                           seperation = self.lfsac )
        #        FPD.add_relative_xVertexConstraint(kind = 'max', location=None,
        #                                           value = self.lfsac+1., weight = 1.0,
        #                                           index = 5, index2 = 6,
        #                                           seperation = self.lfsac )

        #
        #******************************************************************
        # Y FLAT SAC (3,4,5,6,7)
        #-----------------------?
        #print 'using y - fixity'
        #FPD.add_yFixity(index=3,
        #                value=self.maxSecArea)
        FPD.add_yFixity(index=4, value=self.maxSecArea)
        FPD.add_yFixity(index=5, value=self.maxSecArea)
        FPD.add_yFixity(index=6, value=self.maxSecArea)
        FPD.add_yFixity(index=7, value=self.maxSecArea)
        #-----------------------?
        #FPD.add_yFixity(index=8,
        #                value=self.maxSecArea)
        #
        #******************************************************************
        #
        #        FPD.add_yPointConstraint(kind = 'equality',
        #                                 location=.01,
        #                                 value = self.Ab,
        #                                 )
        #
        #******************************************************************
        #
        #
        #******************************************************************
        #
        print 'adding bulb to the SAC functional'
        A_mid = 10.080798436245335
        BulbLength = 4.341062137105493
        #gfunc = spfuncs.gfunc
        #bbow_sac = spfuncs.BBowSAC(Xb=0.,Xe = BulbLength,
        #                           height=A_mid)
        #******************************************************************
        # Fairness
        FPD.add_E1(kind='LS', weight=1.5 / E1_0)
        FPD.add_E2(kind='LS', weight=.5 / E2_0)
        FPD.add_E3(kind='LS', weight=.5 / E3_0)
        FPD.add_ArcLengthApprox(kind='LS', weight=10. / S_0)
        #
        #******************************************************************
        #
        L = Lagrangian(FPD)
        """
        gfunc_bbow_SAC  = spfuncs.gfunc(curve,
                                         bbow_sac,
                                         0.,
                                         .00001,
                                         np.linspace(0.,1.,
                                                     bbow_sac.nump*5,
                                                     endpoint=True),
                                        10000.)
        gfunc_bbow_SAC.analysis_type = 'min'
        L.sp['bbow_sac'] = gfunc_bbow_SAC
        #"""
        #
        #******************************************************************
        #
        interval_data, small = lagrangian_bounds(L, interval_data, small, 1.e4)
        Lspline = IntervalLagrangeSpline(curve, L, data=interval_data)
        #
        #******************************************************************
        #OPTIMIZE - 2nd pass
        print 'Doing second stage SAC solve'
        Lspline.optimize(stop=100)
        #
        #******************************************************************
        # Done
        return Lspline, FPD
    def stage1(self, curve, flat=False):
        #
        #******************************************************************
        # Begin Stage 1
        interval_data, small = interval_bounds(curve)

        FPD = FormParameterDict(curve)
        #
        #******************************************************************
        #  Integral Parameters:
        FPD.add_AreaConstraint(kind='equality', value=self.BareHullVolume)
        FPD.add_XcConstraint(kind='equality', value=self.LCG)
        #
        #******************************************************************
        #  Flat Portion
        if flat:
            FPD.add_yPointConstraint(kind='equality',
                                     location=0.3333333333,
                                     value=self.maxSecArea)  #*2./3.)

            FPD.add_yPointConstraint(kind='equality',
                                     location=0.6666666666,
                                     value=self.maxSecArea)  #*2./3.)
        else:
            print 'SAC stage 1 not enforcing flat section'
        #
        #******************************************************************
        # starting, ending angles
        #            FPD.add_AngleConstraint(kind='LS',
        #                                    location = 0.,
        #                                    value = alphab)
        #            FPD.add_AngleConstraint(kind='LS',
        #                                    location = 1.,
        #                                    value = alphae)
        #
        #******************************************************************
        # Max S.A.
        FPD.add_yPointConstraint(kind='equality',
                                 location=self.LocMaxSection,
                                 value=self.maxSecArea)
        #
        #******************************************************************
        # Fairness
        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)
        #
        #******************************************************************
        #OPTIMIZE - 1st pass
        #
        print 'Doing first stage SAC solve'
        Lspline.optimize()
        #
        #******************************************************************
        # Done
        #
        return Lspline, FPD
Esempio n. 16
0
 FPD = FormParameterDict(curve)
 FPD.add_verticalAngleConstraint(kind='equality', location=0., value=0.)
 FPD.add_xVertexConstraint(kind='equality', value=0.0, index=2)
 FPD.add_yVertexConstraint(kind='equality', value=10., index=2)
 FPD.add_xVertexConstraint(kind='equality', value=0.0, index=3)
 FPD.add_yVertexConstraint(kind='equality', value=10., index=3)
 FPD.add_yVertexConstraint(kind='equality', value=10., index=4)
 FPD.add_yPointConstraint(kind='equality', location=.15, value=10.)
 FPD.add_AngleConstraint(kind='equality', location=1., value=0.)
 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.optimize(stop=50)
 #Lspline.display(mytitle = 'good_run_1')
 cl.append(copy.deepcopy(Lspline.curve))
 #
 #----------------------------------------------------
 #
 interval_data, small = interval_bounds(Lspline.curve)
 FPD = FormParameterDict(Lspline.curve)
 FPD.add_AreaToAnyXAxisConstraint(kind='equality',
                                  value=120.,
                                  x_axis_loc=12.)
 FPD.add_verticalAngleConstraint(kind='equality', location=0., value=0.)
 FPD.add_xVertexConstraint(kind='equality', value=0.0, index=2)
 FPD.add_yVertexConstraint(kind='equality', value=10., index=2)
 FPD.add_xVertexConstraint(kind='equality', value=0.0, index=3)