From dd8b70334e939bc0c4a1d5572023eadd8994b028 Mon Sep 17 00:00:00 2001 From: Daniel Weschke Date: Sun, 10 Feb 2019 20:45:55 +0100 Subject: [PATCH] refine material structure for yield strength and get data as entered --- src/data/AlMg4.5Mn0.7.json | 4 +++- src/data/INFO.json | 14 ++++++++++---- src/materials.py | 32 +++++++++++++++++--------------- 3 files changed, 30 insertions(+), 20 deletions(-) diff --git a/src/data/AlMg4.5Mn0.7.json b/src/data/AlMg4.5Mn0.7.json index 2805baf..943e5d5 100644 --- a/src/data/AlMg4.5Mn0.7.json +++ b/src/data/AlMg4.5Mn0.7.json @@ -16,7 +16,9 @@ "T": ["20-25", "°C"], "rho": [2.66, "g/cm³"], "E": [70, "GPa"], - "R_p02": ["110-130", "MPa"], + "Yield strength": { + "R_p02": ["110-130", "MPa"] + }, "R_m": ["230-290", "MPa"], "Elongation": { "A_5": ["10-15", "%"] diff --git a/src/data/INFO.json b/src/data/INFO.json index cfad5a8..55e1397 100644 --- a/src/data/INFO.json +++ b/src/data/INFO.json @@ -32,9 +32,13 @@ "T": "Reference temperature", "rho": "Density", "E": "Young modulus, module of elasticity", - "R_p": "Yield strength R_p (R_e), R_{p0.2}", - "R_p02": "Yield strength R_p (R_e), R_{p0.2}", - "R_m": "Ultimate tensile strength R_m", + "Yield strength": { + "R_s": "it is detectable only when the material has the yield phenomenon (it does not exist for the cold drawn and the stainless steels)", + "R_p": "it is detectable on cold drawn and stainless steel, in place of R_s", + "R_p02": "load corresponding to a no proportional charge equal to a 0.2% of length L_0", + "R_p10": "load corresponding to a no proportional charge equal to a 1% of length L_0" + }, + "R_m": "Ultimate tensile strength; it is the ratio between the maximum applied force and the original cross-sectional area of the specimen", "Elongation": { "A": "permanent elongation of length L_0, expressed in per cent of length L_0", "A_0": "permanent elongation for proportional specimens with length L_0 equal to 100 mm (used for diameter lower than 4 mm)", @@ -109,7 +113,9 @@ "T": ["20-25", "°C"], "rho": [2.66, "g/cm³"], "E": [70, "GPa"], - "R_p02": ["110-130", "MPa"], + "Yield strength": { + "R_p02": ["110-130", "MPa"] + }, "R_m": ["230-290", "MPa"], "Elongation": { "A_5": ["10-15", "%"] diff --git a/src/materials.py b/src/materials.py index 2d1168f..992350b 100755 --- a/src/materials.py +++ b/src/materials.py @@ -180,9 +180,9 @@ def main(): parser_get.add_argument('-E', '--E', dest='const_collection', action='append_const', const="E", help='get Young\'s modulus, module of elasticity') - parser_get.add_argument('-R', '--R_p02', dest='const_collection', - action='append_const', const="R_p02", - help='get yield strength R_e, R_{p0.2}') + parser_get.add_argument('-R', '--R_p', dest='const_collection', + action='append_const', const="R_p", + help='get yield strength R_p') parser_get.add_argument('--R_m', dest='const_collection', action='append_const', const="R_m", help='get ultimate tensile strength R_m') @@ -207,18 +207,20 @@ def main(): if args.const_collection: data = load_material(args.materialname) if args.debug: - print("data: " + data) - if "rho" in args.const_collection: - #args.const_collection.append("rho(T)") - #f args.debug: - # print(args) - print_quantity(data['Mechanical Properties']['rho']) - if "E" in args.const_collection: - print_quantity(data['Mechanical Properties']['E']) - if "R_p02" in args.const_collection: - print_quantity(data['Mechanical Properties']['R_p02']) - if "R_m" in args.const_collection: - print_quantity(data['Mechanical Properties']['R_m']) + print("data:") + print_material(data) + for element in args.const_collection: # iter the way it is been entered as args + if element == "rho": + print_quantity(data['Mechanical Properties']['rho']) + elif element == "E": + print_quantity(data['Mechanical Properties']['E']) + elif element == "R_p": + if len(data['Mechanical Properties']['Yield strength']) == 1: + print_quantity(next(iter(data['Mechanical Properties']['Yield strength'].values()))) + else: + print_quantity(data['Mechanical Properties']['Yield strength']) + elif element == "R_m": + print_quantity(data['Mechanical Properties']['R_m']) elif args.search: search_list = [element for element in args.search.split(',')]