initial commit
This commit is contained in:
124
plate.py
Executable file
124
plate.py
Executable file
@@ -0,0 +1,124 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""\
|
||||
Circular plate
|
||||
"""
|
||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||
from math import sqrt
|
||||
|
||||
__author__ = "Daniel Weschke"
|
||||
__copyright__ = "Copyright 2019 Daniel Weschke"
|
||||
__credits__ = ["Daniel Weschke"]
|
||||
__license__ = "MIT"
|
||||
__version__ = "2019.01.17"
|
||||
__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 deflection_pinned(p, r, nu, E, t):
|
||||
"""\
|
||||
Central deflection of a pinned supported circular plate.
|
||||
|
||||
p pressure
|
||||
r radius
|
||||
nu Poisson's ratio
|
||||
E Young's modulus
|
||||
t thickness
|
||||
"""
|
||||
return p*r**4*(5+nu)/(64*(1+nu))*(12*(1-nu**2))/(E*t**3)
|
||||
|
||||
def deflection_clamped(p, r, nu, E, t):
|
||||
"""\
|
||||
Central deflection of a clamped supported circular plate.
|
||||
|
||||
p pressure
|
||||
r radius
|
||||
nu Poisson's ratio
|
||||
E Young's modulus
|
||||
t thickness
|
||||
"""
|
||||
return p*r**4*(1)/(64)*(12*(1-nu**2))/(E*t**3)
|
||||
|
||||
def thickness_min(p, d, Rp02, S):
|
||||
"""\
|
||||
Minimum thickness of a circular plate.
|
||||
|
||||
p pressure
|
||||
d diameter
|
||||
Rp02 mechanical strength
|
||||
S safety factor
|
||||
"""
|
||||
return 0.554*d*sqrt(p*S/Rp02)
|
||||
|
||||
def allowable_stress(sigma, S):
|
||||
"""\
|
||||
Allowable stress.
|
||||
|
||||
sigma stress
|
||||
S safety factor
|
||||
"""
|
||||
return sigma/S
|
||||
|
||||
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(
|
||||
'deflection', help="central deflection", prefix_chars='-',
|
||||
description="Central deflection of a circular plate.")
|
||||
parser_a.add_argument('P', nargs='?', type=float, default=0.1, help='pressure [default: 0.1 (MPa = 1 bar)]')
|
||||
parser_a.add_argument('NU', type=float, help='Poisson\'s ratio (CVD diamond 0.1)')
|
||||
parser_a.add_argument('R', type=float, help='radius')
|
||||
parser_a.add_argument('E', type=float, help='Young\'s modulus (CVD diamond 1.05e6)')
|
||||
parser_a.add_argument('T', type=float, help='thickness')
|
||||
parser_a.add_argument('-p', '--pinned', action="store_true", help='pinned support')
|
||||
parser_a.add_argument('-c', '--clamped', action="store_true", help='clamped support')
|
||||
parser_b = subparsers.add_parser(
|
||||
'thickness', help="minimum thickness", prefix_chars='-',
|
||||
description="Minimum thickness of a circular plate.")
|
||||
parser_b.add_argument('P', nargs='?', type=float, default=0.1, help='pressure [default: 0.1 (MPa = 1 bar)]')
|
||||
parser_b.add_argument('D', type=float, help='diameter')
|
||||
parser_b.add_argument('SIG', type=float, help='mechanical strength (CVD diamond 2000..400)')
|
||||
parser_b.add_argument('S', nargs='?', type=float, default=4., help='safety factor [default: 4]')
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.debug:
|
||||
print(args)
|
||||
|
||||
if args.case == 'deflection':
|
||||
if args.pinned:
|
||||
print(deflection_pinned(args.P, args.R, args.NU, args.E, args.T))
|
||||
elif args.clamped:
|
||||
print(deflection_clamped(args.P, args.R, args.NU, args.E, args.T))
|
||||
else:
|
||||
print('error: define a support type.')
|
||||
return 2
|
||||
elif args.case == 'thickness':
|
||||
print(thickness_min(args.P, args.D, args.SIG, args.S))
|
||||
|
||||
return 0
|
||||
|
||||
if __name__ == "__main__":
|
||||
import sys
|
||||
sys.exit(main())
|
||||
87
tube.py
Executable file
87
tube.py
Executable file
@@ -0,0 +1,87 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""\
|
||||
Tube
|
||||
"""
|
||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||
from math import sqrt
|
||||
|
||||
__author__ = "Daniel Weschke"
|
||||
__copyright__ = "Copyright 2019 Daniel Weschke"
|
||||
__credits__ = ["Daniel Weschke"]
|
||||
__license__ = "MIT"
|
||||
__version__ = "2019.02.07"
|
||||
__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 critical_buckling_stress(r, nu, E, t):
|
||||
"""\
|
||||
Critical buckling stress of a thin tube loaded with external pressure p.
|
||||
|
||||
r mean radius (r_a + r_i)/2
|
||||
nu Poisson's ratio
|
||||
E Young's modulus
|
||||
t thickness
|
||||
"""
|
||||
return (E/(4*(1-nu**2))*(t/r)**3)
|
||||
|
||||
def allowable_stress(sigma, S):
|
||||
"""\
|
||||
Allowable stress.
|
||||
|
||||
sigma stress
|
||||
S safety factor, elastic buckling stress state S = 3
|
||||
"""
|
||||
return sigma/S
|
||||
|
||||
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(
|
||||
'buckling', help="critical buckling stress", prefix_chars='-',
|
||||
description="Critical buckling stress of a thin tube loaded with external pressure p.")
|
||||
parser_a.add_argument('NU', type=float, help='Poisson\'s ratio')
|
||||
parser_a.add_argument('R', type=float, help='mean radius')
|
||||
parser_a.add_argument('E', type=float, help='Young\'s modulus')
|
||||
parser_a.add_argument('T', type=float, help='thickness')
|
||||
parser_a.add_argument('S', nargs='?', type=float, default=3., help='safety factor [default for elastic stress state: 3]')
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.debug:
|
||||
print(args)
|
||||
|
||||
if args.case == 'buckling':
|
||||
p_crit = critical_buckling_stress(args.R, args.NU, args.E, args.T)
|
||||
print("p_crit =", p_crit)
|
||||
print("p_allow =", allowable_stress(p_crit, args.S))
|
||||
|
||||
return 0
|
||||
|
||||
if __name__ == "__main__":
|
||||
import sys
|
||||
sys.exit(main())
|
||||
Reference in New Issue
Block a user