<jupyter_start><jupyter_text>PLOT ENGINEERING STRESS AND STRAIN CURVE<jupyter_code>styles = ["b-", "r-", "g-"]
eng_curves = []
for i in range(3):
    j = data["Spec " + str(i + 1)]
    x = list(j["Engineering Strain"])
    y = list(j["Engineering Stress"])
    eng_curves.append(plt.plot(x, y, styles[i], label = "Spec " + str(i + 1)))
plt.xlabel = "Engineering Strain [mm/mm]"
plt.ylabel = "Engineering Stress [MPa]"
plt.legend()
plt.title("Engineering Stress - Strain curve (5 mm/s rate)")
plt.grid(True)
plt.savefig(output_path + "\\Engineering_Curves.pdf")
plt.show()
styles = ["b-", "r-", "g-"]
true_curves = []
for i in range(3):
    j = data["Spec " + str(i + 1)]
    x = list(j["True Strain"])
    y = list(j["True Stress"])
    true_curves.append(plt.plot(x, y, styles[i], label = "Spec " + str(i + 1)))
plt.xlabel = "True Strain [mm/mm]"
plt.ylabel = "True Stress [MPa]"
plt.legend()
plt.title("True Stress - Strain curve (5 mm/s rate)")
plt.grid(True)
plt.savefig(output_path + "\\True_Curves.pdf")
plt.show()
plt.plot(data["Spec 1"]["True Strain"], data["Spec 1"]["True Stress"], "r-", label = "True")
plt.plot(data["Spec 1"]["Engineering Strain"], data["Spec 1"]["Engineering Stress"], "g-", label = "Engineering")
plt.legend()
plt.title("Spec 1")
plt.xlabel = "Strain [mm/mm]"
plt.ylabel = "Stress [MPa]"
plt.plot(data["Spec 2"]["True Strain"], data["Spec 2"]["True Stress"], "r-", label = "True")
plt.plot(data["Spec 2"]["Engineering Strain"], data["Spec 2"]["Engineering Stress"], "g-", label = "Engineering")
plt.legend()
plt.title("Spec 2")
plt.xlabel = "Strain [mm/mm]"
plt.ylabel = "Stress [MPa]"
plt.plot(data["Spec 3"]["True Strain"], data["Spec 3"]["True Stress"], "r-", label = "True")
plt.plot(data["Spec 3"]["Engineering Strain"], data["Spec 3"]["Engineering Stress"], "g-", label = "Engineering")
plt.legend()
plt.title("Spec 3")
plt.xlabel = "Strain [mm/mm]"
plt.ylabel = "Stress [MPa]"<jupyter_output><empty_output><jupyter_text>Find UTS Stress and UTS Strain of the parts<jupyter_code>yeild_stress = None
yeild_strain = None
std_yeild_stress = None
mean_yeild_strain = None
ut_stress = []
ut_strain = []
indices = []
for i in range(1, 4):
    dat = data["Spec " + str(i)]
    a = list(dat["True Stress"])
    b = list(dat["True Strain"])
    ut_stress.append(max(a))
    ut_strain.append(b[a.index(max(a))])
    indices.append(a.index(max(a)))
    
ut_stress
ut_strain
mean_ut_stress = np.mean(ut_stress)
mean_ut_strain = np.mean(ut_strain)
std_ut_stress = np.std(ut_stress)
std_ut_strain = np.std(ut_strain)
mean_ut_stress
mean_ut_strain
std_ut_stress
std_ut_strain<jupyter_output><empty_output><jupyter_text>Find Young's Modulus of the parts - Approach 1 Don't USE IT<jupyter_code>coefs1 = []
strains = []
for i in range(1, 4):
    stress = np.array(data["Spec " + str(i)].loc[0: indices[i - 1], "True Stress"])
    strain = np.array(data["Spec " + str(i)].loc[0: indices[i - 1], "True Strain"])
    strains.append(strain)
    coef = np.polyfit(strain, stress, 1)
    coefs1.append(coef)
coefs1
expressions1 = []
for i in coefs1:
    expressions1.append(np.poly1d(i))
dataset1 = expressions1[0](np.array(data["Spec " + str(1)].loc[0: indices[0], "True Strain"]))
dataset2 = expressions1[1](np.array(data["Spec " + str(2)].loc[0: indices[1], "True Strain"]))
dataset3 = expressions1[2](np.array(data["Spec " + str(3)].loc[0: indices[2], "True Strain"]))
datasets = [dataset1, dataset2, dataset3]
fig, ax = plt.subplots(1, 3)
for i in range(3):
    ax[i].plot(data["Spec " + str(i + 1)]["True Strain"], data["Spec "  + str(i + 1)]["True Stress"], "r-", label = "True")
    ax[i].plot(strains[i], datasets[i], "b--", label = "Elastic Trend")
    ax[i].set_title("Spec " + str(i + 1))
    ax[i].xlabel = "Strain [mm/mm]"
    ax[i].ylabel = "Stress [MPa]"
plt.savefig(output_path + "\\" + "True_Curves_With_Young_Modulus_1.pdf")
Young_Modulus1 = []

for i in coefs1:
    Young_Modulus1.append(i[0])
mean_modulus = np.mean(Young_Modulus1)
std_modulus = np.std(Young_Modulus1)
print(Young_Modulus1)
print(mean_modulus)
print(std_modulus)<jupyter_output>[2177.2889034500868, 2228.1220197025077, 2234.3124955997896]
2213.241139584128
25.547380299319716<jupyter_text>Find Young's Modulus of the parts - Approach 2<jupyter_code>coefs2 = []
strains2 = []
for i in range(1, 4):
    stress2 = np.array(data["Spec " + str(i)].loc[0: 16, "True Stress"])
    strain2 = np.array(data["Spec " + str(i)].loc[0: 16, "True Strain"])
    strains2.append(strain)
    coef = np.polyfit(strain2, stress2, 1)
    coefs2.append(coef)
coefs2
expressions2 = []
for i in coefs2:
    expressions2.append(np.poly1d(i))
dataset21 = expressions2[0](strains2)
dataset22 = expressions2[1](strains2)
dataset23 = expressions2[2](strains2)
datasets2 = [dataset21, dataset22, dataset23]
fig, ax = plt.subplots(1, 3)
for i in range(3):
    ax[i].plot(data["Spec " + str(i + 1)]["True Strain"], data["Spec "  + str(i + 1)]["True Stress"], "r-", label = "True")
    ax[i].plot(strains2[i], datasets2[i].T, "b--", label = "Elastic Trend")
    ax[i].set_title("Spec " + str(i + 1))
    ax[i].xlabel = "Strain [mm/mm]"
    ax[i].ylabel = "Stress [MPa]"
plt.savefig(output_path + "\\" + "True_Curves_With_Young_Modulus_2.pdf")
Young_Modulus2 = []

for i in coefs2:
    Young_Modulus2.append(i[0])
mean_modulus2 = np.mean(Young_Modulus2)
std_modulus2 = np.std(Young_Modulus2)
print(Young_Modulus2)
print(mean_modulus2)
print(std_modulus2)<jupyter_output>[2655.438974306968, 2714.655112589307, 2758.9420819914935]
2709.6787229625897
42.4012316281521<jupyter_text>Finding Yield Stress and Strain<jupyter_code>yield_stress = []
yield_strain = []
indices = []
for i in range(1, 4):
    A = data["Spec " + str(i)]
    for j in range(len(A)):
        if A.loc[j, "True Stress"] > 20:
            yield_stress.append(A.loc[j, "True Stress"])
            yield_strain.append(A.loc[j, "True Strain"])
            indices.append(j)
            break

mean_yield_stress = np.mean(yield_stress)
std_yield_stress = np.std(yield_stress)
mean_yield_strain = np.mean(yield_strain)
std_yield_strain = np.std(yield_strain)
print(yield_stress, yield_strain, sep = "\n")
print(mean_yield_stress, mean_yield_strain, sep = " ")
print(std_yield_stress, std_yield_strain, sep = " ")<jupyter_output>[21.057055593991873, 20.21086679115866, 20.534115821951037]
[0.008193909571430963, 0.007834024231774477, 0.00771003197192938]
20.60067940236719 0.007912655258378273
0.34864681765213257 0.00020521778932543625<jupyter_text>Defining Plastic Region<jupyter_code>plastic1 = data["Spec 1"].loc[indices[0]:, "True Strain"] - yield_strain[0]
plastic2 = data["Spec 2"].loc[indices[1]:, "True Strain"] - yield_strain[1]
plastic3 = data["Spec 3"].loc[indices[2]:, "True Strain"] - yield_strain[2]
plastic = [plastic1, plastic2, plastic3]
plastic_stress1 = data["Spec 1"].loc[indices[0]:, "True Stress"]
plastic_stress2 = data["Spec 2"].loc[indices[1]:, "True Stress"]
plastic_stress3 = data["Spec 3"].loc[indices[2]:, "True Stress"]
plastic_stress = [plastic_stress1, plastic_stress2, plastic_stress3]
fig, ax = plt.subplots(1, 3)
for i in range(3):
    ax[i].plot(plastic[i], plastic_stress[i], "r-", label = "Spec 1")
    ax[i].xlabel = "Strain [mm/mm]"
    ax[i].ylabel = "Stress [MPa]"

plt.title("True Plastic Strain Stress")
plt.savefig(output_path + "\\" + "True_Plastic_Strain_Stress.pdf")

for i in range(1, 4):
    data["Spec " + str(i)].to_excel(output_path + "\\" + "Spec_" + str(i) + ".xlsx")<jupyter_output><empty_output><jupyter_text>Using Linear Extension of the Softening Region<jupyter_code>necking_i = []
for i in range(1, 4):
    A = data["Spec " + str(i)]
    indeX = list(A["True Stress"]).index(max(A["True Stress"]))
    necking_i.append(indeX)
necking_i
for i in range(1, 4):
    A = data["Spec " + str(i)]
    for j in range(necking_i[i-1]):
        A.loc[j, "Abaqus Strain Linear"] = A.loc[j, "True Strain"]
        A.loc[j, "Abaqus Stress Linear"] = A.loc[j, "True Stress"]
    for k in range(necking_i[i-1], len(A)):
        A.loc[k, "Abaqus Strain Linear"] = A.loc[k, "True Strain"]
        a = A.loc[necking_i[i-1], "True Stress"]
        b = a * (1 - A.loc[necking_i[i-1], "True Strain"])
        A.loc[k, "Abaqus Stress Linear"] = a * A.loc[k, "True Strain"] + b
data["Spec 1"]
plt.plot(data["Spec 2"]["Abaqus Strain Linear"], data["Spec 2"]["Abaqus Stress Linear"], "r-", label = "Spec 2")
plt.plot(data["Spec 1"]["Abaqus Strain Linear"], data["Spec 1"]["Abaqus Stress Linear"], "b-", label = "Spec 1")
plt.plot(data["Spec 3"]["Abaqus Strain Linear"], data["Spec 3"]["Abaqus Stress Linear"], "g-", label = "Spec 3")
plt.plot(data["Spec 2"]["True Strain"], data["Spec 2"]["True Stress"], "r.", label = "True Spec 2")
plt.plot(data["Spec 1"]["True Strain"], data["Spec 1"]["True Stress"], "b.", label = "True Spec 1")
plt.plot(data["Spec 3"]["True Strain"], data["Spec 3"]["True Stress"], "g.", label = "True Spec 3")

plt.legend()
plt.title("Import to Abaqus")
plt.xlabel = "Strain [mm/mm]"
plt.ylabel = "Stress [MPa]"
plt.savefig(output_path + "\\" + "Abaqus_Linear_input_vs_true.pdf")<jupyter_output><empty_output><jupyter_text>Using Expenential Extension of the Softening Region (Ling, 1996)<jupyter_code>for i in range(1, 4):
    A = data["Spec " + str(i)]
    for j in range(necking_i[i-1]):
        A.loc[j, "Abaqus Strain Exp"] = A.loc[j, "True Strain"]
        A.loc[j, "Abaqus Stress Exp"] = A.loc[j, "True Stress"]
    for k in range(necking_i[i-1], len(A)):
        A.loc[k, "Abaqus Strain Exp"] = A.loc[k, "True Strain"]
        n = A.loc[necking_i[i-1], "True Strain"]
        K = A.loc[necking_i[i-1], "True Stress"]/(n**n)
        A.loc[k, "Abaqus Stress Exp"] = K * A.loc[k, "True Strain"]**n
plt.plot(data["Spec 2"]["Abaqus Strain Exp"], data["Spec 2"]["Abaqus Stress Exp"], "r-", label = "Spec 2")
plt.plot(data["Spec 1"]["Abaqus Strain Exp"], data["Spec 1"]["Abaqus Stress Exp"], "b-", label = "Spec 1")
plt.plot(data["Spec 3"]["Abaqus Strain Exp"], data["Spec 3"]["Abaqus Stress Exp"], "g-", label = "Spec 3")
plt.plot(data["Spec 2"]["True Strain"], data["Spec 2"]["True Stress"], "r.", label = "True Spec 2")
plt.plot(data["Spec 1"]["True Strain"], data["Spec 1"]["True Stress"], "b.", label = "True Spec 1")
plt.plot(data["Spec 3"]["True Strain"], data["Spec 3"]["True Stress"], "g.", label = "True Spec 3")

plt.legend()
plt.xlabel = "Strain [mm/mm]"
plt.ylabel = "Stress [MPa]"
plt.savefig(output_path + "\\" + "Abaqus_Exp_input_vs_true.pdf")
for i in range(1, 4):
    data["Spec " + str(i)].to_excel(output_path + "\\" + "Spec_" + str(i) + ".xlsx")
yield_strain
plastic1 = data["Spec 1"].loc[indices[0]:, "Abaqus Strain Exp"] - yield_strain[0]
plastic2 = data["Spec 2"].loc[indices[1]:, "Abaqus Strain Exp"] - yield_strain[1]
plastic3 = data["Spec 3"].loc[indices[2]:, "Abaqus Strain Exp"] - yield_strain[2]
plastic = [plastic1, plastic2, plastic3]

plastic_stress1 = data["Spec 1"].loc[indices[0]:, "Abaqus Stress Exp"]
plastic_stress2 = data["Spec 2"].loc[indices[1]:, "Abaqus Stress Exp"]
plastic_stress3 = data["Spec 3"].loc[indices[2]:, "Abaqus Stress Exp"]
plastic_stress = [plastic_stress1, plastic_stress2, plastic_stress3]
plastic_data = {}
for i in range(1, 4):
    plastic_data["Spec_" + str(i) + "_plastic"] = pd.DataFrame({"Plastic Strain" : plastic[i-1],
                                                               "Plastic Stress" : plastic_stress[i-1]})
    plastic_data["Spec_" + str(i) + "_plastic"].to_excel(output_path + "\\" + "Plastic_data_Spec_" + str(i) + ".xlsx")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.19453362255965292, 'fraction_numerical': 0.05301518438177874, 'mean_word_length': 4.830045523520486, 'pattern_counts': {'":': 0, '<': 30, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '305452', 'license': 'MIT', 'n_tokens_mistral': 5124, 'n_tokens_neox': 4536, 'n_words': 961, 'path': 'Material Data/Excel_files/5 mmps Stress Strain Analysis.ipynb', 'repo_name': 'daniyar26/Rsearch_Spring_2022', 'size': '11525'}