How to use MatAn?
There is also an presentation in our repo This tutorial need to be updated! This is almost autogenerated with unitex package
Set up of Sample Class
imports
import os
import matan as mt
import numpy as np
import pandas as pd
sample_name = "FDM-20pPET-10prPET"
sample = mt.sample(sample_name)
Adding tensile test to sample
sample.tensile.add(1)
You can also separately use tensile test class, and later just append the tensile_tests
object into your sample class by simple using add()
method:
material_group = "pOlymers"
standard = "ISO527"
tensile_test = mt.tensile.test()
tensile_test.define(material_group, standard)
sample.add(tensile_test)
Tensile_Test class
SetUp
name = "FDM-20pPET-10prPET"
material_group = "PoLyMeRs"
standard = "iSo527"
tensile_test = mt.tensile.tests(name)
tensile_test.define(material_group=material_group, standard=standard)
tensile_test.add(2)
Read data from the csv
raw_csv_path = os.path.join(*results_path, "METHOD1-10pXXX.raw.csv")
raw_df = pd.read_csv(raw_csv_path, skiprows=4)
init_values = pd.read_csv(
raw_csv_path, skiprows=0, names=["name", "value", "unit"]
)[0:4]
init_length_obj = init_values.values[3][1].split(" ")
init_length = int(init_length_obj[0])
init_force_obj = init_values.values[0][1].split(" ")
init_force = float(init_force_obj[0])
Set Engineering Tensile
Now you can set the engineering data obtained from Tensile Test
print("Engineering values")
tt_obj = tensile_test.results[0]
tt_obj.engineering_values.calculate(
elongation_array=raw_df["Elongation"],
elongation_units="mm",
force_array=raw_df[raw_df.keys()[1]],
force_units="N",
initial_length=init_length,
width=final_df["b"].loc[0].mean(),
height=final_df["h"].loc[0].mean(),
initial_stress=0.1,
)
Calculating Real Tensile values
obj = tensile_test.results[0].real_values
real_values = raw_df["Real stress"]
print("Recalculating from eng to real")
obj.calculate()
Setting Real Tensile
df = raw_df
obj = tensile_test.results[0].real_values
strain = df["Elongation"].apply(lambda elon: elon / init_length)
obj.set(df["Real stress"], "MPa", strain, "mm/mm")
"""
Too small size of strain group, thus, there is a problem with Young's modulus calculations
"""
obj.calculate_parameters()