我尽量说清楚。问题是:
我有两个数组,ELEM和LAMI。你知道吗
ELEM数组包含有限元模型的信息,其类型为:
ndtype= [('conn','i4',3),('sets','a12',2)]
所以ELEM的典型数据是:
array([ ([47, 49, 36], ['web', 'gelcoat']),
([48, 30, 43], ['surf', 'balsa']),...])
现在,LAMI包含了层压序列的数据,可以用于ELEM的元素。拉米属于:
ndtype = [('name', 'a12', 1), ('type', 'a12', 1), ('cons', 'float64', 6)]
比如说
In[1]:LAMI
Out[1]:array([ ('udfrp', 'TRISOTROPIC', [37.0, 90.0, 4.0, 4.0, 0.28, 1860.0]),
('dbfrp', 'TRISOTROPIC', [10.0, 10.0, 8.0, 8.0, 0.3, 1830.0]),
('gelcoat', 'ISOTROPIC', [10.0, 0.3, 1830.0, 0.0, 0.0, 0.0]),
('nexus', 'ISOTROPIC', [1.0, 0.3, 1664.0, 0.0, 0.0, 0.0]),
('balsa', 'TRISOTROPIC', [10.0, 10.0, 2.0, 2.0, 0.3, 128.0])],
dtype=[('name', 'S12'), ('type', 'S12'), ('cons', '<f8', (6,))])
可以看出,ELEM['sets'][1]是元素的材质名称,元素的材质属性存储在LAMI['cons']中。你知道吗
问题是:哪种方法是找到元素的材料属性数组的最佳方法?我试过以下方法:
index = np.where(LAMI['name'][0] == ELEM['sets'][element,1])]
prop_array = LAMI['cons'][index]
但我肯定有更好的办法。谢谢!你知道吗
在这种情况下,可能首选dictionary:
将数组转换为字典将稍微简化访问
另一种方法是定义一个
Material
类,因此每个material
都是一个对象。ELEM
数组可以有一个带有这些指针的object
字段。你知道吗你曾经把
LAMI['cons']
作为一个完整的数组使用过吗?如果不是的话,结构化数组格式可能就没那么有用了。你知道吗使用材质对象的版本:
生产:
但要得到所有元素的
cons
列表,我必须使用理解:相关问题 更多 >
编程相关推荐