引言

电子连接器是借助于电信号和机械力的作用是电路导通或换接的重要组件,主要用于传输电信号或电磁能量。一般而言,一台电子设备中使用连接器多达数十件,连接着几十个电子系统,其质量好坏是产品好坏的一个重要环节。目前的电子连接器设计和其他的工业产品设计一样,在最终定型之前都有若干个可行方案需要去选择。可能这些方案只有个别的参数(材料,厚度等)不一致,这时我们用Abaqus一个一个的去建模仿真搜集结果就显得有些麻烦。

Python是一种面向对象、直译式的电脑程序语言。它包含了一组功能完备的标准库,能够轻松完成很多常见的任务。并且Python和Abaqus可以无缝对接进行各种分析参数的设定,结果的提取。这种情况下我们利用Python和Abaqus联合来进行连接器参数化分析,就会事半功倍。

参数化分析实例

模型介绍


本文模型选取为一个简单的连接器悬臂端子,目标是去评估它的结构刚度(K值)以及塑性变形状况。 考虑的参数变量有3组,分别为:(材料磷青铜(C5191R-H),板材厚度0.30mm),(材料镍铜(C7025-TM02),板材厚度0.25mm),(材料不锈钢(SUS301-1/2H),板材厚度0.20mm)。 端子几何模型如图1所示,装配模型如图2所示。端子的网格划分为S4R单元,将Set-Fix这个集固定。端子上方的刚性板会下压和端子产生接触。接触属性设置为法向硬接触,切向无摩擦力。端子的厚度属性和材料属性暂时先随便填一个。 分析步共计2个Step,step-1是刚性板下压0.5mm,step-2是刚性板上抬0.5mm回到初始位置。之后是生成这个案例的inp文件。

abaqus导出python脚本 abaqus怎么导出odb_abaqus导出python脚本

   

 图1. 端子几何模型   

 


abaqus导出python脚本 abaqus怎么导出odb_Python_02

     图2. 端子的装配模型

用参数来替代inp文件

在上一步生成的inp文件的Section部分,需要将*shell section此行的material=改成material=,之后一行改成,9。

** Section: Section-1*Shell Section, elset=_PickedSet12, material=, offset=SPOS, 9

创建参数化的python脚本并运行

将下面Python文件保存为cons.psf文件

# create the studypars = ('thick1','mat')           cons=ParStudy(par=pars,directory=OFF,verbose=ON)           # define the parameters                       cons.define(CONTINUOUS, par='thick1')cons.define(DISCRETE, par='mat')# sample the parameters                       cons.sample(INTERVAL, par='thick1', interval=0.05, domain=(0.20,0.30))cons.sample(VALUES,par='mat',values=('SUS301-3/4H-N1','C7025-TM02-N1','C5191R-H'))# combine the samples to give the designscons.combine(TUPLE,name='Con')# generate analysis datacons.generate(template='Contact_Study')# execute all analysis jobs sequentiallycons.execute(INTERACTIVE)# PARAMETRIC STUDY OUTPUTcons.output(file=ODB)# GATHER RESULTS FOR HISTORY OUTPUT AND WRITE XYPLOTcons.gather(results='u2',step=1,request=HISTORY,variable='U2',node=1,instance='Rigid-1')cons.gather(results='RF2',step=1,request=HISTORY,variable='RF2',node=1,instance='Rigid-1')cons.report(FILE, file='U_RF.psr', results=('u2','RF2')

----------------------------------------

在Abaqus command中执行命令:Abaqus script=cons.psf

Python编译执行结果如下: 

***COMMENT: Parameter study created with 2 parameter(s) ***COMMENT: Executing the define command ***COMMENT: Current definition for parameter 'thick1':   type      = 'CONTINUOUS'   domain    = None   reference = None   sample    = None ***COMMENT: Executing the define command ***COMMENT: Current definition for parameter 'mat':   type      = 'DISCRETE'   domain    = None   reference = None   sample    = None ***COMMENT: Executing the sample command ***COMMENT: Current sample for parameter 'thick1':   Sample = [0.20000000000000001, 0.25, 0.29999999999999999] ***COMMENT: Executing the sample command ***COMMENT: Current sample for parameter 'mat':   Sample = ['SUS301-3/4H-N1', 'C7025-TM02-N1', 'C5191R-H'] ***COMMENT: Executing the combine command ***COMMENT: Current design(s) in design set 'Con':   c1 = [0.20000000000000001, 'SUS301-3/4H-N1']   c2 = [0.25, 'C7025-TM02-N1']   c3 = [0.29999999999999999, 'C5191R-H'] ***COMMENT: Executing the generate command ***COMMENT: The current generated variation file is 'cons.var' ***COMMENT: The jobs created by the parameter study are:   Contact_Study_cons_Con_c1   Contact_Study_cons_Con_c2Contact_Study_cons_Con_c3 ***COMMENT: Executing the execute command ***COMMENT: Starting execution of the parameter study in INTERACTIVE mode

共3个样本组合,以交互方式执行工作,提示如下:

_________________________________________

  Options:

  (1) Execute the next design of this study

  (2) Execute the next `n` designs of this study

  (3) Skip over the next `n` designs of this study

  (4) Execute the remaining designs of this study

  (5) Skip over the remaining designs of this study

________________________

option = 4Contact_Study_cons_Con_c1 completedContact_Study_cons_Con_c2 completedContact_Study_cons_Con_c3 completed*COMMENT: No more designs remain to be executed*COMMENT: Executing the output command*COMMENT: Executing the gather command*COMMENT: A gather with the following settingresult = 'u2'file = 'ODB'step = 1instance = 'Rigid-1'frameValue = 'LAST' or mode = 1variable = 'U2'node = 1request = 'HISTORY'*COMMENT: Getting the result for design set Con*COMMENT: The gather for 'u2' was successful*COMMENT: Executing the gather command*COMMENT: A gather with the following setting is reresult = 'RF2'file = 'ODB'step = 1instance = 'Rigid-1'frameValue = 'LAST' or mode = 1variable = 'RF2'node = 1request = 'HISTORY'*COMMENT: Getting the result for design set Con*COMMENT: The gather for 'RF2' was successful*COMMENT: Executing the report command*COMMENT: Results written to the file 'U_RF.psr'

查看结果

在Abaqus工作目录下可找到定义的结果文件U_RF.psr查看收集的最大力量的结果:

abaqus导出python脚本 abaqus怎么导出odb_abaqus导出python脚本_03

图3. Psr文件收集到的结果

运行如下脚本viewer_parametric.py,从odb中收集力量和位移数据,合并成RF_U曲线,可更直观的了解设计性能。

for i in range(1,3):    odbName = 'Contact_Study_cons_Con_c' + str(i) + '.odb'    odb = session.openOdb(name=odbName)    session.XYDataFromHistory(name='RF2', odb=odb, outputVariableName='Reaction force: RF2 PI: RIGID-1 Node 1 in NSET SET-1', steps=('Step-1', 'Step-2', ), skipFrequency=1)    session.XYDataFromHistory(name='U2', odb=odb, outputVariableName='Spatial displacement: U2 PI: RIGID-1 Node 1 in NSET SET-1', steps=('Step-1', 'Step-2', ), skipFrequency=1)    xy1 = session.xyDataObjects['U2']    xy2 = session.xyDataObjects['RF2']    xy3 = combine(-xy1, -xy2)    session.XYData(name='RF2vsU2'+'_'+str(i), objectToCopy=xy3, sourceDescription='combine ( -"U2", -"RF2" )')    x0 = session.xyDataObjects['RF2vsU2'+'_'+str(i)]    session.xyReportOptions.setValues(numDigits=9)    session.writeXYReport(fileName= 'Contact_Study_cons_Con_c' + str(i)  + '.rpt', appendMode=OFF, xyData=(x0, ))    del session.xyDataObjects['RF2']    del session.xyDataObjects['U2']    del session.xyDataObjects['RF2vsU2']

查看力位移曲线如下图:

Con_c1; [0.20, 'SUS301-3/4H-N1'];Con_c2; [0.25, 'C7025-TM02-N1'];Con_c3; [0.30, 'C5191R-H'];

三种设计所产生的塑性变形基本相似,力量对比则是C3>C2>C1。

abaqus导出python脚本 abaqus怎么导出odb_优化问题_04

图4. RF vs Stoke