Ejemplo n.º 1
0
 def test_panair_io_02(self):
     model = PanairGrid(log=None, debug=False)
     msg = (
         '$circular sections - nacelle with composite panels\n'
         # =kn\n'
         '1.\n'
         # =kt\n'
         '1.\n'
         # =nopt                                                                 netname\n'
         '0.                                                                    cowlu\n'
         # =nm\n'
         '20.\n'
         # =xs(1)    ri(1)     xs(2)     ri(2)     xs(*)     ri(*)\n'
         '    2.0000    2.3000    1.5756    2.3000    1.1486    2.3000\n'
         '    0.7460    2.3030    0.4069    2.3286    0.1624    2.3790\n'
         '    0.0214    2.4542   -0.0200    2.5485    0.0388    2.6522\n'
         '    0.2056    2.7554    0.4869    2.8522    0.8883    2.9413\n'
         '    1.4250    3.0178    2.1188    3.0656    2.9586    3.0658\n'
         '    3.8551    3.0175    4.6715    2.9439    5.3492    2.8700\n'
         '    6.0000    2.7842    6.4687    2.7442\n'
         # =nn\n'
         '5.\n'
         # =th(1)    th(2)     th(3)     th(4)     th(5)\n'
         '-90.      -45.      0.        45.       90.\n')
     section = msg.split('\n')
     model._read_circular_section(section)
     model.write_panair('junk_circ.inp')
     os.remove('junk_circ.inp')
Ejemplo n.º 2
0
    def test_panair_io_03(self):
        """tests the SWB model"""
        log = get_logger(level='warning')
        in_filename = os.path.join(TEST_PATH, 'SWB', 'SWB.inp')
        #out_filename = os.path.join(TEST_PATH, 'M100', 'M100_out.inp')

        model = PanairGrid(log=log, debug=False)
        model.read_panair(in_filename)
        (points, elements, regions, kt, cp_nrom) = model.get_points_elements_regions()
        model.write_panair('junk_swb.inp')
        os.remove('junk_swb.inp')
Ejemplo n.º 3
0
    def test_panair_io_01(self):
        in_filename = os.path.join(test_path, 'M100', 'M100.inp')
        out_filename = os.path.join(test_path, 'M100', 'M100_out.inp')
        #with open(infile_name, 'w') as f:
            #f.write(lines)

        model = PanairGrid(log=None, debug=False)
        model.read_panair(in_filename)
        #assert len(cart3d.points) == 7, 'npoints=%s' % len(cart3d.points)
        #assert len(cart3d.elements) == 6, 'nelements=%s' % len(cart3d.elements)
        #assert len(cart3d.regions) == 6, 'nregions=%s' % len(cart3d.regions)
        #assert len(cart3d.loads) == 0, 'nloads=%s' % len(cart3d.loads)
        model.write_panair(out_filename)
        (points, elements, regions, kt, cp_nrom) = model.get_points_elements_regions()
        os.remove(out_filename)
Ejemplo n.º 4
0
    def test_panair_io_01(self):
        log = get_logger(level='warning')
        in_filename = os.path.join(test_path, 'M100', 'M100.inp')
        out_filename = os.path.join(test_path, 'M100', 'M100_out.inp')
        #with open(infile_name, 'w') as f:
        #f.write(lines)

        model = PanairGrid(log=log, debug=False)
        model.read_panair(in_filename)
        #assert len(cart3d.points) == 7, 'npoints=%s' % len(cart3d.points)
        #assert len(cart3d.elements) == 6, 'nelements=%s' % len(cart3d.elements)
        #assert len(cart3d.regions) == 6, 'nregions=%s' % len(cart3d.regions)
        #assert len(cart3d.loads) == 0, 'nloads=%s' % len(cart3d.loads)
        model.write_panair(out_filename)
        (points, elements, regions, kt,
         cp_nrom) = model.get_points_elements_regions()
        os.remove(out_filename)
Ejemplo n.º 5
0
    def test_panair_io_01(self):
        """test the M100 model"""
        log = get_logger(level='warning')
        in_filename = os.path.join(TEST_PATH, 'M100', 'M100.inp')
        out_filename = os.path.join(TEST_PATH, 'M100', 'M100_out.inp')
        #with open(infile_name, 'w') as f:
            #f.write(lines)

        model = PanairGrid(log=log, debug=False)
        model.read_panair(in_filename)
        model.write_panair(out_filename)
        (points, elements, regions, kt, cp_nrom) = model.get_points_elements_regions()

        model.write_panair('junk_m100.inp')
        os.remove('junk_m100.inp')
        model.print_options()
        model.print_abutments()
        model.print_grid_summary()
        model.print_out_header()
        os.remove(out_filename)
Ejemplo n.º 6
0
    def write_panair(self, panair_filename, panair_case_filename):
        pan = PanairGrid()
        pan.mach = 0.5
        pan.is_end = True
        pan.ncases = 2
        pan.alphas = [0., 5.]

        i = 0
        pan.nNetworks = 1
        kt = 1
        cp_norm = 1
        for name, comps in sorted(self.components.items()):
            #panair_file.write('$ name = %r\n' % name)
            for comp in comps:
                str(comp)
                namei = name + str(i)
                # lifting_surface_xyz, lifting_surface_nx, lifting_surface_ny
                x = deepcopy(comp.xyz[:, 0])
                y = deepcopy(comp.xyz[:, 1])
                z = deepcopy(comp.xyz[:, 2])
                x = x.reshape((comp.nx, comp.ny))
                y = y.reshape((comp.nx, comp.ny))
                z = z.reshape((comp.nx, comp.ny))

                xyz = np.dstack([x, y, z])
                assert xyz.shape[2] == 3
                patch = PanairPatch(pan.nNetworks, namei, kt, cp_norm, xyz, self.log)
                pan.patches[i] = patch
                pan.nNetworks += 1
                i += 1

                if 'wing' in name.lower():  # make a wing cap
                    namei = 'cap%i' % i
                    #assert comp.lifting_surface_nx == 6, comp.lifting_surface_nx
                    assert comp.ny == 33, comp.ny
                    #print(x.shape)
                    xend = deepcopy(x[-1, :])
                    #print(xend)
                    yend = deepcopy(y[-1, :])
                    zend = deepcopy(z[-1, :])
                    imid = comp.ny // 2
                    x = np.zeros((imid+1, 2), dtype='float32')
                    y = np.zeros((imid+1, 2), dtype='float32')
                    z = np.zeros((imid+1, 2), dtype='float32')
                    #print(imid, xend[imid], xend.min())
                    xflip = list(xend[0:imid+1])
                    yflip = list(yend[0:imid+1])
                    zflip = list(zend[0:imid+1])
                    x[:, 0] = xflip[::-1]
                    y[:, 0] = yflip[::-1]
                    z[:, 0] = zflip[::-1]
                    x[:, 1] = xend[imid:]
                    y[:, 1] = yend[imid:]
                    z[:, 1] = zend[imid:]
                    #print(x)

                    #x = xend[0:imid:-1].extend(x[imid:])
                    #y = yend[0:imid:-1].extend(y[imid:])
                    #z = zend[0:imid:-1].extend(z[imid:])
                    #print(x)
                    x = x.reshape((2, imid+1))
                    y = y.reshape((2, imid+1))
                    z = z.reshape((2, imid+1))

                    #print(xend)
                    xyz = np.dstack([x, y, z])
                    assert xyz.shape[2] == 3
                    patch = PanairPatch(pan.nNetworks, namei, kt, cp_norm,
                                        xyz, self.log)
                    pan.patches[i] = patch
                    pan.nNetworks += 1
                    i += 1
                #i += 1
        pan.write_panair(panair_filename)
Ejemplo n.º 7
0
    def write_panair(self, panair_filename, panair_case_filename):
        #panair_file = open(panair_filename, 'wb')
        pan = PanairGrid()
        pan.mach = 0.5
        pan.isEnd = True
        pan.ncases = 2
        pan.alphas = [0., 5.]


        i = 0
        pan.nNetworks = 1
        kt = 1
        cpNorm = 1
        for name, comps in sorted(iteritems(self.components)):
            #panair_file.write('$ name = %r\n' % name)
            for comp in comps:
                namei = name + str(i)
                x = deepcopy(comp.lifting_surface_xyz[:, 0])
                y = deepcopy(comp.lifting_surface_xyz[:, 1])
                z = deepcopy(comp.lifting_surface_xyz[:, 2])
                x = x.reshape((comp.lifting_surface_nx, comp.lifting_surface_ny))
                y = y.reshape((comp.lifting_surface_nx, comp.lifting_surface_ny))
                z = z.reshape((comp.lifting_surface_nx, comp.lifting_surface_ny))
                patch = PanairPatch(pan.nNetworks, namei, kt, cpNorm, x, y, z, self.log)
                pan.patches[i] = patch
                pan.nNetworks += 1
                i += 1

                if 'wing' in name.lower():  # make a wing cap
                    namei = 'cap%i' % i
                    #assert comp.lifting_surface_nx == 6, comp.lifting_surface_nx
                    assert comp.lifting_surface_ny == 33, comp.lifting_surface_ny
                    #print(x.shape)
                    xend = deepcopy(x[-1, :])
                    print(xend)
                    yend = deepcopy(y[-1, :])
                    zend = deepcopy(z[-1, :])
                    imid = comp.lifting_surface_ny // 2
                    x = np.zeros((imid+1, 2), dtype='float32')
                    y = np.zeros((imid+1, 2), dtype='float32')
                    z = np.zeros((imid+1, 2), dtype='float32')
                    print(imid, xend[imid], xend.min())
                    xflip = list(xend[0:imid+1])
                    yflip = list(yend[0:imid+1])
                    zflip = list(zend[0:imid+1])
                    x[:, 0] = xflip[::-1]
                    y[:, 0] = yflip[::-1]
                    z[:, 0] = zflip[::-1]
                    x[:, 1] = xend[imid:]
                    y[:, 1] = yend[imid:]
                    z[:, 1] = zend[imid:]
                    print (x)

                    #x = xend[0:imid:-1].extend(x[imid:])
                    #y = yend[0:imid:-1].extend(y[imid:])
                    #z = zend[0:imid:-1].extend(z[imid:])
                    #print(x)
                    x = x.reshape((2, imid+1))
                    y = y.reshape((2, imid+1))
                    z = z.reshape((2, imid+1))

                    #print(xend)
                    patch = PanairPatch(pan.nNetworks, namei, kt, cpNorm, x.T, y.T, z.T, self.log)
                    pan.patches[i] = patch
                    pan.nNetworks += 1
                    i += 1
                #i += 1
        pan.write_panair(panair_filename)