Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations KootK on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

[Urgent] Renaming output variables of the .odb file? 3

Status
Not open for further replies.

ShadowWarrior

Civil/Environmental
Aug 21, 2006
171
I have applied filtering of field output, so the variables have a suffix at the end, e.g. LE_Filter-1, RF1_Filter-1.

Is there any way I can rename these variables to their normal form after analysis run, e.g. LE, RF1? Maybe a script can do it?
 
Replies continue below

Recommended for you

You can do this by creating a field output from fields. To access go to Tools->Create Field Output->From Fields. Simply name the field what you want it to be, and select the proper field output. It will appear in a created step called Session Step. See 42.7.4 of the Abaqus/CAE User's guide.
 
@pdiculous963 - That was really helpful, Thank you!

Any chance of getting it done via scripting? Example is appreciated.

Edit: The method you described only applies to one frame at a time, how do I conduct this for the whole step??
 
After you do it once, open up the .rpy file to see the commands Abaqus performed. You those should help show you what abaqus is doing behind the scenes. I would imagine this could be accomplished with a FOR loop, but have only really used scripting for creating and meshing parts; not for viewing analysis results.
 
So this is what I got from the .rpy file -

s1f0_LE_ANTIALIASING = session.odbs['C:/ShadowWarrior/Job-Impact.odb'].steps['Impact'].frames[0].fieldOutputs['LE_ANTIALIASING']
tmpField = s1f0_LE_ANTIALIASING
currentOdb = session.odbs['C:/ShadowWarrior/Job-Impact.odb']
scratchOdb = session.ScratchOdb(odb=currentOdb)
sessionStep = scratchOdb.Step(name='Session Step',
description='Step for Viewer non-persistent fields', domain=TIME,
timePeriod=1.0)
sessionFrame = sessionStep.Frame(frameId=0, frameValue=0.0,
description='Session Frame')
sessionField = sessionFrame.FieldOutput(name='LE',
description='s1f0_LE_ANTIALIASING', field=tmpField)


Could you please tell me how to introduce a For loop to convert the whole STEP? There are total 200 frames in the .odb file.
 
Hello. Just replace 'odbFileName.odb' with your odb file, and 'stepName' with your step name. Execute this script setting the Work Directory of Abaqus CAE in the same path of your odb file.
Enjoy!


Python:
from abaqus import *
from abaqusConstants import *
import odbAccess

Odb='odbFileName.odb'
StepName='stepName'

odb = odbAccess.openOdb(path=Odb)
newStepName='newStepName'

nFrames=odb.steps[StepName].frames[-1].frameId #frames number
StepTime=odb.steps[StepName].frames[-1].frameValue #total time

newStep = odb.Step(name=newStepName, description='Step for new fields', domain=TIME, timePeriod=StepTime)

for N in range(nFrames):
    tmpField = session.odbs[Odb].steps[StepName].frames[N].fieldOutputs['S']
    tempTime = session.odbs[Odb].steps[StepName].frames[N].frameValue
    newFrame = newStep.Frame(frameId=N, frameValue=tempTime, description='Increment: '+str(N) + ' Time: ' + str(tempTime) )
    sessionField = newFrame.FieldOutput(name='newName', description='blabla', field=tmpField)
    
odb.save()
odb.close()
 
@rrg1016 - It failed.

File "C:/ShadowWarrior/Rename_odb.py", line 17, in <module>
tmpField = session.odbs[Odb].steps[StepName].frames[N].fieldOutputs['S']
IndexError: Sequence index out of range


I have total 200 frames in the .odb file, could you please review the code?

Edit:

It seemed to work, but the message pops up at the end. Another problem is, the new step's Time domain is now ranging from T to 2*T (it was 0 to T for original step). Can I keep the original time history range?

 
I revised the code and found some mistakes but nothing related with the indexError. Also I added a +1 at the for loop to complete all the frames. About the re-ranging of the time domain I did't see what you said. I send you some screen shots:

Old step:

StepOrig_kgoe8f.png


New step:

StepNew_yj3p5q.png


Odb information
Capture_l8erqm.png



It's hard to debbug without the odb file, but if you send me this captures of your odb file maybe I can try a new shot.

Questions:

- Did you replace the field Output 'S' with your 'LE_ANTIALIASING' field output? I had forgotten to tell this to you.
- I recommend you to copy the odb file before running the script because it can't replace the new step previously created
- Add a new line to cover all the fields that you want to rename.
- Run the scrip from the Abaqus PDE
- If you have the same index error after re-running the new code, type in the Kernel Command Line Interface (you can find it at the bottom of Abaqus CAE >>>) N to see how many for loops it had did.

New improved code.

Python:
from abaqus import *
from abaqusConstants import *
import odbAccess
Odb='S-02_CASO2-600s_MAX_TMA.odb'
odb = odbAccess.openOdb(path=Odb)
StepName='CASO2-600s'
newStepName='newStepName'

nFrames=odb.steps[StepName].frames[-1].frameId+1 #frames number
StepTime=odb.steps[StepName].frames[-1].frameValue #total time

newStep = odb.Step(name=newStepName, description='Step for new fields', domain=TIME, timePeriod=StepTime)

for N in range(nFrames):
    tempTime = session.odbs[Odb].steps[StepName].frames[N].frameValue
    newFrame = newStep.Frame(frameId=N, frameValue=tempTime, description='Increment:     '+str(N) + '  Step Time:     ' + str(round(tempTime,2)) )
    
    #field 1 to copy
    tmpField = session.odbs[Odb].steps[StepName].frames[N].fieldOutputs['S']
    sessionField = newFrame.FieldOutput(name='S_new', description='blabla', field=tmpField)
    
    #field 2 to copy
    tmpField = session.odbs[Odb].steps[StepName].frames[N].fieldOutputs['U']
    sessionField = newFrame.FieldOutput(name='U_new', description='blabla', field=tmpField)
    
    #add as fields as you need to copy
    
odb.save()
odb.close()
 
@rrg1016- I have executed the below script through cmd line: "abaqus cae script=Rename_odb.py"

Python:
from abaqus import *
from abaqusConstants import *
import odbAccess
import os

#set scratch/working dir
os.chdir(r"C:\ShadowWarrior")

Odb='Job-Impact.odb'
odb = odbAccess.openOdb(path=Odb)

StepName='Impact'
newStepName='newStepName'

nFrames=odb.steps[StepName].frames[-1].frameId+1 #frames number
StepTime=odb.steps[StepName].frames[-1].frameValue #total time

newStep = odb.Step(name=newStepName, description='Step for new fields', domain=TIME, timePeriod=StepTime)

for N in range(nFrames):
    tempTime = session.odbs[Odb].steps[StepName].frames[N].frameValue
    newFrame = newStep.Frame(frameId=N, frameValue=tempTime, description='Increment: '+str(N)+' Step Time: '+str(tempTime))
    
    #field 1 to copy
    tmpField = session.odbs[Odb].steps[StepName].frames[N].fieldOutputs['LE_ANTIALIASING']
    sessionField = newFrame.FieldOutput(name='LE', description='Logarithmic strain components', field=tmpField)
    
    #field 2 to copy
    #tmpField = session.odbs[Odb].steps[StepName].frames[N].fieldOutputs['U']
    #sessionField = newFrame.FieldOutput(name='U_new', description='blabla', field=tmpField)
    
    #add as fields as you need to copy
    
odb.save()
odb.close()

I am doing explicit analysis of 0.006 second, so rounding off the time is not required. Also, can't share the .odb because its ~50GB in size.
1. I did not see any loop counting even though it ran through system cmd and in CAE kernel cmd interface.
2. I have total 201 frames, forgot about the frame id 0.
3. The new step has been created, but its not being saved due to the following error. As soon as I reopen the .odb, "newStepName" disappears.

New error -
File "Rename_odb.py", line 21, in <module>
tempTime = session.odbs[Odb].steps[StepName].frames[N].frameValue
IndexError: Sequence index out of range


Perhaps the loop is not finishing completely?? You see that the Total time at the end of step (Frame ID 200) does not match.

Old step:
PrtScr_capture_2_bieu5n.jpg


New step:
PrtScr_capture_3_dzphfl.jpg
 
As I could see, the time between the original step and the time of the new one are equals. Maybe you are comparing the increments.

The unsolved problem then is the 'index out of range' error. I recommend you to try:

- The easy way is to replace the variable 'nFrames' by an integer number like 150 or 199 in the range() function at the for loop . Increse this value if the error dissapear and decrese it if the error persists.
- On the other hand, as I previusly told you, you have to run the code from Abaqus CAE. Do it from the Abaqus PDE (the interface to write and debbug scrips) or pasting the code in the Kernel Command Line Interface (you can find it at the bottom of Abaqus CAE >>>). Read the value that N reaches to see how many for loops it had did.
- Send me the 50GB odb file [stpatrick2]

 
rrg1016 said:
Do it from the Abaqus PDE (the interface to write and debbug scrips) or pasting the code in the Kernel Command Line Interface (you can find it at the bottom of Abaqus CAE >>>). Read the value that N reaches to see how many for loops it had did.

I have tried both the option you mentioned, but I don't see the value that N reaches to see how many for loops it had did, where can I find it?

Also, Can I get your email address?
 
After running the code, type 'N' in the Kernel Command Line Interface (you can find it at the bottom of Abaqus CAE >>>)

rrg1016 gmail account
 
@rrg1016 - I think I know what is going on.

Python:
nFrames=odb.steps[StepName].frames[-1].frameId #frames number
StepTime=odb.steps[StepName].frames[-1].frameValue #total time

print nFrames
print StepTime

I have printed these two variables and nFrames came out to be 314108, which is actually increment number. I have also used 199, 200, 201 directly instead of nFrames in the range() function at the for loop and it worked fine, 202 gave same "Sequence index out of range" error which is logical.

So, frameId object is not the frame numbers, it is increment number. Also, there is no need to add +1 after it.

Please note that, the so called frame numbers are shown as "Index" in above pictures. We are looking for something like odb>step>index. What is the right object name for this??
 
Excelent! My mistake. [afro2]
Keep the +1 because if you have 200 increments, incrementNumber it's 199 and range(199) will give you [0, 1, ... , 198]

Python:
from abaqus import *
from abaqusConstants import *
import odbAccess
Odb='OdbName.odb'
odb = odbAccess.openOdb(path=Odb)
StepName='StepName'
newStepName='newStepName'

nFrames=odb.steps[StepName].frames[-1].incrementNumber+1 #frames number
StepTime=odb.steps[StepName].frames[-1].frameValue #total time

newStep = odb.Step(name=newStepName, description='Step for new fields', domain=TIME, timePeriod=StepTime)

for N in range(nFrames):
    tempTime = session.odbs[Odb].steps[StepName].frames[N].frameValue
    newFrame = newStep.Frame(frameId=N, frameValue=tempTime, description='Increment:     '+str(N) + ':  Step Time:     ' "{:.2e}".format(tempTime) )
    
    tmpField = session.odbs[Odb].steps[StepName].frames[N].fieldOutputs['S']
    sessionField = newFrame.FieldOutput(name='S_new', description='blabla', field=tmpField)
    
    tmpField = session.odbs[Odb].steps[StepName].frames[N].fieldOutputs['U']
    sessionField = newFrame.FieldOutput(name='U_new', description='blabla', field=tmpField)
    
odb.save()
odb.close()
 
@rrg1016 - You are using ABAQUS/Standard, so the increment number is less and equal to frame numbers. This is why the code is working for you.

I am using ABAQUS/Explicit and it generates close to half a million increments, that is why filtering is necessary and I've requested 200 frame numbers. I need to know the command name for frame numbers, not increment numbers.
 

Python:
from abaqus import *
from abaqusConstants import *
import odbAccess
Odb='OdbName.odb'
odb = odbAccess.openOdb(path=Odb)
StepName='StepName'
newStepName='newStepName'

nFrames=odb.steps[StepName].frames.__len__() #frames number
StepTime=odb.steps[StepName].frames[-1].frameValue #total time

newStep = odb.Step(name=newStepName, description='Step for new fields', domain=TIME, timePeriod=StepTime)

for N in range(nFrames):
    tempTime = session.odbs[Odb].steps[StepName].frames[N].frameValue
    newFrame = newStep.Frame(frameId=N, frameValue=tempTime, description='Increment:     '+str(N) + ':  Step Time:     ' "{:.2e}".format(tempTime) )
    
    tmpField = session.odbs[Odb].steps[StepName].frames[N].fieldOutputs['S']
    sessionField = newFrame.FieldOutput(name='S_new', description='blabla', field=tmpField)
    
    tmpField = session.odbs[Odb].steps[StepName].frames[N].fieldOutputs['U']
    sessionField = newFrame.FieldOutput(name='U_new', description='blabla', field=tmpField)
    
odb.save()
odb.close()
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor