def print_failure_modes(failure_df, stress_applied, moment_applied): #Prints the minimum R's for each criterion and states the failure mode (where applicable) max_stress = MECH530_failure.find_min(failure_df, ['max_FT','max_FC','max_MT','max_MC','max_S']) quad_poly = MECH530_failure.find_min(failure_df, ['(+)']) hashin_crit = MECH530_failure.find_min(failure_df, ['hash_FT','hash_FC','hash_MT','hash_MC']) print "\nFAILURE CRITERION AND ANALYSIS" print "\nMAXIMUM STRESS:" print "-Minimum R = %.3f and laminate fails in %s at %s of ply %d" %(max_stress[0], max_stress[2], max_stress[1]['Pos'], max_stress[1]['Ply']) print "-The load vectors which cause the failure are:" print "R*N = " print 10**(-3) * max_stress[0] * stress_applied.T, "[kN/m]" #Stress and Moment applied [N/m] and [N] --> [kN/m] and [kN] print "R*M = " print 10**(-3) * max_stress[0] * moment_applied.T, "[kN]" print "\nQUADRATIC POLYNOMIAL:" print "-Minimum R = %.3f and laminate fails at %s of ply %d" %(quad_poly[0], quad_poly[1]['Pos'], quad_poly[1]['Ply']) print "-The load vectors which cause the failure are:" print "R*N = " print 10**(-3) * quad_poly[0] * stress_applied.T, "[kN/m]" print "R*M = " print 10**(-3) * quad_poly[0] * moment_applied.T, "[kN]" print "\nHASHIN CRITERION:" print "-Minimum R = %.3f and laminate fails in %s at %s of ply %d" %(hashin_crit[0], hashin_crit[2], hashin_crit[1]['Pos'], hashin_crit[1]['Ply']) print "-The load vectors which cause the failure are:" print "R*N = " print 10**(-3) * hashin_crit[0] * stress_applied.T, "[kN/m]" print "R*M = " print 10**(-3) * hashin_crit[0] * moment_applied.T, "[kN]\n" return max_stress, quad_poly, hashin_crit
def print_loadapplied(case, plybook, plies, stress_applied, stress_type, moment_applied, moment_type, A, A_comp, D, D_comp, h_laminate): #Find the stress, strain and failure criterion R values i = 0 engineering_formatter = lambda x: "%9.4f" % x if x != 0 else "%9.1f" % x numpy.set_printoptions(formatter = {'float_kind':engineering_formatter}) if (stress_type == 'OFF' or stress_type == 'NO') and (moment_type == 'OFF' or moment_type == 'NO'): K = 10**(-9) * D_comp.dot(moment_applied) #Now this will be in [m] since D_comp is in strain_off_av = 10**(-9) * A_comp.dot(stress_applied) #Convert [a], [m/GN] --> [m/N]. This is now unitless if case == 1: print "OFF-AXIS APPLIED RESULTANTS: CASE 1" elif case == 2: print "OFF-AXIS APPLIED RESULTANTS: CASE 2" elif case == 3: print "OFF-AXIS APPLIED RESULTANTS: CASE 3" else: print "OFF-AXIS APPLIED RESULTANTS" print "\nCurvature K =" print K.T, "[1/m]" print "\n(INPUT) Off-axis Applied stress resultant N = " print stress_applied.T, "[N/m]" print "\n(INPUT) Off-axis Applied moment resultant M = " print moment_applied.T, "[N]" h = h_laminate / 2.0 position = {'1':'TOP', '0':'BOTTOM'} while i < plies: temp_env = numpy.zeros(2) #Contains my ply number, and angle if plybook[i][1] == 'CORE': h -= plybook[i][3] #Subtract the thickness of the core else: position_counter = 1 #Start at the top while position_counter > -1: strain_off = strain_off_av + (h * K / 1000.0) #Convert thickness to m stress_on, strain_on = MECH530_matrices.convert_to_on_axis(plybook, i, strain_off) strength = MECH530_failure.failure_props(plybook, i) max_R = MECH530_failure.max_stress(stress_on, strength, i) quad_R = MECH530_failure.quad_poly(stress_on, strength, i) hash_R = MECH530_failure.hashin_crit(stress_on, strength, i) temp_env[0] = plies-i temp_env[1] = plybook[i][2] #The angle temp_R = numpy.hstack((temp_env, max_R, quad_R, hash_R)) temp_stress = numpy.hstack((temp_env, strain_off.flatten(), strain_on.flatten(), stress_on.flatten())) if position_counter == 0: #We've just done the bottom of a ply h == h R_fail = numpy.vstack((R_fail, temp_R)) stress_state = numpy.vstack((stress_state, temp_stress)) #Creates an array full of stresses and strains else: #We've just done the top of a ply and we want to do the bottom next h -= plybook[i][3] #Subtract the thickness of a ply if i == 0: #We need to create the R_fail and result matrices R_fail = temp_R stress_state = temp_stress else: R_fail = numpy.vstack((R_fail, temp_R)) stress_state = numpy.vstack((stress_state, temp_stress)) position_counter -= 1 i += 1 else: pass #Stress DataFrame stress_df = pd.DataFrame(data = stress_state, columns = ['Ply','Angle','e_1','e_2','e_3', 'e_x','e_y','e_z', 'Sigma_x (GPa)','Sigma_y (GPa)','Sigma_z (GPa)' ] ) pos = [k for i in range(len(stress_df)/2) for k in ['TOP','BOT'] ] stress_df['Pos'] = pos stress_df.set_index('Pos', inplace = True) #Failure R values DataFrame failure_df = pd.DataFrame(data = R_fail, columns = ['Ply','Angle','max_FT','max_FC','max_MT', 'max_MC','max_S','(+)','(-)', 'hash_FT','hash_FC','hash_MT','hash_MC' ] ) failure_df['Pos'] = pos #failure_df.set_index('Pos', inplace = True) return stress_state, R_fail, stress_df, failure_df