Does the cyclic analysis work in python?

Forum for asking and answering questions related to use of the OpenSeesPy module

Moderators: silvia, selimgunay, Moderators

Post Reply
SaeedT
Posts: 8
Joined: Fri Dec 03, 2021 3:59 pm

Does the cyclic analysis work in python?

Post by SaeedT »

Hello Everyone,
I was able to run the Pushover analysis example 5, Ex5, in Tcl. However, I couldn't run the example given in OpenSeesPy. Has anyone tried to run this example:
https://openseespydoc.readthedocs.io/en ... tuni2.html

For Pattern command, part of the "Plain Pattern" says: "The command to generate LoadPattern object contains in { } the commands to generate all the loads and the single-point constraints in the pattern."
https://openseespydoc.readthedocs.io/en ... ht=pattern
I couldn't get this but one may think curly braces are required somewhere. Actually if the Python version could mimic the Tcl format that could be the best, however, the example does not include the curly braces. In Tcl the loads associated with the Pattern are placed into {}, but in Python, it is just order of execution that related the loads to the Pattern as I understood. Am I missing something here?

Another related question is about this part of the python code:

Nsteps = int(Dmax/ Dincr)

ok = op.analyze(Nsteps)
print(ok)

# for gravity analysis, load control is fine, 0.1 is the load factor increment (http://opensees.berkeley.edu/wiki/index ... ad_Control)

test = {1:'NormDispIncr', 2: 'RelativeEnergyIncr', 4: 'RelativeNormUnbalance',5: 'RelativeNormDispIncr', 6: 'NormUnbalance'}
algorithm = {1:'KrylovNewton', 2: 'SecantNewton' , 4: 'RaphsonNewton',5: 'PeriodicNewton', 6: 'BFGS', 7: 'Broyden', 8: 'NewtonLineSearch'}

for i in test:
for j in algorithm:

if ok != 0:
if j < 4:
op.algorithm(algorithm[j], '-initial')

else:
op.algorithm(algorithm[j])

op.test(test, Tol, 1000)
ok = op.analyze(Nsteps)
print(test, algorithm[j], ok)
if ok == 0:
break
else:
continue

u2 = op.nodeDisp(2, 1)
print("u2 = ", u2)

Is this based on a common experience in solving cyclic analysis in OpenSees? Do we have to try all of these algorithms to find one that MAY work?
Regardless, can't this code print a trial value that has failed at the end of trials as u2? Maybe we need to move the print under "if ok==0:" before the "break"?

Using Python libraries with OpenSeesPy is a great advantage and I am trying to do all my research with OpenSeesPy.
Thank you for helping with this question.
SaeedT
mhscott
Posts: 879
Joined: Tue Jul 06, 2004 3:38 pm
Location: Corvallis, Oregon USA
Contact:

Re: Does the cyclic analysis work in python?

Post by mhscott »

You can dereference a list in Python by putting a * in front.

It is not uncommon to use different algorithms. Usually 'Newton' is sufficient, but you can switch through other algorithms. There are better switching strategies out there though. Search for "OpenSees smart analyze"
SaeedT
Posts: 8
Joined: Fri Dec 03, 2021 3:59 pm

Re: Does the cyclic analysis work in python?

Post by SaeedT »

Thank you for your response.
Then the example must be working as it is. However, there is no unpacking asterisk.
Since the same happens for fiber command where patch commands just follow and the python interpreter relates those based on the order of execution, I assumed the same style has been used for the pattern and the related load commands. This is a bit different from the Tcl syntax.

I will try the SmartAnalyze.py.

As always very helpful and prompt.

Thank you
noahbrownn
Posts: 1
Joined: Thu Oct 19, 2023 6:01 pm

Re: Does the cyclic analysis work in python?

Post by noahbrownn »

Regarding the Python code snippet, it appears to be a trial and error approach for solving cyclic analysis in OpenSees. The code tries different algorithms and test criteria until a successful analysis (ok == 0) is achieved. Regarding printing the trial value that failed, you can move the print statement under "if ok==0:" before the "break" statement to achieve that.Immaculate Grid

Using Python libraries with OpenSeesPy offers advantages, and you are utilizing it for your research. :?
Post Reply