用户定义的 ACT 扩展的绘图结果

发布于 01-20 03:25 字数 1308 浏览 2 评论 0原文

由于我的模拟,我想要表面体的体积(使用凸壳算法计算)。该计算是在几秒钟内完成的,但是结果的绘制需要很长时间,这成为实验未来设计的问题。我认为主要问题是矩阵(尺寸=节点=超过33 000个节点)填充了相同的音量值以绘制相同的音量值。在不创建此矩阵的情况下,还有其他方法可以获得该值吗? (之后必须选择检索的值作为输出参数) 必须注意的是,音量值是在python中以中间脚本计算的,然后保存在输出文件中,后来由Ironpython在ANSYS ACT中的主脚本中读取。

谢谢!

中间脚本中的矩阵创建(MyICV是计算的卷):

  import numpy as np
  NodeNo=np.array(Col_1)
  ICV=np.full_like(NodeNo,myICV)
  np.savetxt(outputfile,(NodeNo,ICV),delimiter=',',fmt='%f')  

主脚本中结果的绘图:

import csv #after the Cpython function 
resfile=opfile
reader=csv.reader(open(resfile,'rb'),quoting=csv.QUOTE_NONNUMERIC) #read the node number and the scaled displ 

NodeNos=next(reader)
ICVs=next(reader)
#ScaledUxs=next(reader)
a=int(NodeNos[1])
b=ICVs[1]
ExtAPI.Log.WriteMessage(a.GetType().ToString())
ExtAPI.Log.WriteMessage(b.GetType().ToString())
userUnit=ExtAPI.DataModel.CurrentUnitFromQuantityName("Length")
DispFactor=units.ConvertUnit(1,userUnit,"mm")

for id in collector.Ids:
    collector.SetValues(int(NodeNos[NodeNos.index(id)]), {ICVs[NodeNos.index(id)]*DispFactor}) #plot results
  
ExtAPI.Log.WriteMessage("ICV read")

到目前为止,结果看起来如此

As a result of my simulation, I want the volume of a surface body (computed using a convex hull algorithm). This calculation is done in seconds but the plotting of the results takes a long time, which becomes a problem for the future design of experiment. I think the main problem is that a matrix (size = number of nodes =over 33 000 nodes) is filled with the same volume value in order to be plotted. Is there any other way to obtain that value without creating this matrix? (the value retrieved must be selected as an output parameter afterwards)
It must be noted that the volume value is computed in python in an intermediate script then saved in an output file that is later read by Ironpython in the main script in Ansys ACT.

Thanks!

The matrix creation in the intermediate script (myICV is the volume computed) :

  import numpy as np
  NodeNo=np.array(Col_1)
  ICV=np.full_like(NodeNo,myICV)
  np.savetxt(outputfile,(NodeNo,ICV),delimiter=',',fmt='%f')  

Plot of the results in main script :

import csv #after the Cpython function 
resfile=opfile
reader=csv.reader(open(resfile,'rb'),quoting=csv.QUOTE_NONNUMERIC) #read the node number and the scaled displ 

NodeNos=next(reader)
ICVs=next(reader)
#ScaledUxs=next(reader)
a=int(NodeNos[1])
b=ICVs[1]
ExtAPI.Log.WriteMessage(a.GetType().ToString())
ExtAPI.Log.WriteMessage(b.GetType().ToString())
userUnit=ExtAPI.DataModel.CurrentUnitFromQuantityName("Length")
DispFactor=units.ConvertUnit(1,userUnit,"mm")

for id in collector.Ids:
    collector.SetValues(int(NodeNos[NodeNos.index(id)]), {ICVs[NodeNos.index(id)]*DispFactor}) #plot results
  
ExtAPI.Log.WriteMessage("ICV read")

So far the result looks like this
So far the result looks like this

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

非要怀念2025-01-27 03:25:56

考虑到您的“CustomPost”对象与可视化无关,而只是将体积计算作为参数传递,而不对工作流程进行太多更改,我建议您将“范围方法”更改为“几何”,然后选择单个节点(如果扩展结果类型为“Node”;您可以检查 xml 文件上的数据),而不是“All Bodies”。

如果您的代码由于绘图而运行缓慢,这应该可以修复它,因为您将只请求一个节点。

正如您所指的 DoE,我了解您希望迭代运行该模型并读取参数结果。例如,一个简单的技巧可能是通过“Worksheet”生成“NamedSelection”,并选择“Mesh Node”(实体类型),其中“NodeID”为标准且等于“1”。因此,即使通过迭代更改了网格,我们也期望节点 ID 始终为 1,因此保证在每次迭代中成功生成您的 NamedSelection。

然后,您可以将“CustomPost”的范围限定为“NamedSelection”,然后再限定为您创建的范围。这应该有效。

如果您的扩展不接受“NamedSelection”作为“范围方法”,并且您在每次迭代中更改网格(如果不是,您可以直接确定节点范围),我认为是时候手动将参数写入“ “参数集中”中的“输入参数”。但这样您就必须从 Workbench 平台控制模型的执行。

我很好奇事情进展如何。

Considering that your 'CustomPost' object is not relevant in terms of visualization but just to pass the volume calculation as a parameter, without adding many changes to the workflow, I suggest you to change the 'Scoping Method' to 'Geometry' and then selecting a single node (if the extension result type is 'Node'; you can check data on the xml file), instead of 'All Bodies'.

If you code runs slow due to the plotting this should fix it, cause you will be requesting just one node.

As you are referring to DoE, I understand you are expecting to run this model iteratively and read the parameter result. An easy trick might be to generate a 'NamedSelection' by 'Worksheet' and select 'Mesh Node' (Entity Type) with 'NodeID' as Criterion and equal to '1', for example. So even if through your iterations you change the mesh, we expect to have always node ID 1, so your NamedSelection is guaranteed to be generated successfully in each iteration.

Then you can scope you 'CustomPost' to 'NamedSelection' and then to the one you created. This should work.

If your extension does not accept 'NamedSelection' as 'Scoping Method' and you are changing the mesh in each iteration (if you are not, you can directly scope a node), I think it is time to manually write the parameter as an 'Input Parameter', in the 'Parameter Set'. But in this way you will have to control the execution of the model from Workbench platform.

I am curious to see how it goes.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文