How to use all_steps method in Lemoncheesecake

Best Python code snippet using lemoncheesecake

Python Postprocessor.py

Source:Python Postprocessor.py Github

copy

Full Screen

1##########################################################################################################################################################################################2######################################## Pipeline Thermal Expansion & Displacements POSTPROCESSOR ###############################################################################3######################################## Subject: Abaqus FEA Postprocessing ###############################################################################4######################################## Author : Engr.Jesurobo Collins ##################################################################################### #################################################################################################5######################################## Project: Personal project ##############################################################################################6######################################## Tools used: Python,Abaqus,xlsxwriter ##############################################################################################7######################################## Email: collins4engr@yahoo.com ##############################################################################################8#########################################################################################################################################################################################910import sys,os11from abaqus import*12from abaqusConstants import*13from viewerModules import*14from math import*15import xlsxwriter16import glob17import numpy as np1819# CHANGE TO CURRENT WORKING DIRECTORY20os.chdir('C:/temp/Pipeline Parametric studies/Expansion')2122###CREATE EXCEL WORKBOOK, SHEETS AND ITS PROPERTIES####23execFile = 'Results.xlsx'24workbook = xlsxwriter.Workbook(execFile)25workbook.set_properties({26 'title': 'This is Abaqus postprocessing',27 'subject': 'Pipeline Thermal expansion analysis', 28 'author': 'Collins Jesurobo',29 'company': 'Personal Project',30 'comments': 'Created with Python and XlsxWriter'})3132# Create a format to use in the merged range.33merge_format = workbook.add_format({34 'bold': 1,35 'border': 1,36 'align': 'center',37 'valign': 'vcenter',38 'fg_color': 'yellow'})39SHEET1 = workbook.add_worksheet('Summary')40SHEET1.center_horizontally()41SHEET1.fit_to_pages(1, 1)42SHEET1.set_column(0,1,21)43SHEET1.set_column(2,3,19)44SHEET1.set_column(4,6,23)45SHEET1.merge_range('A1:G1', 'MAXIMUM AND MINIMUM DISPLACEMENT WITH CORRESPONDING WORST LOADCASE,WORST LOAD STEP AND NODE WHERE IT OCCURS',merge_format)46SHEET1.merge_range('A9:E9', 'WORST EXPANSION FOR EACH LOADCASE VERSUS WALL THICKNESS STUDIED',merge_format)4748SHEET2 = workbook.add_worksheet('All_steps')49SHEET2.center_horizontally()50SHEET2.fit_to_pages(1, 1)51SHEET2.set_column(0,2,24)52SHEET2.merge_range('A1:F1', 'DISPLACEMENTS RESULTS FOR ALL PIPELINE NODES FOR EACH LOADCASE AND CORRESPONDING LOAD STEP',merge_format)535455# defines the worksheet formatting (font name, size, cell colour etc.)56format_title = workbook.add_format()57format_title.set_bold('bold')58format_title.set_align('center')59format_title.set_align('vcenter')60format_title.set_bg_color('#F2F2F2')61format_title.set_font_size(10)62format_title.set_font_name('Arial')63format_table_headers = workbook.add_format()64format_table_headers.set_align('center')65format_table_headers.set_align('vcenter')66format_table_headers.set_text_wrap('text_wrap')67format_table_headers.set_bg_color('#F2F2F2')68format_table_headers.set_border()69format_table_headers.set_font_size(10)70format_table_headers.set_font_name('Arial')7172###WRITING THE TITLES TO SHEET1,SHEET2###73SHEET1.write_row('B2',['U1 - Expansion(mm)','U2(mm)','U3(mm)','WorstLoadcase','LoadStep','Node'],format_title)74SHEET1.write('A3', 'Max value',format_title)75SHEET1.write('A4', 'Min value',format_title)76SHEET1.write('A5', 'Absolute Max value',format_title)77SHEET1.write_row('A10', ['Loadcase','Thickness(mm)','Max_Expansion(mm)','Min_Expansion(mm)','Abs_Expansion(mm)'],format_title)7879SHEET2.write_row('A2',['Loadcase','LoadStep','Node','U1(mm)','U2(mm)','U3(mm)'],format_title)8081###LOOP THROUGH THE ODBs, LOOP THROUGH EACH STEPS AND EXTRACT DISPLACEMENT RESULTS FOR ALL PIPELINE NODES###82def output1():83 row=184 col=085 for i in glob.glob('*.odb'): # loop to access all odbs in the folder86 odb = session.openOdb(i) # open each odb87 step = odb.steps.keys() # probe the content of the steps object in odb, steps object is a dictionary, so extract the step names with keys()88 section = odb.rootAssembly.instances['PART-1-1'].nodeSets['PIPELINE'] # extract section for pipeline nodeset89 ###DEFINE RESULT OUTPUT####90 for k in range(len(step)):91 U = odb.steps[step[k]].frames[-1].fieldOutputs['U'].getSubset(region=section).values # results for all displacements U 92 for disp in U:93 U1 = disp.data[0] # extract U1 (axial) displacements from all the odbs and loadcases94 U2 = disp.data[1] # extract U2 (lateral) displacements from all the odbs and loadcases95 U3 = disp.data[2] # extract U3 (vertical) displacements from all the odbs and loadcases96 n1 = disp.nodeLabel # extract node numbers 97 ### WRITE OUT MAIN RESULT OUTPUT####98 SHEET2.write(row+1,col,i.split('.')[0],format_table_headers) # loadcases99 SHEET2.write(row+1,col+1,step[k],format_table_headers) # steps in odb100 SHEET2.write(row+1,col+2,n1,format_table_headers) # all nodes in the pipeline101 SHEET2.write(row+1,col+3,U1*1000,format_table_headers) # displacements in axial direction, in mm 102 SHEET2.write(row+1,col+4,U2*1000,format_table_headers) # displacements in lateral direction, in mm103 SHEET2.write(row+1,col+5,U3*1000,format_table_headers) # displacements in vertical direction,in mm104 row+=1105output1()106107### GET THE MAXIMUM AND MINIMUM, AND ABSOLUTE MAXIMUM VALUES AND WRITE THM INTO SUMMARY SHEET(SHEET1) 108def output2():109 SHEET1.write('B3', '=ROUND(max(All_steps!D3:D100000),1)',format_table_headers) # maximum displacement in axial direction-max(U1)110 SHEET1.write('C3', '=ROUND(max(All_steps!E3:E100000),1)',format_table_headers) # maximum displacement in lateral direction-max(U2)111 SHEET1.write('D3', '=ROUND(max(All_steps!F3:F100000),1)',format_table_headers) # maximum displacement in vertical direction-max(U3)112 SHEET1.write('B4', '=ROUND(min(All_steps!D3:D100000),1)',format_table_headers) # minimum displacement in axial direction-min(U1)113 SHEET1.write('C4', '=ROUND(min(All_steps!E3:E100000),1)',format_table_headers) # minimum displacement in lateral direction-min(U2)114 SHEET1.write('D4', '=ROUND(min(All_steps!F3:F100000),1)',format_table_headers) # minimum displacement in vertical direction-min(U3)115 SHEET1.write('B5','=IF(ABS(B3)>ABS(B4),ABS(B3),ABS(B4))',format_table_headers) # absolute maximum U1116 SHEET1.write('C5','=IF(ABS(C3)>ABS(C4),ABS(C3),ABS(C4))',format_table_headers) # absolute maximum U2117 SHEET1.write('D5','=IF(ABS(D3)>ABS(D4),ABS(D3),ABS(D4))',format_table_headers) # absolute maximum U3118119 ### WORST LOADCASE AND LOADSTEP CORRESPONDING TO MAXIMUM AND MINIMUM EXPANSION VALUES120 SHEET1.write('E3','=INDEX(All_steps!A3:A100000,MATCH(MAX(All_steps!D3:D100000),All_steps!D3:D100000,0))',format_table_headers)121 SHEET1.write('F3','=INDEX(All_steps!B3:B100000,MATCH(MAX(All_steps!D3:D100000),All_steps!D3:D100000,0))',format_table_headers)122 SHEET1.write('G3','=INDEX(All_steps!C3:C100000,MATCH(MAX(All_steps!D3:D100000),All_steps!D3:D100000,0))',format_table_headers)123 SHEET1.write('E4','=INDEX(All_steps!A3:A100000,MATCH(MIN(All_steps!D3:D100000),All_steps!D3:D100000,0))',format_table_headers)124 SHEET1.write('F4','=INDEX(All_steps!B3:B100000,MATCH(MIN(All_steps!D3:D100000),All_steps!D3:D100000,0))',format_table_headers)125 SHEET1.write('G4','=INDEX(All_steps!C3:C100000,MATCH(MIN(All_steps!D3:D100000),All_steps!D3:D100000,0))',format_table_headers)126output2()127128### LOADCASES129def output3():130 row=0131 col=0132 for LC in glob.glob('*.odb'):133 SHEET1.write(row+10,col,LC.split('.')[0],format_table_headers)134 row+=1135136# WRITE THE COLUMN FOR WALL THICKNESSES THAT WAS USED IN THE PARAMETRIC STUDIES137Thick_data = [15.9,19.1,22.3,25.1,27.1,30.2] # varied thickness in mm138SHEET1.write_column('B11',Thick_data,format_table_headers)139140### WORST EXPANSION VALUES 141142SHEET1.write('C11','{=MAX(IF(All_steps!A3:A100000=Summary!A11, All_steps!D3:D100000))}',format_table_headers)143SHEET1.write('C12','{=MAX(IF(All_steps!A3:A100000=Summary!A12, All_steps!D3:D100000))}',format_table_headers)144SHEET1.write('C13','{=MAX(IF(All_steps!A3:A100000=Summary!A13, All_steps!D3:D100000))}',format_table_headers)145SHEET1.write('C14','{=MAX(IF(All_steps!A3:A100000=Summary!A14, All_steps!D3:D100000))}',format_table_headers)146SHEET1.write('C15','{=MAX(IF(All_steps!A3:A100000=Summary!A15, All_steps!D3:D100000))}',format_table_headers)147SHEET1.write('C16','{=MAX(IF(All_steps!A3:A100000=Summary!A16, All_steps!D3:D100000))}',format_table_headers)148149SHEET1.write('D11', '{=MIN(IF(All_steps!A3:A100000=Summary!A11,All_steps!D3:D100000))}',format_table_headers)150SHEET1.write('D12','{=MIN(IF(All_steps!A3:A100000=Summary!A12, All_steps!D3:D100000))}',format_table_headers)151SHEET1.write('D13','{=MIN(IF(All_steps!A3:A100000=Summary!A13, All_steps!D3:D100000))}',format_table_headers)152SHEET1.write('D14','{=MIN(IF(All_steps!A3:A100000=Summary!A14, All_steps!D3:D100000))}',format_table_headers)153SHEET1.write('D15','{=MIN(IF(All_steps!A3:A100000=Summary!A15, All_steps!D3:D100000))}',format_table_headers)154SHEET1.write('D16','{=MIN(IF(All_steps!A3:A100000=Summary!A16, All_steps!D3:D100000))}',format_table_headers)155156SHEET1.write('E11','=IF(ABS(C11)>ABS(D11),ABS(C11),ABS(D11))',format_table_headers) 157SHEET1.write('E12','=IF(ABS(C12)>ABS(D12),ABS(C12),ABS(D12))',format_table_headers) 158SHEET1.write('E13','=IF(ABS(C13)>ABS(D13),ABS(C13),ABS(D13))',format_table_headers) 159SHEET1.write('E14','=IF(ABS(C14)>ABS(D14),ABS(C14),ABS(D14))',format_table_headers) 160SHEET1.write('E15','=IF(ABS(C15)>ABS(D15),ABS(C15),ABS(D15))',format_table_headers) 161SHEET1.write('E16','=IF(ABS(C16)>ABS(D16),ABS(C16),ABS(D16))',format_table_headers)162163164# CREATE A PLOT OF EXPANSION VERSUS PIPE WALL THICKNESS165chart = workbook.add_chart({'type': 'line'})166167# Add a series to the chart.168chart.add_series({169 'name': 'Thermal Expansion',170 'categories':'=Summary!$B$11:$B$16', #Thickness in x-axis171 'values': '=Summary!$E$11:$E$16',172 'line':{'color':'blue'}}) #Expansion in y-axis173chart.set_title({'name': 'Thermal Expansion',})174chart.set_x_axis({'name': 'Pipeline Wall Thickness(mm)',})175chart.set_y_axis({'name': 'Thermal Expansion(mm)',})176chart.set_style(9)177178# Insert the chart into the worksheet.179SHEET1.insert_chart('F8', chart)180output3()181182# closes the workbook once all data is written183workbook.close()184185# opens the resultant spreadsheet186os.startfile(execFile)187188# parameteric study completed189190191192193194195196 ...

Full Screen

Full Screen

xiknolik.py

Source:xiknolik.py Github

copy

Full Screen

1import random2print('Hi you play Tic Tac Toe\n')3def print_tablo():4 5 print('\n\n ',all_steps[0],'|',all_steps[1],'|',all_steps[2],'')6 print(' --- --- ---')7 print(' ',all_steps[3],'|',all_steps[4],'|',all_steps[5],'')8 print(' --- --- ---')9 print(' ',all_steps[6],'|',all_steps[7],'|',all_steps[8],' \n\n')10 11def start():12 while True:13 14 global choice15 global steps 16 global all_steps17 steps = []18 all_steps = [1,2,3,4,5,6,7,8,9]19 print('')20 x=input('You want (X) or (O) ')21 choice = x.upper()22 if choice == 'X' or choice == 'O':23 break24 else:25 print('You dont input (X) or (O) ')26def player():27 while True:28 print("")29 try:30 players_step = int(input('Where you want write: '))31 if players_step in range(1,10):32 if players_step not in steps:33 steps.append(players_step)34 result = players_step -135 all_steps[result] = choice36 break37 else:38 print('This place is busy')39 except ValueError:40 print("Input a correct number ")41def comp():42 while True:43 comp_step = random.randint(1,9)44 if comp_step not in steps:45 steps.append(comp_step)46 print("Comp step",comp_step)47 result_comp = comp_step -148 if choice == 'X':49 all_steps[result_comp] = 'O'50 else:51 all_steps[result_comp] = 'X'52 break53 54def game():55 while True:56 if (all_steps[0] == all_steps[1] == all_steps[2] == "X" or57 all_steps[3] == all_steps[4] == all_steps[5] == "X" or58 all_steps[6] == all_steps[7] == all_steps[8] == "X" or59 all_steps[0] == all_steps[4] == all_steps[8] == "X" or60 all_steps[2] == all_steps[4] == all_steps[6] == "X" or61 all_steps[0] == all_steps[3] == all_steps[6] == "X" or62 all_steps[1] == all_steps[4] == all_steps[7] == "X" or63 all_steps[2] == all_steps[5] == all_steps[8] == "X" ):64 print('WIN X')65 break66 elif len(steps) == 9:67 print('NOBODY WIN') 68 break69 elif(all_steps[0] == all_steps[1] == all_steps[2] == "O" or70 all_steps[3] == all_steps[4] == all_steps[5] == "O" or71 all_steps[6] == all_steps[7] == all_steps[8] == "O" or72 all_steps[0] == all_steps[4] == all_steps[8] == "O" or73 all_steps[2] == all_steps[4] == all_steps[6] == "O" or74 all_steps[0] == all_steps[3] == all_steps[6] == "O" or75 all_steps[1] == all_steps[4] == all_steps[7] == "O" or76 all_steps[2] == all_steps[5] == all_steps[8] == "O"): 77 print('WIN O ')78 break79 elif len(steps) == 9:80 print('NOBODY WIN')81 break82 else:83 return True84def play():85 start()86 print_tablo()87 while True:88 if choice == 'X':89 player()90 print_tablo()91 if not game():92 break93 comp()94 print_tablo()95 if not game():96 break 97 else:98 comp()99 print_tablo()100 if not game():101 break102 player()103 print_tablo()104 if not game():105 break106play() 107def play_again():108 while True:109 answer = input('You want play again yes(y) or no? ') == 'y'110 if answer:111 play()112 else:113 break...

Full Screen

Full Screen

file_xo.py

Source:file_xo.py Github

copy

Full Screen

1import random as r2print('\n\t\t HI YOU PLAYED GAME TIC TAC TOK')3all_steps = [1,2,3,4,5,6,7,8,9]4steps = []5def print_tablo():6 print(' ____________________________')7 print(' |',all_steps[0],'|',all_steps[1],'|',all_steps[2],'|')8 print(' ____________________________')9 print(' |',all_steps[3],'|',all_steps[4],'|',all_steps[5],'|')10 print(' ____________________________')11 print(' |',all_steps[6], '|',all_steps[7] ,'|',all_steps[8],'|')12 print(' ____________________________')13def player():14 while True:15 player_steps = int( input(' WHERE YOU WANT WRITE:'))16 if player_steps not in steps:17 steps.append(player_steps)18 result = player_steps -119 all_steps[result] = 'x'20 break21def bot():22 while True:23 bot_comp= r.randint(1,9)24 if bot_comp not in steps:25 steps.append(bot_comp)26 print(' comp step',bot_comp)27 result = bot_comp -128 all_steps[result] = 'O'29 break30while True: 31 print_tablo()32 player()33 print_tablo()...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Lemoncheesecake automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful