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 :
- normalized name
- aliases (commercial or usual names, comma separated)
- treatment (e.g. molded, rolled, normalized, etc.)
- chemical formula
- modulus of elasticity (E, in GPa)
- modulus of rigidity (G, in GPa)
- Poisson’s ratio (nu)
- volumic mass (often called density, in kg/m³)
- tensile yield strength at 0,2 % (S_y, in MPa)
- ultimate tensile strength (S_ut, in MPa)
- thermal expansion coefficient (alpha, in µ/°C)
- brinell hardness
- Rockwell B hardness
- Rockwell C hardness
- fatigue strength at 5E8 cycles (S_f, in MPa)
- elongation at break (epsilon, ratio)
A .csv template is provided in the lib root.
- Check and ensure such data don’t already exist to avoid duplicates
- Use the provided
.csvtemplate and open it in your favorite spreadsheet editor - IMPORTANT ! Use the same exact order of columns and symbols headers
- 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
- 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
- Give your final CSV file a relevant name like
material.csv. For example :stainless-steel.csv,carbon-steel.csv,cast-iron.csvThis name will be added into the database in the category column. - Try to split your data into consistent files to keep less than ~ 100 entries in each files (for maintainability)
- 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.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.
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.