Python script to extract fieldOutput for 2 specific nodes

Wenn du dir nicht sicher bist, in welchem der anderen Foren du die Frage stellen sollst, dann bist du hier im Forum für allgemeine Fragen sicher richtig.
Antworten
karthikbrs
User
Beiträge: 1
Registriert: Freitag 20. Februar 2015, 03:05

Hello everyone!

I badly want your help!
I am required to extract the fieldOutput(Acoustic Pressure) for only 2 nodes(Eg, NodeLabel=32078 and NodeLabel=33789), which I am struggling to achieve. I have the Python script which extracts the Acoustic Pressure for all the nodes and it is working fine, but I need only 2 nodes with the Acoustic Pressure value and not all nodes!
The script for extracting Acoustic pressure for all nodes is :

Code: Alles auswählen

from odbAccess import *
from abaqusConstants import *
import part

jobname  = 'working-copy'
stepname = 'Acoustic Pressure'
resultfile_name = 'Pressure' 		# file to be written in


odb_file = jobname + '.odb'
inp_file = jobname + '.inp'

odb         = openOdb(odb_file,readOnly=True)
number_freq = len(odb.steps[stepname].frames)
assembly    = odb.rootAssembly


for i in xrange(number_freq): 				# for all frequencies calculated in step
	f=odb.steps[stepname].frames[i].frequency
	if f>0:
		result_file = resultfile_name + '_' + str(f) + '.txt'
		file_results = open(result_file,'w+')
		number_nodes=len(odb.steps[stepname].frames[i].fieldOutputs['POR'].values)
		data_i=odb.steps[stepname].frames[i].fieldOutputs['POR']
		for ii in xrange(number_nodes): 	[b]# for all nodes in model (nodes of different parts together in one list)[/b]
			part=data_i.values[ii].instance.name
			nodeID=data_i.values[ii].nodeLabel			
			u=data_i.values[ii].data
			ui=data_i.values[ii].conjugateData
			file_results.write('%10i %13E %13E\n' % (nodeID,u,ui))
	
		# close file where it was written in		
		file_results.close()
		
# ***************************************************************************************************************************
Can you please help me to modify this script such that it extracts Acoustic Pressure for 2 specific nodes!

Thanks In Advance!!
Zuletzt geändert von Anonymous am Freitag 20. Februar 2015, 08:55, insgesamt 1-mal geändert.
Grund: Enclosed source code in Python code tags.
Sirius3
User
Beiträge: 17741
Registriert: Sonntag 21. Oktober 2012, 17:20

@karthikbrs: you can use "if" to achieve this.

Code: Alles auswählen

from odbAccess import openOdb

NODE_IDS = (32078, 33789)
jobname = 'working-copy'
stepname = 'Acoustic Pressure'
resultfile_name = 'Pressure' # file to be written in

odb_file = jobname + '.odb'
inp_file = jobname + '.inp'

odb = openOdb(odb_file,readOnly=True)
for frame in odb.steps[stepname].frames:
    freq = frame.frequency
    if freq>0:
        result_file = "%s_%s.txt" % (resultfile_name, freq)
        with open(result_file,'w+') as file_results: 
            for value in frame.fieldOutputs['POR'].values:
                part = value.instance.name
                nodeID = value.nodeLabel
                if nodeID in NODE_IDS:    
                    u = value.data
                    ui = value.conjugateData
                    file_results.write('%10i %13E %13E\n' % (nodeID,u,ui))
Antworten