Closed mefuller closed 2 years ago
tube.Tube.available_materials
and tube.Flange.available_materials
-- this needs to be better documentedNot exactly part of the issue, but since I'm in here working on documentation and planning to do some precommit script work for the materials list, this seems like a good time to implement some general code-quality stuff that I think is important, but didn't have on my radar when I submitted this for publication.
I am still working on addressing some of your concerns in this issue, and I will be updating the example documentation next. For now, I would like to answer a couple of your questions:
Can / How should the program be applied to tubing or piping that is not NPS/schedule, but defined instead with actual dimensions? I.e. is there an option to supply two of three of ID,OD, and wall thickness? What about metric?
The provided NPS measurements are a convenience, and are not required to be used for the calculations. Any pint quantities can be given as inputs (provided the dimensionality is correct), in any desired unit system. For example:
In [2]: import pint
...: from pypbomb.tube import Tube
...: ureg = pint.UnitRegistry()
...: quant = ureg.Quantity
...: Tube.dynamic_load_factor(
...: tube_id=quant(1, "m"),
...: tube_od=quant(3.5, "ft"),
...: cj_velocity=quant(1700, "m/s"),
...: elastic_modulus=quant(130, "GPa"),
...: density=quant(6.8, "g/cm**3"),
...: poisson_ratio=0.4,
...: )
Out[2]: 2
In [3]: Tube.dynamic_load_factor(
...: tube_id=quant(1, "MPa"), # bad units
...: tube_od=quant(3.5, "ft"),
...: cj_velocity=quant(1700, "m/s"),
...: elastic_modulus=quant(130, "GPa"),
...: density=quant(6.8, "g/cm**3"),
...: poisson_ratio=0.4,
...: )
Traceback (most recent call last):
File "/home/mick/anaconda3/envs/pypbomb/lib/python3.8/site-packages/IPython/core/interactiveshell.py", line 3397, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-4-f05c59913c33>", line 1, in <cell line: 1>
Tube.dynamic_load_factor(
File "/d/pypbomb/pypbomb/tube.py", line 1004, in dynamic_load_factor
units.check_pint_quantity(tube_id, "length", True)
File "/d/pypbomb/pypbomb/units.py", line 70, in check_pint_quantity
raise ValueError(
ValueError: mass / length / time ** 2 is not length
Although wall thickness is included in the NPS dimension results from Tube.get_dimensions()
, that is again done as a convenience for the user; it is not used as an input in the calculation functions. Instead, it is calculated from ID and OD.
Bolt.calculate_safety_factors()
currently requires ANSI inch threads (I only have tabulated dimensions for ANSI inch included at the moment) . Within that method, the thread size and class passed into calculate_safety_factors
are only used to in a call to Bolt.calculate_stress_areas()
. It would be possible to make calculate_safety_factors
to accept plate and screw areas as inputs instead, which would make it standard-agnostic and therefore able to accommodate metric fasteners as well. It would also be possible to expand the tabulated bolt measurements to include metric at a later date.
Can one create custom materials/mechanical properties?
As with tube dimensions, mechanical property lookups (e.g. Tube.get_density()
) are also a convenience (for Tube
, anyway; flange classes are found using ASME B16.6 ratings, which require use of one of the Flange.available_materials
). If you have a maximum allowable stress that you're comfortable using for a material and the ID and OD of your desired tube, you can use those values as inputs to Tube.calculate_max_pressure
. If you'd rather skip that and use a maximum pressure from some other source, that's fine too; Tube.calculate_max_initial_pressure
doesn't really care where the inputs come from so long as the data types and dimensionality are correct.
@mefuller I have added PR #14, which I hope adequately addresses the concerns raised in this issue. When you have a chance, please let me know if this is sufficient, or if there is anything else you would like me to add or clarify. Thank you!
It's a beefy PR due to the addition of black and isort. I would recommend looking at specific commits that you are interested in, as well as the updated documentation.
In the example usage, no link is provided for a list of allowed materials nor is the source of their properties apparent
Please also make clear that the "sizes" entered are NPS (no units)
Can / How should the program be applied to tubing or piping that is not NPS/schedule, but defined instead with actual dimensions? I.e. is there an option to supply two of three of ID,OD, and wall thickness? What about metric?
Can one create custom materials/mechanical properties?
Links to relevant documentation/tables/etc. for NPS, ASME flanges, and UNC/UNF fasteners (andany other supported standard hardware) would be appreciated