odbCoordinateReader2.py
Script to open an output database and print intial and final
coordinates of step 1 (first and last frames of step 1).
This could be updated by only writing out a node set instead of all the nodes.
Note that in order for this to be used, the output identifier COORD must
be written to the ODB. This is not a default setting for preselected field
variables.
M. E. Barkey 2/15/2015
"""
odbCoordinateReader2.py
Script to open an output database and print intial and final
coordinates of step 1 (first and last frames of step 1).
This could be updated by only writing out a node set instead of all the nodes.
Note that in order for this to be used, the output identifier COORD must
be written to the ODB. This is not a default setting for preselected field
variables.
M. E. Barkey 2/15/2015
"""
#based on ABAQUS 6.13 example
#9.10.3 An Abaqus Scripting Interface version of FPERT
import sys
from odbAccess import *
from types import IntType
# Get input from the user
odbName = raw_input('Enter odb name (w/o .odb): ')
odb = openOdb(odbName + '.odb')
modes = 1
factors = 2
#this reads the first frame [0] of the first step [0]
step = odb.steps.values()[0]
coords = step.frames[0].fieldOutputs['COORD']
#this reads the last frame [-1] of the first step [0]
steplast = odb.steps.values()[0]
coordslast = steplast.frames[-1].fieldOutputs['COORD']
#open a text ouput file and write the initial and final coordinates.
outFile = open(odbName + '.coordinates.dat', 'w')
#these text lines are 65 characters long
outFile.write('ODB Coordinate Reader********************************************')
header = \
"""
*****************************************************************
** Input ODB file: %s
** Coordinate data from the original mesh step 1 frame 0. ****
*****************************************************************
"""
header2 = \
"""
*****************************************************************
*****************************************************************
** Coordinate data from the original mesh step 1 frame -1 (last).
*****************************************************************
"""
#the variable odbName is placed in the position of %s in the header
outFile.write(header % (odbName))
#this format statement if for the node label and tuple write
format = '%6i, %14.7e, %14.7e, %14.7e\n'
#the indent in python means a loop
for value in coords.values:
outFile.write(
format % ((value.nodeLabel,) + tuple(value.data)))
outFile.write('***** End of coordinates of first frame.*************************')
outFile.write(header2)
#this format statement if for the node label and tuple write
format = '%6i, %14.7e, %14.7e, %14.7e\n'
#the indent in python means a loop
for value in coordslast.values:
outFile.write(
format % ((value.nodeLabel,) + tuple(value.data)))
outFile.write('***** End of coordinates of last frame.**************************')
outFile.close()
Fortran program to read in the coordinate file created by the python script.
Some additional files are needed and will be packaged later.
Some post processing is done with the coordinate information.
C1234567
Program coord
C M. E. Barkey 2-15-2015
C This program is designed to work with output from my odb Coordinate Reader progam.
C totn = total nodes, get number of lines by crimson editor
C from line number of last node in step - line number of first node in step + 1
C if totn is greater than 50,000 then update the array sizes
integer node1(50000), node2(50000), i, totn, j, k
integer xplus(500), xminus(500), yplus(500), yminus(500)
integer ixp(500), ixm(500), iyp(500), iym(500), znode
double precision yd(500), xd(500), zref, zdistx(500),zdisty(500)
double precision crd1(50000,3), crd2(50000,3)
character*100 line
character*65 line2
C node at center of impact end is 7340
C will use node 7484 as the zref (impact end, edge)
znode = 7484
open (30, file = 'xplus.txt')
open (31, file = 'xminus.txt')
open (32, file = 'yplus.txt')
open (33, file = 'yminus.txt')
do 220 j = 1, 81
read(30, *) xplus(j)
read(31, *) xminus(j)
read(32, *) yplus(j)
read(33, *) yminus(j)
220 continue
close(30)
close(31)
close(32)
close(33)
i = 0
totn = 23435
open (20, file = "ti-126-4.coordinates.dat")
500 format (a65)
read (20,500) line2
write (*,*) line2
read (20,500) line2
write (*,*) line2
read (20,500) line2
write (*,*) line2
read (20,500) line2
write (*,*) line2
read (20,500) line2
write (*,*) line2
do 200 j = 1, totn
read (20, *) node1(j), crd1(j, 1), crd1(j,2), crd1(j,3)
200 continue
write(*,*) node1(totn),crd1(totn, 1),crd1(totn,2), crd1(totn,3)
read (20,500) line2
write (*,*) line2
read (20,500) line2
write (*,*) line2
read (20,500) line2
write (*,*) line2
read (20,500) line2
write (*,*) line2
read (20,500) line2
write (*,*) line2
do 210 j = 1, totn
i = i + 1
read (20, *) node2(j), crd2(j, 1), crd2(j,2), crd2(j,3)
210 continue
write(*,*) node2(totn),crd2(totn, 1),crd2(totn,2), crd2(totn,3)
close(20)
do 310 j = 1, totn
if (znode.eq.node1(j)) then
zref = crd2(j,3)
end if
310 continue
do 240 k = 1, 81
do 230 j = 1, totn
if (xplus(k).eq.node1(j)) then
ixp(k)=j
end if
if (xminus(k).eq.node1(j)) then
ixm(k)=j
end if
if (yplus(k).eq.node1(j)) then
iyp(k)=j
end if
if (yminus(k).eq.node1(j)) then
iym(k)=j
end if
230 continue
240 continue
do 250 k = 1, 81
write(*,*) ixp(k), 'xplus****************'
j=ixp(k)
write(*,*) node1(j), crd1(j, 1), crd1(j,2), crd1(j,3)
write(*,*) node2(j), crd2(j, 1), crd2(j,2), crd2(j,3)
250 continue
do 260 k = 1, 81
write(*,*) ixm(k), 'xminus***************'
j=ixm(k)
write(*,*) node1(j), crd1(j, 1), crd1(j,2), crd1(j,3)
write(*,*) node2(j), crd2(j, 1), crd2(j,2), crd2(j,3)
260 continue
do 270 k = 1, 81
write(*,*) iyp(k), 'yplus****************'
j=iyp(k)
write(*,*) node1(j), crd1(j, 1), crd1(j,2), crd1(j,3)
write(*,*) node2(j), crd2(j, 1), crd2(j,2), crd2(j,3)
270 continue
do 280 k = 1, 81
write(*,*) iym(k), 'yminus***************'
j=iym(k)
write(*,*) node1(j), crd1(j, 1), crd1(j,2), crd1(j,3)
write(*,*) node2(j), crd2(j, 1), crd2(j,2), crd2(j,3)
280 continue
do 290 k = 1, 81
write(*,*) 'horizontal diameter****z-vals should be same*'
i=ixm(k)
j=ixp(k)
xd(k) = crd2(j,1) - crd2(i,1)
zdistx(k) = crd2(j,3) - zref
write(*,*) xd(k), crd2(j,3), crd2(i,3), zref, zdist
290 continue
do 300 k = 1, 81
write(*,*) 'vertical diameter****z-vals should be same*'
i=iym(k)
j=iyp(k)
yd(k) = crd2(j,2) - crd2(i,2)
zdisty(k) = crd2(j,3) - zref
write(*,*) xd(k), crd2(j,3), crd2(i,3), zref, zdist
300 continue
open (34, file = 'profile.xls')
do 330 k = 1, 81
write(*,*) 'writing diameters'
write(34,*) xd(k), char(9), yd(k), char(9),zdistx(k),
& char(9),zdisty(k)
330 continue
close(34)
stop
end