0% found this document useful (0 votes)
2 views1 page

Cylinder Flow: Velocity & Stream Functions

The document contains a Python script that calculates the velocity potential and stream function for flow around a cylinder using complex potential functions. It defines functions to compute these values based on user inputs for uniform velocity, cylinder radius, and coordinates. The results are then printed to the console.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views1 page

Cylinder Flow: Velocity & Stream Functions

The document contains a Python script that calculates the velocity potential and stream function for flow around a cylinder using complex potential functions. It defines functions to compute these values based on user inputs for uniform velocity, cylinder radius, and coordinates. The results are then printed to the console.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Problem 1.

import cmath

# Complex potential function for flow around a cylinder

def complex_potential_cylinder(z, U, a):

return U * (z + (a**2 / z))

def velocity_potential_cylinder(z, U, a):

return complex_potential_cylinder(z, U, a).real

def stream_function_cylinder(z, U, a):

return complex_potential_cylinder(z, U, a).imag

# Inputs

U = float(input("Enter the uniform velocity (U): "))

a = float(input("Enter the radius of the cylinder (a): "))

x = float(input("Enter the x-coordinate: "))

y = float(input("Enter the y-coordinate: "))

z = complex(x, y)

# Calculate and display results

φ_cylinder = velocity_potential_cylinder(z, U, a)

ψ_cylinder = stream_function_cylinder(z, U, a)

print(f"Velocity Potential (φ): {φ_cylinder}")

print(f"Stream Function (ψ): {ψ_cylinder}")

You might also like