Jelajahi Sumber

changed ansys-server

Willi Zschiebsch 4 tahun lalu
induk
melakukan
4ec118675e
1 mengubah file dengan 92 tambahan dan 52 penghapusan
  1. 92 52
      lib/test/server/gfk_plate.py

+ 92 - 52
lib/test/server/gfk_plate.py

@@ -12,13 +12,13 @@ def sim_rotor(materials, angles, outer_diameter=0.250, inner_diameter=0.050, thi
 
     path = os.getcwd() + "\\ws"
     mapdl = pyansys.launch_mapdl(run_location=path, interactive_plotting=True, loglevel='ERROR', override=True)
-
+    # """
     # clear existing geometry
     mapdl.finish()
     mapdl.clear()
 
-    th = 50  # [°C]        Herstellungstemperatur
-    tn = 50  # [°C]        Nutzungstemperatur
+    th = 50  # [°C]
+    tn = 50  # [°C]
 
     mapdl.prep7()
     # define Material
@@ -59,77 +59,102 @@ def sim_rotor(materials, angles, outer_diameter=0.250, inner_diameter=0.050, thi
         mapdl.mpdata("DYY", i + 1, "", materials[i]["d22"])
         mapdl.mpdata("DZZ", i + 1, "", materials[i]["d33"])
 
-    # define Element
-    mapdl.et(1, "SHELL181")
-    # enable Laminate
-    mapdl.run("KEYOPT,1,8,1")
-
-    # define Laminate
-    mapdl.run("SECT, 1, SHELL")
-
-    # secdata, Thickness ,MatId,theta,Number of integration points in layer
-    if len(angles) != len(materials):
-        for i in range(0, len(angles)):
-            mapdl.secdata(layer_thickness, 1, angles[i], 3)
-            print(str(angles[i]))
-    else:
-        for i in range(0, len(angles)):
-            mapdl.secdata(layer_thickness, i + 1, angles[i], 3)
-
-    # Shell node will be offset to midplane of the section
-    mapdl.secoffset("MID")
-    mapdl.run("seccontrol,,,,,,,")
-
-    mapdl.run("/ESHAPE,1.0")
-    # define Geometry
-    # change global coordinate system to cylindric system
+    mapdl.et(1, "SOLID186")
+
     mapdl.csys(1)
-    mapdl.cyl4(0, 0, inner_diameter / 2, 0, outer_diameter / 2, 180)
-    mapdl.cyl4(0, 0, inner_diameter / 2, 180, outer_diameter / 2, 360)
-    # mapdl.aplot()
-    mapdl.nsel("S", "LOC", "Y", 0)
-    mapdl.nummrg("ALL")
-    mapdl.nsel("S", "LOC", "Y", 180)
-    mapdl.nummrg("ALL")
-    mapdl.lsel("S", "", "", 1, 7, 2)
-    mapdl.lesize("ALL", "", "", 20)
-    mapdl.lsel("S", "", "", 2, 4, 2)
-    mapdl.lesize("ALL", "", "", 20)
+    mapdl.k(1, str(inner_diameter/2), 0, str(-thickness/2))
+    mapdl.k(2, str(inner_diameter/2), 0, str(thickness/2))
+    mapdl.k(3, str(outer_diameter/2), 0, str(thickness/2))
+    mapdl.k(4, str(outer_diameter/2), 0, str(-thickness/2))
+    mapdl.l(1, 2)
+    mapdl.l(2, 3)
+    mapdl.l(3, 4)
+    mapdl.l(4, 1)
+    mapdl.al(1, 2, 3, 4)
+    mapdl.k(5, 0, 0, str(thickness/2))
+    mapdl.k(6, 0, 0, str(-thickness/2))
+    mapdl.run("VROT,1,,,,,,5,6")
+
+    arcdiv = 20*4
+    darc = 360/arcdiv
+
+    mapdl.lsel("S", "LOC", "X", str(inner_diameter/2))
+    mapdl.lsel("R", "LOC", "Z", str(-thickness/2))
+    mapdl.lesize("ALL", "", "", str(arcdiv/4))
+    mapdl.lsel("S", "LOC", "X", str(inner_diameter/2))
+    mapdl.lsel("R", "LOC", "Z", str(thickness/2))
+    mapdl.lesize("ALL", "", "", str(arcdiv/4))
+    mapdl.lsel("S", "LOC", "X", str(outer_diameter/2))
+    mapdl.lsel("R", "LOC", "Z", str(-thickness/2))
+    mapdl.lesize("ALL", "", "", str(arcdiv/4))
+    mapdl.lsel("S", "LOC", "X", str(outer_diameter/2))
+    mapdl.lsel("R", "LOC", "Z", str(thickness/2))
+    mapdl.lesize("ALL", "", "", str(arcdiv/4))
+    for i in range(0, 4):
+        mapdl.lsel("S", "LOC", "Y", str(90*i))
+        mapdl.lsel("R", "LOC", "Z", str(-thickness/2))
+        mapdl.lesize("ALL", "", "", str(arcdiv/4))
+        mapdl.lsel("S", "LOC", "Y", str(90*i))
+        mapdl.lsel("R", "LOC", "Z", str(thickness/2))
+        mapdl.lesize("ALL", "", "", str(arcdiv/4))
+        mapdl.lsel("S", "LOC", "Y", str(90*i))
+        mapdl.lesize("ALL", "", "", str(len(angles)))
+
     mapdl.lsel("ALL")
-    mapdl.mshape(0, "2D")  # quadratic 2D Shapes
-    mapdl.mshkey(1)  # 0-free meshing
-    mapdl.amesh("ALL")
+    mapdl.mshape(0, "3D")
+    mapdl.mshkey(1)
+    mapdl.vmesh("ALL")
+    # mapdl.eplot("ALL")
+
+    for j in range(1, len(angles)+1):
+        for i in range(0, 20*4):
+            mapdl.csys(1)
+            mapdl.esel("S", "CENT", "Y", str(darc*(i + 0.5)))
+            mapdl.esel("R", "CENT", "Z", str(thickness*(-1/2+1/len(angles)*(j-1))), str(thickness*(-1/2+1/len(angles)*j)), str(thickness/len(angles)/2))
+            mapdl.local(str(j*100+i), 0, 0, 0, 0, str(angles[j-1]+darc*(i + 0.5)))
+            mapdl.emodif("all", "ESYS", str(j*100+i))
+            if len(angles) == len(materials):
+                mapdl.emodif("all", "MAT", str(j))
+
+    mapdl.esel("ALL")
 
     mapdl.run("/SOLU")
-    mapdl.omega("", "", omega)  # [rad/s]	Winkelgeschwindigkeit(+: gegen Uhrzeigersinn))
+    mapdl.csys(1)
+    mapdl.omega("", "", omega)
     mapdl.nsel("S", "LOC", "X", inner_diameter / 2)
     mapdl.d("ALL", "UX", 0)
     mapdl.d("ALL", "UY", 0)
+    # D,ALL,ROTX,0
+    # D,ALL,ROTY,0
+    # D,ALL,ROTZ,0
+    mapdl.nsel("R", "LOC", "Z", 0)
     mapdl.d("ALL", "UZ", 0)
-    mapdl.d("ALL", "ROTX", 0)
-    mapdl.d("ALL", "ROTY", 0)
-    mapdl.d("ALL", "ROTZ", 0)
     mapdl.run("ALLS")
-
     mapdl.outres("ALL", "ALL")
-    # mapdl.open_gui()
     mapdl.solve()
     mapdl.finish()
 
+    # """
+    # mapdl.run("/INPUT, C:/Users/Willi/Documents/projects/gfk-plate/script/01_Modell.inp")
+
+    # mapdl.solve()
+    # mapdl.finish()
+
     mapdl.run("/Post1")
 
     result = mapdl.result
-    mapdl.aplot()
+    # mapdl.aplot()
     # result.plot_principal_nodal_stress(0, '1', show_edges=True, show_axes=True)
-    result.plot_nodal_solution(0, 'x')
-    result.plot_principal_nodal_stress(0, '1', show_edges=True, show_axes=True)
+    result.plot_nodal_solution(0, 'z', show_displacement=True)
+    result.plot_principal_nodal_stress(0, 'S1', show_edges=True, show_axes=True)
+
     # """
     nodenump, stress = result.principal_nodal_stress(0)
 
     # von first principle stress is the first column
     # must be nanmax as the shell element stress is not recorded
 
-
+    """
     mapdl.run('*GET, NODE_COUNT, NODE, ,COUNT')
     mapdl.run('*GET, ELEM_COUNT, ELEM, ,COUNT')
     mapdl.load_parameters()
@@ -163,12 +188,27 @@ def sim_rotor(materials, angles, outer_diameter=0.250, inner_diameter=0.050, thi
         # s1max = np.nanmax(stresses)
         # nodenump, stress = result.principal_nodal_stress(0)
         # s1max[i] = np.nanmax(element_stress[:, -5])
-
+    
     s1max = np.nanmax(s1max)
     s2max = np.nanmax(s2max)
     srmax = np.nanmax(srmax)
     stmax = np.nanmax(stmax)
+    # """
+    nodenump, stress = result.principal_nodal_stress(0)
+
+    # von first principle stress is the first column
+    # must be nanmax as the shell element stress is not recorded
+    s1max = np.nanmax(stress[:, -5])
 
+    # von second principle stress is the first column
+    # must be nanmax as the shell element stress is not recorded
+    s2max = np.nanmax(stress[:, -4])
+
+    nodenum, stress = result.nodal_stress(0)
+    # von Mises stress is the last column
+    # must be nanmax as the shell element stress is not recorded
+    srmax = np.nanmax(stress[:, -6])
+    stmax = np.nanmax(stress[:, -5])
     # von second principle stress is the first column
     # must be nanmax as the shell element stress is not recorded
     #s2max = np.nanmax(stress[:, -4])