在PyMAPDL中创建围绕另一个关键点的关键点。

huangapple go评论105阅读模式
英文:

Creation of keypoints in PyMAPDL around another keypoint

问题

我在 PyMAPDL 中尝试创建风力涡轮机模型,已经建立了塔和机舱,但在制作风力涡轮机叶片时遇到了困难。叶片数量为3,彼此间隔120度。长度单位为毫米,塔高为180米。

尝试的代码如下:

  1. blade_radius = 50000
  2. blade_count = 3
  3. blade_tips_keypoints = []
  4. blade_lines = []
  5. for i in range(blade_count):
  6. angle = i * 360 / blade_count
  7. mapdl.kwpave(p1=nacelle_keypoints[-1])
  8. mapdl.wprota(thzx=angle)
  9. blade_tips_keypoints.append(mapdl.k(0, 0, blade_radius))
  10. for i in range(blade_count):
  11. blade_lines.append(mapdl.l(p1=nacelle_keypoints[-1], p2=blade_tips_keypoints[i]))

这导致生成的关键点和线如下:

生成的关键点
生成的线

英文:

I am trying to create a wind turbine model in PyMAPDL. I got to a point where I have a tower and a nacelle. However, I got stuck making the blades of the wind turbine.

They should be 3 and separated 120 degrees between them. To give you some context, the length units are mm, the tower height is 180m.

The code that I tried was the following:

  1. blade_radius = 50000
  2. blade_count = 3
  3. blade_tips_keypoints = []
  4. blade_lines = []
  5. for i in range(blade_count):
  6. angle = i * 360 / blade_count
  7. mapdl.kwpave(p1 = nacelle_keypoints[-1])
  8. mapdl.wprota(thzx = angle)
  9. blade_tips_keypoints.append(mapdl.k(0, 0, blade_radius))
  10. for i in range(blade_count):
  11. blade_lines.append(mapdl.l(p1 = nacelle_keypoints[-1], p2 = blade_tips_keypoints[i]))

The result of this is the following:

These are the keypoints it generated
These are the lines it generated

答案1

得分: 1

  1. 有一些需要更新的事情。首先,工作平面的旋转是增量而不是总量。所以角度应该是:
  2. ```python
  3. angle = 360 / blade_count

此外,从关键点定义来看,我相当确定工作平面应该绕 Z 轴旋转:

  1. mapdl.wprota(thxy = angle)

最后,关键点是在当前坐标系统中定义的。您希望使用的是工作平面,而不是全局坐标系。因此,在创建关键点之前需要在坐标系之间进行切换:

  1. mapdl.csys(4)
  2. blade_tips_keypoints.append(mapdl.k(0, 0, blade_radius))
  3. mapdl.csys(0)

Mike

  1. <details>
  2. <summary>英文:</summary>
  3. There are a few things to be updated. The first is that the Working Plane rotation is incremental, not total. So the angle should be:
  4. ```python
  5. angle = 360 / blade_count

Also from the KeyPoint definition I'm pretty sure that the WP should be rotated about Z so:

  1. mapdl.wprota(thxy = angle)

Lastly the keypoints are defined in the current coordinate system. Which you want to be the Working Plane and not the Global CS. So bookend the keypoint creation with a change in coordinate systems:

  1. mapdl.csys(4)
  2. blade_tips_keypoints.append(mapdl.k(0, 0, blade_radius))
  3. mapdl.csys(0)

Mike

答案2

得分: 1

经过大量测试,错误出在关键点给定的坐标上。应该是y坐标而不是z坐标。以下是正确的代码。

  1. blade_radius = 10000
  2. blade_count = 3
  3. blade_tips_keypoints = []
  4. blade_lines = []
  5. for i in range(blade_count):
  6. angle = 360 / blade_count
  7. mapdl.kwpave(p1=nacelle_keypoints[-1])
  8. mapdl.wprota(thzx=angle)
  9. mapdl.csys(4)
  10. blade_tips_keypoints.append(mapdl.k(0, blade_radius, 0))
  11. mapdl.csys(0)
  12. print(f'关键点 {blade_tips_keypoints[i]}'.center(5, "#"))
  13. X = mapdl.get(entity='KP', entnum=blade_tips_keypoints[i], item1='LOC', it1num='X')
  14. Y = mapdl.get(entity='KP', entnum=blade_tips_keypoints[i], item1='LOC', it1num='Y')
  15. Z = mapdl.get(entity='KP', entnum=blade_tips_keypoints[i], item1='LOC', it1num='Z')
  16. print(f'x = {X}\ny = {Y}\nz = {Z}')
  17. for i in range(blade_count):
  18. blade_lines.append(mapdl.l(p1=nacelle_keypoints[-1], p2=blade_tips_keypoints[i]))
英文:

After much testing, the error was in the coordinate the keypoint was being given. Instead of the z coordinate, it should have been the y coordinate. The correct code is listed below.

  1. blade_radius = 10000
  2. blade_count = 3
  3. blade_tips_keypoints = []
  4. blade_lines = []
  5. for i in range(blade_count):
  6. angle = 360 / blade_count
  7. mapdl.kwpave(p1 = nacelle_keypoints[-1])
  8. mapdl.wprota(thzx = angle)
  9. mapdl.csys(4)
  10. blade_tips_keypoints.append(mapdl.k(0, blade_radius, 0))
  11. mapdl.csys(0)
  12. print(f&#39; Keypoint {blade_tips_keypoints[i]} &#39;.center(5, &quot;#&quot;))
  13. X = mapdl.get(entity = &#39;KP&#39;, entnum = blade_tips_keypoints[i], item1 = &#39;LOC&#39;, it1num = &#39;X&#39;)
  14. Y = mapdl.get(entity = &#39;KP&#39;, entnum = blade_tips_keypoints[i], item1 = &#39;LOC&#39;, it1num = &#39;Y&#39;)
  15. Z = mapdl.get(entity = &#39;KP&#39;, entnum = blade_tips_keypoints[i], item1 = &#39;LOC&#39;, it1num = &#39;Z&#39;)
  16. print(f&#39;x = {X}\ny = {Y}\nz = {Z}&#39;)
  17. for i in range(blade_count):
  18. blade_lines.append(mapdl.l(p1 = nacelle_keypoints[-1], p2 = blade_tips_keypoints[i]))

huangapple
  • 本文由 发表于 2023年4月14日 00:08:46
  • 转载请务必保留本文链接:https://go.coder-hub.com/76007589.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定