LibreMecaDesign.lib package

Submodules

lib.build module

This module imports all CSV data sheet from the lib directory into a sqlite database. This script has to be executed each time a data sheet is added or edited. You just need to call it without argument.

Warning

Each new call of the module overwrite the previous database. Make a backup before.

Included data

  • Carbon steel
  • Tool steel
  • Stainless steel

Adding data

Only standard data from reputable and trusted sources are and should be used in the librairies.

For materials properties, data should include in this order :

  1. normalized name
  2. aliases (commercial or usual names, comma separated)
  3. treatment (e.g. molded, rolled, normalized, etc.)
  4. chemical formula
  5. modulus of elasticity (E, in GPa)
  6. modulus of rigidity (G, in GPa)
  7. Poisson’s ratio (nu)
  8. volumic mass (often called density, in kg/m³)
  9. tensile yield strength at 0,2 % (S_y, in MPa)
  10. ultimate tensile strength (S_ut, in MPa)
  11. thermal expansion coefficient (alpha, in µ/°C)
  12. brinell hardness
  13. Rockwell B hardness
  14. Rockwell C hardness
  15. fatigue strength at 5E8 cycles (S_f, in MPa)
  16. elongation at break (epsilon, ratio)

A .csv template is provided in the lib root.

  1. Check and ensure such data don’t already exist to avoid duplicates
  2. Use the provided .csv template and open it in your favorite spreadsheet editor
  3. IMPORTANT ! Use the same exact order of columns and symbols headers
  4. Ensure values have a correct number format in the final CSV file :
  • numbers should use dots . as decimal separator
  • numbers should not be into quotation marks “” meaning their format in the spreadsheet should be number
  • numbers should not use thousands separators
  1. Include the data source (organization, book, etc.) of your data in the 1st line of the header. It will be used in the database as a comment and to ensure the trustability of the data
  2. Give your final CSV file a relevant name like material.csv. For example : stainless-steel.csv, carbon-steel.csv, cast-iron.csv This name will be added into the database in the category column.
  3. Try to split your data into consistent files to keep less than ~ 100 entries in each files (for maintainability)
  4. Save your file into the proper directory : the one mentioning the source organization of the data or the standard used to compute/measure the data : ISO, ACNOR, SAE, ASHRAE, etc.

Note

  • Use “dimensionless” as a unit for ratios and coefficients, and “none” if a unit is not relevant (for text) to ensure the correct column spacing.
  • Use SI units ONLY ! British units will be converted on the fly in the code.
lib.build.SI_convert(line, prop)[source]

Convert usual engineering units & multiples to SI units to normalize database

Note

the units and multiple handled from the CSV data-sheet are considered given in usual engineering habits (GPa, MPa, etc.) because they are human-readable and standard tables are given is such units. However, to make the database unit-independant and facilitate later querying, multiples have to be normalized into SI standards.

lib.build.build_property(prop)[source]

Sequence of functions to build a new property into the database

lib.build.check_pattern(line, prop)[source]

Check and ensure that the properties are given in the expected order to avoid mixing up the columns

Parameters:
  • line (str list) – the header line corresponding to the symbols of the given columns
  • prop – the desired property to check
Returns:

raise an error if given and expected headers don’t match

lib.build.create_tables(cursor, prop)[source]

Create the relevant tables into the database

Parameters:
  • cursor – sqlite 3 cursor
  • prop – the desired property - for now : “materials”
lib.build.database_handle(db)[source]

Create or overwrite the sqlite3 database and open a connection if it does.

Parameters:db (str) – database filename
Returns:connection socket to the sqlite3 database
lib.build.insert_property(prop, cursor, comment, category, line)[source]

Build the database insertion with the relevant formatted data

Parameters:
  • prop (string) – the property to build
  • cursor (sqlite3 handler) – the database cursor handler
  • comment (string) – the comment to add in every insertion, namely : the source of the data - should be the first line of the CSV data-sheet
  • category (string) – the category of the property to add. For exemple : cast iron, stainless steel, carbon steel, etc.
  • line (list of strings) – the data line from the CSV data-sheet
lib.build.parse_csv(PATH, cursor, database, prop)[source]

Parse the CSV files and process their data

Parameters:
  • PATH – root of all the librairies
  • cursor – sqlite3 handler
  • database – sqlite file
  • prop – the given property

lib.geometry module

Reference

Machine Design, an integrated approach. Robert L. Norton, Prentice Hall. Fifth Edition, 2014.

Résistance des matériaux. Bazergui, Bui-Quoc, Biron, McIntyre, Laberge, Presses internationales Polytechnique. Third Edition, 2002.

General consideration

For beams, use the x axis along the longest dimension of the beam. Thus the cross-section of the beam will be in the (y, z) plan.

class lib.geometry.geometry(**kwargs)[source]

Store and compute basic geometrical properties of a material object

Parameters:
  • position (3 elements array or tuple) – coordinates of the origin of the object. For example, the centroid of an extreme surface
  • dimensions (3 elements array or tuple) – lengths over the 3 space dimensions or formal expressions of these dimensions.
  • a,b – geometric parameters to compute section properties for standard/usual profiles as defined in Norton’s Machine design book.
circle()[source]
Parameters:
  • a – radius
  • b – none
hollow_circle()[source]
Parameters:
  • a – external diameter
  • b – internal diameter
rectangle()[source]
Parameters:
  • a – height
  • b – width
right_triangle()[source]
Parameters:
  • a – height
  • b – width
semi_circle()[source]
Parameters:a – external diameter

lib.materials module

This imports materials properties as a class and make them query-able by mapping their names and aliases to human-readable names.

class lib.materials.materials(material, standard='', **kwds)[source]
processdata(dir, file)
trimdata(file)

Extract the symbols of the properties from the 3rd line of the data-sheet

Module contents