Exemplo n.º 1
0
    def _read_points(self, section):
        """
        .. code-block:: console

          $points - wing-body  with composite panels
          =kn                                               cpnorm
          4.                                                2.
          =kt
          1.
          =nm       nn                                                          netname
          11.       3.                                                          winga
          =x(1,1)   y(1,1)    z(1,1)    x(*,*)    y(*,*)    z(*,*)
             69.4737    9.2105    0.0000   63.7818    9.5807    0.7831

        """
        nnetworks = integer(section[1][0:10], 'nnetworks')
        cp_norm = section[1][50:60].strip()
        #cp_norm = double(section[1][50:60], 'cp_norm')

        kt = integer(section[2][0:10], 'kt')
        #if cp_norm:
            #self.log.debug("nnetworks=%s cp_norm=%s" % (nnetworks, cp_norm))
        #else:
            #self.log.debug("nnetworks=%s" % (nnetworks))

        n = 4
        self.msg += '      kn,kt            %i          %i\n' % (nnetworks, kt)

        for unused_inetwork in range(nnetworks):
            #self.log.debug("lines[* %s] = %s" % (n - 1, section[n - 1]))
            nm = integer(section[n - 1][0:10], 'nm')
            nn = integer(section[n - 1][10:20], 'nn')
            network_name = section[n - 1][70:80]
            #self.log.debug("kt=%s nm=%s nn=%s netname=%s" % (
                #kt, nm, nn, network_name))

            xyz = np.zeros([nm, nn, 3], dtype='float32')
            #y = zeros([nm, nn])
            #z = zeros([nm, nn])
            nfull_lines = nm // 2
            npartial_lines = nm % 2
            nlines = nfull_lines + npartial_lines
            #print "nfull_lines=%s npartial_lines=%s nlines=%s" % (
                #nfull_lines, npartial_lines, nlines)
            for j in range(nn):
                lines = section[n:n + nlines]
                n += nlines
                #print '\n'.join(lines)
                points = self.split_points(lines, nfull_lines, npartial_lines)

                for i, point in enumerate(points):
                    xyz[i, j, :] = [point[0], point[1], point[2]]

            self.add_patch(network_name, kt, cp_norm, xyz)
            n += 1
        return True
Exemplo n.º 2
0
 def _read_cases(self, section):
     """
     $cases - no. of solutions
     =nacase
     1.
     """
     self.ncases = integer(section[1][0:10], 'ncases')
     #self.log.debug("ncases = %s" % (self.ncases))
     return True
Exemplo n.º 3
0
    def _read_symmetry(self, section):
        """
        .. code-block:: console

          $symmetry - xz plane of symmetry
          =misymm   mjsymm
          1.        0.

        .. warning::

            doesnt consider antisymmetryic
        """
        # doesnt consider antisymmetric
        self.xz_symmetry = integer(section[1][0:10], 'xz_symmetry')
        self.xy_symmetry = integer(section[1][10:20], 'xy_symmetry')

        # doesnt consider antisymmetric
        #self.xy_symmetry = integer(section[1][10:20], 'xy_symmetry')
        self.nsymmetry_planes = self.xz_symmetry + self.xy_symmetry
        self.symmetry_section = '\n'.join(section) + '\n'
        self.log.debug("xz_symmetry=%s xy_symmetry=%s" % (
            self.xz_symmetry, self.xy_symmetry))
        return True
Exemplo n.º 4
0
    def __init__(self, inetwork, network_name, kt, cp_norm, xyz, log):
        self.log = log

        self.inetwork = inetwork  # lets it print out in order, does it need a deepcopy???
        self.network_name = network_name.strip()
        #self.log.debug('network_name=%r' % (network_name))
        #self.log.debug("****patch.network_name=%s" % (self.network_name))
        self.kt = kt
        if cp_norm == '':
            cp_norm = 0
        self.cp_norm = integer(cp_norm, 'cp_norm')
        self.matchw = 0
        self.xyz = xyz
        self.nrows = xyz.shape[0]
        self.ncols = xyz.shape[1]
Exemplo n.º 5
0
    def _read_trailing_wakes(self, section):
        """
        .. code-block:: console

          $trailing wakes from body
          =kn                                               cpnorm
          2.
          =kt       matcw
          18.       1.
          =inat     insd      xwake     twake                                   netname
          bodyl     3.        100.      .0                                      bodylwk
          bodyu     3.        100.      .0                                      bodyuwk
        """
        #return True  # disable wakes
        nnetworks = integer_or_blank(section[1][0:10], 'nnetworks', 0)

        cp_norm = integer_or_blank(section[1][50:60], 'cp_norm', 0)

        #print "section[2] = ",section[2]
        kt = integer(section[2][0:10], 'kt')

        matchw = section[2][10:20].strip()
        if matchw:
            matchw = float(matchw)
        #if cp_norm:
            #print "nnetworks=%s cp_norm=%s" % (nnetworks, cp_norm)
        #else:
            #print "nnetworks=%s" % (nnetworks)
        #print ""
        #matcw = integer(section[2][10:20], 'matcw)

        n = 3  # line number
        self.msg += '      kn,kt            %i          %i\n' % (nnetworks, kt)
        #self.log.debug('kt=%s cp_norm=%s matchw=%s' % (kt, cp_norm, matchw))
        for unused_inetwork in range(nnetworks):
            #self.log.debug("lines[* %s] = %s" % (n, section[n]))

            trailed_panel = section[n][0:10].strip()
            edge_number = integer(section[n][10:20], 'edge_number')
            xwake = double(section[n][20:30], 'xwake')  # x distance

            # 0-wake parallel to x axis
            #1-wake in direction of compressibility
            twake = double(section[n][30:40], 'twake')
            network_name = section[n][70:80].strip()
            self.log.debug('trailed_panel=%s edge_number=%s xwake=%s twake=%s network_name=%s' % (
                trailed_panel, edge_number, xwake, twake, network_name))
            try:
                patch = self.find_patch_by_name(trailed_panel)
            except KeyError:
                self.log.debug('trailed_panel isnt defined...trailed_panel=%r' % (trailed_panel))
                raise

            (unused_p1, xyz1) = patch.get_edge(edge_number)

            npoints = xyz1.shape[0]
            xyz = np.zeros([2, npoints, 3])

            xyz[0, :, :] = xyz1
            if twake == 0.:
                xyz[1, :, 0] = np.ones([npoints]) * xwake
                xyz[1, :, 1] = xyz1[:, 1]
                xyz[1, :, 2] = xyz1[:, 2]
            else:
                #alphaC, betaC
                raise NotImplementedError('twake isnt supported')
            #self.log.debug("--xyz---")
            #self.log.debug(xyz)
            #nm = integer(section[n-1][0 :10], 'nm')
            #nn = integer(section[n-1][10:20], 'nn')
            options = [kt, cp_norm, matchw, trailed_panel, edge_number, xwake,
                       twake]
            patch = self.add_wake_patch(network_name, options, xyz)
            self.log.info('----------------------------')
            n += 1
        return True
Exemplo n.º 6
0
    def _read_circular_section(self, section):
        """
        .. code-block:: console
          $circular sections - nacelle with composite panels
          =kn
          2.
          =kt
          1.
          =nopt                                                                 netname
          0.                                                                    cowlu
          =nm
          20.
          =xs(1)    ri(1)     xs(2)     ri(2)     xs(*)     ri(*)
              2.0000    2.3000    1.5756    2.3000    1.1486    2.3000
              0.7460    2.3030    0.4069    2.3286    0.1624    2.3790
              0.0214    2.4542   -0.0200    2.5485    0.0388    2.6522 # 18
              0.2056    2.7554    0.4869    2.8522    0.8883    2.9413
              1.4250    3.0178    2.1188    3.0656    2.9586    3.0658 # 36
              3.8551    3.0175    4.6715    2.9439    5.3492    2.8700 # 42
              6.0000    2.7842    6.4687    2.7442 # 46 ->23
          =nn
          5.
          =th(1)    th(2)     th(3)     th(4)     th(5)
          -90.      -45.      0.        45.       90.
        """
        nnetworks = integer(section[1][0:10], 'nnetworks')
        cp_norm = section[1][50:60].strip()

        kt = integer(section[2][0:10], 'kt')
        if cp_norm:
            self.log.debug("nnetworks=%s cp_norm=%s" % (nnetworks, cp_norm))
        else:
            self.log.debug("nnetworks=%s" % (nnetworks))
        #print("nnetworks=%s cp_norm=%s" % (nnetworks, cp_norm))

        n = 3
        self.msg += '      kn,kt            %i          %i\n' % (nnetworks, kt)

        for unused_inetwork in range(nnetworks):
            #self.log.debug("lines[%s] = %s" % (n, section[n]))
            # 0-noDisplacement; 1-Specify
            ndisplacement = integer(section[n][0:10], 'ndisplacement')
            assert ndisplacement in [0, 1], section[n]
            n += 1

            #print("\nsection[n] = ", section[n].strip())
            nx_nr = integer(section[n][0:10], 'nx_nr')
            assert nx_nr > 0, section[n]
            #print("nxr = %s" % nxr)
            network_name = section[n][70:80]
            #self.log.debug("kt=%s nx_nr=%s ndisplacement=%s network_name=%s" %
                           #(kt, nx_nr, ndisplacement, network_name))

            nfull_lines = nx_nr // 3
            npartial_lines = int(ceil(nx_nr % 3 / 3.))
            nx_nr_lines = nfull_lines + npartial_lines
            #print("X,Rad - nfull_lines=%s npartial_lines=%s nx_nr_lines=%s\n" % (
                #nfull_lines, npartial_lines, nx_nr_lines))
            n += 1

            Xin = []
            R = []
            lines_full = section[n:n + nx_nr_lines]
            n += nx_nr_lines

            assert len(lines_full) == 7, len(lines_full)

            ipoint = 1
            for line in lines_full:
                if len(line[0:60].strip()) > 0:
                    x1 = double(line[0:10], 'x%i' % ipoint)
                    r1 = double(line[10:20], 'r%i' % ipoint)
                    Xin.append(x1)
                    R.append(r1)
                    ipoint += 1
                else:  # pragma: no cover
                    raise RuntimeError(line.rstrip())

                if len(line[20:60].strip()) > 0:
                    x2 = double(line[20:30], 'x%i' % ipoint)
                    r2 = double(line[30:40], 'r%i' % ipoint)
                    Xin.append(x2)
                    R.append(r2)
                    ipoint += 1

                if len(line[40:60].strip()) > 0:
                    x3 = double(line[40:50], 'x%i' % ipoint)
                    r3 = double(line[50:60], 'r%i' % ipoint)
                    Xin.append(x3)
                    R.append(r3)
                    ipoint += 1
            assert nx_nr == len(Xin), 'nx,nr=%s Xin=%s len(Xin)=%s' % (nx_nr, Xin, len(Xin))

            #----------------------------------------------------
            #print("section[n] = ", section[n].strip())
            ntheta = integer(section[n][0:10], 'ntheta')
            assert ntheta > 0, section[n]
            #print("ntheta = %s" % ntheta)
            nfull_lines = ntheta // 6
            npartial_lines = int(ceil(ntheta % 6 / 6.))
            ntheta_lines = nfull_lines + npartial_lines
            #print("Theta - nfull_lines=%s npartial_lines=%s nlines=%s" % (
            #    nfull_lines, npartial_lines, ntheta_lines))
            n += 1

            lines = section[n:n + ntheta_lines]
            theta = []

            ipoint = 1
            for line in lines:
                #print(line)
                if len(line[0:60].rstrip()) > 0:
                    (theta1) = double(line[0:10], 'theta%i' % ipoint)
                    theta.append(theta1)
                    ipoint += 1
                else:  # pragma: no cover
                    raise RuntimeError(line.rstrip())

                if len(line[0:60].rstrip()) > 0:
                    (theta2) = double(line[10:20], 'theta%i' % ipoint)
                    theta.append(theta2)
                    ipoint += 1

                if len(line[20:60].rstrip()) > 0:
                    (theta3) = double(line[20:30], 'theta%i' % ipoint)
                    theta.append(theta3)
                    ipoint += 1

                if len(line[30:60].rstrip()) > 0:
                    (theta4) = double(line[30:40], 'theta%i' % ipoint)
                    theta.append(theta4)
                    ipoint += 1

                if len(line[40:60].rstrip()) > 0:
                    (theta5) = double(line[40:50], 'theta%i' % ipoint)
                    theta.append(theta5)
                    ipoint += 1

                if len(line[50:60].rstrip()) > 0:
                    (theta6) = double(line[50:60], 'theta%i' % ipoint)
                    theta.append(theta6)
                    ipoint += 1
            n += ntheta_lines

            assert ntheta == len(theta)
            sin_theta_r = [sin(radians(thetai)) for thetai in theta]
            cos_theta_r = [cos(radians(thetai)) for thetai in theta]

            zi = 0.
            # TODO: can't we use numpy meshgrid?
            XYZ = np.zeros([nx_nr, ntheta, 3], dtype='float32')
            #print("Xin=%s \nR=%s" % (Xin, R))
            for (i, x, r) in zip(count(), Xin, R):
                for (j, sin_theta, cos_theta) in zip(count(), sin_theta_r, cos_theta_r):
                    y = r * sin_theta
                    z = r * cos_theta + zi
                    #print("x=%s y=%s z=%s" % (x, y, z))
                    XYZ[i, j, :] = [x, y, z]

            #print("--XYZ--")
            #print(xyz)
            self.add_patch(network_name, kt, cp_norm, XYZ)
        return True
Exemplo n.º 7
0
 def _read_data_check(self, section):
     self.data_check = integer(section[1][0:10], 'data_check')
     #self.data_check = 2
     return True