Export Nodal results time history via Python API

Post Reply
a1rodrig
Posts: 10
Joined: Tue Aug 29, 2023 12:04 am

Export Nodal results time history via Python API

Post by a1rodrig » Wed Oct 11, 2023 12:22 am

Dear STKO,

I am currently trying to export nodal displacement time history to a text file.
I am able to do so by going over the displacement at each time step following the Python API tutorials provided.

My question is:
Is it possible to access the entire displacement time-history for a single node at once?
I have over 9000 time-steps and 30 nodes, therefore going step by step in a 'for loop' becomes a very lengthy process

I have attached my code for reference.
Thank you for your help.
Attachments
Extract_Nodal_Results.zip
(1.79 KiB) Downloaded 241 times

STKO Team
Posts: 3066
Joined: Tue Oct 29, 2019 8:45 am

Re: Export Nodal results time history via Python API

Post by STKO Team » Mon Oct 16, 2023 9:45 am

Try this:
Extract_Nodal_Results.zip
(1.93 KiB) Downloaded 253 times
I fixed an error in the indexing. The step_id is not necessarily 1-based (it depends on how many stages you have).
I used the zip command to iterate over the step_id and the step_time at the same time:

Code: Select all

for step_id, step_time in zip(all_steps, all_times): #Loop for timesep
To speed up the process I made a reduced mesh containing only the nodes you need to extract.
It will reduce the size of the dataset of each evaluation:

Code: Select all

# make a fake mesh with only the required nodes
# 1. do a first evaluation to get the real mesh
# 2. from the real mesh get the requested nodes and copy them into the reduced mesh
# 3. save the reduced mesh in the evaluation options
opt.step = all_steps[0]
field = Disp.evaluate(opt)
reduced_mesh = MpcMesh()
for i in NODES:
	inode = field.mesh.getNode(i)
	reduced_mesh.addNode(inode)
opt.mesh = reduced_mesh
Let me know the speed-up you get. I tried it on a small model and it already gave a 20x speed-up

a1rodrig
Posts: 10
Joined: Tue Aug 29, 2023 12:04 am

Re: Export Nodal results time history via Python API

Post by a1rodrig » Tue Oct 17, 2023 11:24 pm

Reducing the mesh for each evaluation worked perfectly!
It was able to speed up the process by 20x

Thank you very much for your help.

Andres R

STKO Team
Posts: 3066
Joined: Tue Oct 29, 2019 8:45 am

Re: Export Nodal results time history via Python API

Post by STKO Team » Wed Oct 18, 2023 8:38 am

You're welcome. And the speed up will be greater as the ratio total_number_of_nodes/required_number_of_nodes increases (i.e. for large models the speed up is larger)

Post Reply