piping-core 0.2.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (539) hide show
  1. b313/__init__.py +64 -0
  2. b313/_angle_intervals.py +147 -0
  3. b313/_branch_arithmetic.py +245 -0
  4. b313/_high_pressure_pressure_design_source.py +84 -0
  5. b313/_radical_arithmetic.py +102 -0
  6. b313/_typed_models.py +288 -0
  7. b313/allowable_stresses.py +1107 -0
  8. b313/alloy_allowables.py +871 -0
  9. b313/aluminum_allowables.py +915 -0
  10. b313/aluminum_flanges.py +593 -0
  11. b313/ambient_effects.py +194 -0
  12. b313/api.py +44846 -0
  13. b313/appendix_a_application_notes.py +80 -0
  14. b313/appendix_a_carbon.py +213 -0
  15. b313/appendix_a_carbon_stress.py +126 -0
  16. b313/appendix_a_index.py +359 -0
  17. b313/appendix_a_iron.py +70 -0
  18. b313/appendix_a_module_catalog.py +144 -0
  19. b313/appendix_a_operations.py +1892 -0
  20. b313/appendix_a_quality.py +127 -0
  21. b313/appendix_b_module_catalog.py +121 -0
  22. b313/appendix_b_notes.py +240 -0
  23. b313/appendix_b_operations.py +96 -0
  24. b313/appendix_b_pipe.py +398 -0
  25. b313/appendix_b_source.py +68 -0
  26. b313/appendix_c_module_catalog.py +119 -0
  27. b313/appendix_c_operations.py +71 -0
  28. b313/appendix_c_properties.py +285 -0
  29. b313/appendix_c_source.py +55 -0
  30. b313/appendix_d.py +318 -0
  31. b313/appendix_d_module_catalog.py +84 -0
  32. b313/appendix_d_operations.py +64 -0
  33. b313/appendix_d_requirements.py +348 -0
  34. b313/appendix_e.py +323 -0
  35. b313/appendix_f.py +692 -0
  36. b313/appendix_f_advisories.py +212 -0
  37. b313/appendix_f_operations.py +45 -0
  38. b313/appendix_g.py +194 -0
  39. b313/appendix_g_module_catalog.py +62 -0
  40. b313/appendix_g_operations.py +14 -0
  41. b313/appendix_g_requirements.py +171 -0
  42. b313/appendix_h.py +542 -0
  43. b313/appendix_h_module_catalog.py +90 -0
  44. b313/appendix_h_operations.py +198 -0
  45. b313/appendix_j.py +338 -0
  46. b313/appendix_j_module.py +325 -0
  47. b313/appendix_k_adapters.py +85 -0
  48. b313/appendix_k_module.py +235 -0
  49. b313/appendix_k_operations.py +56 -0
  50. b313/appendix_l_module.py +425 -0
  51. b313/appendix_l_operations.py +69 -0
  52. b313/appendix_m.py +190 -0
  53. b313/appendix_m_module.py +271 -0
  54. b313/appendix_m_operations.py +14 -0
  55. b313/appendix_p.py +911 -0
  56. b313/appendix_p_module.py +482 -0
  57. b313/appendix_p_operations.py +86 -0
  58. b313/appendix_q.py +90 -0
  59. b313/appendix_q_module.py +188 -0
  60. b313/appendix_q_operations.py +13 -0
  61. b313/appendix_s.py +2144 -0
  62. b313/appendix_s_adapters.py +222 -0
  63. b313/appendix_s_module.py +262 -0
  64. b313/appendix_s_operations.py +22 -0
  65. b313/appendix_s_original_operations.py +114 -0
  66. b313/appendix_v.py +853 -0
  67. b313/appendix_v_module.py +342 -0
  68. b313/appendix_v_operations.py +35 -0
  69. b313/appendix_x_adapters.py +43 -0
  70. b313/appendix_x_module.py +566 -0
  71. b313/appendix_x_operations.py +38 -0
  72. b313/appendix_x_original_operations.py +37 -0
  73. b313/appendix_z.py +274 -0
  74. b313/appendix_z_module.py +263 -0
  75. b313/appendix_z_operations.py +15 -0
  76. b313/attachment_weld_inspection.py +213 -0
  77. b313/back_matter_module.py +89 -0
  78. b313/back_matter_operations.py +11 -0
  79. b313/bellows_fatigue.py +704 -0
  80. b313/bellows_manufacture.py +208 -0
  81. b313/bellows_shop_test.py +504 -0
  82. b313/bellows_test_records.py +283 -0
  83. b313/bend_pressure.py +504 -0
  84. b313/bending_forming.py +1175 -0
  85. b313/bolting_allowables.py +753 -0
  86. b313/bolting_service.py +1274 -0
  87. b313/bond_acceptance.py +151 -0
  88. b313/bonding_production.py +1364 -0
  89. b313/bonding_qualification.py +1145 -0
  90. b313/bonding_requirements_catalog.py +40 -0
  91. b313/branch_pressure.py +1649 -0
  92. b313/branch_pressure_basis.py +580 -0
  93. b313/branch_welding.py +1021 -0
  94. b313/brazing_soldering.py +485 -0
  95. b313/calculation_plan.py +1486 -0
  96. b313/calculation_records.py +2226 -0
  97. b313/carbon_allowables.py +254 -0
  98. b313/carbon_hydrotest_exemption.py +98 -0
  99. b313/case_181.py +1291 -0
  100. b313/casting_quality.py +677 -0
  101. b313/catalog.py +1360 -0
  102. b313/category_m_assembly_catalog.py +62 -0
  103. b313/category_m_auxiliary.py +103 -0
  104. b313/category_m_auxiliary_catalog.py +62 -0
  105. b313/category_m_bending_forming_catalog.py +62 -0
  106. b313/category_m_bolting_catalog.py +58 -0
  107. b313/category_m_brazed_joint_catalog.py +58 -0
  108. b313/category_m_caulked_joint_catalog.py +58 -0
  109. b313/category_m_components.py +1595 -0
  110. b313/category_m_conditions_catalog.py +60 -0
  111. b313/category_m_criteria_catalog.py +61 -0
  112. b313/category_m_design.py +346 -0
  113. b313/category_m_examination.py +121 -0
  114. b313/category_m_examination_catalog.py +61 -0
  115. b313/category_m_expanded_joint_catalog.py +58 -0
  116. b313/category_m_fabrication_scope_catalog.py +62 -0
  117. b313/category_m_fitting_catalog.py +63 -0
  118. b313/category_m_flange_catalog.py +61 -0
  119. b313/category_m_flanged_joint_catalog.py +58 -0
  120. b313/category_m_flexibility.py +99 -0
  121. b313/category_m_flexibility_catalog.py +58 -0
  122. b313/category_m_general_catalog.py +61 -0
  123. b313/category_m_heat_treatment_catalog.py +62 -0
  124. b313/category_m_inspection_catalog.py +62 -0
  125. b313/category_m_joint_general_catalog.py +58 -0
  126. b313/category_m_material.py +114 -0
  127. b313/category_m_material_catalog.py +62 -0
  128. b313/category_m_methods_catalog.py +184 -0
  129. b313/category_m_personnel.py +138 -0
  130. b313/category_m_personnel_catalog.py +58 -0
  131. b313/category_m_pipe_catalog.py +62 -0
  132. b313/category_m_preheat_catalog.py +62 -0
  133. b313/category_m_pressure_basis_catalog.py +58 -0
  134. b313/category_m_pressure_design_catalog.py +58 -0
  135. b313/category_m_procedure_catalog.py +58 -0
  136. b313/category_m_records_catalog.py +79 -0
  137. b313/category_m_relief.py +130 -0
  138. b313/category_m_special_joint_catalog.py +58 -0
  139. b313/category_m_standards.py +207 -0
  140. b313/category_m_standards_catalog.py +62 -0
  141. b313/category_m_support.py +83 -0
  142. b313/category_m_support_catalog.py +58 -0
  143. b313/category_m_system_catalog.py +62 -0
  144. b313/category_m_testing_catalog.py +266 -0
  145. b313/category_m_threaded_joint_catalog.py +61 -0
  146. b313/category_m_tubing_joint_catalog.py +58 -0
  147. b313/category_m_valve_catalog.py +62 -0
  148. b313/category_m_weld_catalog.py +62 -0
  149. b313/category_m_weld_fabrication_catalog.py +62 -0
  150. b313/category_ma_assembly.py +250 -0
  151. b313/category_ma_assembly_catalog.py +50 -0
  152. b313/category_ma_bolting_catalog.py +42 -0
  153. b313/category_ma_bond_catalog.py +54 -0
  154. b313/category_ma_bonding.py +204 -0
  155. b313/category_ma_bonding_catalog.py +60 -0
  156. b313/category_ma_bonds.py +58 -0
  157. b313/category_ma_caulked_joint_catalog.py +55 -0
  158. b313/category_ma_conditions_catalog.py +64 -0
  159. b313/category_ma_criteria_catalog.py +64 -0
  160. b313/category_ma_examination_catalog.py +75 -0
  161. b313/category_ma_expanded_joint_catalog.py +55 -0
  162. b313/category_ma_fabrication_scope_catalog.py +58 -0
  163. b313/category_ma_fitting_catalog.py +56 -0
  164. b313/category_ma_fittings.py +92 -0
  165. b313/category_ma_flange_catalog.py +54 -0
  166. b313/category_ma_flanged_joint_catalog.py +55 -0
  167. b313/category_ma_flanges.py +49 -0
  168. b313/category_ma_flexibility_catalog.py +58 -0
  169. b313/category_ma_forming_catalog.py +56 -0
  170. b313/category_ma_general_catalog.py +68 -0
  171. b313/category_ma_inspection_catalog.py +52 -0
  172. b313/category_ma_joint_general_catalog.py +42 -0
  173. b313/category_ma_lined_fabrication_catalog.py +49 -0
  174. b313/category_ma_material_catalog.py +64 -0
  175. b313/category_ma_materials.py +150 -0
  176. b313/category_ma_methods.py +164 -0
  177. b313/category_ma_methods_catalog.py +150 -0
  178. b313/category_ma_nonplastic_catalog.py +49 -0
  179. b313/category_ma_personnel_catalog.py +55 -0
  180. b313/category_ma_pipe_catalog.py +40 -0
  181. b313/category_ma_pressure_basis_catalog.py +40 -0
  182. b313/category_ma_pressure_design_catalog.py +42 -0
  183. b313/category_ma_procedure_catalog.py +52 -0
  184. b313/category_ma_records_catalog.py +74 -0
  185. b313/category_ma_special_joint_catalog.py +58 -0
  186. b313/category_ma_specific_piping_catalog.py +58 -0
  187. b313/category_ma_standards.py +142 -0
  188. b313/category_ma_standards_catalog.py +47 -0
  189. b313/category_ma_support_catalog.py +58 -0
  190. b313/category_ma_testing.py +403 -0
  191. b313/category_ma_testing_catalog.py +60 -0
  192. b313/category_ma_threaded_joint_catalog.py +59 -0
  193. b313/category_ma_threaded_joints.py +57 -0
  194. b313/category_ma_tubing_joint_catalog.py +58 -0
  195. b313/category_ma_valve_catalog.py +45 -0
  196. b313/category_ma_valves.py +166 -0
  197. b313/charpy.py +685 -0
  198. b313/charpy_report.py +1236 -0
  199. b313/charpy_temperature.py +291 -0
  200. b313/clad_fabrication.py +198 -0
  201. b313/clause_citations.py +106 -0
  202. b313/clause_index.py +519 -0
  203. b313/closure_pressure.py +611 -0
  204. b313/code_cases.py +157 -0
  205. b313/code_cases_adapters.py +105 -0
  206. b313/code_cases_module.py +549 -0
  207. b313/code_cases_operations.py +51 -0
  208. b313/code_context.py +44 -0
  209. b313/combined_leak.py +804 -0
  210. b313/component_dimensional_inspection.py +439 -0
  211. b313/component_qualification.py +1522 -0
  212. b313/component_rating_route.py +18 -0
  213. b313/component_requirements.py +1907 -0
  214. b313/copper_allowables.py +533 -0
  215. b313/database_core.py +279 -0
  216. b313/defect_removal.py +211 -0
  217. b313/definitions.py +283 -0
  218. b313/design_loads.py +902 -0
  219. b313/designer_qualification.py +178 -0
  220. b313/displacement_stress.py +866 -0
  221. b313/document_reference_types.py +28 -0
  222. b313/documented_impact_coverage.py +162 -0
  223. b313/documented_tack_welds.py +127 -0
  224. b313/drainage_slope.py +124 -0
  225. b313/eddy_current_examination.py +375 -0
  226. b313/elevated_temperature_examination.py +472 -0
  227. b313/examination_extent.py +127 -0
  228. b313/examination_items.py +13 -0
  229. b313/examination_methods_catalog.py +50 -0
  230. b313/examination_qualification.py +1363 -0
  231. b313/examination_responsibility.py +376 -0
  232. b313/execution_provenance.py +90 -0
  233. b313/expansion_joint_design.py +1074 -0
  234. b313/expansion_joint_layout.py +744 -0
  235. b313/external_data.py +215 -0
  236. b313/external_pressure.py +682 -0
  237. b313/fabrication_requirements.py +1105 -0
  238. b313/figure_catalog.py +270 -0
  239. b313/fillet_socket_welding.py +244 -0
  240. b313/fitting_service.py +1490 -0
  241. b313/flange_pressure.py +703 -0
  242. b313/flange_service.py +1518 -0
  243. b313/flanged_expanded_joints.py +672 -0
  244. b313/flexibility_screening.py +1794 -0
  245. b313/forming_heat_treatment_model.py +25 -0
  246. b313/forming_heat_treatment_requirements.py +90 -0
  247. b313/front_matter.py +243 -0
  248. b313/general_pressure_design.py +244 -0
  249. b313/hardness_examination.py +192 -0
  250. b313/hardness_limits.py +102 -0
  251. b313/heat_treatment.py +1521 -0
  252. b313/heat_treatment_execution.py +441 -0
  253. b313/high_pressure_acceptance.py +147 -0
  254. b313/high_pressure_allowances.py +257 -0
  255. b313/high_pressure_assembly_requirements.py +218 -0
  256. b313/high_pressure_assembly_requirements_catalog.py +92 -0
  257. b313/high_pressure_auxiliary.py +83 -0
  258. b313/high_pressure_auxiliary_catalog.py +81 -0
  259. b313/high_pressure_bending_forming_requirements.py +163 -0
  260. b313/high_pressure_bending_forming_requirements_catalog.py +103 -0
  261. b313/high_pressure_bolting_requirements.py +112 -0
  262. b313/high_pressure_bolting_requirements_catalog.py +46 -0
  263. b313/high_pressure_bpv_evidence.py +154 -0
  264. b313/high_pressure_brazed_joint_catalog.py +43 -0
  265. b313/high_pressure_brazing_requirements_catalog.py +85 -0
  266. b313/high_pressure_casting.py +258 -0
  267. b313/high_pressure_caulked_joint_catalog.py +43 -0
  268. b313/high_pressure_component_basis.py +325 -0
  269. b313/high_pressure_component_general.py +180 -0
  270. b313/high_pressure_component_general_catalog.py +42 -0
  271. b313/high_pressure_component_requirements.py +81 -0
  272. b313/high_pressure_component_requirements_catalog.py +91 -0
  273. b313/high_pressure_conditions.py +363 -0
  274. b313/high_pressure_conditions_catalog.py +65 -0
  275. b313/high_pressure_criteria.py +316 -0
  276. b313/high_pressure_criteria_catalog.py +76 -0
  277. b313/high_pressure_design_conditions.py +785 -0
  278. b313/high_pressure_examination.py +627 -0
  279. b313/high_pressure_examination_methods_catalog.py +130 -0
  280. b313/high_pressure_examination_requirements.py +411 -0
  281. b313/high_pressure_examination_requirements_catalog.py +119 -0
  282. b313/high_pressure_expanded_joint_catalog.py +43 -0
  283. b313/high_pressure_fabrication_requirements_catalog.py +61 -0
  284. b313/high_pressure_fatigue_amplitude.py +214 -0
  285. b313/high_pressure_fatigue_pressure_basis.py +160 -0
  286. b313/high_pressure_fitting_requirements.py +249 -0
  287. b313/high_pressure_fitting_requirements_catalog.py +47 -0
  288. b313/high_pressure_flange_design.py +365 -0
  289. b313/high_pressure_flange_requirements.py +448 -0
  290. b313/high_pressure_flange_requirements_catalog.py +43 -0
  291. b313/high_pressure_flanged_joint.py +556 -0
  292. b313/high_pressure_flanged_joint_requirements.py +125 -0
  293. b313/high_pressure_flanged_joint_requirements_catalog.py +43 -0
  294. b313/high_pressure_flexibility.py +748 -0
  295. b313/high_pressure_flexibility_catalog.py +44 -0
  296. b313/high_pressure_gasket.py +43 -0
  297. b313/high_pressure_general_catalog.py +145 -0
  298. b313/high_pressure_heat_treatment_requirements.py +281 -0
  299. b313/high_pressure_heat_treatment_requirements_catalog.py +90 -0
  300. b313/high_pressure_inspection_requirements_catalog.py +79 -0
  301. b313/high_pressure_joint_requirements.py +103 -0
  302. b313/high_pressure_joint_requirements_catalog.py +43 -0
  303. b313/high_pressure_leak.py +2016 -0
  304. b313/high_pressure_leak_requirements_catalog.py +132 -0
  305. b313/high_pressure_material_evidence.py +471 -0
  306. b313/high_pressure_materials.py +537 -0
  307. b313/high_pressure_materials_catalog.py +100 -0
  308. b313/high_pressure_occasional_stress.py +145 -0
  309. b313/high_pressure_personnel.py +241 -0
  310. b313/high_pressure_personnel_catalog.py +80 -0
  311. b313/high_pressure_pipe.py +633 -0
  312. b313/high_pressure_pipe_exam.py +694 -0
  313. b313/high_pressure_pipe_requirements.py +257 -0
  314. b313/high_pressure_pipe_requirements_catalog.py +52 -0
  315. b313/high_pressure_preheat_requirements_catalog.py +73 -0
  316. b313/high_pressure_pressure_design.py +434 -0
  317. b313/high_pressure_pressure_design_catalog.py +63 -0
  318. b313/high_pressure_procedure.py +49 -0
  319. b313/high_pressure_procedure_catalog.py +77 -0
  320. b313/high_pressure_records.py +214 -0
  321. b313/high_pressure_records_catalog.py +88 -0
  322. b313/high_pressure_seam.py +16 -0
  323. b313/high_pressure_special_joint_catalog.py +43 -0
  324. b313/high_pressure_stress.py +1750 -0
  325. b313/high_pressure_stress_limits.py +112 -0
  326. b313/high_pressure_stress_values.py +97 -0
  327. b313/high_pressure_support_catalog.py +59 -0
  328. b313/high_pressure_systems_catalog.py +64 -0
  329. b313/high_pressure_threaded_joint_catalog.py +43 -0
  330. b313/high_pressure_tubing_joint_catalog.py +43 -0
  331. b313/high_pressure_valve_requirements.py +253 -0
  332. b313/high_pressure_valve_requirements_catalog.py +43 -0
  333. b313/high_pressure_weld_requirements.py +136 -0
  334. b313/high_pressure_weld_requirements_catalog.py +43 -0
  335. b313/high_pressure_welding_requirements.py +138 -0
  336. b313/high_pressure_welding_requirements_catalog.py +130 -0
  337. b313/hydrostatic.py +793 -0
  338. b313/hydrostatic_record.py +1151 -0
  339. b313/impact_procedure_record.py +224 -0
  340. b313/impact_records.py +410 -0
  341. b313/impact_test_plan.py +1010 -0
  342. b313/implementation_tracking.py +213 -0
  343. b313/in_process_examination.py +481 -0
  344. b313/index_project_resolutions.py +73 -0
  345. b313/initial_service_leak.py +347 -0
  346. b313/instrument_connection.py +212 -0
  347. b313/instrument_piping.py +917 -0
  348. b313/interpretation_index_module.py +252 -0
  349. b313/interpretation_index_operations.py +23 -0
  350. b313/interpretation_project_resolutions.py +62 -0
  351. b313/interpretations.py +834 -0
  352. b313/interpretations_adapters.py +69 -0
  353. b313/interpretations_module.py +418 -0
  354. b313/interpretations_operations.py +24 -0
  355. b313/iron_allowables.py +577 -0
  356. b313/jacketed_leak.py +1102 -0
  357. b313/joining_material_exposure.py +178 -0
  358. b313/joint_assessment.py +112 -0
  359. b313/joint_identity.py +8 -0
  360. b313/joint_selection.py +3248 -0
  361. b313/lap_finishing.py +160 -0
  362. b313/leak_identity.py +154 -0
  363. b313/leak_materials.py +45 -0
  364. b313/leak_preparation.py +778 -0
  365. b313/leak_pressure_precautions.py +319 -0
  366. b313/leak_records.py +1281 -0
  367. b313/leak_route.py +302 -0
  368. b313/leak_source.py +875 -0
  369. b313/leak_test_exceptions.py +1002 -0
  370. b313/leak_testing_catalog.py +37 -0
  371. b313/lined_fabrication.py +633 -0
  372. b313/lined_fabrication_catalog.py +40 -0
  373. b313/listed_component_rating.py +659 -0
  374. b313/longitudinal_stress.py +367 -0
  375. b313/material_conformance.py +196 -0
  376. b313/material_impact_coverage.py +194 -0
  377. b313/material_serviceability_evidence.py +174 -0
  378. b313/material_specification.py +763 -0
  379. b313/material_temperature_cases.py +255 -0
  380. b313/metal_assembly.py +1623 -0
  381. b313/metal_modulus.py +229 -0
  382. b313/metal_temperature.py +643 -0
  383. b313/metal_thermal.py +82 -0
  384. b313/metallic_clad_temperature.py +166 -0
  385. b313/metallic_pressure_basis.py +1109 -0
  386. b313/miter_pressure.py +402 -0
  387. b313/module_api.py +240 -0
  388. b313/movement_clearance.py +136 -0
  389. b313/nickel_allowables.py +650 -0
  390. b313/nomenclature_project_resolutions.py +39 -0
  391. b313/nonmetal_assembly.py +1334 -0
  392. b313/nonmetal_assembly_catalog.py +45 -0
  393. b313/nonmetal_auxiliary_materials.py +77 -0
  394. b313/nonmetal_bolting.py +128 -0
  395. b313/nonmetal_bond_service_catalog.py +40 -0
  396. b313/nonmetal_caulked_joint_catalog.py +36 -0
  397. b313/nonmetal_component_standards.py +269 -0
  398. b313/nonmetal_component_standards_catalog.py +40 -0
  399. b313/nonmetal_conditions.py +516 -0
  400. b313/nonmetal_design_conditions_catalog.py +59 -0
  401. b313/nonmetal_design_criteria_catalog.py +44 -0
  402. b313/nonmetal_design_limits.py +97 -0
  403. b313/nonmetal_examination.py +1791 -0
  404. b313/nonmetal_examination_catalog.py +58 -0
  405. b313/nonmetal_expanded_joint_catalog.py +36 -0
  406. b313/nonmetal_external_loading.py +237 -0
  407. b313/nonmetal_fabrication.py +1301 -0
  408. b313/nonmetal_fabrication_scope_catalog.py +40 -0
  409. b313/nonmetal_fitting_service_catalog.py +40 -0
  410. b313/nonmetal_flange_service.py +174 -0
  411. b313/nonmetal_flanged_joint_guidance.py +59 -0
  412. b313/nonmetal_flexibility.py +1513 -0
  413. b313/nonmetal_flexibility_catalog.py +40 -0
  414. b313/nonmetal_forming_catalog.py +40 -0
  415. b313/nonmetal_hydrostatic.py +811 -0
  416. b313/nonmetal_inspection_catalog.py +46 -0
  417. b313/nonmetal_joint_service_catalog.py +36 -0
  418. b313/nonmetal_material_requirements_catalog.py +40 -0
  419. b313/nonmetal_methods_catalog.py +55 -0
  420. b313/nonmetal_occasional.py +152 -0
  421. b313/nonmetal_personnel_catalog.py +48 -0
  422. b313/nonmetal_pneumatic.py +235 -0
  423. b313/nonmetal_pressure_design_catalog.py +44 -0
  424. b313/nonmetal_procedure_catalog.py +46 -0
  425. b313/nonmetal_properties.py +158 -0
  426. b313/nonmetal_qualification.py +990 -0
  427. b313/nonmetal_rating.py +803 -0
  428. b313/nonmetal_records_catalog.py +46 -0
  429. b313/nonmetal_scope_catalog.py +45 -0
  430. b313/nonmetal_service.py +1241 -0
  431. b313/nonmetal_special_joint_catalog.py +40 -0
  432. b313/nonmetal_specific_piping_catalog.py +40 -0
  433. b313/nonmetal_standards.py +124 -0
  434. b313/nonmetal_support_catalog.py +40 -0
  435. b313/nonmetal_temperature.py +682 -0
  436. b313/nonmetal_temperature_interpolation.py +96 -0
  437. b313/nonmetal_temperature_limits.py +349 -0
  438. b313/nonmetal_testing_catalog.py +54 -0
  439. b313/nonmetal_threaded_joint_catalog.py +40 -0
  440. b313/nonmetal_tubing_joint_catalog.py +36 -0
  441. b313/nonmetal_valve_service_catalog.py +38 -0
  442. b313/nonplastic_joining_catalog.py +40 -0
  443. b313/normal_weld_examination.py +1736 -0
  444. b313/occasional_variation.py +794 -0
  445. b313/owner_inspection.py +972 -0
  446. b313/pad_vent_history.py +194 -0
  447. b313/pipe_calibration.py +61 -0
  448. b313/pipe_scan_coverage.py +36 -0
  449. b313/pipe_service.py +464 -0
  450. b313/pipe_support.py +2570 -0
  451. b313/planar_frame.py +980 -0
  452. b313/pneumatic.py +707 -0
  453. b313/preheat.py +1083 -0
  454. b313/preheat_history.py +270 -0
  455. b313/pressure_coefficients.py +176 -0
  456. b313/pressure_design.py +656 -0
  457. b313/pressure_relief_piping.py +3500 -0
  458. b313/progressive_sampling.py +934 -0
  459. b313/project_examination.py +82 -0
  460. b313/project_fabrication.py +156 -0
  461. b313/project_records.py +1080 -0
  462. b313/qualification_envelope.py +41 -0
  463. b313/radiographic_examination.py +504 -0
  464. b313/reactions.py +637 -0
  465. b313/reclaimed_material.py +155 -0
  466. b313/reducer_pressure.py +496 -0
  467. b313/reference_standards.py +632 -0
  468. b313/reinforced_pipe_pressure.py +234 -0
  469. b313/relief_device_requirements.py +129 -0
  470. b313/relief_discharge_routing.py +205 -0
  471. b313/relieving_interpretations.py +231 -0
  472. b313/rule_bindings.py +8308 -0
  473. b313/runtime_release.json +543 -0
  474. b313/scope.py +1378 -0
  475. b313/seal_thread_coverage.py +213 -0
  476. b313/seal_welding.py +89 -0
  477. b313/sensitive_leak.py +631 -0
  478. b313/service_junction.py +340 -0
  479. b313/severe_cyclic_examination.py +609 -0
  480. b313/severe_cyclic_procedure.py +138 -0
  481. b313/small_width_impact.py +159 -0
  482. b313/source_dispositions.py +136 -0
  483. b313/spatial_frame.py +3771 -0
  484. b313/specific_piping_identity.py +541 -0
  485. b313/spring_protection.py +84 -0
  486. b313/stainless_allowables.py +1205 -0
  487. b313/stress_limits.py +28 -0
  488. b313/stress_range_graph.py +71 -0
  489. b313/stress_ratio_curve.py +514 -0
  490. b313/subject_index_module.py +360 -0
  491. b313/subject_index_operations.py +19 -0
  492. b313/supplement_tracking.py +130 -0
  493. b313/supplementary_examination.py +1023 -0
  494. b313/support_cold_forming.py +99 -0
  495. b313/support_creep.py +90 -0
  496. b313/support_engagement.py +110 -0
  497. b313/support_reactions.py +75 -0
  498. b313/support_resonance.py +129 -0
  499. b313/support_temperature.py +112 -0
  500. b313/support_threads.py +121 -0
  501. b313/support_unknown_steel.py +117 -0
  502. b313/surface_examination.py +150 -0
  503. b313/table_a1.py +405 -0
  504. b313/table_equation_reference.py +246 -0
  505. b313/thermal_movement.py +298 -0
  506. b313/thermoplastic_hds.py +205 -0
  507. b313/thermoplastic_pressure.py +142 -0
  508. b313/threaded_components.py +1208 -0
  509. b313/titanium_zirconium_allowables.py +535 -0
  510. b313/toughness_curves.py +540 -0
  511. b313/toughness_records.py +99 -0
  512. b313/ultrasonic_examination.py +1147 -0
  513. b313/unlisted_metal_toughness.py +142 -0
  514. b313/valve_seat_preservation.py +263 -0
  515. b313/valve_service.py +837 -0
  516. b313/valve_service_records.py +44 -0
  517. b313/visual_examination.py +379 -0
  518. b313/weld_acceptance.py +842 -0
  519. b313/weld_environment.py +195 -0
  520. b313/weld_fabrication.py +1560 -0
  521. b313/weld_factor_evidence.py +120 -0
  522. b313/weld_identification.py +202 -0
  523. b313/weld_peening.py +158 -0
  524. b313/weld_preparation.py +858 -0
  525. b313/weld_quality.py +313 -0
  526. b313/weld_strength.py +452 -0
  527. b313/welded_joint_service.py +1072 -0
  528. b313/welded_joints.py +98 -0
  529. b313/welding_materials.py +284 -0
  530. b313/welding_qualification.py +844 -0
  531. b313/work_tracking.py +319 -0
  532. piping_core/__init__.py +62 -0
  533. piping_core-0.2.0.dist-info/METADATA +474 -0
  534. piping_core-0.2.0.dist-info/RECORD +539 -0
  535. piping_core-0.2.0.dist-info/WHEEL +5 -0
  536. piping_core-0.2.0.dist-info/licenses/LICENSE +21 -0
  537. piping_core-0.2.0.dist-info/licenses/NOTICE +41 -0
  538. piping_core-0.2.0.dist-info/top_level.txt +3 -0
  539. piping_engine/__init__.py +10 -0
b313/__init__.py ADDED
@@ -0,0 +1,64 @@
1
+ # SPDX-License-Identifier: MIT
2
+ """Public imports for the B31.3 extraction catalogs."""
3
+
4
+ __version__ = "0.2.0"
5
+
6
+ from .catalog import (
7
+ Bookmark,
8
+ Candidate,
9
+ DocumentCatalog,
10
+ FacingRowCandidate,
11
+ Page,
12
+ PageLayout,
13
+ SourceLocation,
14
+ StressPointCandidate,
15
+ StressReviewCatalog,
16
+ StressRowLine,
17
+ StressSpread,
18
+ TableCellCandidate,
19
+ TableGridCandidate,
20
+ )
21
+ from .table_a1 import (
22
+ TableA1BlankCell, TableA1Catalog, TableA1GradeDesignation, TableA1MaterialIdentity,
23
+ TableA1StressBasisTrace, TableA1StressCell, TableA1StressSeries,
24
+ )
25
+
26
+ __all__ = [
27
+ "B313",
28
+ "ModuleAPI",
29
+ "OperationSelector",
30
+ "OperationContract",
31
+ "ModuleCallOutcome",
32
+ "Bookmark",
33
+ "Candidate",
34
+ "DocumentCatalog",
35
+ "FacingRowCandidate",
36
+ "Page",
37
+ "PageLayout",
38
+ "SourceLocation",
39
+ "StressPointCandidate",
40
+ "StressReviewCatalog",
41
+ "StressRowLine",
42
+ "StressSpread",
43
+ "TableA1BlankCell",
44
+ "TableA1Catalog",
45
+ "TableA1GradeDesignation",
46
+ "TableA1MaterialIdentity",
47
+ "TableA1StressBasisTrace",
48
+ "TableA1StressCell",
49
+ "TableA1StressSeries",
50
+ "TableCellCandidate",
51
+ "TableGridCandidate",
52
+ ]
53
+
54
+
55
+ def __getattr__(name):
56
+ """Load public calculation entry points only when requested by the caller."""
57
+ if name == 'B313':
58
+ from .api import B313
59
+ return B313
60
+ if name in {'ModuleAPI', 'OperationSelector', 'OperationContract', 'ModuleCallOutcome'}:
61
+ from importlib import import_module
62
+ return getattr(import_module('.module_api', __name__), name)
63
+ raise AttributeError(f'module {__name__!r} has no attribute {name!r}')
64
+
@@ -0,0 +1,147 @@
1
+ # SPDX-License-Identifier: MIT
2
+ """Rigorous real-angle enclosures for pressure-limit comparisons.
3
+
4
+ Only integer outward rounding and rational arithmetic decide inequalities.
5
+ NIST DLMF4.19.2/4.24.3 give the cosine/arctangent series. The alternating
6
+ tail is bounded by its next term after terms decrease. Machin's identity
7
+ pi/4=4atan(1/5)-atan(1/239) follows from the exact tangent addition formula.
8
+ Decimal approximations returned for reporting never decide a limit.
9
+ """
10
+
11
+ from decimal import Decimal, ROUND_HALF_EVEN, localcontext
12
+ from fractions import Fraction
13
+ from functools import lru_cache
14
+
15
+
16
+ def _ceil(numerator: int, denominator: int) -> int:
17
+ return -((-numerator) // denominator)
18
+
19
+
20
+ def _atan_inverse_scaled(inverse: int, scale: int) -> tuple[int, int]:
21
+ low = high = 0
22
+ power, index = inverse, 0
23
+ while True:
24
+ denominator = (2 * index + 1) * power
25
+ term_low, term_high = scale // denominator, _ceil(scale, denominator)
26
+ if index % 2:
27
+ low, high = low - term_high, high - term_low
28
+ else:
29
+ low, high = low + term_low, high + term_high
30
+ next_power = power * inverse * inverse
31
+ remainder = _ceil(scale, (2 * index + 3) * next_power)
32
+ if remainder <= 1:
33
+ return low - remainder, high + remainder
34
+ power, index = next_power, index + 1
35
+
36
+
37
+ @lru_cache(maxsize=32)
38
+ def _pi_scaled(digits: int) -> tuple[int, int]:
39
+ scale = 10 ** digits
40
+ a_low, a_high = _atan_inverse_scaled(5, scale)
41
+ b_low, b_high = _atan_inverse_scaled(239, scale)
42
+ return 16 * a_low - 4 * b_high, 16 * a_high - 4 * b_low
43
+
44
+
45
+ @lru_cache(maxsize=256)
46
+ def _cos_scaled(numerator: int, denominator: int, digits: int) -> tuple[int, int]:
47
+ scale = 10 ** digits
48
+ pi_low, pi_high = _pi_scaled(digits)
49
+ x_low = numerator * pi_low // (180 * denominator)
50
+ x_high = _ceil(numerator * pi_high, 180 * denominator)
51
+ squared_low = x_low * x_low // scale
52
+ squared_high = _ceil(x_high * x_high, scale)
53
+ # For 0<=angle<=180, x<=pi and the alternating cosine tail decreases
54
+ # beyond the first terms; these enclosures keep x² strictly below12.
55
+ assert 0 <= squared_low <= squared_high < 12 * scale
56
+ term_low = term_high = scale
57
+ total_low = total_high = scale
58
+ index = 0
59
+ while True:
60
+ index += 1
61
+ divisor = scale * (2 * index - 1) * (2 * index)
62
+ term_low = term_low * squared_low // divisor
63
+ term_high = _ceil(term_high * squared_high, divisor)
64
+ if index % 2:
65
+ total_low, total_high = total_low - term_high, total_high - term_low
66
+ else:
67
+ total_low, total_high = total_low + term_low, total_high + term_high
68
+ if index >= 2 and term_high <= 2:
69
+ remainder = _ceil(term_high * squared_high,
70
+ scale * (2 * index + 1) * (2 * index + 2))
71
+ return max(-scale, total_low - remainder), min(scale, total_high + remainder)
72
+
73
+
74
+ def cos_degrees_bounds(angle: Decimal, *, digits: int = 50) -> tuple[Fraction, Fraction]:
75
+ """Enclose cos(angle) on [0,180] degrees, preserving exact rational cases."""
76
+ if not isinstance(angle, Decimal) or not angle.is_finite() or not 0 <= angle <= 180:
77
+ raise ValueError("Supply a finite Decimal angle between0and180degrees")
78
+ if type(digits) is not int or digits < 20:
79
+ raise ValueError("Use an integer enclosure precision of at least20digits")
80
+ exact = {0: Fraction(1), 60: Fraction(1, 2), 90: Fraction(0),
81
+ 120: Fraction(-1, 2), 180: Fraction(-1)}
82
+ if angle in exact:
83
+ return exact[angle], exact[angle]
84
+ value = Fraction(angle)
85
+ low, high = _cos_scaled(value.numerator, value.denominator, digits)
86
+ scale = 10 ** digits
87
+ return Fraction(low, scale), Fraction(high, scale)
88
+
89
+
90
+ def half_angle_tangent_squared_bounds(
91
+ angle: Decimal, *, digits: int = 50,
92
+ ) -> tuple[Fraction, Fraction]:
93
+ """Enclose tan²(angle/2); refine a near180degree denominator if needed."""
94
+ if not isinstance(angle, Decimal) or not angle.is_finite() or not 0 <= angle < 180:
95
+ raise ValueError("Supply a finite Decimal direction change in[0,180)")
96
+ while True:
97
+ low_cos, high_cos = cos_degrees_bounds(angle, digits=digits)
98
+ if low_cos > -1:
99
+ return ((1 - high_cos) / (1 + high_cos),
100
+ (1 - low_cos) / (1 + low_cos))
101
+ digits *= 2
102
+
103
+
104
+ def compare_half_angle_tangent_squared(angle: Decimal, threshold: Fraction) -> int:
105
+ """Compare mathematical tan²(angle/2) with an exact rational threshold.
106
+
107
+ Return-1/0/1. Exact rational squared-tangent cases are handled by the
108
+ exact cosine cases; other rational-degree angles refine until separated.
109
+ No point approximation or reporting tolerance can establish equality.
110
+ """
111
+ if not isinstance(threshold, Fraction):
112
+ raise ValueError("Supply an exact Fraction comparison threshold")
113
+ digits = 40
114
+ while True:
115
+ low, high = half_angle_tangent_squared_bounds(angle, digits=digits)
116
+ if low == high:
117
+ return (low > threshold) - (low < threshold)
118
+ if low > threshold:
119
+ return 1
120
+ if high < threshold:
121
+ return -1
122
+ digits *= 2
123
+
124
+
125
+ def half_angle_tangent_degrees(angle: Decimal, *, precision: int = 40) -> Decimal:
126
+ """Return a Decimal report value; decisions must use the interval comparison."""
127
+ if type(precision) is not int or precision < 2:
128
+ raise ValueError("Use an integer reporting precision of at least2digits")
129
+ digits = max(20, precision + 16)
130
+ while True:
131
+ low, high = half_angle_tangent_squared_bounds(angle, digits=digits)
132
+ with localcontext() as context:
133
+ context.prec = precision + 8
134
+ context.rounding = ROUND_HALF_EVEN
135
+ lower = (Decimal(low.numerator) / Decimal(low.denominator)).sqrt()
136
+ upper = (Decimal(high.numerator) / Decimal(high.denominator)).sqrt()
137
+ # Enclose the roots themselves using exact rational comparisons,
138
+ # including any rounding in Decimal division/sqrt.
139
+ while Fraction(lower) ** 2 > low:
140
+ lower = lower.next_minus()
141
+ while Fraction(upper) ** 2 < high:
142
+ upper = upper.next_plus()
143
+ context.prec = precision
144
+ rounded_low, rounded_high = +lower, +upper
145
+ if rounded_low == rounded_high:
146
+ return rounded_low
147
+ digits *= 2
@@ -0,0 +1,245 @@
1
+ # SPDX-License-Identifier: MIT
2
+ """Exact branch-area arithmetic; Decimal reports never decide inequalities.
3
+
4
+ On a fixed clipping/zone branch every quantity has form C+S*sin(b)+I/sin(b).
5
+ After multiplication by positive sin(b), comparison is a rational polynomial
6
+ of degree at most two. Outward cosine enclosures decide nonzero values.
7
+ All possible quadratic equalities for rational-degree b in[45,90] occur at
8
+ 45,54,60,90degrees and are reduced exactly before interval refinement.
9
+
10
+ Indeed z=exp(i*pi*(90-b)/180) is a root of unity and satisfies z²-2*sin(b)*z+1=0.
11
+ A quadratic sin(b) implies phi(order(z))<=4. The orders are1,2,3,4,5,6,8,10,12;
12
+ within the stated angular range these give b=90,60,54,45. This uses the
13
+ cyclotomic degree theorem (Sharifi, Algebraic Number Theory,3.1.14).
14
+ The cosine enclosures reuse the integer outward-series implementation.
15
+ """
16
+
17
+ from dataclasses import dataclass
18
+ from decimal import Context, Decimal, ROUND_FLOOR, ROUND_HALF_EVEN, localcontext
19
+ from fractions import Fraction as F
20
+ from functools import lru_cache
21
+
22
+ from ._angle_intervals import cos_degrees_bounds
23
+
24
+
25
+ def _finite_decimal(value: F) -> Decimal | None:
26
+ denominator = value.denominator
27
+ twos = fives = 0
28
+ while denominator % 2 == 0:
29
+ denominator //= 2
30
+ twos += 1
31
+ while denominator % 5 == 0:
32
+ denominator //= 5
33
+ fives += 1
34
+ if denominator != 1:
35
+ return None
36
+ scale = max(twos, fives)
37
+ coefficient = value.numerator * 2 ** (scale - twos) * 5 ** (scale - fives)
38
+ # Decimal(int) is exact and avoids Python's int-to-text digit limit.
39
+ # Constructing its tuple also avoids ambient Decimal scaling/rounding.
40
+ digits = Decimal(coefficient).as_tuple()
41
+ return Decimal((digits.sign, digits.digits, -scale))
42
+
43
+
44
+ def _rounded(value: F, precision: int, rounding: str = ROUND_HALF_EVEN) -> Decimal:
45
+ with localcontext(Context(prec=precision, rounding=rounding)):
46
+ return Decimal(value.numerator) / Decimal(value.denominator)
47
+
48
+
49
+ def decimal_report(value: F, precision: int = 40, *, downward: bool = False) -> Decimal:
50
+ """Preserve every finite decimal digit; bound nonterminating credits below."""
51
+ finite = _finite_decimal(value)
52
+ return finite if finite is not None else _rounded(value, precision, ROUND_FLOOR if downward else ROUND_HALF_EVEN)
53
+
54
+
55
+ def finite_sum(values) -> Decimal:
56
+ return decimal_report(sum((F(value) for value in values), F(0)))
57
+
58
+
59
+ def _validate_angle(angle: Decimal) -> None:
60
+ if not isinstance(angle, Decimal) or not angle.is_finite() or not 45 <= angle <= 90:
61
+ raise ValueError('Supply a finite Decimal branch angle in[45,90]degrees')
62
+
63
+
64
+ @lru_cache(maxsize=256)
65
+ def _sine_bounds(angle: Decimal, digits: int) -> tuple[F, F]:
66
+ _validate_angle(angle)
67
+ complement = _finite_decimal(F(90) - F(angle))
68
+ assert complement is not None
69
+ return cos_degrees_bounds(complement, digits=digits)
70
+
71
+
72
+ def _scaled_bounds(coefficient: F, low: F, high: F) -> tuple[F, F]:
73
+ return (coefficient * low, coefficient * high) if coefficient >= 0 else (coefficient * high, coefficient * low)
74
+
75
+
76
+ def polynomial_sign(angle: Decimal, square: F, linear: F, constant: F) -> int:
77
+ """Sign of square*sin²+linear*sin+constant, including exact equalities."""
78
+ _validate_angle(angle)
79
+ square, linear, constant = F(square), F(linear), F(constant)
80
+ if angle == 90:
81
+ value = square + linear + constant
82
+ return (value > 0) - (value < 0)
83
+ if angle in (45, 60):
84
+ constant += square * (F(1, 2) if angle == 45 else F(3, 4))
85
+ square = F(0)
86
+ elif angle == 54:
87
+ # sin54=(1+sqrt5)/4, so sin²54=sin54/2+1/4.
88
+ constant += square / 4
89
+ linear += square / 2
90
+ square = F(0)
91
+ if square == linear == 0:
92
+ return (constant > 0) - (constant < 0)
93
+ digits = 40
94
+ while True:
95
+ low, high = _sine_bounds(angle, digits)
96
+ a, b = _scaled_bounds(square, low * low, high * high)
97
+ c, d = _scaled_bounds(linear, low, high)
98
+ if a + c + constant > 0:
99
+ return 1
100
+ if b + d + constant < 0:
101
+ return -1
102
+ digits *= 2
103
+
104
+
105
+ @dataclass(frozen=True)
106
+ class SineValue:
107
+ constant: F = F(0)
108
+ sine: F = F(0)
109
+ inverse: F = F(0)
110
+
111
+ def __post_init__(self):
112
+ for name in ('constant', 'sine', 'inverse'):
113
+ object.__setattr__(self, name, F(getattr(self, name)))
114
+
115
+ def __add__(self, other):
116
+ if not isinstance(other, SineValue):
117
+ other = SineValue(F(other))
118
+ return SineValue(self.constant + other.constant, self.sine + other.sine, self.inverse + other.inverse)
119
+
120
+ __radd__ = __add__
121
+
122
+ def __neg__(self):
123
+ return SineValue(-self.constant, -self.sine, -self.inverse)
124
+
125
+ def __sub__(self, other):
126
+ return self + (-other if isinstance(other, SineValue) else -F(other))
127
+
128
+ def __rsub__(self, other):
129
+ return -self + other
130
+
131
+ def __mul__(self, scalar):
132
+ scalar = F(scalar)
133
+ return SineValue(self.constant * scalar, self.sine * scalar, self.inverse * scalar)
134
+
135
+ __rmul__ = __mul__
136
+
137
+ def sign(self, angle):
138
+ return polynomial_sign(angle, self.sine, self.constant, self.inverse)
139
+
140
+ def _reduce(self, angle):
141
+ if angle == 90:
142
+ return SineValue(self.constant + self.sine + self.inverse)
143
+ if angle in (45, 60):
144
+ return SineValue(self.constant, self.sine + self.inverse * (2 if angle == 45 else F(4, 3)))
145
+ if angle == 54:
146
+ return SineValue(self.constant - 2 * self.inverse, self.sine + 4 * self.inverse)
147
+ return self
148
+
149
+ def report(self, angle, precision=40):
150
+ _validate_angle(angle)
151
+ value = self._reduce(angle)
152
+ if value.sine == value.inverse == 0:
153
+ return decimal_report(value.constant, precision)
154
+ digits = max(40, precision + 16)
155
+ while True:
156
+ low, high = _sine_bounds(angle, digits)
157
+ a, b = _scaled_bounds(value.sine, low, high)
158
+ c, d = _scaled_bounds(value.inverse, 1 / high, 1 / low)
159
+ rounded_low = _rounded(value.constant + a + c, precision)
160
+ rounded_high = _rounded(value.constant + b + d, precision)
161
+ if rounded_low == rounded_high:
162
+ return rounded_low
163
+ digits *= 2
164
+
165
+
166
+ def lesser(left, right, angle):
167
+ return left if (left - right).sign(angle) <= 0 else right
168
+
169
+
170
+ def greater(left, right, angle):
171
+ return left if (left - right).sign(angle) >= 0 else right
172
+
173
+
174
+ def zone_values(*, angle, run_od, branch_od, run_wall, branch_wall, allowance,
175
+ ring_or_saddle_thickness, effective_opening_length):
176
+ _validate_angle(angle)
177
+ dh, db, th, tb, c, tr = map(F, (run_od, branch_od, run_wall, branch_wall, allowance, ring_or_saddle_thickness))
178
+ run_net, branch_net = th - c, tb - c
179
+ d1 = SineValue(F(effective_opening_length)) if effective_opening_length is not None else SineValue(inverse=db - 2 * branch_net)
180
+ d2 = lesser(SineValue(dh), greater(d1, SineValue(branch_net + run_net) + d1 * F(1, 2), angle), angle)
181
+ l4 = min(F(5, 2) * run_net, F(5, 2) * branch_net + tr)
182
+ if (d1 - d2 * 2).sign(angle) > 0:
183
+ raise ValueError('Effective opening exceeds the reinforcement zone')
184
+ return d1, d2, l4
185
+
186
+
187
+ def clipped_sections(sections, *, half_width, lower_height, upper_height, run_allowable,
188
+ qualified, angle, section_type):
189
+ seen, clipped, results = set(), [], []
190
+ for section in sections:
191
+ if (not isinstance(section, section_type) or not isinstance(section.section_id, str)
192
+ or not section.section_id.strip() or section.section_id in seen
193
+ or not isinstance(section.reference, str) or not section.reference.strip()
194
+ or len(section.run_offset_interval) != 2 or len(section.surface_height_interval) != 2):
195
+ raise ValueError('Supply distinct referenced rectangular reinforcement sections')
196
+ seen.add(section.section_id)
197
+ x0, x1 = section.run_offset_interval
198
+ y0, y1 = section.surface_height_interval
199
+ if (any(not isinstance(value, Decimal) or not value.is_finite()
200
+ for value in (x0, x1, y0, y1, section.allowable_stress))
201
+ or x0 >= x1 or y0 >= y1 or section.allowable_stress <= 0):
202
+ raise ValueError('Supply increasing intervals and a positive reinforcement allowable stress')
203
+ left = greater(SineValue(F(x0)), -half_width, angle)
204
+ right = lesser(SineValue(F(x1)), half_width, angle)
205
+ bottom, top = max(F(y0), F(lower_height)), min(F(y1), F(upper_height))
206
+ area = SineValue()
207
+ if (right - left).sign(angle) > 0 and bottom < top:
208
+ for a, b, c, d in clipped:
209
+ if ((lesser(right, b, angle) - greater(left, a, angle)).sign(angle) > 0
210
+ and max(bottom, c) < min(top, d)):
211
+ raise ValueError('Added reinforcement sections must not overlap inside the credit zone')
212
+ clipped.append((left, right, bottom, top))
213
+ area = (right - left) * (top - bottom)
214
+ credit = area * min(F(1), F(section.allowable_stress) / F(run_allowable)) if qualified else SineValue()
215
+ results.append((section, area, credit))
216
+ return tuple(results)
217
+
218
+
219
+ def welded_values(*, angle, pressure_side, run_od, branch_od, run_wall, branch_wall,
220
+ run_pressure_thickness, branch_pressure_thickness, allowance,
221
+ ring_or_saddle_thickness, effective_opening_length, run_allowable,
222
+ branch_allowable, added_areas, added_sections, qualified, section_type):
223
+ d1, d2, l4 = zone_values(angle=angle, run_od=run_od, branch_od=branch_od,
224
+ run_wall=run_wall, branch_wall=branch_wall, allowance=allowance,
225
+ ring_or_saddle_thickness=ring_or_saddle_thickness,
226
+ effective_opening_length=effective_opening_length)
227
+ th, tb, c, stress_h, stress_b = map(F, (run_pressure_thickness, branch_pressure_thickness, allowance, run_allowable, branch_allowable))
228
+ run_net, branch_net = F(run_wall) - c, F(branch_wall) - c
229
+ factor = F(1, 2) if pressure_side == 'external' else F(1)
230
+ if effective_opening_length is None:
231
+ bore = F(branch_od) - 2 * branch_net
232
+ a1 = SineValue(-th * bore * factor, inverse=2 * th * bore * factor)
233
+ else:
234
+ opening = F(effective_opening_length)
235
+ a1 = SineValue(2 * th * opening * factor, sine=-th * opening * factor)
236
+ a2 = (d2 * 2 - d1) * max(F(0), run_net - th)
237
+ a3 = SineValue(inverse=2 * l4 * max(F(0), branch_net - tb) * min(F(1), stress_b / stress_h))
238
+ a4 = SineValue(sum((F(item.area_in_zone) * min(F(1), F(item.allowable_stress) / stress_h)
239
+ for item in added_areas), F(0))) if qualified else SineValue()
240
+ sections = clipped_sections(added_sections, half_width=d2, lower_height=-run_net, upper_height=l4,
241
+ run_allowable=stress_h, qualified=qualified, angle=angle,
242
+ section_type=section_type)
243
+ if sections:
244
+ a4 = sum((credit for _, _, credit in sections), SineValue())
245
+ return (d1, d2, SineValue(l4), a1, a2, a3, a4, a2 + a3 + a4 - a1), sections
@@ -0,0 +1,84 @@
1
+ # SPDX-License-Identifier: MIT
2
+ """Original K304 paragraph ownership from retained bold heading geometry."""
3
+ from bisect import bisect_right
4
+ import json
5
+ import re
6
+
7
+ from .catalog import SourceLocation
8
+ from .leak_source import _design_target_lines
9
+ from .pressure_design import _SOURCE_HASH
10
+
11
+
12
+ def _source_provisions(document):
13
+ """Keep each original glyph line once and retain its actual clause/footnote.
14
+
15
+ A regular-font line beginning with a crossreference is body text. Only an
16
+ original bold heading can change the active clause, including across the
17
+ printed column and page continuations.
18
+ """
19
+ if document.sha256 != _SOURCE_HASH:
20
+ raise ValueError('Use the B31.3-2008 K304 source')
21
+
22
+ def position(page, bounds):
23
+ return page, int(bounds[0] >= 300), bounds[1], bounds[0]
24
+
25
+ # Candidate and bold-font geometry are the same original heading evidence
26
+ # used by DocumentCatalog.clause_headings; K304 occupies only these pages.
27
+ from contextlib import closing
28
+ import sqlite3
29
+ with closing(sqlite3.connect(document.source_db_path.resolve().as_uri()+'?mode=ro',uri=True)) as db:
30
+ candidates=db.execute("SELECT page,label,bbox FROM candidate WHERE kind='clause' AND page BETWEEN 140 AND 144 AND (label='K304' OR label LIKE 'K304.%') ORDER BY page,id").fetchall()
31
+ bold_by_page={}
32
+ headings=[]
33
+ for page,label,bounds in candidates:
34
+ if page not in bold_by_page:
35
+ bold_by_page[page]={tuple(line['bbox']) for block in document.layout(page).glyph_layout['blocks']
36
+ for line in block.get('lines',()) if line['spans'] and line['spans'][0]['flags'] & 16}
37
+ box=tuple(json.loads(bounds))
38
+ if box in bold_by_page[page]:headings.append((position(page,box),label))
39
+ headings.sort()
40
+ if len(headings) != 31:
41
+ raise ValueError('Retain every original K304 heading and its typography')
42
+ positions = [p for p, _ in headings]
43
+ result = []
44
+ active, path = None, ()
45
+ for raw, loc in _design_target_lines(document, 'K304'):
46
+ index = bisect_right(positions, position(loc.pdf_page, loc.bounds_pt)) - 1
47
+ if index < 0:
48
+ raise ValueError('Retain the original K304 source boundary')
49
+ heading = headings[index][1]
50
+ if heading != active:
51
+ active, path = heading, ()
52
+ role = 'edition_change_marker' if raw.strip() == '(08)' else (
53
+ 'license_print_artifact' if raw.startswith('--`') else 'native_body')
54
+ letter = re.match(r'^\(([a-d])\)', raw)
55
+ number = re.match(r'^\(([12])\)', raw)
56
+ if letter:
57
+ if heading == 'K304.1.1' and path == ('b',):
58
+ role = 'nomenclature_c_exception_condition'
59
+ else:
60
+ path = (letter[1],)
61
+ elif number and path and heading in ('K304.7.2', 'K304.8.2'):
62
+ path = path[0], number[1]
63
+ label = heading + ''.join('(' + p + ')' for p in path)
64
+ result.append((label, role, raw, loc.pdf_page, json.dumps(loc.bounds_pt)))
65
+ for page, col, top, bottom, label, role in (
66
+ (140, 1, 697, 733, 'K304.1.1(b)', 'footnote3'),
67
+ (141, 0, 608, 697, 'K304.1.2', 'footnotes4_5'),
68
+ (141, 0, 697, 733, 'K304.1.2', 'footnote6'),
69
+ (143, 0, 655, 670, 'K304.8.1', 'footnote7'),
70
+ (143, 0, 670, 697, 'K304.8.1', 'footnote8'),
71
+ (143, 0, 697, 733, 'K304.8.1', 'footnote9'),
72
+ (143, 1, 714, 733, 'K304.8.3', 'footnote10'),
73
+ ):
74
+ left, right = (300, 565) if col else (35, 300)
75
+ for raw, loc in document.text_region(SourceLocation(_SOURCE_HASH, page, (left, top, right, bottom))):
76
+ if left <= loc.bounds_pt[0] < right:
77
+ result.append((label, role, raw, page, json.dumps(loc.bounds_pt)))
78
+ unique, seen = [], set()
79
+ for row in result:
80
+ identity = row[3], tuple(json.loads(row[4])), row[2]
81
+ if identity not in seen:
82
+ seen.add(identity)
83
+ unique.append(row)
84
+ return unique
@@ -0,0 +1,102 @@
1
+ # SPDX-License-Identifier: MIT
2
+ """Exact signs and rational enclosures for C+B*sqrt(Q).
3
+
4
+ Opposite-signed terms are compared by squaring their nonnegative
5
+ magnitudes with Fraction arithmetic. Reporting uses integer square-root
6
+ enclosures and cannot decide acceptance. Perfect-square rationals reduce
7
+ exactly, preserving equality and every terminating Decimal digit.
8
+ """
9
+
10
+ from dataclasses import dataclass
11
+ from fractions import Fraction as F
12
+ from math import isqrt
13
+
14
+ from ._branch_arithmetic import _rounded, decimal_report
15
+
16
+
17
+ def root_bounds(radicand: F, digits: int) -> tuple[F, F]:
18
+ radicand = F(radicand)
19
+ if radicand < 0 or type(digits) is not int or digits < 2:
20
+ raise ValueError('Use a nonnegative rational and at least two enclosure digits')
21
+ scale = 10 ** digits
22
+ numerator, denominator = radicand.numerator * scale * scale, radicand.denominator
23
+ low = isqrt(numerator // denominator)
24
+ high = low if low * low * denominator == numerator else low + 1
25
+ return F(low, scale), F(high, scale)
26
+
27
+
28
+ @dataclass(frozen=True)
29
+ class RadicalValue:
30
+ constant: F = F(0)
31
+ coefficient: F = F(0)
32
+ radicand: F = F(0)
33
+
34
+ def __post_init__(self):
35
+ c, b, q = F(self.constant), F(self.coefficient), F(self.radicand)
36
+ if q < 0:
37
+ raise ValueError('Use a nonnegative square-root radicand')
38
+ numerator, denominator = isqrt(q.numerator), isqrt(q.denominator)
39
+ if b == 0 or numerator * numerator == q.numerator and denominator * denominator == q.denominator:
40
+ c += b * F(numerator, denominator)
41
+ b, q = F(0), F(0)
42
+ object.__setattr__(self, 'constant', c)
43
+ object.__setattr__(self, 'coefficient', b)
44
+ object.__setattr__(self, 'radicand', q)
45
+
46
+ def __add__(self, other):
47
+ if not isinstance(other, RadicalValue):
48
+ other = RadicalValue(F(other))
49
+ if self.coefficient == 0:
50
+ return RadicalValue(self.constant + other.constant, other.coefficient, other.radicand)
51
+ if other.coefficient == 0:
52
+ return RadicalValue(self.constant + other.constant, self.coefficient, self.radicand)
53
+ if self.radicand != other.radicand:
54
+ raise ValueError('Use one common radical basis')
55
+ return RadicalValue(self.constant + other.constant, self.coefficient + other.coefficient, self.radicand)
56
+
57
+ __radd__ = __add__
58
+
59
+ def __neg__(self):
60
+ return RadicalValue(-self.constant, -self.coefficient, self.radicand)
61
+
62
+ def __sub__(self, other):
63
+ return self + (-other if isinstance(other, RadicalValue) else -F(other))
64
+
65
+ def __rsub__(self, other):
66
+ return -self + other
67
+
68
+ def __mul__(self, scalar):
69
+ scalar = F(scalar)
70
+ return RadicalValue(self.constant * scalar, self.coefficient * scalar, self.radicand)
71
+
72
+ __rmul__ = __mul__
73
+
74
+ def sign(self) -> int:
75
+ c, b, q = self.constant, self.coefficient, self.radicand
76
+ if b == 0:
77
+ return (c > 0) - (c < 0)
78
+ if c == 0 or (c > 0) == (b > 0):
79
+ return (b > 0) - (b < 0)
80
+ delta = b * b * q - c * c
81
+ return ((delta > 0) - (delta < 0)) * (1 if b > 0 else -1)
82
+
83
+ def report(self, precision: int = 40):
84
+ if type(precision) is not int or precision < 2:
85
+ raise ValueError('Use a reporting precision of at least two digits')
86
+ if self.coefficient == 0:
87
+ return decimal_report(self.constant, precision)
88
+ digits = max(40, precision + 16)
89
+ while True:
90
+ low, high = root_bounds(self.radicand, digits)
91
+ a, b = self.constant + self.coefficient * low, self.constant + self.coefficient * high
92
+ lower, upper = _rounded(min(a, b), precision), _rounded(max(a, b), precision)
93
+ if lower == upper:
94
+ return lower
95
+ digits *= 2
96
+
97
+
98
+ def extruded_factor(header_od, branch_od):
99
+ ratio = F(branch_od) / F(header_od)
100
+ regime = '1' if ratio > F(3, 5) else '2' if ratio > F(3, 20) else '3'
101
+ factor = F(1) if regime == '1' else F(3, 5) + F(2, 3) * ratio if regime == '2' else F(7, 10)
102
+ return ratio, regime, factor