def create_plot_data_exp_fatigue_life(fatigue_data, figure_path=None, figure_name=None): #============================================================================== # x,y label #============================================================================== xlabel = xylabels['experimental_life'] ylabel = xylabels['equivalent_strain_amplitude'] # ylabel = xylabels['axial_strain_amplitude'] # label_dict = {'TC-IP':'TMF-IP', # 'TC-OP':'TMF-OP', # 'TC-IP-TGMF':'TGMF-IP', # 'TC-OP-TGMF':'TGMF-OP', # 'TC-IF':'IF', # 'TC-IP-TGMF-TBC':'TGMF-IP-TBC', # } #============================================================================== # plot lines #============================================================================== i = 0 marker_list = ['s', 'o', '^', 'D'] plot_data = PlotData() i = 0 marker_list = ['s', 'o', '^', 'D', '<', '^', '>'] for load_type in ['TC-IF', 'TC-IP', 'TC-OP', 'TC-90', 'PRO-IP', 'NPR-IP']: experimental_life = fatigue_data.loadTypeFilter( load_type, 'experimental_life') equivalent_strain_amplitude = fatigue_data.loadTypeFilter( load_type, 'equivalent_strain_amplitude') plot_data.addLine(experimental_life, equivalent_strain_amplitude, xlabel=xlabel, ylabel=ylabel, linelabel=load_type, linewidth=2, linestyle='', marker=marker_list[i], markersize=12, color='auto') i += 1 material = material_in718() life, epsilon_amplitude = material.plotMansonCoffinAxial() plot_data.addLine(life, epsilon_amplitude * 100, xlabel=xlabel, ylabel=ylabel, linelabel='TC-IF-Coffin-Manson', linewidth=2, linestyle='-', marker=None, markersize=12, color='black') plot_data.writeToFile(figure_path, figure_name)
def create_plot_data_exp_temperature(figure_path=None,figure_name=None): #============================================================================== # x,y label #============================================================================== xlabel = xylabels['runing_time'] ylabel = xylabels['temperature'] #============================================================================== # plot lines #============================================================================== i = 0 marker_list = ['s','o','^','D'] plot_data = PlotData() # for name in ['30_0_','50_0_','70_0_','90_0_']: # for name in ['30_25_','50_25_','70_25_','90_25_']: # for name in ['30_50_','50_50_','70_50_','90_50_']: for name in ['30_67_','50_67_','70_67_','90_67_']: # for name in ['90_0_','90_25_','90_50_','90_67_']: # for name in ['70_0_','70_25_','70_50_','70_67_']: # for name in ['50_0_','50_25_','50_50_','50_67_']: # for name in ['30_0_','30_25_','30_50_','30_67_']: ExperimentDirectory = 'F:\\Cloud\\Database\\IN718\\Temperature2\\' filename = ExperimentDirectory + name + '.csv' experiment = ExperimentData(filename) time = experiment.runing_time temperature = experiment.temperature plot_data.addLine(time, temperature, xlabel=xlabel, ylabel=ylabel, linelabel='Exp.' + name.split('_')[0] + '%', linewidth=2, linestyle='--', marker='', markersize=6, color='auto') SimulationDirectory = 'F:\\Cloud\\Simulation\\Temperature\\' filename = SimulationDirectory + name + '.csv' simulation = SimulationData(filename,1) time = simulation.runing_time temperature = simulation.temperature plot_data.addLine(time, temperature, xlabel=xlabel, ylabel=ylabel, linelabel=name.split('_')[0] + '%', linewidth=2, linestyle='-', marker=None, markersize=12, color='auto') i += 1 plot_data.writeToFile(figure_path,figure_name)
def create_plot_data_exp_nth_cycle(name, nth_cycle, figure_path=None, figure_name=None): #============================================================================== # x,y label #============================================================================== xlabel = xylabels['axial_strain'] ylabel = xylabels['axial_stress'] #============================================================================== # plot lines #============================================================================== i = 0 marker_list = ['s', 'o', '^', 'D'] plot_data = PlotData() filename = ExperimentDirectory + name + '.csv' experiment = ExperimentData(filename) strain = experiment.obtainNthCycle('axial_strain', nth_cycle) stress = experiment.obtainNthCycle('axial_stress', nth_cycle) plot_data.addLine(strain * 100, stress, xlabel=xlabel, ylabel=ylabel, linelabel='', linewidth=2, linestyle='-', marker=None, markersize=12, color='auto') i += 1 plot_data.writeToFile(figure_path, figure_name)
def create_plot_data_exp_half_life_cycle(figure_path=None,figure_name=None): #============================================================================== # x,y label #============================================================================== xlabel = xylabels['axial_strain'] ylabel = xylabels['axial_stress'] #============================================================================== # plot lines #============================================================================== i = 0 marker_list = ['s','o','^','D'] plot_data = PlotData() # for name in experiment_type_dict['TC-IF']: for name in ['08','16']: # print name filename = ExperimentDirectory + name + '.csv' experiment = ExperimentData(filename) # print experiment.half_life_cycle strain = experiment.obtainNthCycle('axial_strain',experiment.half_life_cycle) stress = experiment.obtainNthCycle('axial_stress',experiment.half_life_cycle) plot_data.addLine(strain*100, stress, xlabel=xlabel, ylabel=ylabel, linelabel='', linewidth=2, linestyle='-', marker=None, markersize=12, color='auto') i += 1 plot_data.writeToFile(figure_path,figure_name)
def create_plot_data_fatigue_life(fatigue_data, figure_path=None, figure_name=None): #============================================================================== # x,y label #============================================================================== xlabel = xylabels['experimental_life'] ylabel = xylabels['predicted_life'] #============================================================================== # plot lines #============================================================================== i = 0 marker_list = ['s', 'o', '^', '<', 'D', '>', '*'] plot_data = PlotData() for load_type in ['TC-IF', 'TC-IP', 'TC-OP', 'TC-90', 'PRO-IP', 'NPR-IP']: experimental_life = fatigue_data.loadTypeFilter( load_type, 'experimental_life') predicted_life = fatigue_data.loadTypeFilter(load_type, 'predicted_life') plot_data.addLine(experimental_life, predicted_life, xlabel=xlabel, ylabel=ylabel, linelabel=load_type, linewidth=2, linestyle='', marker=marker_list[i], markersize=12) i += 1 plot_data.writeToFile(figure_path, figure_name)
def create_plot_data(fatigue_data, figure_path=None, figure_name=None): #============================================================================== # x,y label #============================================================================== xlabel = xylabels['experimental_life'] ylabel = 'Fatigue Damage Parameter' #============================================================================== # plot lines #============================================================================== i = 0 marker_list = ['s', 'o', '^', '<', 'D', '>', '*'] plot_data = PlotData() for load_type in ['TC-IF', 'TC-IP', 'TC-OP', 'TC-IP-TGMF', 'TC-OP-TGMF']: experimental_life = fatigue_data.loadTypeFilter( load_type, 'experimental_life') fatigue_coefficient = fatigue_data.loadTypeFilter( load_type, 'fatigue_coefficient') plot_data.addLine(experimental_life, fatigue_coefficient, xlabel=xlabel, ylabel=ylabel, linelabel=load_type, linewidth=2, linestyle='', marker=marker_list[i], markersize=12) i += 1 plot_data.writeToFile(figure_path, figure_name)
def create_plot_data_exp_half_life_cycle(figure_path=None,figure_name=None): #============================================================================== # x,y label #============================================================================== xlabel = xylabels['axial_strain'] ylabel = xylabels['axial_stress'] #============================================================================== # plot lines #============================================================================== i = 0 marker_list = ['s','o','^','D'] plot_data = PlotData() for name in ['7116','7111','7115','7114']: filename = ExperimentDirectory + name + '.csv' experiment = ExperimentData(filename) strain = experiment.obtainNthCycle('axial_strain',experiment.half_life_cycle) stress = experiment.obtainNthCycle('axial_stress',experiment.half_life_cycle) plot_data.addLine(strain*100, stress, xlabel=xlabel, ylabel=ylabel, linelabel='', linewidth=2, linestyle='-', marker=None, markersize=12, color='auto') i += 1 material = material_in718() epsilon,sigma = material.plotCyclicStrengthCoefficient() plot_data.addLine(epsilon*100, sigma, xlabel=xlabel, ylabel=ylabel, linelabel='Ramberg-Osgood', linewidth=4, linestyle='--', marker=None, markersize=12, color='black') plot_data.writeToFile(figure_path,figure_name)
def plot_exp_nth_cycle(figure_title='', figure_path=None, figure_name=None, save_types=[]): #============================================================================== # title #============================================================================== title = figure_title #============================================================================== # figure format # http://matplotlib.org/users/customizing.html?highlight=rcparams #============================================================================== plot_format() mpl.rcParams['figure.subplot.left'] = 0.15 #============================================================================== # grid set up #============================================================================== #plt.grid(True, which='major',linestyle='-') #plt.grid(True, which='minor',linestyle='-') #plt.grid(True, which='major') #plt.grid(True, which='minor') #============================================================================== # print title #============================================================================== plt.title(title, fontsize=16) #============================================================================== # x,y limite #============================================================================== plt.xlim(-1, 1) plt.ylim(-1000, 1000) #============================================================================== # xy log scale #============================================================================== # plt.xscale('log') # plt.yscale('log') #============================================================================== # xy axial equal #============================================================================== ax = plt.gca() # ax.set_aspect('equal') ax.set_aspect('auto') #============================================================================== # plot lines #============================================================================== plot_data = PlotData() plot_data.readFromFile(figure_path, figure_name) plot_data.plot() #============================================================================== # http://stackoverflow.com/questions/21920233/matplotlib-log-scale-tick-label-number-formatting #============================================================================== ax.xaxis.set_major_locator(MultipleLocator(0.5)) ax.xaxis.set_minor_locator(MultipleLocator(0.1)) ax.xaxis.set_major_formatter(ScalarFormatter()) ax.yaxis.set_major_locator(MultipleLocator(500)) ax.yaxis.set_minor_locator(MultipleLocator(100)) ax.yaxis.set_major_formatter(ScalarFormatter()) #============================================================================== # show legend #============================================================================== plt.legend(loc=0) #============================================================================== # save figures #============================================================================== if figure_path <> None and figure_name <> None: for save_type in save_types: plt.savefig(figure_path + figure_name + save_type, dpi=150, transparent=True) print 'save as', figure_path + figure_name + save_type # plt.show() plt.close()
def create_plot_data(figure_path=None,figure_name=None): #============================================================================== # x,y label #============================================================================== xlabel = xylabels['axial_strain'] ylabel = xylabels['axial_stress'] #============================================================================== # plot lines #============================================================================== i = 0 marker_list = ['s','o','^','D'] plot_data = PlotData() experiment_log = ExperimentLog(ExperimentLogFile) for name in ['7101','7102','7103']: experiment_log.output(name) regular = r'.*' load_type = experiment_log.obtainItem(name,'load_type',regular)[0] regular = r'\d+\.?\d*' temperature_mode = experiment_log.obtainItem(name,'temperature_mode',regular) if len(temperature_mode) == 1: temperature_list = [float(temperature_mode[0]), float(temperature_mode[0])] if len(temperature_mode) == 2: temperature_list = [float(temperature_mode[0]), float(temperature_mode[1])] d_out = float(experiment_log.obtainItem(name,'d_out',regular)[0]) gauge_length = float(experiment_log.obtainItem(name,'gauge_length',regular)[0]) axial_strain = float(experiment_log.obtainItem(name,'axial_strain',regular)[0]) angel_strain = float(experiment_log.obtainItem(name,'angel_strain',regular)[0]) equivalent_strain = float(experiment_log.obtainItem(name,'equivalent_strain',regular)[0]) period = float(experiment_log.obtainItem(name,'period',regular)[0]) axial_temperature_phase = float(experiment_log.obtainItem(name,'axial_temperature_phase',regular)[0]) filename = ExperimentDirectory + name + '.csv' experiment = ExperimentData(filename) strain = experiment.axial_strain stress = experiment.axial_stress plot_data.addLine(strain*100, stress, xlabel=xlabel, ylabel=ylabel, linelabel='Exp.' + str(int(temperature_mode[0])+273)+'K', linewidth=2, linestyle='', marker=marker_list[i], markersize=12, color=color_list[i], skip=20) sim_filename = SimulationDirectory + name + '.csv' period = 200 simulation = SimulationData(sim_filename,period) strain = simulation.axial_strain stress = simulation.axial_stress plot_data.addLine(strain*100, stress, xlabel=xlabel, ylabel=ylabel, linelabel='Sim.' + str(int(temperature_mode[0])+273)+'K', linewidth=2, linestyle='-', marker=None, markersize=12, color=color_list[i]) i += 1 plot_data.writeToFile(figure_path,figure_name)
ax2.set_xlim(0, 750) ax2.set_ylim(0, 0.5) #============================================================================== # http://stackoverflow.com/questions/21920233/matplotlib-log-scale-tick-label-number-formatting #============================================================================== # ax.xaxis.set_major_locator(MultipleLocator(0.5)) # ax.xaxis.set_minor_locator(MultipleLocator(0.1)) # ax.xaxis.set_major_formatter(ScalarFormatter()) # ax.yaxis.set_major_locator(MultipleLocator(500)) # ax.yaxis.set_minor_locator(MultipleLocator(100)) # ax.yaxis.set_major_formatter(ScalarFormatter()) #============================================================================== # show legend #============================================================================== plt.legend(loc=4) #============================================================================== # save figures #============================================================================== plot_data.saveFigure() plt.show() plt.close() figure_path = ArticleFigureDirectory figure_name = 'plot_elastic_by_temperature_in718' plot_data = PlotData(figure_path, figure_name, save_types=['.pdf']) create_plot_data_elastic_by_temperature_in718(plot_data) plot_elastic_by_temperature_in718(plot_data) shutil.copy(__file__, ArticleFigureDirectory)
def create_plot_data_exp_half_life_cycle(figure_path=None,figure_name=None): #============================================================================== # x,y label #============================================================================== xlabel = xylabels['shear_strain'] ylabel = xylabels['shear_stress'] #============================================================================== # plot lines #============================================================================== i = 0 marker_list = ['s','o','^','D'] plot_data = PlotData() experiment_log = ExperimentLog(ExperimentLogFile) for name in ['7006','7007','7009']: experiment_log.output(name) regular = r'.*' load_type = experiment_log.obtainItem(name,'load_type',regular)[0] regular = r'\d+\.?\d*' temperature_mode = experiment_log.obtainItem(name,'temperature_mode',regular) if len(temperature_mode) == 1: temperature_list = [float(temperature_mode[0]), float(temperature_mode[0])] if len(temperature_mode) == 2: temperature_list = [float(temperature_mode[0]), float(temperature_mode[1])] d_out = float(experiment_log.obtainItem(name,'d_out',regular)[0]) gauge_length = float(experiment_log.obtainItem(name,'gauge_length',regular)[0]) axial_strain = float(experiment_log.obtainItem(name,'axial_strain',regular)[0]) angel_strain = float(experiment_log.obtainItem(name,'angel_strain',regular)[0]) equivalent_strain = float(experiment_log.obtainItem(name,'equivalent_strain',regular)[0]) period = float(experiment_log.obtainItem(name,'period',regular)[0]) axial_temperature_phase = float(experiment_log.obtainItem(name,'axial_temperature_phase',regular)[0]) filename = ExperimentDirectory + name + '.csv' experiment = ExperimentData(filename) strain = experiment.obtainNthCycle('shear_strain',experiment.half_life_cycle) stress = experiment.obtainNthCycle('shear_stress',experiment.half_life_cycle) plot_data.addLine(strain*100, stress, xlabel=xlabel, ylabel=ylabel, linelabel=str(int(temperature_mode[0])+273)+'K', linewidth=2, linestyle='-', marker=None, markersize=12, color=color_list[i]) i += 1 # material = material_in718() # epsilon,sigma = material.plotCyclicStrengthCoefficient() # plot_data.addLine(epsilon*100, # sigma, # xlabel=xlabel, # ylabel=ylabel, # linelabel='Ramberg-Osgood', # linewidth=4, # linestyle='--', # marker=None, # markersize=12, # color='black') plot_data.writeToFile(figure_path,figure_name)
def create_plot_data_exp_half_life_cycle(figure_path=None, figure_name=None): #============================================================================== # x,y label #============================================================================== xlabel = xylabels['axial_strain'] ylabel = xylabels['axial_stress'] #============================================================================== # plot lines #============================================================================== i = 0 marker_list = ['s', 'o', '^', 'D'] plot_data = PlotData() experiment_log = ExperimentLog(ExperimentLogFile) # for name in ['7110','7111','7112','7113','7114','7115','7116']: for name in ['7045']: experiment_log.output(name) regular = r'.*' load_type = experiment_log.obtainItem(name, 'load_type', regular)[0] regular = r'\d+\.?\d*' temperature_mode = experiment_log.obtainItem(name, 'temperature_mode', regular) if len(temperature_mode) == 1: temperature_list = [ float(temperature_mode[0]), float(temperature_mode[0]) ] if len(temperature_mode) == 2: temperature_list = [ float(temperature_mode[0]), float(temperature_mode[1]) ] d_out = float(experiment_log.obtainItem(name, 'd_out', regular)[0]) gauge_length = float( experiment_log.obtainItem(name, 'gauge_length', regular)[0]) axial_strain = float( experiment_log.obtainItem(name, 'axial_strain', regular)[0]) angel_strain = float( experiment_log.obtainItem(name, 'angel_strain', regular)[0]) equivalent_strain = float( experiment_log.obtainItem(name, 'equivalent_strain', regular)[0]) period = float(experiment_log.obtainItem(name, 'period', regular)[0]) axial_temperature_phase = float( experiment_log.obtainItem(name, 'axial_temperature_phase', regular)[0]) filename = ExperimentDirectory + name + '.csv' experiment = ExperimentData(filename) print experiment.axial_count_index_list e_list = [] count = [] for i in experiment.axial_count_index_list[2:200:50]: strain = experiment.obtainNthCycle('axial_strain', i) stress = experiment.obtainNthCycle('axial_stress', i) masing = obtain_masing_curve([strain, stress]) e = obtain_youngs_modulus(masing, 0.002) count.append(i) e_list.append(e) plot_data.addLine(masing[0] * 100, masing[1], xlabel=xlabel, ylabel=ylabel, linelabel=str(int(temperature_mode[0]) + 273) + 'K', linewidth=2, linestyle='-', marker=None, markersize=12, color='auto') # plot_data.addLine(count, # e_list, # xlabel=xlabel, # ylabel=ylabel, # linelabel='', # linewidth=2, # linestyle='', # marker='o', # markersize=12, # color='auto') plot_data.writeToFile(figure_path, figure_name)
def plot_exp_coffin_manson(figure_path=None, figure_name=None, save_types=[]): #============================================================================== # title #============================================================================== title = '' #============================================================================== # figure format # http://matplotlib.org/users/customizing.html?highlight=rcparams #============================================================================== plot_format() #============================================================================== # grid set up #============================================================================== #plt.grid(True, which='major',linestyle='-') #plt.grid(True, which='minor',linestyle='-') #plt.grid(True, which='major') #plt.grid(True, which='minor') #============================================================================== # print title #============================================================================== plt.title(title, fontsize=16) #============================================================================== # x,y limite #============================================================================== plt.xlim(1E1, 2E6) plt.ylim(0.2, 2.0) #============================================================================== # xy log scale #============================================================================== plt.xscale('log') plt.yscale('log') #============================================================================== # xy axial equal #============================================================================== ax = plt.gca() ax.set_aspect('equal') ax.set_aspect('auto') #============================================================================== # http://stackoverflow.com/questions/21920233/matplotlib-log-scale-tick-label-number-formatting #============================================================================== # ax.yaxis.set_major_locator(MultipleLocator(0.2)) # ax.yaxis.set_minor_locator(MultipleLocator(0.1)) # ax.yaxis.set_major_formatter(ScalarFormatter()) #============================================================================== # plot lines #============================================================================== plot_data = PlotData() plot_data.readFromFile(figure_path, figure_name) plot_data.plot() #============================================================================== # Normalized #============================================================================== plt.yticks([]) plt.ylabel('Normalized $\Delta\\varepsilon/2$') #============================================================================== # show legend #============================================================================== plt.legend(loc=0) # plt.legend(loc=0,fontsize='small',frameon=True,numpoints=1,title='Temperature') #============================================================================== # save figures #============================================================================== if figure_path <> None and figure_name <> None: for save_type in save_types: plt.savefig(figure_path + figure_name + save_type, dpi=150, transparent=True) print 'save as', figure_path + figure_name + save_type plt.show() plt.close()
def create_plot_data_monotonic_cyclic_osgood(figure_path=None, figure_name=None): #============================================================================== # x,y label #============================================================================== xlabel = xylabels['axial_strain_amplitude'] ylabel = xylabels['axial_stress_amplitude'] #============================================================================== # plot lines #============================================================================== i = 0 marker_list = ['s', 'o', '^', 'D'] plot_data = PlotData() cyclic_strain = [] cyclic_stress = [] for name in experiment_type_dict['TC-IF']: # print name filename = ExperimentDirectory + name + '.csv' experiment = ExperimentData(filename) # print experiment.half_life_cycle stress = experiment.obtainNthCycle('axial_stress', experiment.half_life_cycle) strain = experiment.obtainNthCycle('axial_strain', experiment.half_life_cycle) stress_amplitude = (max(stress) - min(stress)) / 2.0 strain_amplitude = (max(strain) - min(strain)) / 2.0 * 100 cyclic_strain.append(strain_amplitude) cyclic_stress.append(stress_amplitude) name = '7102' # 650C monotonic tension filename = ExperimentDirectory + name + '.csv' experiment = ExperimentData(filename) monotonic_stress = list(experiment.axial_stress)[::20] monotonic_strain = list(experiment.axial_strain * 100.0)[::20] plot_data.addLine(monotonic_strain, monotonic_stress, xlabel=xlabel, ylabel=ylabel, linelabel='Monotonic Exp.', linewidth=2, linestyle='', marker=marker_list[i], markersize=12, color='blue') i += 1 plot_data.addLine(cyclic_strain, cyclic_stress, xlabel=xlabel, ylabel=ylabel, linelabel='Cyclic Exp.', linewidth=2, linestyle='', marker=marker_list[i], markersize=12, color='red') i += 1 material = material_in718() epsilon, sigma = material.plotStrengthCoefficient() plot_data.addLine(epsilon * 100, sigma, xlabel=xlabel, ylabel=ylabel, linelabel='Monotonic Fit.', linewidth=2, linestyle='-', marker=None, markersize=12, color='blue') epsilon, sigma = material.plotCyclicStrengthCoefficient() plot_data.addLine(epsilon * 100, sigma, xlabel=xlabel, ylabel=ylabel, linelabel='Cyclic Fit.', linewidth=2, linestyle='-', marker=None, markersize=12, color='red') plot_data.writeToFile(figure_path, figure_name)
def plot_fatigue_life(figure_path=None, figure_name=None, save_types=[]): #============================================================================== # title #============================================================================== title = '' #============================================================================== # figure format # http://matplotlib.org/users/customizing.html?highlight=rcparams #============================================================================== plot_format() mpl.rcParams['figure.figsize'] = (8, 8) fig, ax = plt.subplots() #============================================================================== # grid set up #============================================================================== #plt.grid(True, which='major',linestyle='-') #plt.grid(True, which='minor',linestyle='-') #plt.grid(True, which='major') #plt.grid(True, which='minor') #============================================================================== # print title #============================================================================== plt.title(title, fontsize=16) #============================================================================== # x,y limite #============================================================================== plt.xlim(1E0, 1E5) plt.ylim(1E0, 1E5) #============================================================================== # xy axial equal #============================================================================== plt.gca().set_aspect('equal') plt.gca().set_aspect('auto') #============================================================================== # xy log scale #============================================================================== plt.xscale('log') plt.yscale('log') #============================================================================== # plot lines #============================================================================== plot_data = PlotData() plot_data.readFromFile(figure_path, figure_name) plot_data.plot() #============================================================================== # plot 1x lines #============================================================================== linewidth = 1.0 plt.plot([1, 1e5], [1, 1e5], color='black', linewidth=linewidth) #============================================================================== # plot 2x lines #============================================================================== linewidth = 0.5 plt.plot([2, 1e5], [1, 5e4], color='black', linewidth=linewidth) plt.plot([1, 5e4], [2, 1e5], color='black', linewidth=linewidth) #============================================================================== # plot 5x lines #============================================================================== plt.plot([5, 1e5], [1, 2e4], color='black', linewidth=linewidth) plt.plot([1, 2e4], [5, 1e5], color='black', linewidth=linewidth) #============================================================================== # show legend #============================================================================== plt.legend(loc=0) # plt.show() #============================================================================== # save figures #============================================================================== if figure_path <> None and figure_name <> None: for save_type in save_types: plt.savefig(figure_path + figure_name + save_type, dpi=150, transparent=True) print 'save as', figure_path + figure_name + save_type plt.close()
def create_plot_data(figure_path=None, figure_name=None): #============================================================================== # x,y label #============================================================================== xlabel = xylabels['axial_strain'] ylabel = xylabels['axial_stress'] #============================================================================== # plot lines #============================================================================== i = 0 marker_list = ['s', 'o', '^', 'D'] plot_data = PlotData() experiment_log = ExperimentLog(ExperimentLogFile) # for name in ['7110','7111','7112','7113','7114','7115','7116']: # for name in ['7110','7111','7112','7113','7114']: # for name in experiment_type_dict['TC-IP'] + experiment_type_dict['TC-OP']: # for name in experiment_type_dict['TC-OP']: # for name in experiment_type_dict['PRO-IP']: # for name in experiment_type_dict['NPR-IP']+experiment_type_dict['PRO-IP']+['7110','7111','7112','7113','7114']: for name in ['7111']: experiment_log.output(name) regular = r'.*' load_type = experiment_log.obtainItem(name, 'load_type', regular)[0] regular = r'\d+\.?\d*' temperature_mode = experiment_log.obtainItem(name, 'temperature_mode', regular) if len(temperature_mode) == 1: temperature_list = [ float(temperature_mode[0]), float(temperature_mode[0]) ] if len(temperature_mode) == 2: temperature_list = [ float(temperature_mode[0]), float(temperature_mode[1]) ] d_out = float(experiment_log.obtainItem(name, 'd_out', regular)[0]) gauge_length = float( experiment_log.obtainItem(name, 'gauge_length', regular)[0]) axial_strain = float( experiment_log.obtainItem(name, 'axial_strain', regular)[0]) angel_strain = float( experiment_log.obtainItem(name, 'angel_strain', regular)[0]) equivalent_strain = float( experiment_log.obtainItem(name, 'equivalent_strain', regular)[0]) period = float(experiment_log.obtainItem(name, 'period', regular)[0]) axial_temperature_phase = float( experiment_log.obtainItem(name, 'axial_temperature_phase', regular)[0]) filename = ExperimentDirectory + name + '.csv' experiment = ExperimentData(filename) # print experiment.axial_count_index_list youngs_modulus, poisson_ratio, shear_modulus, yield_stress = calculate_elastic_by_temperature_in718( 650) e_list = [] count = [] for i in experiment.axial_count_index_list[1:-1:1]: strain = experiment.obtainNthCycle('axial_strain', i) stress = experiment.obtainNthCycle('axial_stress', i) p = (max(strain) - max(stress) / youngs_modulus) * 4 * i masing = obtain_masing_curve([strain, stress]) e = obtain_youngs_modulus(masing, 0.0025) count.append(i) e_list.append(e) # damage = 1.0 - np.array(e_list)/youngs_modulus damage = 1.0 - np.array(e_list) / max(e_list) if min(damage) <= 0: damage += abs(min(damage)) else: damage -= abs(min(damage)) # plot_data.addLine(masing[0]*100, # masing[1], # xlabel=xlabel, # ylabel=ylabel, # linelabel=str(int(temperature_mode[0])+273)+'K', # linewidth=2, # linestyle='-', # marker=None, # markersize=12, # color='auto') damage[0] = 0 # damage[1]=0 # damage[2]=0 # damage[3]=0 plot_data.addLine(count, damage, xlabel='Accumulated plastic strain $p$ [%]', ylabel='Damage $D$', linelabel=axial_strain, linewidth=2, linestyle='', marker='o', markersize=12, color='auto') plot_data.writeToFile(figure_path, figure_name)
def plot(figure_path=None, figure_name=None, save_types=[]): #============================================================================== # title #============================================================================== title = '' #============================================================================== # figure format # http://matplotlib.org/users/customizing.html?highlight=rcparams #============================================================================== plot_format() mpl.rcParams['figure.figsize'] = (8, 6) fig, ax = plt.subplots() #============================================================================== # grid set up #============================================================================== #plt.grid(True, which='major',linestyle='-') #plt.grid(True, which='minor',linestyle='-') #plt.grid(True, which='major') #plt.grid(True, which='minor') #============================================================================== # print title #============================================================================== plt.title(title, fontsize=16) #============================================================================== # x,y limite #============================================================================== # plt.xlim(1E1,1E5) plt.ylim(5E0, 1E2) #============================================================================== # xy axial equal #============================================================================== plt.gca().set_aspect('equal') plt.gca().set_aspect('auto') #============================================================================== # xy log scale #============================================================================== plt.xscale('log') plt.yscale('log') #============================================================================== # plot lines #============================================================================== plot_data = PlotData() plot_data.readFromFile(figure_path, figure_name) plot_data.plot() #============================================================================== # http://stackoverflow.com/questions/21920233/matplotlib-log-scale-tick-label-number-formatting #============================================================================== # ax.xaxis.set_major_locator(MultipleLocator(0.5)) # ax.xaxis.set_minor_locator(MultipleLocator(0.1)) # ax.xaxis.set_major_formatter(ScalarFormatter()) # ax.yaxis.set_major_locator(MultipleLocator(5)) # ax.yaxis.set_minor_locator(MultipleLocator(5)) # ax.yaxis.set_major_formatter(ScalarFormatter()) #============================================================================== # plot 1x lines #============================================================================== # linewidth = 1.0 # plt.plot([10,1e5],[10,1e5],color='black',linewidth=linewidth) #============================================================================== # plot 2x lines #============================================================================== # linewidth = 0.5 # plt.plot([20,1e5],[10,5e4],color='black',linewidth=linewidth) # plt.plot([10,5e4],[20,1e5],color='black',linewidth=linewidth) #============================================================================== # plot 5x lines #============================================================================== # plt.plot([50,1e5],[10,2e4],color='black',linewidth=linewidth) # plt.plot([10,2e4],[50,1e5],color='black',linewidth=linewidth) #============================================================================== # show legend #============================================================================== plt.legend(loc=0) #============================================================================== # save figures #============================================================================== if figure_path <> None and figure_name <> None: for save_type in save_types: plt.savefig(figure_path + figure_name + save_type, dpi=150, transparent=True) print 'save as', figure_path + figure_name + save_type plt.show() plt.close()
def create_plot_data_exp_coffin_manson(fatigue_data, figure_path=None, figure_name=None): plot_data = PlotData() #============================================================================== # x,y label #============================================================================== xlabel = xylabels['experimental_life'] ylabel = xylabels['axial_strain_amplitude'] #============================================================================== # plot lines #============================================================================== i = 0 marker_list = ['s', 'o', '^', 'D', '<'] for load_type in ['TC-IF']: experimental_life = fatigue_data.loadTypeFilter( load_type, 'experimental_life') equivalent_strain_amplitude = fatigue_data.loadTypeFilter( load_type, 'equivalent_strain_amplitude') plot_data.addLine(experimental_life, equivalent_strain_amplitude, xlabel=xlabel, ylabel=ylabel, linelabel=load_type, linewidth=2, linestyle='', marker=marker_list[i], markersize=12) i += 1 plot_data.addLine(life_NASA, strain_amplitude_NASA, xlabel=xlabel, ylabel=ylabel, linelabel='NASA', linewidth=2, linestyle='', marker=marker_list[i], markersize=12) i += 1 plot_data.addLine(life_BHU, strain_amplitude_BHU, xlabel=xlabel, ylabel=ylabel, linelabel='G.S. Mahobia 2014', linewidth=2, linestyle='', marker=marker_list[i], markersize=12) material = material_in718() life, epsilon_amplitude = material.plotMansonCoffinAxial() plot_data.addLine(life, epsilon_amplitude * 100, xlabel=xlabel, ylabel=ylabel, linelabel='', linewidth=2, linestyle='-', marker=None, markersize=12, color='blue') material = material_in718_NASA() life, epsilon_amplitude = material.plotMansonCoffinAxial() plot_data.addLine(life, epsilon_amplitude * 100, xlabel=xlabel, ylabel=ylabel, linelabel='', linewidth=2, linestyle='-', marker=None, markersize=12, color='green') material = material_in718_BHU() life, epsilon_amplitude = material.plotMansonCoffinAxial() plot_data.addLine(life, epsilon_amplitude * 100, xlabel=xlabel, ylabel=ylabel, linelabel='', linewidth=2, linestyle='-', marker=None, markersize=12, color='red') plot_data.writeToFile(figure_path, figure_name)