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

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

Creation of keypoints in PyMAPDL around another keypoint

问题

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

尝试的代码如下:

blade_radius = 50000
blade_count = 3

blade_tips_keypoints = []
blade_lines = []

for i in range(blade_count):
    angle = i * 360 / blade_count
    
    mapdl.kwpave(p1=nacelle_keypoints[-1])
    mapdl.wprota(thzx=angle)

    blade_tips_keypoints.append(mapdl.k(0, 0, blade_radius))

for i in range(blade_count):
    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:

blade_radius = 50000
blade_count = 3

blade_tips_keypoints = []
blade_lines = []

for i in range(blade_count):
    angle = i * 360 / blade_count
    
    mapdl.kwpave(p1 = nacelle_keypoints[-1])
    mapdl.wprota(thzx = angle)

    blade_tips_keypoints.append(mapdl.k(0, 0, blade_radius))

for i in range(blade_count):
    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

有一些需要更新的事情。首先,工作平面的旋转是增量而不是总量。所以角度应该是:

```python
angle = 360 / blade_count

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

mapdl.wprota(thxy = angle)

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

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

Mike


<details>
<summary>英文:</summary>

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:

```python
angle = 360 / blade_count

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

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:

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

Mike

答案2

得分: 1

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

blade_radius = 10000
blade_count = 3

blade_tips_keypoints = []
blade_lines = []

for i in range(blade_count):
    angle = 360 / blade_count
    
    mapdl.kwpave(p1=nacelle_keypoints[-1])
    mapdl.wprota(thzx=angle)

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

    print(f'关键点 {blade_tips_keypoints[i]}'.center(5, "#"))
    X = mapdl.get(entity='KP', entnum=blade_tips_keypoints[i], item1='LOC', it1num='X')
    Y = mapdl.get(entity='KP', entnum=blade_tips_keypoints[i], item1='LOC', it1num='Y')
    Z = mapdl.get(entity='KP', entnum=blade_tips_keypoints[i], item1='LOC', it1num='Z')
    print(f'x = {X}\ny = {Y}\nz = {Z}')

for i in range(blade_count):
    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.


blade_radius = 10000
blade_count = 3

blade_tips_keypoints = []
blade_lines = []

for i in range(blade_count):
    angle = 360 / blade_count
    
    mapdl.kwpave(p1 = nacelle_keypoints[-1])
    mapdl.wprota(thzx = angle)

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

    print(f&#39; Keypoint {blade_tips_keypoints[i]} &#39;.center(5, &quot;#&quot;))
    X = mapdl.get(entity = &#39;KP&#39;, entnum = blade_tips_keypoints[i], item1 = &#39;LOC&#39;, it1num = &#39;X&#39;)
    Y = mapdl.get(entity = &#39;KP&#39;, entnum = blade_tips_keypoints[i], item1 = &#39;LOC&#39;, it1num = &#39;Y&#39;)
    Z = mapdl.get(entity = &#39;KP&#39;, entnum = blade_tips_keypoints[i], item1 = &#39;LOC&#39;, it1num = &#39;Z&#39;)
    print(f&#39;x = {X}\ny = {Y}\nz = {Z}&#39;)

for i in range(blade_count):
    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-2.html
匿名

发表评论

匿名网友

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

确定