vel1 = [(i[0]**2 + i[1]**2)**(0.5) for i in velocity] pot = list(map(case.off_body_potential, _grid)) with open(check_path("results/coordinates_not_aligned/field.vtk"), "w") as _file: writer = VtkWriter() writer.structed_grid(_file, "airfoil", [nx, ny, 1]) writer.points(_file, grid) writer.data(_file, velocity, name="velocity", _type="VECTORS", data_type="POINT_DATA") writer.data(_file, pot, name="pot", _type="SCALARS", data_type="POINT_DATA") writer.data(_file, vel1, name="vel", _type="SCALARS", data_type="POINT_DATA") with open(check_path("results/coordinates_not_aligned/airfoil.vtk"), "w") as _file: writer = VtkWriter() writer.unstructed_grid(_file, "airfoil") writer.points(_file, [[i[0], i[1], 0] for i in coordiantes]) writer.lines(_file, [range(len(coordiantes))])
nx = 200 ny = 200 space_x = np.linspace(-0.2, 1.5, nx) space_y = np.linspace(-0.5, 0.5, ny) grid = [paraBEM.Vector2(x, y) for y in space_y for x in space_x] velocity = list(map(case.off_body_velocity, grid)) pot = list(map(case.off_body_potential, grid)) with open(check_path("results/airfoil_2d_linear/field.vtk"), "w") as _file: writer = VtkWriter() writer.structed_grid(_file, "airfoil", [nx, ny, 1]) writer.points(_file, grid) writer.data(_file, velocity, name="velocity", _type="VECTORS", data_type="POINT_DATA") writer.data(_file, pot, name="pot", _type="SCALARS", data_type="POINT_DATA") with open(check_path("results/airfoil_2d_linear/shape.vtk"), "w") as _file: writer = VtkWriter() writer.unstructed_grid(_file, "airfoil") writer.points(_file, [[i[0], i[1], 0] for i in airfoil.coordinates]) writer.lines(_file, [range(len(airfoil.coordinates))])
panels.append(paraBEM.Panel2([points[-1], points[0]])) # panelmethode case = Case(panels) case.v_inf = paraBEM.Vector2(1, 0.3) case.run() # plt.plot(np.array(case.matrix.values).T) # # plt.show() nx = 200 ny = 200 space_x = np.linspace(-0.2, 1.5, nx) space_y = np.linspace(-0.5, 0.5, ny) grid = [paraBEM.Vector2(x, y) for y in space_y for x in space_x] velocity = list(map(case.off_body_velocity, grid)) pot = list(map(case.off_body_potential, grid)) with open(check_path("results/airfoil_2d_linear/field.vtk"), "w") as _file: writer = VtkWriter() writer.structed_grid(_file, "airfoil", [nx, ny, 1]) writer.points(_file, grid) writer.data(_file, velocity, name="velocity", _type="VECTORS", data_type="POINT_DATA") writer.data(_file, pot, name="pot", _type="SCALARS", data_type="POINT_DATA") with open(check_path("results/airfoil_2d_linear/shape.vtk"), "w") as _file: writer = VtkWriter() writer.unstructed_grid(_file, "airfoil") writer.points(_file, [[i[0], i[1], 0]for i in airfoil.coordinates]) writer.lines(_file, [range(len(airfoil.coordinates))])
nx = 100 ny = 100 space_x = np.linspace(-2, 2, nx) space_y = np.linspace(-2, 2, ny) grid = [paraBEM.Vector2(x, y) for y in space_y for x in space_x] velocity = list(map(case.off_body_velocity, grid)) pot = list(map(case.off_body_potential, grid)) with open(check_path("results/cylinder_2d_linear/field.vtk"), "w") as _file: writer = VtkWriter() writer.structed_grid(_file, "airfoil", [nx, ny, 1]) writer.points(_file, grid) writer.data(_file, velocity, name="velocity", _type="VECTORS", data_type="POINT_DATA") writer.data(_file, pot, name="pot", _type="SCALARS", data_type="POINT_DATA") with open(check_path("results/cylinder_2d_linear/shape.vtk"), "w") as _file: writer = VtkWriter() writer.unstructed_grid(_file, "airfoil") writer.points(_file, [[i[0], i[1], 0] for i in vector]) writer.lines(_file, [range(len(vector))])
case = Case(airfoil.panels) case.v_inf = Vector2(np.cos(alpha), np.sin(alpha)) case.run() print(np.array(case.matrix.values)) nx = 300 ny = 300 space_x = np.linspace(-1, 2, nx) space_y = np.linspace(-0.2, 0.2, ny) vec = lambda x: paraBEM.Vector2(x[0], x[1]) vec3 = lambda x: [x[0], x[1], 0] grid = [paraBEM.Vector2(x, y) for y in space_y for x in space_x] velocity = list(map(vec3, map(case.off_body_velocity, grid))) vel1 = [(i[0]**2 + i[1]**2)**(0.5) for i in velocity] pot = list(map(case.off_body_potential, grid)) with open(check_path("results/neumann/field.vtk"), "w") as _file: writer = VtkWriter() writer.structed_grid(_file, "airfoil", [nx, ny, 1]) writer.points(_file, grid) writer.data(_file, velocity, name="velocity", _type="VECTORS", data_type="POINT_DATA") writer.data(_file, pot, name="pot", _type="SCALARS", data_type="POINT_DATA") writer.data(_file, vel1, name="vel", _type="SCALARS", data_type="POINT_DATA") with open(check_path("results/neumann/airfoil.vtk"), "w") as _file: writer = VtkWriter() writer.unstructed_grid(_file, "airfoil") writer.points(_file, [list(i.points[0]) + [0] for i in case.panels]) writer.lines(_file, [range(len(case.panels))])
# ---------------------------------------------------------- with open(check_path("results/conformal_mapping/joukowsky_z.vtk"), "w") as _file: writer = VtkWriter() writer.structed_grid(_file, "z_plane", [num_x, num_y, 1]) writer.points(_file, list(map(complex_to_3vec, z_grid))) writer.data(_file, z_stream, name="stream", _type="SCALARS", data_type="POINT_DATA") writer.data(_file, z_pot, name="pot", _type="SCALARS", data_type="POINT_DATA") writer.data(_file, z_vel, name="velocity", _type="VECTORS", data_type="POINT_DATA") with open(check_path("results/conformal_mapping/joukowsky_zeta.vtk"), "w") as _file: writer = VtkWriter() writer.structed_grid(_file, "zeta_plane", [num_x, num_y, 1]) writer.points(_file, list(map(complex_to_3vec, zeta_grid))) writer.data(_file, zeta_stream, name="stream", _type="SCALARS", data_type="POINT_DATA") writer.data(_file, zeta_pot, name="pot", _type="SCALARS", data_type="POINT_DATA") writer.data(_file, zeta_vel, name="velocity", _type="VECTORS", data_type="POINT_DATA") with open(check_path("results/conformal_mapping/joukowsky_circle.vtk"), "w") as _file: writer = VtkWriter() writer.unstructed_grid(_file, "circle") writer.points(_file, circle) writer.lines(_file, [range(len(circle))]) with open(check_path("results/conformal_mapping/joukowsky_airfoil.vtk"), "w") as _file: writer = VtkWriter() writer.unstructed_grid(_file, "airfoil") writer.points(_file, airfoil) writer.lines(_file, [range(len(airfoil))])
airfoil = list(map(complex_to_3vec, airfoil.coordinates())) # ---------------------------------------------------------- with open(check_path("results/conformal_mapping/vandevooren_zeta.vtk"), "w") as _file: writer = VtkWriter() writer.structed_grid(_file, "zeta_plane", [num_x, num_y, 1]) writer.points(_file, list(map(complex_to_3vec, z_to_zeta))) writer.data(_file, zeta_stream, name="stream", _type="SCALARS", data_type="POINT_DATA") writer.data(_file, zeta_pot, name="pot", _type="SCALARS", data_type="POINT_DATA") writer.data(_file, zeta_vel, name="velocity", _type="VECTORS", data_type="POINT_DATA") with open(check_path("results/conformal_mapping/vandevooren_airfoil.vtk"), "w") as _file: writer = VtkWriter() writer.unstructed_grid(_file, "airfoil") writer.points(_file, airfoil) writer.lines(_file, [range(len(airfoil))])
vector = [paraBEM.PanelVector2(*i) for i in xy] vector += [vector[0]] # important for calculating the gradients panels = [paraBEM.Panel2([vec, vector[i+1]]) for i, vec in enumerate(vector[:-1])] vector[0].wake_vertex = True # setting up the case case = Case(panels) case.v_inf = paraBEM.Vector2(1, 0.5) case.run() nx = 100 ny = 100 space_x = np.linspace(-2, 2, nx) space_y = np.linspace(-2, 2, ny) grid = [paraBEM.Vector2(x, y) for y in space_y for x in space_x] velocity = list(map(case.off_body_velocity, grid)) pot = list(map(case.off_body_potential, grid)) with open(check_path("results/cylinder_2d_linear/field.vtk"), "w") as _file: writer = VtkWriter() writer.structed_grid(_file, "airfoil", [nx, ny, 1]) writer.points(_file, grid) writer.data(_file, velocity, name="velocity", _type="VECTORS", data_type="POINT_DATA") writer.data(_file, pot, name="pot", _type="SCALARS", data_type="POINT_DATA") with open(check_path("results/cylinder_2d_linear/shape.vtk"), "w") as _file: writer = VtkWriter() writer.unstructed_grid(_file, "airfoil") writer.points(_file, [[i[0], i[1], 0]for i in vector]) writer.lines(_file, [range(len(vector))])