Esempio n. 1
0
    def _get_P(self, nP, airfoil):
        P = numpy.zeros((airfoil.shape[0],4,3),order='F')
        for j in range(4):
            P[:,j,:2] = airfoil[:,:]
            P[:,j,2] = j
        bse = BSEmodel([P])

        bse.set_bspline_option('num_pt', 0, 'u', 
                               airfoil.shape[0])
        bse.set_bspline_option('num_cp', 0, 'u', 
                               int(airfoil.shape[0]/3))
        bse.set_bspline_option('num_pt', 0, 'v', 4)
        bse.set_bspline_option('num_cp', 0, 'v', 4)
        bse.assemble()
        cp = bse.vec['cp_str'].array
        pt = bse.vec['pt_str'].array
        jac = bse.jac['d(pt_str)/d(cp_str)']

        bse.vec['pt_str'].surfs[0][:, :, :] = P
        mtx = jac.T.dot(jac)
        rhs = jac.T.dot(pt)
        for dim in xrange(3):
            cp[:, dim] = scipy.sparse.linalg.cg(mtx, rhs[:, dim])[0]
        fit = numpy.array(cp)

        bse.set_bspline_option('num_pt', 0, 'u', nP)
        bse.assemble()
        cp = bse.vec['cp_str'].array
        pt = bse.vec['pt_str'].array

        cp[:, :] = fit[:, :]
        bse.apply_jacobian('pt_str', 'd(pt_str)/d(cp_str)', 'cp_str')

        return bse.vec['pt_str'].surfs[0][:, 0, :]
Esempio n. 2
0
    def _get_P(self, nP, airfoils, name, bunch_LE, bunch_TE):
        def bunch_start(ind, a):
            ind[:] = ind**a
        def bunch_end(ind, a):
            ind[:] = 1 - (1-ind)**a

        airfoil = airfoils[name]

        P = numpy.zeros((airfoil.shape[0],4,3),order='F')
        for j in range(4):
            P[:,j,:2] = airfoil[:,:]
            P[:,j,2] = j
        bse = BSEmodel([P])

        bse.set_bspline_option('num_pt', 0, 'u',
                               airfoil.shape[0])
        bse.set_bspline_option('num_cp', 0, 'u',
                               int(airfoil.shape[0]/3))
        bse.set_bspline_option('num_pt', 0, 'v', 4)
        bse.set_bspline_option('num_cp', 0, 'v', 4)
        bse.assemble()
        cp = bse.vec['cp_str'].array
        pt = bse.vec['pt_str'].array
        jac = bse.jac['d(pt_str)/d(cp_str)']

        bse.vec['pt_str'].surfs[0][:, :, :] = P
        mtx = jac.T.dot(jac)
        rhs = jac.T.dot(pt)
        for dim in range(3):
            cp[:, dim] = scipy.sparse.linalg.cg(mtx, rhs[:, dim])[0]
        fit = numpy.array(cp)

        bse.set_bspline_option('num_pt', 0, 'u', nP)
        bse.assemble()
        cp = bse.vec['cp_str'].array
        pt = bse.vec['pt_str'].array

        cp[:, :] = fit[:, :]
        surfs = numpy.zeros(nP).astype(int)
        ind_u = numpy.linspace(0, 1, nP)
        if name == 'upp':
            bunch_start(ind_u, bunch_TE)
            bunch_end(ind_u, bunch_LE)
        elif name == 'low':
            bunch_start(ind_u, bunch_LE)
            bunch_end(ind_u, bunch_TE)
        ind_v = numpy.zeros(nP)
        bse.add_jacobian('new', surfs, ind_u, ind_v, 3)
        bse.apply_jacobian('new', 'd(new)/d(cp_str)', 'cp_str')

        return bse.vec['new'].array[:, :]
Esempio n. 3
0
    def _get_P(self, nP, airfoils, name, bunch_LE, bunch_TE):
        def bunch_start(ind, a):
            ind[:] = ind**a
        def bunch_end(ind, a):
            ind[:] = 1 - (1-ind)**a

        airfoil = airfoils[name]

        P = numpy.zeros((airfoil.shape[0],4,3),order='F')
        for j in range(4):
            P[:,j,:2] = airfoil[:,:]
            P[:,j,2] = j
        bse = BSEmodel([P])

        bse.set_bspline_option('num_pt', 0, 'u', 
                               airfoil.shape[0])
        bse.set_bspline_option('num_cp', 0, 'u', 
                               int(airfoil.shape[0]/3))
        bse.set_bspline_option('num_pt', 0, 'v', 4)
        bse.set_bspline_option('num_cp', 0, 'v', 4)
        bse.assemble()
        cp = bse.vec['cp_str'].array
        pt = bse.vec['pt_str'].array
        jac = bse.jac['d(pt_str)/d(cp_str)']

        bse.vec['pt_str'].surfs[0][:, :, :] = P
        mtx = jac.T.dot(jac)
        rhs = jac.T.dot(pt)
        for dim in xrange(3):
            cp[:, dim] = scipy.sparse.linalg.cg(mtx, rhs[:, dim])[0]
        fit = numpy.array(cp)

        bse.set_bspline_option('num_pt', 0, 'u', nP)
        bse.assemble()
        cp = bse.vec['cp_str'].array
        pt = bse.vec['pt_str'].array

        cp[:, :] = fit[:, :]
        surfs = numpy.zeros(nP).astype(int)
        ind_u = numpy.linspace(0, 1, nP)
        if name == 'upp':
            bunch_start(ind_u, bunch_TE)
            bunch_end(ind_u, bunch_LE)
        elif name == 'low':
            bunch_start(ind_u, bunch_LE)
            bunch_end(ind_u, bunch_TE)
        ind_v = numpy.zeros(nP)
        bse.add_jacobian('new', surfs, ind_u, ind_v, 3)
        bse.apply_jacobian('new', 'd(new)/d(cp_str)', 'cp_str')

        return bse.vec['new'].array[:, :]