def display_with_yield(disp = True): """Display the plot of the file with its yield point and returns the model and that point.""" """Opens file browser and gets selection""" model = getfile() data = model.get_experimental_data() yieldpoint = None """Gets radio button input as to which method to use to optimize""" if yield_method.get() == 1: yieldpoint = material_analytics.yield_stress_classic_unfitted(data) elif yield_method.get() == 2: yieldpoint = material_analytics.yield_stress_classic_fitted(data) elif yield_method.get() == 3: yieldpoint = material_analytics.yield_stress(data) else: elastic, plastic = material_analytics.kmeanssplit(data) yieldpoint = plastic[0][None,] if disp: """Displays the found yield stress""" plot.plotmult2D(data, yieldpoint, title = 'File', marker1 = 'o', xtitle = 'Strain ($\epsilon$)', ytitle= 'Stress ($\sigma$)') return model, yieldpoint
def constitutive_model(): """Display the plot of the file fitted to a constitutive model""" """Displays the currently selected yield point""" model, yieldpoint = display_with_yield(disp=False) data = model.get_experimental_data() """Will need to be set to user-input guess""" guess = [-150,1] """[0,1] is the first row, second column, which is the stress values""" SS_stress = yieldpoint[0,1] model_training_methods = ['Nelder-Mead','Powell','CG','Newton-CG','BFGS','L-BFGS-B','SLSQP','COBYLA','TNC','Basinhopping','Brute Force','Genetic Algorithm'] """Because basinhopping, brute force, and GA are all in separate libraries, they are handled as separate cases.""" optmethod = optimization_method.get()-1 if optmethod<9: model_params = optimization_suite.minimize_suite(model.mcfunc, methods=[model_training_methods[optmethod],], guess = guess ,SS_stress=SS_stress) elif optmethod==9: model_params = optimization_suite.minimize_suite(model.mcfunc, methods=[basinhopping,], guess = guess ,SS_stress=SS_stress) elif optmethod==10: model_params = optimization_suite.minimize_suite(model.mcfunc, methods=[brute,], guess = guess ,SS_stress=SS_stress) else: model_params = optimization_suite.GA_minimize(model.mcfunc, guess) """Plots the data versus the fitted irreversible model data""" plot.plotmult2D(data, model.irreversible_model(model_params,SS_stress), title = 'Fitted Thermodynamics', xtitle = 'Strain ($\epsilon$)', ytitle= 'Stress ($\sigma$)')
def display_with_yield(disp=True): """Display the plot of the file with its yield point and returns the model and that point.""" """Opens file browser and gets selection""" model = getfile() data = model.get_experimental_data() yieldpoint = None """Gets radio button input as to which method to use to optimize""" if yield_method.get() == 1: yieldpoint = material_analytics.yield_stress_classic_unfitted(data) elif yield_method.get() == 2: yieldpoint = material_analytics.yield_stress_classic_fitted(data) elif yield_method.get() == 3: yieldpoint = material_analytics.yield_stress(data) else: elastic, plastic = material_analytics.kmeanssplit(data) yieldpoint = plastic[0][None, ] if disp: """Displays the found yield stress""" plot.plotmult2D(data, yieldpoint, title='File', marker1='o', xtitle='Strain ($\epsilon$)', ytitle='Stress ($\sigma$)') return model, yieldpoint
def update(): """Display the plot of the file with its yield point""" """Opens file browser and gets selection""" name = tkFileDialog.askopenfilename() """Creates model for data""" if 'xml' in name: model = strainmodel(name, type='xml') else: model = strainmodel(name) data = model.get_experimental_data() """Will need to be set to user-input guess""" guess = [-150,1] yieldpoint = None """Gets radio button input as to which method to use to optimize""" if yield_method.get() == 1: yieldpoint = material_analytics.yield_stress_classic_unfitted(data) elif yield_method.get() == 2: yieldpoint = material_analytics.yield_stress_classic_fitted(data) elif yield_method.get() == 3: yieldpoint = material_analytics.yield_stress(data) else: elastic, plastic = material_analytics.kmeanssplit(data) yieldpoint = plastic[0][None,] """Displays the found yield stress""" plot.plotmult2D(data, yieldpoint, title = 'File', xtitle = 'Strain ($\epsilon$)', ytitle= 'Stress ($\sigma$)') """[0,1] is the first row, second column, which is the stress values""" SS_stress = yieldpoint[0,1] model_training_methods = ['Nelder-Mead','Powell','CG','Newton-CG','BFGS','L-BFGS-B','SLSQP','COBYLA','TNC','Basinhopping','Brute Force','Genetic Algorithm'] """Because basinhopping, brute force, and GA are all in separate libraries, they are handled as separate cases.""" optmethod = optimization_method.get()-1 if optmethod<9: model_params = optimization_suite.minimize_suite(model.mcfunc, methods=[model_training_methods[optmethod],], guess = guess ,SS_stress=SS_stress) elif optmethod==9: model_params = optimization_suite.minimize_suite(model.mcfunc, methods=[basinhopping,], guess = guess ,SS_stress=SS_stress) elif optmethod==10: model_params = optimization_suite.minimize_suite(model.mcfunc, methods=[brute,], guess = guess ,SS_stress=SS_stress) else: model_params = optimization_suite.GA_minimize(model.mcfunc, guess) """Plots the data versus the fitted irreversible model data""" plot.plotmult2D(data, model.irreversible_model(model_params,SS_stress), title = 'Fitted Thermodynamics', xtitle = 'Strain ($\epsilon$)', ytitle= 'Stress ($\sigma$)')
def constitutive_model(): """Display the plot of the file fitted to a constitutive model""" """Displays the currently selected yield point""" model, yieldpoint = display_with_yield(disp=False) data = model.get_experimental_data() """Will need to be set to user-input guess""" guess = [-150, 1] """[0,1] is the first row, second column, which is the stress values""" SS_stress = yieldpoint[0, 1] model_training_methods = [ 'Nelder-Mead', 'Powell', 'CG', 'Newton-CG', 'BFGS', 'L-BFGS-B', 'SLSQP', 'COBYLA', 'TNC', 'Basinhopping', 'Brute Force', 'Genetic Algorithm' ] """Because basinhopping, brute force, and GA are all in separate libraries, they are handled as separate cases.""" optmethod = optimization_method.get() - 1 if optmethod < 9: model_params = optimization_suite.minimize_suite( model.mcfunc, methods=[ model_training_methods[optmethod], ], guess=guess, SS_stress=SS_stress) elif optmethod == 9: model_params = optimization_suite.minimize_suite(model.mcfunc, methods=[ basinhopping, ], guess=guess, SS_stress=SS_stress) elif optmethod == 10: model_params = optimization_suite.minimize_suite(model.mcfunc, methods=[ brute, ], guess=guess, SS_stress=SS_stress) else: model_params = optimization_suite.GA_minimize(model.mcfunc, guess) """Plots the data versus the fitted irreversible model data""" plot.plotmult2D(data, model.irreversible_model(model_params, SS_stress), title='Fitted Thermodynamics', xtitle='Strain ($\epsilon$)', ytitle='Stress ($\sigma$)')
def statistical_model(): """Display the plot of the file fitted to a statistical model""" """Displays the currently selected yield point""" model, yieldpoint = display_with_yield(disp=False) data = model.get_experimental_data() """This is for the logarithmic model""" if fit_method.get() == 1: model = material_analytics.log_approx(data) """This is for the custom, slope-based model""" if fit_method.get() == 2: model = material_analytics.stress_model(data, yieldpoint) """Take some points from the model to plot them""" fittedpts = material_analytics.samplepoints(model,[0.,max(data[:,0])],10000) plot.plotmult2D(data,fittedpts,marker1 = 'o', marker2 = '-',title = 'Stress v Strain',xtitle ='Strain ($\epsilon$)',ytitle='Stress ($\sigma$)')
def statistical_model(): """Display the plot of the file fitted to a statistical model""" """Displays the currently selected yield point""" model, yieldpoint = display_with_yield(disp=False) data = model.get_experimental_data() """This is for the logarithmic model""" if fit_method.get() == 1: model = material_analytics.log_approx(data) """This is for the custom, slope-based model""" if fit_method.get() == 2: model = material_analytics.stress_model(data, yieldpoint) """Take some points from the model to plot them""" fittedpts = material_analytics.samplepoints(model, [0., max(data[:, 0])], 10000) plot.plotmult2D(data, fittedpts, marker1='o', marker2='-', title='Stress v Strain', xtitle='Strain ($\epsilon$)', ytitle='Stress ($\sigma$)')