Here’s a Python program that simulates Bernoulli’s equation:
pythonCopy codeimport math
# Define fluid properties and flow conditions
rho = 1000 # density of water in kg/m^3
v1 = 5 # velocity of fluid at point 1 in m/s
p1 = 100000 # pressure of fluid at point 1 in Pa
g = 9.81 # acceleration due to gravity in m/s^2
h = 10 # height difference between point 1 and point 2 in m
# Calculate velocity and pressure at point 2
v2 = math.sqrt((2*g*h) + ((p1 - 0.5*rho*(v1**2))/rho))
p2 = p1 + (0.5*rho*(v1**2)) - (0.5*rho*(v2**2))
# Print results
print("Velocity at point 2 = %.2f m/s" % v2)
print("Pressure at point 2 = %.2f Pa" % p2)
In this program, we first define the fluid properties and flow conditions, including the density of the fluid (water), the velocity and pressure at point 1, the acceleration due to gravity, and the height difference between point 1 and point 2. We then use Bernoulli’s equation to calculate the velocity and pressure at point 2, based on the conservation of energy principle.
Finally, we print the results to the console, showing the velocity and pressure at point 2 in meters per second (m/s) and Pascals (Pa), respectively.
Note that this program assumes a constant density for the fluid, which is not always the case in real-world scenarios. Additionally, this program only simulates a simple case of Bernoulli’s equation, and more complex scenarios may require additional calculations or numerical methods.