Example #1
0
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()
Example #2
0
def tut3D_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",
        sigma_zz_tut: "sigma_zz",
        tau_yz_tut: "tau_yz",
        tau_zx_tut: "tau_zx",
        angle1_tut: "Angle x",
        angle2_tut: 'Angle y',
        angle3_tut: 'Angle z'
    }
    Small_font = game_font(20)
    head_text = Small_font.render("Tutorial 3-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))
    enterButton.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()
                tut3D_stress_input_window_check.endCurrent()
            if enterButton.isOver(pos):
                mohrCircle_input = []
                try:
                    mohr_3d = Stress_MohrCircle(σxx=float(sigma_xx_tut.text),
                                                σyy=float(sigma_yy_tut.text),
                                                σzz=float(sigma_zz_tut.text),
                                                σxy=float(tau_xy_tut.text),
                                                σyz=float(tau_yz_tut.text),
                                                σzx=float(tau_zx_tut.text))
                    mohr_3d.ndims = 3
                    mohr_3d.isGraph = False
                    if (angle1_tut.text != '' and angle2_tut.text != ''):
                        angle_check = 1
                        mohr_3d.reqAngle_normal_3d = [
                            round(np.cos(np.deg2rad(float(angle1_tut.text))),
                                  3),
                            round(np.cos(np.deg2rad(float(angle2_tut.text))),
                                  3), 0
                        ]
                        mohr_3d.isAngle_stress = True
                    mohr_3d.stress_execute()
                    tut3D_stress_input_window_check.endCurrent()
                    tut3D_step1_window_check.makeCurrent()
                except Exception as e:
                    print(e)
                    tut3D_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)
Example #3
0
def tut3D_step7_window(screen, prev_win, windows):
    Big_font = game_font(60)
    Small_font = game_font(25)
    extra_small_font = game_font(18)
    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 3-D Mode", 1, (0, 0, 0))
    mid_text = mid_font.render("STEP-7", 1, (0, 0, 0))
    screen.blit(head_text, (80, 70))
    screen.blit(mid_text, (80, 150))
    l = np.cos(np.deg2rad(float(angle1_tut.text)))
    m = np.cos(np.deg2rad(float(angle2_tut.text)))
    n = np.sqrt(1 - l**2 - m**2)
    if (n == None):
        n = 0
    tut_text = [
        "To find the the value of stresses on plane",
        "whose normal's direction vector is (l,m,n)",
        "l = cos(" + str(angle1_tut.text) + ") = " + str(round(l, 3)),
        "m = cos(" + str(angle2_tut.text) + ") = " + str(round(m, 3)),
        "n = sqrt(1 - l^2 -m^2) =  " + str(round(n, 3)),
    ]
    tut2_text = [
        "use the following formula to obtain normal", "and shear stress : ",
        "sig_normal = l^2*sig_1+m^2*sig_2+n^2*sig_3",
        "sig_shear = l^2*sig_1^2 + m^2*sig_2^2 + n^2*sig_3^2 - sig_normal^2",
        "PLot the point (sig_normal, sig_shear)"
    ]
    count = 0
    for text in tut_text:
        text = Small_font.render(text, 1, (0, 0, 0))
        screen.blit(text, (70, 200 + count))
        count += 40
    count = 0
    for text in tut2_text:
        text = extra_small_font.render(text, 1, (0, 0, 0))
        screen.blit(text, (40, 400 + count))
        count += 25
    backButton.draw(screen, (0, 0, 0))
    graphButton.draw(screen, (0, 0, 0))
    finishButton.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):
                tut3D_step6_window_check.makeCurrent()
                tut3D_step7_window_check.endCurrent()
            if finishButton.isOver(pos):
                tut3D_final_window_check.makeCurrent()
                tut3D_step7_window_check.endCurrent()
            if graphButton.isOver(pos):
                mohr_3d = Stress_MohrCircle(σxx=float(sigma_xx_tut.text),
                                            σyy=float(sigma_yy_tut.text),
                                            σzz=float(sigma_zz_tut.text),
                                            σxy=float(tau_xy_tut.text),
                                            σyz=float(tau_yz_tut.text),
                                            σzx=float(tau_zx_tut.text))
                mohr_3d.ndims = 3
                mohr_3d.isGraph = True
                if (angle1_tut.text != '' and angle2_tut.text != ''):
                    angle_check = 1
                    mohr_3d.reqAngle_normal_3d = [
                        round(np.cos(np.deg2rad(float(angle1_tut.text))), 3),
                        round(np.cos(np.deg2rad(float(angle2_tut.text))), 3), 0
                    ]
                    mohr_3d.isAngle_stress = True
                mohr_3d.stress_execute()
Example #4
0
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)
Example #5
0
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()