简体   繁体   English

如何减少程序在 Abaqus python 中的运行时间?

[英]How can i reduce the running time of the program in Abaqus python?

It is taking more time, when i have more elements.当我有更多元素时,它会花费更多时间。 Any suggestions?有什么建议么? Thanks in advance!提前致谢!
elements = odb.rootAssembly.instances[instanceName].elements元素 = odb.rootAssembly.instances[instanceName].elements

   en=[]
   nn=[]
   for elem in elements:
       e=elem.label
       n = elem.connectivity
       en.append(e)
       nn.append(n)
   eLn = numpy.array(en)
   nLn = numpy.array(nn)

I'd use list comprehensions, but even so your runtime is still going to be proportional to the length of the list.我会使用列表理解,但即便如此,您的运行时间仍将与列表的长度成正比。

en = [e.label for e in elements]
nn = [n.connectivity for n in elements]

is likely worse, because you're iterating over elements twice.可能更糟,因为您要对elements进行两次迭代。

Perhaps if you explain what you're trying to achieve with this minimal snippet we could help you more.或许,如果您解释了您试图用这个最小片段实现的目标,我们可以为您提供更多帮助。

I'm uncertain what value the calls to numpy.array() give you.我不确定调用numpy.array()会给你带来什么价值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM