News:

SMF - Just Installed!

Main Menu
Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - Mark Barkey

#78
Scripting and Python / ODB temperature reader
December 10, 2016, 02:40:54 AM

#read selected frame results for nodal temperatures from ODB file
#M. E. Barkey
# 9 December 2016



#with reference from python code from Mustaine
#ww3.cad.de/foren/ubb/Forum254/HTML/000798.shmtl
#and
#www.eng-tips.com/viewthread.cfm?qid=306565




import sys
from odbAccess import *
from abaqusConstants import *
from types import IntType
from numpy import array


odbName = 'spt1'
odb = openOdb(odbName + '.odb', readOnly=False)


print'------------------------------------------------'
print'This step will be read from the ODB'
#this is the step just as it is labeled in the ODB when the input file was analyzed
steptoread=odb.steps['Step-2']
print' selected step:  ', steptoread.name
print ''
print'------------------------------------------------'
#frame 0 is the first frame
# from -1 is the last frame
#these are the same frame numbers that are in the ODB
frametoread=steptoread.frames[4]

#this grabs only the NT11 field data
print'Only write out the NT11 (temperature) field from this frame of this step.'
odbSelectResults=frametoread.fieldOutputs['NT11']

#this was written for ABAQUS 6.14-2, the following may be different for other verions
#values in the field odbSelectResults
#here is an example with data in it
#({'baseElementType': '', 'conjugateData': None, 'conjugateDataDouble': 'unknown', 'data': 570.72705078125,
#'dataDouble': 'unknown', 'elementLabel': None, 'face': None, 'instance': 'OdbInstance object',
#'integrationPoint': None, 'inv3': None, 'localCoordSystem': None, 'localCoordSystemDouble': 'unknown',
#'magnitude': None, 'maxInPlanePrincipal': None, 'maxPrincipal': None, 'midPrincipal': None, 'minInPlanePrincipal': None,
#'minPrincipal': None, 'mises': None, 'nodeLabel': 41313, 'outOfPlanePrincipal': None, 'position': NODAL,
#'precision': SINGLE_PRECISION, 'press': None, 'sectionPoint': None, 'tresca': None, 'type': SCALAR})

#this is to get the nodes in the root assembly
#nodes = odbSelectResults.getSubset(region=odb.rootAssembly.nodeSets[' ALL NODES'])

#this will show the fields that are in nodes
#print nodes

print '-------------------------------------------'

print 'selected results  ', odbSelectResults.name

t = odbSelectResults

print
print '-------------------------------------------'

#this prints out the data (temperature) of element 50 in t
#print t.values[50].data

#this prints out the 0-10 elements of t
#for n in range (0,10):
# print t.values[n].data

#this prints out the nodeLabels and data (temperature) for the nodes
#this is a loop for all the number of entries in the tuple
#notice that nodeLabel and data are fields from above and that any of these fields can be included in the statement
#they must be spelled correctly including capitalization

for x in t.values:
    print x.nodeLabel, x.data
   

   
text = 'This is a header line'   
for x in t.values:
    output = str(x.nodeLabel) +'\t'+str(x.data)
    text = '\n'.join([text, output])
   
data = file('results.xls', 'w')   
data.write(text)
data.close()
   


odb.close()


#79
Scripting and Python / Re: Python resources
December 04, 2016, 07:37:36 PM
Basic examples  python 2.7.x


#error in
#https://www.amazon.com/Python-Beginners-Guide-Programming-Code-ebook/dp/B01MYO0CMV/ref=sr_1_1
#text string requires 'text'

print('Hello, World!')

#error in
#https://www.amazon.com/Python-Beginners-Programming-beginners-programming-ebook/dp/B01N3N6768/ref=sr_1_2
#input does not work, needed raw_input
#variable name is different than Name; uppercase and lowercase are different variables

name = raw_input('what is yourname?')

print ('Hello ' + name + '!')

             




#error in
#https://www.amazon.com/Python-Beginners-Guide-Programming-Code-ebook/dp/B01MYO0CMV/ref=sr_1_1
#text string requires 'text'

print('Hello, World!')

#error in
#examples below from this book, but corrected to work properly
#https://www.amazon.com/Python-Beginners-Programming-beginners-programming-ebook/dp/B01N3N6768/ref=sr_1_2
#input does not work, needed raw_input
#variable name is different than Name; uppercase and lowercase are different variables

#comment out these lines, but they do work
#name = raw_input('what is yourname?')
#print ('Hello ' + name + '!')


#this example doesn't work
#print(name[0]Upper()+[1:]Lower())


print (0.6/0.2)

#  to slashes represent floor division; see the following for more details
#http://python-history.blogspot.com/2010/08/why-pythons-integer-division-floors.html

print (0.6//0.2)

a = round (3.14159, 2)
print a

a = round (3.14159, 4)
print a

stringa = str(a)

#the variable name below will not work
#string-a = str(a)

print ('pi to four digits:  ' + stringa)


#mutable means variable can change values
#immutable means that the variable cannot change values


#strings

#\n newline
#\t tab
#\\ backslash
#\' single quote
#\" double quote


#index 0 on left, -1 on right side

#empty_tupl is not defined
#print(empty_tupl)


#these beginning python books are hoorendously written

A = [66.25, 333, 333, 1, 1234.5]
print A.count(333)
print A.count(66.25)
print A.count('x')

#inserts -1 into list after element 2
A.insert(2,-1)
#appends antother 333 at the end of the list
A.append(333)
print A

#removes the first 333
A.remove(333)
print A

A.reverse()
print A

A.sort()
print A

A.pop()
print A
#80
Scripting and Python / Re: Python resources
December 04, 2016, 07:28:54 PM
#81
at the >>> command line in ABAQUS CAE

import odbAccess
dir (odbAccess)


to get a list of commands available in the odbAccess
to get information about a command:  dir (AQUA)dire

#83
Scripting and Python / Re: Python resources
December 04, 2016, 01:05:57 AM
python identifiers:  variables, functions, modules, classes

class identifiers start in uppercase


indents are used as code blocks


if - elif    is an if-elseif         block


comments use #
#this is a comment




#84
Scripting and Python / Python resources
December 04, 2016, 12:54:24 AM
Python

https://www.python.org/


ABAQUS through 6.14 appears to use Python 2.7.x

reserved words
https://docs.python.org/2/reference/lexical_analysis.html


and
del     
from     
not       
while
as   
elif     
global   
or     
with
assert
else     
if       
pass   
yield
break
except
import 
print
class   
exec     
in       
raise
continue
finally
is   
return
def     
for     
lambda 
try
#85
Fortran Programs / Re: CSV-tab converter
November 08, 2016, 11:19:05 PM

       Program csvtab


c
c      M. E. Barkey
c      23 October 2016
c      This program converts comma to tab delimitted.
c
c





       Real a, b, olda
      Character*8  lc1
      Character*11 lc2
      Character*13 lc3
      Integer i, j, nofiles, fl, newl
      Character*80 filename, fullname
      character*90 outfile
      character*90 prefix

   

     
      open (16, file = 'numfiles.dat')
      read(16,*) nofiles
      close(16)
     
     
      open (15, file = 'filelist.dat')
     
      do 500 j = 1, nofiles
     
      read (15,*) filename
     
      outfile = trim(filename) // '.xls'
     
     
      fullname = trim(filename)
     
      fl = len(fullname)
     
      newl = fl -4
      prefix = trim(fullname(1:newl))
      outfile = trim(prefix) // '.xls'
     
     
      write (*,*) 'Processing: ', prefix, outfile
       
     
     
     

     
     
     
     
     
   
      open (12, file = outfile)


       open (14, file = filename, status = 'old')

       
       
       
       
       
        read (14, *) lc1, lc2, lc3
C        write (*,*) lc1, lc2, lc3
       
        do 100 i = 1, 1000000
       
        read (14, *) a, b
C        write(*,*) a,b
       

       
       
       
        if (olda.eq.a) then
        go to 300
        end if
   
        write (12,*) a, char(9), b
        olda = a
       
       
       
100 continue       
       
300    continue       
       
close(12)
close (14)

500    continue


stop

900   format (a8, a11, a13)

       End

#88
Welcome Center / Theme reset
November 06, 2016, 01:44:33 AM
I have reset the theme since the previous theme had some issues with Firefox.  I will update the header as I get time.
#89
Hi,

I don't know.  I can look into it, but I can't promise anything.  With luck, some additional people will join and respond.  For now, sorry that I cannot provide more information.
#90
Scripting and Python / Re: ODB Coordinate Reader
February 16, 2015, 04:14:42 AM
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