Recording and writing to an text file when using adaptive time steps

miran
Posts: 42
Joined: Wed Apr 29, 2020 7:15 pm

Recording and writing to an text file when using adaptive time steps

Post by miran » Fri May 14, 2021 3:23 pm

Hi,

I have a parameterized model with high levels of non-linearity. I use the adaptive time step, which works great. I never have convergence issues, and the analysis speeds when up solution field is smooth. However, since the model is parameterized in the frequency domain (and eventually also with respect to load intensity), I have many results files to post-process. Since the "recorder" command in OpenSees does not seem to work properly when the time steps are altered, this becomes a cumbersome (and unnecessary) task.

Is there any way to automatically generate a result file (displacements) when we use adaptive time steps?
Regards,

Miran Cemalovic
PhD Candidate
Department of Structural Engineering
Norwegian University of Science and Technology (NTNU)
NO-7491 Trondheim, Norway
https://www.ntnu.edu/employees/mirancem

Horace Horsecollar
Posts: 33
Joined: Mon Mar 22, 2021 11:42 am

Re: Recording and writing to an text file when using adaptive time steps

Post by Horace Horsecollar » Sat May 15, 2021 9:50 am

Dear Miran,
We did not understand what you would like to do. Could you please explain with more details?

You probably can do it with the new API python interface, knowing your skills it would be very useful for your research (https://asdeasoft.net/?webinar).
Regards

miran
Posts: 42
Joined: Wed Apr 29, 2020 7:15 pm

Re: Recording and writing to an text file when using adaptive time steps

Post by miran » Tue May 18, 2021 6:29 pm

Hi,

I basically wish to automatically generate .txt-files with the desired results when I use the adaptive time step. As it stands now, I have to manually go through the post-processor in STKO and extract the results for each analysis. When I have, say 25 mpco-files for each analysis, this becomes quite cumbersome.

In essence: I want to automatically create result files (.txt, xlsx or whatever) when I use adaptive time steps. The "recorder" command in OpenSees does not work for this purpose when the time steps are altered due to non-convergence.
Regards,

Miran Cemalovic
PhD Candidate
Department of Structural Engineering
Norwegian University of Science and Technology (NTNU)
NO-7491 Trondheim, Norway
https://www.ntnu.edu/employees/mirancem

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

Re: Recording and writing to an text file when using adaptive time steps

Post by STKO Team » Thu May 20, 2021 1:04 pm

I basically wish to automatically generate .txt-files with the desired results when I use the adaptive time step. As it stands now, I have to manually go through the post-processor in STKO and extract the results for each analysis. When I have, say 25 mpco-files for each analysis, this becomes quite cumbersome.
When you say "go through the post-processor in STKO and extract the results for each analysis" do you mean "manually with the extract chart data command?".
In this case the fastest way to do it is to use the Python API to create a tool that performs this extraction automatically and writes everything to text files.

We've done something similar in the latest 2 webinar.
Let us know if the Python API in the STKO post processor may work for you. In this case we will guide you through the process

miran
Posts: 42
Joined: Wed Apr 29, 2020 7:15 pm

Re: Recording and writing to an text file when using adaptive time steps

Post by miran » Sat May 22, 2021 1:07 pm

That is exactly the issue - I have to extract the data with the chart data command manually.

I already have external Python scripts that post-process this data,. Thus, the extraction of the data is the bottle neck and the only issue that stands in the way of completely automatizing the entire analysis in the frequency domain.

I am not very familiar with the PyMpc package yet, but I have no problem using the API (or running a Python code externally). However, If I have to open each .mpco file individually in STKO, then it is really of no use.

Just to summarize - I need to automatically extract the data from multiple .mpco-recorders generated from a parameterized model, since the "recorder" command in OpenSees does not work when time steps are altered using adaptive time steps. I could not find anything resembling this in the PyMPc documentation.

If would be of great value if you have a suggestion on how to do this.
Regards,

Miran Cemalovic
PhD Candidate
Department of Structural Engineering
Norwegian University of Science and Technology (NTNU)
NO-7491 Trondheim, Norway
https://www.ntnu.edu/employees/mirancem

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

Re: Recording and writing to an text file when using adaptive time steps

Post by STKO Team » Mon May 24, 2021 9:14 am

Dear Miran,

This was quite difficult because some concepts here have not been discussed yet in our webinars.
However, it can be done:
You can automatically open MPCO databases.

Here you can find an example:
parametric_python_api.zip
(633.75 KiB) Downloaded 220 times

The parametric_python_folder contains some sub-directories, each one with an MPCO result corresponding to a different parameter of the analysis.
There is a python script (process_mpco_files.py) that recursively searches for all MPCO files located in that directory and sub-directories and opens them all.

Once you have all your Databases open, you can process them following our first Python API webinar.
Let us know if something is not clear about the script.
Probably the most difficult part to understand is the way I call the OpenDatabase command, using a worker thread to check the "busy" state of the Application

miran
Posts: 42
Joined: Wed Apr 29, 2020 7:15 pm

Re: Recording and writing to an text file when using adaptive time steps

Post by miran » Fri Jun 04, 2021 11:42 am

Hi,

Thank you for the example file! I have played around with it, and I am able to extract and write files as I wish - when using OpenSees SP.

Capture.JPG
Capture.JPG (121.39 KiB) Viewed 4594 times

However, I cannot make it work for MP. Actually, when I run the script with MP-files, I don't get an error. Instead, it opens the first mpco database, and nothing else happens. No files are written and no other mpco databases are opened.

Is this possible to do with the API for MP databases?

The folder for one parameterized analysis make look something like shown below.

Capture2.JPG
Capture2.JPG (954.08 KiB) Viewed 4594 times
Regards,

Miran Cemalovic
PhD Candidate
Department of Structural Engineering
Norwegian University of Science and Technology (NTNU)
NO-7491 Trondheim, Norway
https://www.ntnu.edu/employees/mirancem

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

Re: Recording and writing to an text file when using adaptive time steps

Post by STKO Team » Fri Jun 04, 2021 12:56 pm

Actually the MPCO partitioned files are the same for OpenSeesSP and OpenSeesMP...
There must be an error somewhere else.

The typical error with OpenSeesMP is this:
  • You first partition your model with N partitions -> it creates N MPCO files
  • Then you run it again with M (< N) partitions -> it creates M MPCO files
  • however in the same folder there are N MPCO files.
  • the remaining (M-N) files are incompatible with the new M files.
  • When your try to open one of them, STKO thinks they are all part of a single model, but since they are incompatible, it makes an error and it exits
Send your SCD files for OpenSeesMP, let me have a look

miran
Posts: 42
Joined: Wed Apr 29, 2020 7:15 pm

Re: Recording and writing to an text file when using adaptive time steps

Post by miran » Sun Jun 06, 2021 3:10 pm

Thank you for the reply. You are right, there is not an actual error. The code that I attached in the previous post opens all the mpco databases and creates the desired files. I made on simple adjustment - I changed the name so that only the "0.mpco"-files are opened.

0mpco.JPG
0mpco.JPG (28.83 KiB) Viewed 4585 times

However, once the mpco-files are opened, it takes about 10-15 min to create each output file. This is the reason why I thought the code crashed.

The reason why it takes so long is that I have up till 2000 time steps per analysis. Hence, the loop that assesses each time step individually is very time consuming (screenshot below). I have checked this by removing the loop and only opening the databases - works like a charm.

In order to extract the displacements and time data, I have followed your examples from previous webinars where you have computed the drift. However, in this case, I only need the already recorded data (time and displacements), so I am guessing that there is no need for a loop. However, since I do not yet understand PyMpc very well, I cannot figure out how to directly write these files.

So my question is - how can I directly write time and displacements for a node without assessing each time step individually through a loop?

loop.JPG
loop.JPG (74.48 KiB) Viewed 4585 times
Regards,

Miran Cemalovic
PhD Candidate
Department of Structural Engineering
Norwegian University of Science and Technology (NTNU)
NO-7491 Trondheim, Norway
https://www.ntnu.edu/employees/mirancem

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

Re: Recording and writing to an text file when using adaptive time steps

Post by STKO Team » Mon Jun 07, 2021 8:21 am

Thank you for the reply. You are right, there is not an actual error. The code that I attached in the previous post opens all the mpco databases and creates the desired files. I made on simple adjustment - I changed the name so that only the "0.mpco"-files are opened.
Exactly, you already find the solution for this issue. OpenSeesMP and OpenSeesSP write partitioned MPCO databases. So when you want to open them in STKO you have to open only 1 of each partitioned set.
So my question is - how can I directly write time and displacements for a node without assessing each time step individually through a loop?
Results in a FEM model are discretized in time and space.
We decided to keep them contiguous in space (1 Dataset for each time step).
This is the most performant approach for graphic plots of the whole model, since we try to create a visual representation of the entire mesh at a fixed time step.

However, for X-Y data (charts) it would have been more performant to keep data contiguous in time (1 Dataset for each node/element).

So if you want to extract data for a single node or element, what you have done is the only way to do it with the MPCO database. If it takes time and you don't want your application to freeze, you have to write all your code so that it works on a working thread, using a Progress bar to let the user understand that the script is actually working... We gave some code snippets during our first PythonAPI webinar (see the call types).

There is another, more performant way to do it, without the MPCO recorder. During your analysis, you can write text files with only the desired results. 1 file for each node/element. You can do it either using the Monitor (it will write .plt files, which are actually text files) or creating standard OpenSees recorders. Then you can post process them in the STKO post processor with python.

Post Reply