original product, please refer this source
from: http://yhtian.blogspot.com
author: Dr. Yinghui Tian
batching.... automatic...
Step1:
create folder/directory using DOS batch file - MDCases.bat:
---------------------------
md case33
md case34
...
-----------------------------
step2:
generating INP files from Excel using VBA by taking an input as template. the VBA code:
VBA CODE:
---------------------
Option Explicit
Private Sub generatefile()
Dim chanout As Integer, chanin As Integer
Dim i As Long, j As Long
Dim outfile As String, infile As String, txt As String
Worksheets("CalculationCases").Select
chanin = 20
' infile = "E:\ResearchJob\Anchor\YieldLoci\FlapEher\20degree\Case2.inp"
infile = "E:\JobsDoing\PlateAnchor\YieldLoci\20degree\Case2\Case2.inp"
For i = 23 To 58
' outfile = "E:\ResearchJob\Anchor\YieldLoci\FlapEher\20degree\Case" & (i - 3) & "\Case" & (i - 3) & ".inp"
outfile = "E:\JobsDoing\PlateAnchor\YieldLoci\20degree\Case" & (i - 3) & "\Case" & (i - 3) & ".inp"
chanout = i
Open outfile For Output As #chanout
Open infile For Input As #chanin
For j = 1 To 72729
Line Input #chanin, txt
Print #chanout, txt
Next j
Line Input #chanin, txt
Line Input #chanin, txt
If (Cells(i, 4) > 0.0001) Then
Print #chanout, "SetRPFlukeCenter, 1, 1," & Cells(i, 4)
End If
If (Cells(i, 5) > 0.0001) Then
Print #chanout, "SetRPFlukeCenter, 2, 2," & Cells(i, 5)
End If
If (Cells(i, 6) > 0.0001) Then
Print #chanout, "SetRPFlukeCenter, 6, 6," & Cells(i, 6)
End If
For j = 72732 To 72745
Line Input #chanin, txt
Print #chanout, txt
Next j
Close #chanout
Close #chanin
Next i
End Sub
-------------------------------------------
Step3.
Run the ABAQUS jobs using DOS batch file - AbaqusJobs.bat
--------------------------------------------------------------
(
cd case28
abaqus job=case28 interactive
cd..
cd case29
abaqus job=case29 interactive
cd..
cd case30
abaqus job=case30 interactive
cd..
)
----------------------------------------------------------------
the tricky thing is the bracket!!!!!
Step4.
Extract from odb using Python
---------------------------------------------------------------
from abaqus import *
from abaqusConstants import *
session.Viewport(name='Viewport: 1', origin=(0.0, 0.0), width=226.010262340307, height=61.6927062869072)
session.viewports['Viewport: 1'].makeCurrent()
session.viewports['Viewport: 1'].maximize()
from viewerModules import *
for i in range(39):
odbfile = 'E:/YTian/SEPLA/YieldLoci/20degree/Case' + str(i+1) + '/Case' + str(i+1) +'.odb'
o2 = session.openOdb(name=odbfile)
session.viewports['Viewport: 1'].setValues(displayedObject=o2)
odb = session.odbs[odbfile]
session.xyDataListFromField(odb=odb, outputPosition=NODAL, variable=(('RF', NODAL, ((COMPONENT, 'RF1'), (COMPONENT, 'RF2'), )), ('RM3', NODAL), ('U', NODAL, ((COMPONENT, 'U1'), (COMPONENT, 'U2'), )), ('UR3', NODAL), ), nodeSets=('SETRPFLUKECENTER', ))
x0 = session.xyDataObjects['RF:RF1 PI: ASSEMBLY N: 1']
x1 = session.xyDataObjects['RF:RF2 PI: ASSEMBLY N: 1']
x2 = session.xyDataObjects['RM3 PI: ASSEMBLY N: 1']
x3 = session.xyDataObjects['U:U1 PI: ASSEMBLY N: 1']
x4 = session.xyDataObjects['U:U2 PI: ASSEMBLY N: 1']
x5 = session.xyDataObjects['UR3 PI: ASSEMBLY N: 1']
outfile='Result_Case'+str(i+1)+'.dat'
session.writeXYReport(fileName=outfile, appendMode=OFF, xyData=(x0, x1, x2, x3, x4, x5))
del session.xyDataObjects['RF:RF1 PI: ASSEMBLY N: 1']
del session.xyDataObjects['RF:RF2 PI: ASSEMBLY N: 1']
del session.xyDataObjects['RM3 PI: ASSEMBLY N: 1']
del session.xyDataObjects['U:U1 PI: ASSEMBLY N: 1']
del session.xyDataObjects['U:U2 PI: ASSEMBLY N: 1']
del session.xyDataObjects['UR3 PI: ASSEMBLY N: 1']
odb.close()
-----------------------------------------------------------------------------------------
Step5.
combine the 54 XY files:
-----------------------------------------------------------------------------------------
Ncase = 54
nln = 0
infile = range(Ncase)
eofile = range(Ncase)
path = 'E:/ResearchJob/Anchor/YieldLoci/FlapEher/20degree'
filename = path + '/ResultsCombined.dat'
outfile = open(filename, 'w')
for i in range(Ncase):
eofile[i] = 0
outfile.write(' V H M v h beta ')
filename = path + '/Result_Case' + str(i+1) + '.dat'
infile[i] = open(filename, 'r')
infile[i].readline()
infile[i].readline()
infile[i].readline()
infile[i].readline()
outfile.write('\n')
for i in range(Ncase):
outfile.write(' Case'+str(i+1)+' ')
outfile.write('\n')
while True:
# nln += 1
for i in range(Ncase):
if eofile[i] ==0:
line = infile[i].readline()
data = line.split()
if len(data) <7:
data = ['-','-','-','-','-','-','-']
eofile[i] = 1
else:
data = ['-','-','-','-','-','-','-']
outfile.write(data[1])
outfile.write(' ')
outfile.write(data[2])
outfile.write(' ')
outfile.write(data[3])
outfile.write(' ')
outfile.write(data[4])
outfile.write(' ')
outfile.write(data[5])
outfile.write(' ')
outfile.write(data[6])
outfile.write(' ')
outfile.write('\n')
if sum(eofile)==Ncase:
break
outfile.close()
for i in range(Ncase):
infile[i].close()
------------------------------------------------------------------------
订阅:
博文评论 (Atom)
没有评论:
发表评论