我使用Pyvista在笛卡尔坐标系中显示一个回转体结构(TPMS)。我现在尝试以柱坐标显示结构。Pyvista确实显示了一些圆柱形的东西,但单位单元格长度似乎不均匀(虽然没有理由更改此参数,但我的参数“a”保持稳定。这种更改似乎特别沿z方向出现,但我不明白为什么(见图)
谢谢你的帮助
import pyvista as pv
import numpy as np
from numpy import cos, sin, pi
from random import uniform
lattice_par = 1.0 # Unit cell length
a = (2*pi)/lattice_par
res = 200j
r, theta, z = np.mgrid[0:2:res, 0:2*pi:res, 0:4:res]
# consider using non-equidistant r for uniformity
def GyroidCyl(r, theta, z, b=0.8):
return (sin(a*(r*cos(theta) - 1))*cos(a*(r*sin(theta) - 1))
+ sin(a*(r*sin(theta) - 1))*cos(a*(z - 1))
+ sin(a*(z - 1))*cos(a*(r*cos(theta) - 1))
- b)
vol3 = GyroidCyl(r, theta, z)
# compute Cartesian coordinates for grid points
x = r * cos(theta)
y = r * sin(theta)
grid = pv.StructuredGrid(x, y, z)
grid["vol3"] = vol3.flatten()
contours3 = grid.contour([0]) # Isosurface = 0
pv.set_plot_theme('document')
p = pv.Plotter()
p.add_mesh(contours3, scalars=contours3.points[:, 2], show_scalar_bar=False, interpolate_before_map=True,
show_edges=False, smooth_shading=False, render=True)
p.show_axes_all()
p.add_floor()
p.show_grid()
p.add_title('Gyroid in cylindrical coordinates')
p.add_text('Volume Fraction Parameter = ' + str(b))
p.show(window_size=[2040, 1500])
因此,您在评论中注意到,您正在尝试复制this paper中解释的策略。他们所做的是取一个普通的回转体单元,然后把它转换成一个圆柱壳。如果igloos是圆柱形的,那么回转体单元就是一块雪砖。把它们放在一个挨着一个的地方,把它们堆成一列,你就得到了一个圆柱体
由于我不能使用报纸上的数字,我们必须自己重新制作一些。因此,必须从隐式函数定义的正则gyroid开始
(或其某些变体)。以下是单个单元的外观:
使用“单位细胞”一词意味着有一个潜在的无限晶格,它可以通过将这些(矩形)单位细胞整齐地堆叠在一起来构建。通过一些想象,我们可以说服自己这是真的。或者我们可以看看这个公式,注意到由于三角函数,函数在
x
、y
和z
中是周期的,周期为2*pi
。这也告诉我们,我们可以通过引入晶格参数a
、b
和c
,将单位单元转换为具有任意矩形尺寸:(这些
kx
、ky
和kz
量在固体物理学中称为波矢量。)相应的更改仅影响标题:
这就是我们的出发点。我们要做的是拿这个单元,弯曲它,使它对应于圆柱体上的30度圆弧,然后用这个单元堆叠圆柱体。根据这篇论文,他们用12个单位细胞在一个平面上创建了一个圆(因此产生了30度的幻数),并将三个这样的圆带相互叠放在一起以构建圆柱体
文中还相当清楚地解释了实际映射。而函数的原始{}、{}和{}参数基本上分别在{}、{}和{}之间插值,在新设置中{}在半径范围{}内插值,{}在角度范围{}内插值,{}只是{}。(在
x
和y
这两篇文章中,关于这个约定似乎是相反的,但这并不重要。如果它重要,那就留给读者作为练习。)所以我们需要做的是或多或少地保留当前的网格点,但是转换相应的
x
、y
和z
网格点,使它们位于圆柱体上。这里有一个例子:如果要查看圆柱形设置中的单个转换单位单元,请为函数使用
phi
和z
的单个域,并仅将网格点转换为1/12的整圆:但在(不再是一个)单元中不容易看到曲率:
相关问题 更多 >
编程相关推荐