In [1]:
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
In [2]:
df_ag2s =  pd.read_csv("Ag2S_compression_ref_Xun_shi.csv")
In [3]:
df_x03_a =  pd.read_csv("64-2_x=0.3_amo_1.csv",header=1)
df_x03_s =  pd.read_csv("63-4_x=0.3_sta_1.csv",header=1)
df_x04_a =  pd.read_csv("63-2_x=0.4_amo_1.csv",header=1)
df_x04_s =  pd.read_csv("65-1_x=0.4_sta_1.csv",header=1)
df_x05_a =  pd.read_csv("66-2_x=0.5_amo_1.csv",header=1)
df_x05_s =  pd.read_csv("66-1_x=0.5_sta_1.csv",header=1)
df_x06_a =  pd.read_csv("61-2_x=0.6_amo_1.csv",header=1)
df_x06_s =  pd.read_csv("61-1_x=0.6_sta_1.csv",header=1)
In [4]:
df_x03_a
Out[4]:
(s) (mm) (N) Unnamed: 3 (%) (MPa) (mm).1
0 0.000 0.0000 2.5410 0.0 0.0000 0.0842 0.0000
1 0.020 0.0000 2.5416 0.0 0.0000 0.0842 0.0000
2 0.040 0.0000 2.4403 0.0 0.0000 0.0808 0.0000
3 0.060 0.0000 2.4472 0.0 0.0000 0.0811 0.0000
4 0.080 0.0000 2.4657 0.0 0.0000 0.0817 0.0000
... ... ... ... ... ... ... ...
77082 1541.328 2.5688 9996.9180 0.0 90.1338 331.1257 2.5688
77083 1541.348 2.5688 9997.6270 0.0 90.1338 331.1492 2.5688
77084 1541.368 2.5689 9998.4629 0.0 90.1358 331.1769 2.5689
77085 1541.388 2.5689 9999.2217 0.0 90.1378 331.2020 2.5689
77086 1541.408 2.5689 10000.0215 0.0 90.1378 331.2285 2.5689

77087 rows × 7 columns

In [5]:
df_al = pd.read_csv("Al_compression.csv")
In [6]:
def plot_strain_stress(l_df,l_d,l_h,l_lab,xmin,xmax,ymin,ymax,filename):
    l_color = ["black","red", "blue","green","cyan","purple","orange","pink","gray","brown"]
    l_mrks = ["o","^", "*","d",">"]
    plt.clf() # initialization
    plt.figure(figsize=(8, 6))
    plt.axis([xmin,xmax,ymin,ymax])
    plt.tick_params(direction="in")
    plt.rcParams["font.family"] = "Times New roman"
    plt.rcParams["axes.linewidth"] = 1.5
    plt.tick_params(direction="in")
    plt.rcParams["xtick.major.size"] = 10
    plt.rcParams["xtick.major.width"] = 1.5
    plt.rcParams["ytick.major.size"] = 10
    plt.rcParams["ytick.major.width"] = 1.5
    plt.rcParams["font.size"] = 30
    #plt.tick_params(labelleft=False)
    #plt.ylabel("Heat flow, mW")
    plt.ylabel(r"Stress (MPa)")
    plt.xlabel(r"Strain (%)")
    l_st = ["-","--",":","-."]
    for i,df in enumerate(l_df):
        d, h = l_d[i],l_h[i]
        S = np.pi*0.25*d*d
        plt.plot(df.iloc[:,1]/d*100,df.iloc[:,2]/S,color=l_color[i],label=l_lab[i])
        #plt.plot(df.iloc[:,4],df.iloc[:,5],color=l_color[i],label=l_lab[i])
    #plt.hlines([0.5],0,1000,linestyle=":")
    plt.legend(loc='upper left')
    plt.savefig(filename,bbox_inches="tight")
    plt.show()
In [7]:
def plot_strain_stress2(l_df,l_dif_s,l_dif_c,l_lst,l_col,l_df_ref,xmin,xmax,ymin,ymax,filename):
    l_mrks = ["o","^", "*","d",">"]
    plt.clf() # initialization
    plt.figure(figsize=(8, 6))
    plt.axis([xmin,xmax,ymin,ymax])
    plt.tick_params(direction="in")
    plt.rcParams["font.family"] = "Times New roman"
    plt.rcParams["axes.linewidth"] = 1.5
    plt.tick_params(direction="in")
    plt.rcParams["xtick.major.size"] = 10
    plt.rcParams["xtick.major.width"] = 1.5
    plt.rcParams["ytick.major.size"] = 10
    plt.rcParams["ytick.major.width"] = 1.5
    plt.rcParams["font.size"] = 30
    #plt.tick_params(labelleft=False)
    #plt.ylabel("Heat flow, mW")
    plt.ylabel(r"Compression stress (MPa)")
    plt.xlabel(r"Strain (%)")
    plt.yscale("log")
    l_st = ["-","--",":","-."]
    for i,df in enumerate(l_df):
        ic = l_dif_c[i]
        plt.plot(df.iloc[:,4]-l_dif_s[i],df.iloc[:,5]-df.iloc[ic,5],color=l_col[i],linestyle = l_lst[i])
    if len(l_df_ref)>0:
        for i,df in enumerate(l_df_ref):
            plt.plot(df.iloc[:,0],df.iloc[:,1],color="black",linestyle=":")
    #plt.hlines([0.5],0,1000,linestyle=":")
    #plt.legend(loc='upper left')
    plt.savefig(filename,bbox_inches="tight")
    plt.show()
In [8]:
l_df = [df_x03_a,df_x04_a,df_x05_a,df_x06_a]
l_dif_s = [5, 5, 5, 6.0]
l_dif_c = [4537,4653,4458,4900]
l_lst = ["-","-","-","-"]
l_col = ["black","red","blue","purple"]
l_df_ref = [df_al,df_ag2s]
plot_strain_stress2(l_df,l_dif_s,l_dif_c,l_lst,l_col,l_df_ref,0,40,1,1e3,"test.jpg")
<Figure size 432x288 with 0 Axes>
No description has been provided for this image
In [9]:
l_df = [df_x03_a,df_x03_s,df_x04_a,df_x04_s,df_x05_a,df_x05_s,df_x06_a,df_x06_s]
l_dif_s = [5, 5.5, 5, 5.5, 5, 5.5, 6.0, 5.5]
l_dif_c = [4537,4511,4653,4859,4458,4492,4900,4724]
l_lst = [":","-",":","-",":","-",":","-"]
l_col = ["black","black","red","red","blue","blue","purple","purple"]
plot_strain_stress2(l_df,l_dif_s,l_dif_c,l_lst,l_col,[],0,40,0,200,"test.jpg")
<Figure size 432x288 with 0 Axes>
No description has been provided for this image
In [10]:
l_df = [df_x05_a,df_x05_s]
l_dif_s = [ 5, 5.5]
l_dif_c = [4458,4492]
l_lst = ["-","-",":","-",":","-",":","-"]
l_col = ["black","red"]
plot_strain_stress2(l_df,l_dif_s,l_dif_c,l_lst,l_col,[],0,40,0,150,"test.jpg")
<Figure size 432x288 with 0 Axes>
No description has been provided for this image
In [11]:
l_df = [df_x03_a,df_x03_s,df_x04_a,df_x04_s,df_x05_a,df_x05_s,df_x06_a,df_x06_s]
l_dif_s = [5.3, 5.5, 5, 5.5, 5, 5.5, 6.0, 5.6]
l_dif_c = [4537,4511,4653,4859,4458,4492,4900,4724]
l_lst = [":","-",":","-",":","-",":","-"]
l_col = ["black","black","red","red","blue","blue","purple","purple"]
plot_strain_stress2(l_df,l_dif_s,l_dif_c,l_lst,l_col,[],0,4,0,50,"test.jpg")
<Figure size 432x288 with 0 Axes>
No description has been provided for this image
In [13]:
l_df = [df_x04_s,df_x05_s,df_x06_s]
l_dif_s = [ 5.5, 5.5, 5.5]
l_dif_c = [4859,4492,4724]
l_lst = ["-","-","-"]
l_col = ["red","blue","purple"]
#plot_strain_stress2(l_df,l_dif_s,l_dif_c,l_lst,l_col,0,40,0,150,"test.jpg")
In [14]:
def plot_strain_stress3(iylog,l_df,l_dif_s,l_dif_c,l_lst,l_col,l_h0,l_df_ref,xmin,xmax,ymin,ymax,filename):
    l_mrks = ["o","^", "*","d",">"]
    plt.clf() # initialization
    plt.figure(figsize=(8, 6))
    plt.axis([xmin,xmax,ymin,ymax])
    plt.tick_params(direction="in")
    plt.rcParams["font.family"] = "Times New roman"
    plt.rcParams["axes.linewidth"] = 1.5
    plt.tick_params(direction="in")
    plt.rcParams["xtick.major.size"] = 10
    plt.rcParams["xtick.major.width"] = 1.5
    plt.rcParams["ytick.major.size"] = 10
    plt.rcParams["ytick.major.width"] = 1.5
    plt.rcParams["font.size"] = 30
    #plt.tick_params(labelleft=False)
    #plt.ylabel("Heat flow, mW")
    plt.ylabel(r"Compression stress (MPa)")
    plt.xlabel(r"Strain (%)")
    if iylog == 1:
        plt.yscale("log")
    l_st = ["-","--",":","-."]
    for i,df in enumerate(l_df):
        ic = l_dif_c[i]
        #plt.plot(df.iloc[:,4]-l_dif_s[i],df.iloc[:,5]-df.iloc[ic,5],color=l_col[i],linestyle = l_lst[i])
        #plt.plot((df.iloc[ic:,6]-df.iloc[ic,6])/(l_h0[i]-df.iloc[ic,6]),df.iloc[ic:,5]-df.iloc[ic,5],color=l_col[i],linestyle = l_lst[i])
        plt.plot((df.iloc[:,6]-df.iloc[ic,6])/(l_h0[i]-df.iloc[ic,6])*100,\
                 (df.iloc[:,5]-df.iloc[ic,5])*(1-(df.iloc[:,6]-df.iloc[ic,6])/(l_h0[i]-df.iloc[ic,6])),\
                 color=l_col[i],linestyle = l_lst[i])
        #print(l_h0[i],df.iloc[ic,6])
    if len(l_df_ref)>0:
        for i,df in enumerate(l_df_ref):
            plt.plot(df.iloc[:,0],df.iloc[:,1],color="black",linestyle=":")
    #plt.hlines([0.5],0,1000,linestyle=":")
    #plt.legend(loc='upper left')
    plt.savefig(filename,bbox_inches="tight")
    plt.show()
In [15]:
l_df = [df_x03_a,df_x04_a,df_x05_a,df_x06_a]
l_dif_s = [5, 5, 5, 6.0]
l_dif_c = [4600,4653,4550,4900]
l_h0 = [2.853,3.1,2.97,2.72]
l_lst = ["-","-","-","-"]
l_col = ["black","red","blue","purple"]
l_df_ref = [df_al,df_ag2s]
plot_strain_stress3(1,l_df,l_dif_s,l_dif_c,l_lst,l_col,l_h0,l_df_ref,0,40,1,1e3,"test.jpg")
<Figure size 432x288 with 0 Axes>
No description has been provided for this image
In [16]:
l_df = [df_x03_a,df_x04_a,df_x05_a,df_x06_a]
l_dif_s = [5, 5, 5, 6.0]
l_dif_c = [4600,4653,4550,4900]
l_h0 = [2.853,3.1,2.97,2.72]
l_lst = ["-","-","-","-"]
l_col = ["black","red","blue","purple"]
l_df_ref = []
plot_strain_stress3(0,l_df,l_dif_s,l_dif_c,l_lst,l_col,l_h0,l_df_ref,-0.1,2,0,3e1,"test.jpg")
<Figure size 432x288 with 0 Axes>
No description has been provided for this image
In [16]:
from scipy.optimize import curve_fit
import matplotlib.pyplot as plt
import numpy as np
In [17]:
l_df = [df_x06_s,df_x05_a]
l_dif_s = [  5.5, 5]
l_dif_c = [4724,4550]
l_lst = ["-","-"]
l_col = ["green","red"]
l_h0 = [2.73,2.97]
plot_strain_stress3(1,l_df,l_dif_s,l_dif_c,l_lst,l_col,l_h0,[],0,40,1,1e3,"test.jpg")
<Figure size 432x288 with 0 Axes>
No description has been provided for this image
In [23]:
l_df = [df_x06_s,df_x05_a]
l_dif_s = [  5.5, 5]
l_dif_c = [4850,4550]
l_lst = ["-","-"]
l_col = ["green","red"]
l_h0 = [2.73,2.97]
plot_strain_stress3(0,l_df,l_dif_s,l_dif_c,l_lst,l_col,l_h0,[],0,2,0,20,"test.jpg")
<Figure size 432x288 with 0 Axes>
No description has been provided for this image
In [15]:
l_df = [df_x06_a,df_x05_a,df_x03_s]
l_dif_s = [6,5,5.5]
l_dif_c = [4900,4550,4511]
l_lst = ["-"]*len(l_df)
l_col = ["black","red","blue"]
l_h0 = [2.72,2.97,2.73]
l_df_ref = [df_al,df_ag2s]
plot_strain_stress3(1,l_df,l_dif_s,l_dif_c,l_lst,l_col,l_h0,l_df_ref,0,40,1,1e3,"test.jpg")
<Figure size 432x288 with 0 Axes>
No description has been provided for this image
In [24]:
l_df = [df_x06_a,df_x05_a,df_x03_s]
l_dif_s = [6,5,5.5]
l_dif_c = [4900,4550,4511]
l_lst = ["-"]*len(l_df)
l_col = ["black","red","blue"]
l_h0 = [2.72,2.97,2.73]
l_df_ref = [df_al,df_ag2s]
plot_strain_stress3(0,l_df,l_dif_s,l_dif_c,l_lst,l_col,l_h0,[],-0.1,4,0,2e1,"test.jpg")
<Figure size 432x288 with 0 Axes>
No description has been provided for this image
In [38]:
l_df = [df_x04_s,df_x05_s,df_x06_s,df_x05_a]
l_dif_s = [ 5.5, 5.5, 5.5]
l_dif_c = [4859,4492,4850,4550]
l_lst = ["-","-","-",":"]
l_col = ["red","blue","purple","blue"]
l_h0 = [2.73,2.94,2.72,2.97]
plot_strain_stress3(0,l_df,l_dif_s,l_dif_c,l_lst,l_col,l_h0,[],0,2,0,2e1,"test.jpg")
<Figure size 432x288 with 0 Axes>
No description has been provided for this image
In [69]:
def fit(df,n1,n2):
    return curve_fit(linear,0.01*df.iloc[n1:n2,4],df.iloc[n1:n2,5])
In [70]:
def linear(x,a,b):
    return a*x+b
In [72]:
p_x03a = fit(df_x03_a,4300,5000)
p_x03a
Out[72]:
(array([747.33388928, -27.98349781]),
 array([[37.34071876, -2.02995227],
        [-2.02995227,  0.11056247]]))
In [73]:
p_x03s = fit(df_x03_s,4511,5336)
p_x03s
Out[73]:
(array([1060.21035737,  -47.87998264]),
 array([[ 1.15035002, -0.06910579],
        [-0.06910579,  0.00416117]]))
In [74]:
p_x04a = fit(df_x04_a,4300,5000)
p_x04a
Out[74]:
(array([1241.69081471,  -48.96219715]),
 array([[25.85906875, -1.2929288 ],
        [-1.2929288 ,  0.06476714]]))
In [75]:
p_x04s = fit(df_x04_s,4511,5336)
p_x04s
Out[75]:
(array([1326.37845615,  -59.65899265]),
 array([[21.3287582 , -1.18964498],
        [-1.18964498,  0.06651001]]))
In [76]:
p_x05a = fit(df_x05_a,4300,5000)
p_x05a
Out[76]:
(array([779.54650817, -28.98287406]),
 array([[34.06264938, -1.77721066],
        [-1.77721066,  0.09290065]]))
In [77]:
p_x05s = fit(df_x05_s,4511,5336)
p_x05s
Out[77]:
(array([1093.55901783,  -49.94146525]),
 array([[49.09357589, -2.96098483],
        [-2.96098483,  0.17900494]]))
In [78]:
p_x06a = fit(df_x06_a,4900,5715)
p_x06a
Out[78]:
(array([720.33335894, -32.50256546]),
 array([[ 0.2491464 , -0.01619875],
        [-0.01619875,  0.00105526]]))
In [84]:
p_x06s = fit(df_x06_s,4711,6000)
p_x06s
Out[84]:
(array([906.28142292, -39.73576392]),
 array([[13.98196818, -0.87247454],
        [-0.87247454,  0.05470506]]))