Search code examples
pythonabaqus

Abaqus: Creating a new FieldOutput (format?)


Been struggling with following: I want to create a new FieldOutput (lets say some simple aritmetic operation with the tensors) for a given el. set. Not the whole model as this would be too costly and Im interested in that particular area/set anyway.

I open an odb with the results....

from abaqus import *
from odbAccess import *
from abaqusConstants import *
import visualization
import fileinput
import os

# to make prettyPrint work!
from odbAccess import *
from textRepr import *

# open odb
odb_path="analysis45.odb"
my_odb=session.openOdb(name=odb_path,readOnly=FALSE)

Some substitutions that assure that it always opens the step/instance no matter what their name is...

# automate the proces of reading the step no matter what its name is
StepNames=(my_odb.steps.keys() )        #   it is a list of all step names
lastStep=( StepNames[-1] )  

# automation of an instance naming (in the same way)
NaseInstance = (my_odb.rootAssembly.instances.keys())
MojeInstance = ( NaseInstance[-1] ) 
CelaMojeInstance=my_odb.rootAssembly.instances[MojeInstance]

Found somebody elses way to calculate new data and stuff them into a new scalar here: https://gist.github.com/crmccreary/5015483 I am, though, not successful in understanding what exactly happens there as this script is much more complicated and Im not a programmer at all.

Tried to simplify the task by hard-prescribing some value directly to the field (with the intention to replace this by a function later on and finally to loop over the whole elset this way). Im getting a message regarding "illegal argument type for built-in operation" form which I assume that the format of the data Im trying to insert is not correct. Tried the documentation w/o success. May I ask for a hint/help? Thanks!

NewField =my_odb.steps[lastStep].frames[0].FieldOutput(name='New_scalar_field',description='Our brand new scalar field', type=SCALAR)
NewField.addData(position=NODAL, instance=CelaMojeInstance, labels=[1657, 1658, 1683, 1684, 14193, 14194, 14195, 14196], data=[(6),(12),(6),(12),(6),(12),(6),(12)])

my_odb.save()
my_odb.close()

This guys solution seems to be quite the same to the mine: http://abaqus-users.1086179.n5.nabble.com/Writing-Results-to-Existing-ODB-file-td21750.html

I understand that the question may be too trivial or too silly for seniors, sorry about that.


Solution

  • For some reason it works when I type:

    data=[(6.0,),(12.0,),(6.0,),(12.0,),(6.0,),(12.0,),(6.0,),(12.0,)]
    

    with the commas after the values. I dont really know why. Hopefully it helps somebody else in the future.