Running the model in loop with different co-eff of friction. #2460
-
Hello, from ansys.mapdl.core import launch_mapdl
import os
def mu_changer(all_elem, mu):
mapdl.prep7()
mapdl.mp('MU','2', mu)
for i in range(len(all_elem)):
j = int(all_elem[i][0])
mapdl.mpchg('2', str(j))
mapdl.finish()
path = os.getcwd()
mapdl = launch_mapdl(run_location = path + "\X_Ansys_Pymodel_Co-ff_of_friction")
mapdl.clear()
_ = mapdl.input(r"model1_input09.txt")
for mt in range(3):
all_mu = [0.15, 0.3, 1, 0]
mu_nxt = all_mu[mt+1]
print("Calc for mu: ", all_mu[mt])
Pres_list = []
list_elements_ids = []
mapdl.allsel()
mapdl.finish()
mapdl.slashsolu()
mapdl.outres('erase')
mapdl.outres('all', 'all')
for i in range(1,5):
mapdl.time(i)
mapdl.solve()
mapdl.finish()
mapdl.post1()
for i in range(0,5):
mapdl.set(i)
mapdl.esel('s','ename','',174)
mapdl.nsle()
list_elements_ids = mapdl.presol('nmisc',41).to_list()
mapdl.allsel()
for id in list_elements_ids:
pressure = mapdl.get_value('elem',id[0],'smisc',13)
Pres_list.append([i, int(id[0]), "{:.2e}".format(pressure)])
Pres_list = sorted(Pres_list, key=lambda x: x[1])
Coo_Elem = []
for id in list_elements_ids:
x = mapdl.get_value('elem',id[0],'CENT','X')
y = mapdl.get_value('elem',id[0],'CENT','Y')
z = mapdl.get_value('elem',id[0],'CENT','Z')
Coo_Elem.append([int(id[0]), x, y, z])
file_name = "Master_list_Steps_"+ str(all_mu[mt]) +".txt"
Master_list = []
for j in range(len(list_elements_ids)):
temp = []
temp.append(int(list_elements_ids[j][0]))
for i in range(len(Pres_list)):
if Pres_list[i][1] == int(list_elements_ids[j][0]):
temp.append(Pres_list[i][2])
temp.append(Coo_Elem[j][1])
temp.append(Coo_Elem[j][2])
temp.append(Coo_Elem[j][3])
Master_list.append(temp)
with open(file_name, "w") as file:
file.write("TS " + '\t' + '\t' + '\t' + '\t' + '\t' + '\t' + '\t' + "0.000000"+ '\t' + "1.000000"+ '\t' + "2.000000"+ '\t' + "3.000000"+ '\t' + "4.000000" + '\n')
file.write('\n' + "#Presure" + '\n')
for item in Master_list:
file.write("#" + str(item[0]) + '\t' + str(round(item[31], 2)) + '\t' + '\t' + str(round(item[32], 2))
+ '\t' + '\t' + str(round(item[33], 2)) + '\t' + '\t' + item[1]
+ '\t' + item[7] + '\t' + item[13] + '\t' + item[19] + '\t' + item[25] + '\n')
print(len(Master_list))
print("Done")
mapdl.finish()
mu_changer(list_elements_ids, mu_nxt) |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
Hi @ShaileshFle Can you please correct your posting by enclosing the PyMAPDL code in tick marks ( ```). These are tick marks on the same key as the tilde (~) and not single quotes. I don't think the spacing is correct in the listing, and spacing is very important! When writing the comment you can use: ```python And what do you mean that you are not getting an answer. You are not getting any answer i.e. the results don't change? Or something else? |
Beta Was this translation helpful? Give feedback.
-
Hi, I have attached the file. While creating the model I have already given it a mu = 0.15 and hence I am not changing its value in the first loop. So at the end of first loop the mu value is changed, and it is used for the second loop. So I think it should match |
Beta Was this translation helpful? Give feedback.
-
@ShaileshFle So a few observations. There is nothing in the model that would create contact pressure. The forced movement in in the +/- X direction whereas the pressure would be in the Z. And the two parts are just touching. Is there meant to be some other load that would cause (contact) pressure between the two parts? Generally this type of frictional contact model should be run with large deformations turned on. You may want to switch the target/contact side so that the contact side is always in contact. Mike |
Beta Was this translation helpful? Give feedback.
@ShaileshFle So a few observations. There is nothing in the model that would create contact pressure. The forced movement in in the +/- X direction whereas the pressure would be in the Z. And the two parts are just touching. Is there meant to be some other load that would cause (contact) pressure between the two parts?
Generally this type of frictional contact model should be run with large deformations turned on.
You may want to switch the target/contact side so that the contact side is always in contact.
Mike