简体   繁体   English

Abaqus Python:如何编辑或删除 odb 输出数据库中的数据

[英]Abaqus Python: How can I edit or remove data from an odb output database

So in the Abaqus Scripting Interface there is no direct way to delete data off an odb file or to duplicate an odb with some data removed from the database.因此,在 Abaqus 脚本界面中,没有直接的方法可以从 odb 文件中删除数据,也无法通过从数据库中删除一些数据来复制 odb。

So how can we edit the odb to remove unwanted output?那么我们如何编辑 odb 以删除不需要的输出呢?

One option to construct an edited odb is to use the "odbcombine" Abaqus plugin.构建编辑过的 odb 的一种选择是使用“odbcombine”Abaqus 插件。 I believe this plugin is an officially supported Abaqus product.我相信这个插件是官方支持的 Abaqus 产品。

The plugin can be imported from the abaqus_plugins folder by该插件可以从 abaqus_plugins 文件夹中导入

sys.path.insert('r'/abaqus_main/6.14-1/code/python2.7/lib/abaqus_plugins/odbCombine')
import odbCombineKernel
odbCombineKernel.combineOdbs(jobName='myjob',
                             configName='myconfig.xml', 
                             loadODB=1) 

For this command to work it requires an XML input file.要使此命令起作用,它需要一个 XML 输入文件。 The XML file must be configured with something like: XML 文件必须配置如下:

<?xml version="1.0" ?>
<OdbInput>
    <MasterOdb Name="oldjob.odb"/>
</OdbInput>

If you only specify a Master Odb, you don't need additional odb's to combine.如果您只指定一个主 Odb,则不需要额外的 odb 来组合。 Then the odbcombine tool works as an odb filter rather than a combiner.然后 odbcombine 工具用作 odb 过滤器而不是组合器。

Another way to create a more or less blank odb is to submit a new analysis to the Abaqus server using the "datacheck" option.创建或多或少空白 odb 的另一种方法是使用“数据检查”选项向 Abaqus 服务器提交新分析。 However this odb will still contain steps from the input file, but no frames.然而,这个 odb 仍将包含来自输​​入文件的步骤,但没有帧。

To get rid of the steps, you need to submit a modified input file without *step/*end step keywords.要摆脱这些步骤,您需要提交一个没有 *step/*end step 关键字的修改后的输入文件。 A simple function can do that, for example:一个简单的函数可以做到这一点,例如:

def _remove_inp_steps(path, newpath):
    """Remove steps from input file so that a blank odb can be generated

    Parameters
    ----------
    path : str
        Path of original input file 
    newpath : str
        Path of new input file to create with steps removed 
    """
    with open(path, 'r') as f:
        lines = f.readlines()

    key_start = '*step'
    key_end = '*end step'
    is_in_step = False

    # Go through file and remove all data contained within steps.
    line = '** DUMMY INPUT FILE USED TO CREATE A BLANK OUTPUT DATABASE FILE; RUN WITH DATACHECK\n'

    newlines = [line]

    for line in lines:
        line2 = line.lower()

        if line2.startswith(key_start):
            is_in_step = True
        elif line2.startswith(key_end):
            is_in_step = False
        else:
            if not is_in_step:
                newlines.append(line)

    with open(newpath, 'w') as f:
        f.writelines(newlines)
    return

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

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