Beispiel #1
0
def spm_geometry_and_inside_outside_test():
    # # Write your own path here
    # path = r'C:\Users\User\Documents\python\aero\airfoils_data'
    # # Airfoil name
    # name = 'ua79sff.txt'
    # test_fig = figure.Airfoil(name, path)

    test_fig = figure.Circle(10, num_points=20)
    # test_fig = figure.Ellipse(10, 5, num_points=50)
    # test_fig = figure.Square(10, num_points=50)
    # test_fig = figure.Rectangle(10, 5, num_points=50)
    # test_fig = figure.Triangle((0, 0), (6, 0), (3, 3))
    # test_fig = figure.Triangle((0, 0), (0, 6), (3, 3))
    # test_fig = figure.Triangle((0, 0), (6, 3), (3, 4))
    # test_fig = figure.Polygon('Polygon',
    #                           [(1, 1), (2, 2), (3, 3),
    #                            (2, 3), (2, 4), (1, 4), (0, 3)])
    # test_fig = figure.Ogive(2, 1, 5)
    geometry = Geometry(test_fig, 1)
    x0, y0, dx, dy = test_fig.rect
    grid = figure.Grid(x0, y0,
                       1.5 * dx, 1.5 * dy, 20)
    plt = Plot(grid)
    plt.plot_figure(test_fig)
    plt.plot_source_panel_method(geometry)

    for x in grid.x:
        for y in grid.y:
            res = test_fig.is_inside(x, y)
            if not res:
                plt.plot_point(x, y, '.y')

    plt.show()
Beispiel #2
0
def circle_pressure_coef_spm_test():
    circle = figure.Circle(10, num_points=100)
    spm = SPMCircle(circle, 1.0)

    grid = figure.Grid(np.pi, -1.0, 2.0 * np.pi, 4.0)
    plt = Plot(grid)
    tetta = np.linspace(0.0, 2.*np.pi, 360)
    cp = 1. - 4. * (np.sin(tetta) ** 2)
    analytic_coef = figure.Figure('Pressure coef', tetta, cp)
    plt.plot_figure(analytic_coef)

    spm_coef = figure.Figure('Spm coef', spm.geometry.angle_cp, spm.surface_cp)
    plt.plot_figure(spm_coef, '*b')

    plt.show()
Beispiel #3
0
def circulation_flow_figure_test() -> None:
    """
    This test shows example of how circulation
    can be calculated for different shapes and
    for given flow.
    """
    # Make grid for plot
    grid = figure.Grid(0, 0, 20, 20)

    # Create flow
    lift_flow = flow.LiftingCylinderFlow(vel=2, kappa=5, gamma=15)

    # Calculate velocities in the given points of the grid
    lift_flow.set_grid(grid)

    # Init plot
    plt = Plot(grid)

    # Create figures
    ellipse = figure.Ellipse(8.0, 1.0, 0.0, -7.0)
    circle = figure.Circle(2.0)
    square = figure.Square(4.0, 6.0, 5.0, num_points=360)
    triangle = figure.Triangle((-3.0, 3.0), (-8.0, 3.0), (-5.5, 8.0))

    # Draw the flow's streamlines and the figures
    plt.plot_stream_line(lift_flow)
    plt.plot_figure(ellipse)
    plt.plot_figure(circle)
    plt.plot_figure(square)
    plt.plot_figure(triangle)

    # Calculate circulations inside the given figures
    el_gamma = Circulation.circulation(grid, lift_flow, ellipse)
    ci_gamma = Circulation.circulation(grid, lift_flow, circle)
    sq_gamma = Circulation.circulation(grid, lift_flow, square)
    tr_gamma = Circulation.circulation(grid, lift_flow, triangle)

    # Draw text
    plt.plot_text(ellipse.center, '{:.02f}'.format(el_gamma))
    plt.plot_text(circle.center, '{:.02f}'.format(ci_gamma))
    plt.plot_text(square.center, '{:.02f}'.format(sq_gamma))
    plt.plot_text(triangle.center, '{:.02f}'.format(tr_gamma))

    # Show the plot
    plt.show()
Beispiel #4
0
def grid_source_panel_method_test():
    fgr = figure.Circle(10, num_points=180)
    # fgr = figure.Ellipse(10, 5, num_points=100)
    # fgr = figure.Square(10, num_points=100)
    # fgr = figure.Rectangle(10, 5, num_points=100)
    # fgr = figure.Triangle((0, 0), (6, 0), (3, 3))
    # fgr = figure.Ogive(2, 1, 5)

    spm = SourcePanelMethod(fgr, 1)

    grid = figure.Grid(0.0, 0.0, 30.0, 30.0, 30)
    plt = Plot(grid)

    spm.set_grid(grid)

    plt.plot_filled_figure(fgr)
    plt.plot_stream_line(spm)
    # plt.plot_flow(spm)
    # plt.plot_contour(spm)

    plt.show()
Beispiel #5
0
        dc = wx.ClientDC(self)
        dc.DrawLine(line.begin(), line.end())
        return 0

    def resize(self):
        self.SetSize((300, 400))

    def draw_circle(self, circle):
        dc = wx.ClientDC(self)
        dc.SetPen(wx.Pen(wx.Colour(0, 12, 56)))
        dc.DrawPointList(circle)

        dc.SetBrush(wx.Brush('#785f36'))
        dc.DrawRectangle(250, 195, 90, 60)

    # def max(self):
    #     self.ShowFullScreen(True)


if __name__ == '__main__':
    point1 = (50, 60)
    point2 = (50, 90)
    line = figure.Line(point1, point2)
    app = wx.App()
    e = Example()
    e.draw_line(line)
    circle = figure.Circle((0, 0), 50)
    points = circle.points()
    e.draw_circle(points)
    app.MainLoop()