def _calc_mohr(self): mohr_circle = Stress_MohrCircle(self.σxx, self.σyy,self.σxy, self.σzz,self.σyz,self.σzx) if(self.angle2d!=None and self.ndims==2): mohr_circle.isAngle_stress = True mohr_circle.reqAngle_stress_2d = self.angle2d elif(self.ndims==3 and self.angle1!=None and self.angle2!=None): l,m,n= np.cos(np.deg2rad(self.angle1)), np.cos(np.deg2rad(self.angle2)), np.cos(np.deg2rad(self.angle3)) mohr_circle.isAngle_stress = True l,m,n = round(l,3),round(m,3),round(n,3) mohr_circle.reqAngle_normal_3d = list([l,m,n]) mohr_circle.ndims = self.ndims return mohr_circle.stress_execute()
def tut2D_step5_window(screen, prev_win, windows): Big_font = game_font(60) Small_font = game_font(25) mid_font = game_font(40) # print(sigma_xx_tut.text, sigma_yy_tut.text, tau_xy_tut.text, angle_tut.text) head_text = Big_font.render("Tutorial 2-D Mode", 1, (0, 0, 0)) mid_text = mid_font.render("STEP-5", 1, (0, 0, 0)) screen.blit(head_text, (80, 70)) screen.blit(mid_text, (80, 150)) tut_text = [ "Now, using the center and radius being ", "Thus the new line has its end-points on", "the circle. These endpoints denote the new", "(sigma_xx, -tau_xy) and (sigma_yy, tau_xy)", " ", "Thus you get the required values of stress", "at the required angle using Mohr's Circle!!!" ] count = 0 for text in tut_text: text = Small_font.render(text, 1, (0, 0, 0)) screen.blit(text, (70, 200 + count)) count += 40 backButton.draw(screen, (0, 0, 0)) finishButton.draw(screen, (0, 0, 0)) graphButton.draw(screen, (0, 0, 0)) for event in pygame.event.get(): pos = pygame.mouse.get_pos() if event.type == pygame.QUIT: global running running = False if event.type == pygame.MOUSEBUTTONDOWN: if backButton.isOver(pos): tut2D_step4_window_check.makeCurrent() tut2D_step5_window_check.endCurrent() if finishButton.isOver(pos): tut2D_final_window_check.makeCurrent() tut2D_step5_window_check.endCurrent() if graphButton.isOver(pos): req_mohr = Stress_MohrCircle(float(sigma_xx_tut.text), float(sigma_yy_tut.text), float(tau_xy_tut.text)) # req_mohr.angle = float(angle_tut.text) req_mohr.ndims = 2 # req_mohr.plot_angle2d() req_mohr.isAngle_stress = True req_mohr.reqAngle_stress_2d = float(angle_tut.text) req_mohr.isGraph = True req_mohr.stress_execute()
def tut2D_stress_input_window(screen, prev_win, windows): global angle_check clock = pygame.time.Clock() input_boxes = { sigma_xx_tut: "sigma_xx", sigma_yy_tut: "sigma_yy", tau_xy_tut: "tau_xy", angle_tut: "angle" } Small_font = game_font(20) head_text = Small_font.render("Tutorial 2- D Mode", 1, (0, 0, 0)) for box in input_boxes.keys(): box_text = Small_font.render(input_boxes[box] + ":", 1, (0, 0, 0)) screen.blit(box_text, (box.x - 120, box.y)) screen.blit(head_text, (360, 100)) backButton.draw(screen, (0, 0, 0)) nextButton.draw(screen, (0, 0, 0)) for event in pygame.event.get(): pos = pygame.mouse.get_pos() if event.type == pygame.QUIT: global running running = False if event.type == pygame.MOUSEBUTTONDOWN: if backButton.isOver(pos): tutorialwindow_check.makeCurrent() tut2D_stress_input_window_check.endCurrent() if nextButton.isOver(pos): try: mohr_2d = Stress_MohrCircle(σxx=float(sigma_xx_tut.text), σyy=float(sigma_yy_tut.text), σzz=0, σxy=float(tau_xy_tut.text), σyz=0, σzx=0) mohr_2d.ndims = 2 mohr_2d.isGraph = False if (angle_tut.text != ''): mohr_2d.isAngle_stress = True angle_check = 1 mohr_2d.reqAngle_stress_2d = float(angle_tut.text) else: angle_check = 0 mohr_2d.stress_execute() tut2D_stress_input_window_check.endCurrent() tut2D_step1_window_check.makeCurrent() except: tut2D_stress_input_window_check.endCurrent() incompatible_input_window_check.makeCurrent() for box in input_boxes.keys(): if box.render().collidepoint(event.pos): print("click") box.active = True else: box.active = False box_text_input(event, input_boxes) if event.type == pygame.MOUSEMOTION: if backButton.isOver(pos): backButton.color = (255, 0, 0) else: backButton.color = (180, 0, 0) for box in input_boxes.keys(): txt_surface = Small_font.render(box.text, True, box.color) width = max(200, txt_surface.get_width() + 10) box.render().w = width screen.blit(txt_surface, (box.x + 5, box.y + 5)) pygame.draw.rect(screen, box.color, box.render(), 2) clock.tick(30)
def tut2D_step3_window(screen, prev_win, windows): global angle_check global sigma1, sigma2, curr_angle Big_font = game_font(60) Small_font = game_font(25) extra_small_font = game_font(15) mid_font = game_font(40) # print(sigma_xx_tut.text, sigma_yy_tut.text, tau_xy_tut.text, angle_tut.text) head_text = Big_font.render("Tutorial 2-D Mode", 1, (0, 0, 0)) mid_text = mid_font.render("STEP-3", 1, (0, 0, 0)) screen.blit(head_text, (80, 70)) screen.blit(mid_text, (80, 150)) tut_text = [ "Now, using the center and radius being ", "the distance between the center and one ", "of the plotted points, draw a circle.", "Thus you get your Mohr's Circle", "The points where the circle cuts the X-axis", "are the principal stresses." ] count = 0 for text in tut_text: text = Small_font.render(text, 1, (0, 0, 0)) screen.blit(text, (70, 200 + count)) count += 40 backButton.draw(screen, (0, 0, 0)) xButton = nextButton if angle_check == 0: xButton = finishButton xButton.draw(screen, (0, 0, 0)) graphButton.draw(screen, (0, 0, 0)) try: mohr_2d = Stress_MohrCircle(σxx=float(sigma_xx_tut.text), σyy=float(sigma_yy_tut.text), σzz=0, σxy=float(tau_xy_tut.text), σyz=0, σzx=0) mohr_2d.ndims = 2 mohr_2d.isGraph = False if (angle_gen.text != ''): mohr_2d.isAngle_stress = True mohr_2d.reqAngle_stress_2d = float(angle_gen.text) _, sig, _, _, _, curr_angle = mohr_2d.stress_execute() sigma1, sigma2 = sig[0][0], sig[1][0] curr_angle = round(np.rad2deg(curr_angle), 2) answer_txt = "sigma_1 : " + str(sigma1) + ", sigma_2 : " + str( sigma2) + ", phi : " + str(curr_angle) + " deg" answer_txt = extra_small_font.render(answer_txt, 1, (0, 0, 0)) screen.blit(answer_txt, (50, 480)) except ValueError: # print(e) answer_txt = "sigma_1 : sigma_2 : phi" answer_txt = extra_small_font.render(answer_txt, 1, (0, 0, 0)) screen.blit(answer_txt, (50, 480)) for event in pygame.event.get(): pos = pygame.mouse.get_pos() if event.type == pygame.QUIT: global running running = False if event.type == pygame.MOUSEBUTTONDOWN: if backButton.isOver(pos): tut2D_step2_window_check.makeCurrent() tut2D_step3_window_check.endCurrent() if xButton.isOver(pos): if xButton == nextButton: tut2D_step3_window_check.endCurrent() tut2D_step4_window_check.makeCurrent() else: tut2D_step3_window_check.endCurrent() tut2D_final_window_check.makeCurrent() if graphButton.isOver(pos): req_mohr = tut_Stress_MohrCircle(float(sigma_xx_tut.text), float(sigma_yy_tut.text), float(tau_xy_tut.text)) req_mohr.ndims = 2 req_mohr.plot_circle()