def mesh( A, D, SA ): """Compute a number of values for the overall wire mesh. :param A: Center-to-center distance across mesh opening (in) :param D: Wire diameter (in) :param SA: Screen area (ft²) :returns: dict with computed values. - WV Wire Volume per cell - N number of cells - TV total volume - FA windvane area """ results= AttrDict( A=A, D=D, SA=SA ) # Mesh Description results.CA=3.464*(A/2)**2 # Cell Area LS=1.155*A/2 # Length of Side WL=3*LS # Wire Length LSO=1.155*(A-D)/2 results.OA=3.464*((A-D)/2)**2 # Open Area results.WA = results.CA - results.OA # Wire Area # Materials Description results.WV=WL*math.pi*(D/2)**2 results.N=SA/results.CA*144 results.TV=results.WV*results.N results.FF=results.WA/results.CA results.FA=SA*results.FF return results
def freq_wavelength( **kw ): """A kind of **Solver** for frequency-wavelength problems in Standard units of meters and Hertz. :param f: Frequency in Hz :param l: Wavelength in m :returns: dict with both values """ c= 299792.458 args= AttrDict( kw ) if 'f' in args: args.l= 1000*c/args.f elif 'l' in args: args.f = c/(args.l/1000) else: raise NoSolutionError( "Insufficient Data: {0!r}".format(args) ) return args
def design_final( shape, **args ): """Given a shape (Square or Circle), and some parameters, final design. :param V: target volume :param N: given angle :param D: given size or diameter :param M: hopper height, larger than the minimum :returns: dict with design parameters added. """ args= AttrDict( args ) def height_from_h( H ): args.H = H shape.height( args ) return args.K - args.M args.H = bisection( height_from_h, args.M, args.H-1 ) return args
def design_hopper( shape, **args ): """Given a shape (Square or Circle), and some parameters, initial design with minimum height, H, for the hopper. :param V: target volume :param N: given angle :param D: given size or diameter :returns: dict with design parameters added. """ args= AttrDict( args ) def hopper_vol_from_h( H ): args.H = H shape.volume( args ) return args.V - args.V_H # In principle, we should develop a rational upper limit. # The overall volume, though, is a good estimator for the # upper bound. args.H = bisection( hopper_vol_from_h, 0, args.V ) return args
def involute( radius, phi=None ): """Compute involute dimensions given radius and optional angle phi. :param radius: Radius of circle :param phi: optional angle in radians. :returns: dictionary with numerous values for the involute. - radius, given - diameter, :math:`2 \\times r` - baseline, :math:`\\pi \\times r` - involute circumference If Phi is provided - phi, given - C_X, C_Y, location of point C on the involate at angle phi - CO length of the line from origin to C - CE length of the line from circumference to C - OCE the angle at C (on involute) between O and E (on circumference) - COE the angle at O between C (on involute) and E (on circumference) """ args = AttrDict() args.radius= radius args.diameter = 2*args.radius args.baseline = math.pi*args.radius args.involute = args.radius*math.pi**2/2 if phi is not None: args.phi= phi args.C_X= args.radius*(math.sin(phi)-phi*math.cos(phi)) args.C_Y= args.radius*(math.cos(phi)-phi*math.sin(phi)) args.CO= math.sqrt( args.C_X**2 + args.C_Y**2 ) try: args.CE= math.sqrt( args.CO**2 - args.radius**2 ) except ValueError as e: print( "{0} computing sqrt({CO:7.3f}**2-{radius:7.3f}**2)".format(e,**args) ) args.CE = args.COE = args.OCE = float("NaN") return args args.OCE = math.atan2( args.radius, args.CE ) args.COE = math.pi/2-args.OCE return args