Python - Distance to Shock/Mach Diamond
by matt392 in Circuits > Software
43 Views, 1 Favorites, 0 Comments
Python - Distance to Shock/Mach Diamond
print ("This program will calculate the distance from the nozzle to the first Shock/Mach Diamond.") import math ### Formula for calculating the the distance from the nozzle to the first Shock/Mach Diamond: # Ditance = (.67 * NozzleDiameter) * sqrt((FlowPressure/AtmosphericPressure)) ########################################### # Enter the NozzleDiameter, FlowPressure, AtmosphericPressure def SolveForDistanceNozzleToShockDiamond(): print ("Solving for the the distance.") # Enter the Nozzle Diameter NozzleDiameter = float(input("Enter the nozzle diameter in meters: ") ) # Enter the flow pressure FlowPressure = float(input("Enter the flow pressure: ") ) # Enter the Atmospheric Pressure AtmosphericPressure = float(input("Enter the atmospheric pressure: ") ) # Calculate the fraction FractionCalculated = (FlowPressure/AtmosphericPressure) print("The fraction is: ", FractionCalculated) # Calculate the square root SquareRootOfFraction = math.sqrt(FractionCalculated) print("The square root of the fraction is: ", SquareRootOfFraction) # Calculate the left side of the equation LeftSideOfEquation = (.67 * NozzleDiameter) print("The left side of the equation is: ", LeftSideOfEquation) # Multiply both sides together to get distance Distance = LeftSideOfEquation * SquareRootOfFraction print("The distance from the nozzle to the Shock Diamond is: ", Distance, " meters.") ContinueCalculations = "y" # Check to see if the user wants to continue to calculate the distance while (ContinueCalculations=="y"): SolveForDistanceNozzleToShockDiamond() ContinueCalculations = input("Would like to do another calculation for the distance from the nozzle to the shock diamond? (y/n): ") print("==================================") print ("Thank you to www.fxsolver.com for assistance with this formula.")