OrganPipe: Offer multiple units for the pressure given

This commit is contained in:
Florian Festi 2018-05-18 14:12:30 +02:00
parent 924372f79d
commit 6538c92910
1 changed files with 12 additions and 0 deletions

View File

@ -23,6 +23,12 @@ from math import *
pitches = ['c', 'c#', 'd', 'd#', 'e', 'f', 'f#', 'g', 'g#', 'a', 'a#' ,'b'] pitches = ['c', 'c#', 'd', 'd#', 'e', 'f', 'f#', 'g', 'g#', 'a', 'a#' ,'b']
pressure_units = { 'Pa' : 1.0,
'mBar' : 100.,
'mmHg' : 133.322,
'mmH2O' : 9.80665,
}
class OrganPipe(Boxes): # Change class name! class OrganPipe(Boxes): # Change class name!
"""Rectangular organ pipe based on pipecalc""" """Rectangular organ pipe based on pipecalc"""
@ -70,6 +76,10 @@ class OrganPipe(Boxes): # Change class name!
help=u"Distance in halftones in the Normalmensur by Töpfer") help=u"Distance in halftones in the Normalmensur by Töpfer")
self.argparser.add_argument( self.argparser.add_argument(
"--windpressure", action="store", type=float, default=588.4, "--windpressure", action="store", type=float, default=588.4,
help="uses unit selected below")
self.argparser.add_argument(
"--windpressure_units", action="store", type=str, default='Pa',
choices=pressure_units.keys(),
help="in Pa") help="in Pa")
self.argparser.add_argument( self.argparser.add_argument(
"--stopped", action="store", type=boolarg, default=False, "--stopped", action="store", type=boolarg, default=False,
@ -80,6 +90,8 @@ class OrganPipe(Boxes): # Change class name!
t = self.thickness t = self.thickness
f = self.getFrequency(self.pitch, self.octave, 440) f = self.getFrequency(self.pitch, self.octave, 440)
self.windpressure *= pressure_units.get(self.windpressure_units, 1.0)
speed_of_sound = 343.6 # XXX util::speed_of_sound(self.air_temperature); // in m/s speed_of_sound = 343.6 # XXX util::speed_of_sound(self.air_temperature); // in m/s
air_density = 1.2 air_density = 1.2
air_speed = self.getAirSpeed(self.windpressure, air_density) air_speed = self.getAirSpeed(self.windpressure, air_density)