[Urgent] Renaming output variables of the .odb file?
[Urgent] Renaming output variables of the .odb file?
(OP)
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?
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?





RE: [Urgent] Renaming output variables of the .odb file?
RE: [Urgent] Renaming output variables of the .odb file?
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??
RE: [Urgent] Renaming output variables of the .odb file?
RE: [Urgent] Renaming output variables of the .odb 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.
RE: [Urgent] Renaming output variables of the .odb file?
Enjoy!
CODE --> 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()RE: [Urgent] Renaming output variables of the .odb file?
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?
RE: [Urgent] Renaming output variables of the .odb file?
Old step:
New step:
Odb information
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.
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()RE: [Urgent] Renaming output variables of the .odb file?
CODE --> 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:
New step:
RE: [Urgent] Renaming output variables of the .odb file?
RE: [Urgent] Renaming output variables of the .odb file?
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
RE: [Urgent] Renaming output variables of the .odb file?
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?
RE: [Urgent] Renaming output variables of the .odb file?
rrg1016 gmail account
RE: [Urgent] Renaming output variables of the .odb file?
CODE --> Python
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??
RE: [Urgent] Renaming output variables of the .odb file?
Keep the +1 because if you have 200 increments, incrementNumber it's 199 and range(199) will give you [0, 1, ... , 198]
CODE --> 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()RE: [Urgent] Renaming output variables of the .odb file?
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.
RE: [Urgent] Renaming output variables of the .odb file?
CODE --> 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()RE: [Urgent] Renaming output variables of the .odb file?