#!/usr/bin/env python # -*- coding: utf-8 -*- """\ Beam """ from __future__ import absolute_import, division, print_function, unicode_literals from math import sqrt, pi __author__ = "Daniel Weschke" __copyright__ = "Copyright 2020 Daniel Weschke" __credits__ = ["Daniel Weschke"] __license__ = "MIT" __version__ = "2020.10.21" __maintainer__ = "Daniel Weschke" __email__ = "daniel.weschke@directbox.de" __status__ = "Production" # "Prototype", "Development", "Production" VERSION = """\ %(prog)s version {version} {copyright} For Unicode characters check the file encoding that the console is using. Windows user may execute the command "chcp 65001".""".format( version=__version__, copyright=__copyright__) EPILOG = """\ """ def eigen_frequency_fixed_free(n, E, I, rho, A, L): """\ Dynamic beam equation, the Euler-Lagrange equation, of an Euler-Bernoulli beam. Free vibration of a cantilever beam (fixed-free support). Returns the natural frequencies of vibration. !!! Currently only the first four frequencies can be calculated. n Mode number (1 for first mode, ...) E Elastic modulus / Young's modulus I Second moment of area of the beam's cross-section rho Density A Cross-section L Length beta_n := ((mu*omega_n^2)/(E*I))^(1/4) omega_n = beta_n^2*sqrt(E*I/mu) β_n can be solved numerically β1 L/π = 0.59686..., β2 L/π = 1.49418..., β3 L/π = 2.50025..., β4 L/π = 3.49999..., ... """ # mu Mass per unit length beta = [0.59686, 1.49418, 2.50025, 3.49999] beta_n = beta[n-1]*pi/L if n < len(beta) else 0 mu = rho * A return beta_n**2*sqrt(E*I/mu)/(2*pi) def main(): """\ Main function """ import argparse parser = argparse.ArgumentParser( description=__doc__, prefix_chars='-', epilog=EPILOG, #usage="%(prog)s [OPTION]... NAME", formatter_class=argparse.RawTextHelpFormatter, ) parser.add_argument('-v', '--verbose', action="store_true", help="Verbose output") parser.add_argument('-V', '--version', action='version', version=VERSION) parser.add_argument('-D', '--debug', dest='debug', action='store_true', help=argparse.SUPPRESS) subparsers = parser.add_subparsers(help='', dest='case') parser_a = subparsers.add_parser( 'frequency', help="eigen frequencies", prefix_chars='-', description=r"""Eigen frequencies of an Euler-Bernoulli beam. βₙ² ⎛E I⎞¹/₂ π fₙ = --- ⎜---⎟ with βₙ = -- aₙ 2π ⎝ρ A⎠ L aₙ is a numerically solved value. !!! Currently only the first four frequencies can be calculated. """, formatter_class=argparse.RawTextHelpFormatter) parser_a.add_argument('N', type=int, help='Mode number') parser_a.add_argument('E', type=float, help='Young\'s modulus') parser_a.add_argument('I', type=float, help='Second moment of area') parser_a.add_argument('RHO', type=float, help='Density') parser_a.add_argument('A', type=float, help='Area') parser_a.add_argument('L', type=float, help='Length') args = parser.parse_args() if args.debug: print(args) if args.case == 'frequency': f_n = eigen_frequency_fixed_free(args.N, args.E, args.I, args.RHO, args.A, args.L) print("f_" + str(args.N) + " =", f_n) return 0 if __name__ == "__main__": import sys sys.exit(main())