乐于分享
好东西不私藏

电驱NVH自动仿真插件开发1——JMAG与ABAQUS联合二次开发

电驱NVH自动仿真插件开发1——JMAG与ABAQUS联合二次开发
    基于JMAG二次开发API,开发插件Create_case.py与NVH foece to abaqus.py提高电磁仿真和后处理效率。
     Create_case.py用于自动创建仿真电流边界、求解设置、计算工况。
     NVH foece to abaqus.py用于自动读取JMAG电磁数据导出到文本文件中。
     基于Abaqus二次开发API,开发Motor_NVH插件,用于自动创建电驱频响有限元模型,该插件自动将JMAG输出的时域数据转换成频域载荷谱,并完成有限远模型的求解与边界设置,极大提高了电驱振动仿真的效率。
     部分JMAG插件代码如下:

app= designer.GetApplication()

study=app.GetCurrentStudy()

study.DeleteResult()

defget_parameters_from_dialog(app):

dialog=app.CreateDialogBox()

setup_param_input_dialog(appdialog)

returndialog

defsetup_param_input_dialog(appdialog):

dialogTitle="JMAG-Designer: Create Calculation Case Setting"

label_1="Case set File:"

label_2="Number of Poles:"

dialog.SetTitle(dialogTitle)

dialog.AddLabel(label_101)

dialog.AddSaveFilename(open_file"""""*.csv"11)

dialog.AddLabel(label_201)

dialog.AddInteger(Num_poles""411)

defCreate_parameter(study,ploe_num):

table=study.GetDesignTable()

new_p={'Speed':'3000','poles':str(ploe_num),'Ia':'300','phase':'40','step_angle':'0.5'}

p_num=table.NumParameters()

old_p=[]

foriinrange(p_num):

old_p.append(table.GetEquation(i).GetName())

foriinrange(len(new_p)):

p_name=list(new_p.keys())[i]

ifp_namenotinold_p:

table.AddEquation(p_name)

p_index=table.GetParameterOrder(p_name)

table.GetEquation(p_index).SetType(0)

table.GetEquation(p_index).SetExpression(new_p[p_name])

foriinrange(study.NumConditions()):

ifstudy.GetCondition(i).GetType()=='Motion: Rotation':

study.GetCondition(i).SetValue('AngularVelocity','Speed')

study.GetCircuit().GetComponent('CS1').SetValue('Amplitude''Ia')

study.GetCircuit().GetComponent('CS1').SetValue('Frequency''poles/2*Speed/60')

study.GetCircuit().GetComponent('CS1').SetValue('PhaseU''phase')

study.GetStep().SetValue('StepType'1)

study.GetStep().SetValue('Step''720/poles/step_angle+1')

study.GetStep().SetValue('EndPoint''2/poles/(Speed/60)')

study.GetStep().SetValue('StepDivision''720/poles/step_angle')

defCreate_case(study,file,poles):

Create_parameter(study,poles)

file=open(file,'r')

lines=file.readlines()

num_case=study.GetDesignTable().NumCases()

case_order=num_case-1

forlineinlines[1:]:

case_order+=1

data=line.split(',')

r_v=data[0]

I_am=data[1]

phase=data[2]

study.GetDesignTable().AddCase()

r_v_index=study.GetDesignTable().GetParameterOrder('Speed')

study.GetDesignTable().SetValue(case_orderr_v_indexr_v)

Ia_index=study.GetDesignTable().GetParameterOrder('Ia')

study.GetDesignTable().SetValue(case_orderIa_indexI_am)

phase_index=study.GetDesignTable().GetParameterOrder('phase')

study.GetDesignTable().SetValue(case_orderphase_indexphase)

poles_index=study.GetDesignTable().GetParameterOrder('poles')

study.GetDesignTable().SetValue(case_orderpoles_indexpoles)

defmain_create_case(study):

parameters=get_parameters_from_dialog(app)

ret=parameters.Show()

file=parameters.GetValue(open_file)

poles=parameters.GetValue(Num_poles)

ifret==1:

Create_case(study,file,poles)

else:

pass

open_file='open_file'

Num_poles='num_poles'

main_create_case(study)

已关注
关注
重播 分享