class TestCell(unittest.TestCase): def setUp(self, numpoints=100): self.prof1 = Profile2D.compute_naca(1223) self.prof2 = Profile2D.compute_naca(1223) for prof in [self.prof1, self.prof2]: naca = random.randint(1, 1399) #prof.compute_naca(naca=1223, numpoints=numpoints) prof.close() prof.normalize() self.ballooning = BallooningBezier() self.rib2 = Rib(self.prof1, self.ballooning, [0., 0.12, 0], 1., 20 * math.pi / 180, 2 * math.pi / 180, 0, 7.) self.rib3 = Rib(self.prof2, self.ballooning, [0.2, 0.3, -0.1], 0.8, 30 * math.pi / 180, 5 * math.pi / 180, 0, 7.) self.rib1 = self.rib2.copy() self.rib1.mirror() self.cell1 = Cell(self.rib1, self.rib2) self.cell2 = Cell(self.rib2, self.rib3) def test_show_cell(self, num=10): #print(self.rib1.profile_2d.x_values) ribs = [self.cell1.midrib(x * 1. / num) for x in range(num)] ribs += [self.cell2.midrib(x * 1. / num) for x in range(num)] Graph.Graphics([Graph.Line(x.data) for x in ribs] + [Graph.Line(self.rib1.profile_3d.data)]) def test_mirror(self): cell1 = self.cell2 cell2 = self.cell2.copy() cell2.mirror() print(cell1._basic_cell.normvectors) print([[p, normvector] for p, normvector in zip( cell1.prof2.data, cell1._basic_cell.normvectors)]) Graph.Graphics([ Graph.Line(cell1.rib1.profile_3d.data), Graph.Line(cell2.rib1.profile_3d.data), Graph.Red, Graph.Line(cell1.prof2.data), Graph.Line(cell2.prof2.data), Graph.Green ] + [ Graph.Line([p, p + normvector]) for p, normvector in zip( cell2.prof2.data, cell2.basic_cell.normvectors) ])
class TestCell(unittest.TestCase): def setUp(self, numpoints=100): self.prof1 = Profile2D.compute_naca(1223) self.prof2 = Profile2D.compute_naca(1223) for prof in [self.prof1, self.prof2]: naca = random.randint(1, 1399) # prof.compute_naca(naca=1223, numpoints=numpoints) prof.close() prof.normalize() self.ballooning = BallooningBezier() self.rib2 = Rib(self.prof1, self.ballooning, [0.0, 0.12, 0], 1.0, 20 * math.pi / 180, 2 * math.pi / 180, 0, 7.0) self.rib3 = Rib( self.prof2, self.ballooning, [0.2, 0.3, -0.1], 0.8, 30 * math.pi / 180, 5 * math.pi / 180, 0, 7.0 ) self.rib1 = self.rib2.copy() self.rib1.mirror() self.cell1 = Cell(self.rib1, self.rib2) self.cell2 = Cell(self.rib2, self.rib3) def test_show_cell(self, num=10): # print(self.rib1.profile_2d.x_values) ribs = [self.cell1.midrib(x * 1.0 / num) for x in range(num)] ribs += [self.cell2.midrib(x * 1.0 / num) for x in range(num)] Graph.Graphics([Graph.Line(x.data) for x in ribs] + [Graph.Line(self.rib1.profile_3d.data)]) def test_mirror(self): cell1 = self.cell2 cell2 = self.cell2.copy() cell2.mirror() print(cell1._basic_cell.normvectors) print([[p, normvector] for p, normvector in zip(cell1.prof2.data, cell1._basic_cell.normvectors)]) Graph.Graphics( [ Graph.Line(cell1.rib1.profile_3d.data), Graph.Line(cell2.rib1.profile_3d.data), Graph.Red, Graph.Line(cell1.prof2.data), Graph.Line(cell2.prof2.data), Graph.Green, ] + [Graph.Line([p, p + normvector]) for p, normvector in zip(cell2.prof2.data, cell2.basic_cell.normvectors)] )
r1 = r2.copy() r1.mirror() r3 = Rib(a, b2, [0.2, 0.3, -0.1], 0.8, 30 * math.pi / 180, 5 * math.pi / 180, 0, 7) cell1 = Cell(r1, r2, midribs) cell1.recalc() cell2 = Cell(r2, r3, []) cell2.recalc() num = 20 #ribs = [cell1.midrib(x*1./num) for x in range(num+1)] #ribs += [cell2.midrib(x*1./num) for x in range(num+1)] #G.Graphics3D([G.Line(r1.profile_3d.data),G.Line(r2.profile_3d.data),G.Line([[0.,0.,0.],[1.,0.,0.]]),G.Line([[0.,0.,0.],[0.,0.5,0.]])]) #Graph.Graphics3D([Graph.Line(x.data) for x in ribs]) ribs = [] for x in range(num + 1): ribs.append(cell1.midrib(x * 1. / num).data) for x in range(1, num + 1): ribs.append(cell2.midrib(x * 1. / num).data) ribs = numpy.concatenate(ribs) polygons = [] points = a.numpoints for i in range(2 * num): for j in range(points - 1): polygons.append( Graph.Polygon([i * points + j, i * points + j + 1, (i + 1) * points + j + 1, (i + 1) * points + j])) polygons.append(Graph.Axes(size=0.3)) Graph.Graphics3D(polygons, ribs)
r1.mirror() r3 = Rib(a, b2, [0.2, 0.3, -0.1], 0.8, 30 * math.pi / 180, 5 * math.pi / 180, 0, 7) cell1 = Cell(r1, r2, midribs) cell1.recalc() cell2 = Cell(r2, r3, []) cell2.recalc() num = 20 # ribs = [cell1.midrib(x*1./num) for x in range(num+1)] # ribs += [cell2.midrib(x*1./num) for x in range(num+1)] # G.Graphics3D([G.Line(r1.profile_3d.data),G.Line(r2.profile_3d.data),G.Line([[0.,0.,0.],[1.,0.,0.]]),G.Line([[0.,0.,0.],[0.,0.5,0.]])]) # Graph.Graphics3D([Graph.Line(x.data) for x in ribs]) ribs = [] for x in range(num + 1): ribs.append(cell1.midrib(x * 1.0 / num).data) for x in range(1, num + 1): ribs.append(cell2.midrib(x * 1.0 / num).data) ribs = numpy.concatenate(ribs) polygons = [] points = a.numpoints for i in range(2 * num): for j in range(points - 1): polygons.append( Graph.Polygon([i * points + j, i * points + j + 1, (i + 1) * points + j + 1, (i + 1) * points + j]) ) polygons.append(Graph.Axes(size=0.3)) Graph.Graphics3D(polygons, ribs)