繁体   English   中英

Abaqus Python命令将关键字插入.inp文件

[英]Abaqus Python Command to insert keyword to the .inp file

提出此问题的整个目的源于尝试对线性约束方程式的创建进行多过程处理( http://abaqus.software.polimi.it/v6.14/books/usb/default.htm?startat=pt08ch35s02aus129.html Abaqus / CAE中的#usb-cni-pequation ),用于将周期性边界条件应用于网格模型。 由于我的模型有超过一百万个元素,并且我需要对1000个此类模型进行蒙特卡洛模拟,因此我想对由于Abaqus的许可和多线程限制而找不到解决方案的过程进行并行处理/ CAE。 在此进行一些讨论: Abaqus / CAE中的Python多处理

我目前正在尝试使用创建的节点集在Abaqus外部执行方程式定义,因为我知道输入文件的方程式语法。

** Constraint: <name>
*Equation
<dof>
<set1>, <dof>, <coefficient1>.
<set2>, <dof>, <coefficient2>.
<set3>, <dof>, <coefficient3>.

e.g.
** Constraint: Corner_c1_Constraint-1-pair1
*Equation
3
All-1.c1_Node-1, 1, 1.
All-1.c5_Node-1, 1, -1.
RefPoint-3.SetRefPoint3, 1, -1.

除了直接将这些行写入.inp文件之外,我还可以将这些命令作为一个单独的文件编写,并使用以下命令将其链接到模型的.inp文件:

*EQUATION, INPUT=file_name

我正在寻找Abaqus Python命令来将诸如上述的关键字写入.inp文件,而不是自己指定Equation约束。 上面链接的《用户指南》指示通过GUI进行指定,但是在我的Abaqus CAE 2018版本中我无法做到这一点。

Abaqus / CAE用法:
交互模块:创建约束:公式:将鼠标悬停在数据表上的同时单击鼠标按钮3,然后选择“从文件读取”。

因此,我正在寻找脚本参考手册中的命令来代替它。 有一些命令可以解析输入文件( http://abaqus.software.polimi.it/v6.14/books/ker/pt01ch24.html ),但是没有什么可以直接写入输入文件而不是通过脚本执行的命令。 我知道我可以将其硬编码到输入文件中,但是我想通过大量的模拟来实现尽可能多的自动化调用。 我已经尝试使用适当的算法和numpy数组优化代码,但是对于一个模型,预处理本身要花费数小时。

ps这是我关于SO的第一篇文章-所以我不确定这个问题的措词是否合适。 希望对实际问题的任何答案或对使Abaqus / CAE中的预处理步骤并行化的预期结果的任何其他解决方案。

您正在寻找KeywordBlock对象。 这使您可以将任何内容作为格式字符串写入输入文件(关键字,注释等)。 我认为,这种方法比要求您自己以编程方式编写输入文件(或更新现有文件)的替代方法更不会出错。

在装配级别创建零件实例时,将创建KeywordBlock对象。 它将您在CAE中执行的所有操作与相应的关键字一起存储。

请注意,您对KeywordBlock对象所做的任何更改在写入时都会同步到Job输入文件,但不会更新CAE Model数据库。 因此,例如,如果您使用KeywordBlock存储约束方程式的关键字,则约束定义将不会显示在CAE模型树中。 Mdb的其余部分不知道它们存在。

如您所知,关键字必须写入输入文件的适当部分。 例如, *equation关键字可以在零件,零件实例或装配级别定义(请参见“关键字参考手册”)。 将关键字存储在KeywordBlock对象中时,也必须考虑到这一点(不幸的是,它不会自动将关键字正确地放置在正确的位置!)。 副作用是,写入KeywordBlock并不总是安全的-也就是说,只要它可能与通过CAE GUI进行的后续更改相冲突。 我相信Abaqus文档建议您最后添加关键字。

因此,基本上,请阅读KeywordBlock对象,找到合适的位置,然后insert新的关键字。 这是一个示例片段,可以帮助您入门:

partname = "Part-1"
model = mdb.models["Model-1"]
modelkwb = model.keywordBlock
assembly = model.rootAssembly

if assembly.isOutOfDate:
    assembly.regenerate()

# Synch edits to modelkwb with those made in the model. We don't need
# access to *nodes and *elements as they would appear in the inp file,
# so set the storeNodesAndElements arg to False.
modelkwb.synchVersions(storeNodesAndElements=False)

# Search the modelkwb for the desired insertion point. In this example, 
# we are looking for a line that indicates we are beginning the Part-Level 
# block for the specific Part we are interested in. If it is found, we 
# break the loop, storing the line number, and then write our keywords
# using the insert method (which actually inserts just below the specified
# line number, fyi). 
line_num = 0
for n, line in enumerate(modelkwb.sieBlocks):
    if line.replace(" ","").lower() == "*part,name={0}".format(partname.lower()):
        line_num = n
        break
if line_num:
    kwds = "your keyword as a string here (may be multiple lines)..."
    modelkwb.insert(position=line_num, text=kwds)
else:
    e = ("Error: Part '{}' was not found".format(partname),
         "in the Model KeywordBlock.")
    raise Exception(" ".join(e))

暂无
暂无

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

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