Python - Poiseuille's Law (Airway Resistance)
by matt392 in Circuits > Software
93 Views, 1 Favorites, 0 Comments
Python - Poiseuille's Law (Airway Resistance)
print ("This program will calculate airway resistance in a person using Poiseuille's Law.") import math # Airway resistance in a person using Poiseuille Equation: # Airway resistance = [(8 * dynamic viscosity) * length]/[pi * (radius of pipe**4)] ########################################### # 1 function: solve for airway resistance # Function to solve for airway resistance # Solve for resistance: enter dynamic viscosity, length, radius # Airway resistance = [(8 * dynamic viscosity) * length]/[math.pi * (radius of pipe**4)] def SolveForAirwayResistance(): print ("Solving for airway resistance") # The pi variable is coming from Python's constant: math.pi pi = math.pi DynamicViscosity = float(input("Enter the dynamic viscosity: ") ) Length = float(input("Enter the length of the airway: ") ) Radius = float(input("Enter the radius of the airway: ") ) AirwayResistance = ( (8 * DynamicViscosity) * Length)/(pi * (Radius**4) ) print("The airway resistance is:", AirwayResistance) ContinueCalculations = "y" # Check to see if the user wants to continue to calculate airway resistance while (ContinueCalculations=="y"): SolveForAirwayResistance() ContinueCalculations = input("Would like to do another calculation for airway resistance? (y/n): ") print("==================================") print ("Thank you to www.FxSolver.com for information on this formula.")