zhuminjie / OpenSeesPyDoc

OpenSeesPy Documentation
http://openseespydoc.readthedocs.io
Other
145 stars 106 forks source link

Python 3.7.8 shell #202

Closed Sadia328 closed 4 years ago

Sadia328 commented 4 years ago

I am new to this language and trying to run the folowing Frame example in Python Shell. But Unfortunately I am not able to get Figure of mode shape of Frame and figure showing nodes IDs. Rather I am just getting a 3D Frame structure. Could anyone guide me.

https://openseespydoc.readthedocs.io/en/latest/src/ModelRendering.html

u-anurag commented 4 years ago

Which frame example are you talking about?

Sadia328 commented 4 years ago

##################################################################

3D frame example to show how to render opensees model and

plot mode shapes

Date - 10/09/2020

##################################################################

from openseespy.postprocessing.Get_Rendering import from openseespy.opensees import

import numpy as np

from math import asin, sqrt import matplotlib.pyplot as pl from mpl_toolkits.mplot3d import Axes3D

set some properties

wipe()

model('Basic', '-ndm', 3, '-ndf', 6)

properties

units kip, ft

numBayX = 2 numBayY = 2 numFloor = 7

bayWidthX = 120.0 bayWidthY = 120.0 storyHeights = [162.0, 162.0, 156.0, 156.0, 156.0, 156.0, 156.0, 156.0, 156.0, 156.0, 156.0]

E = 29500.0 massX = 0.49 M = 0. coordTransf = "Linear" # Linear, PDelta, Corotational massType = "-lMass" # -lMass, -cMass

nodeTag = 1

add the nodes

- floor at a time

zLoc = 0. for k in range(0, numFloor + 1): xLoc = 0. for i in range(0, numBayX + 1): yLoc = 0. for j in range(0, numBayY + 1): node(nodeTag, xLoc, yLoc, zLoc) mass(nodeTag, massX, massX, 0.01, 1.0e-10, 1.0e-10, 1.0e-10) if k == 0: fix(nodeTag, 1, 1, 1, 1, 1, 1)

        yLoc += bayWidthY
        nodeTag += 1

    xLoc += bayWidthX

if k < numFloor:
    storyHeight = storyHeights[k]

zLoc += storyHeight

add column element

geomTransf(coordTransf, 1, 1, 0, 0) geomTransf(coordTransf, 2, 0, 0, 1)

eleTag = 1 nodeTag1 = 1

for k in range(0, numFloor): for i in range(0, numBayX+1): for j in range(0, numBayY+1): nodeTag2 = nodeTag1 + (numBayX+1)*(numBayY+1) iNode = nodeCoord(nodeTag1) jNode = nodeCoord(nodeTag2) element('elasticBeamColumn', eleTag, nodeTag1, nodeTag2, 50., E, 1000., 1000., 2150., 2150., 1, '-mass', M, massType) eleTag += 1 nodeTag1 += 1

nodeTag1 = 1+ (numBayX+1)*(numBayY+1)

add beam elements

for j in range(1, numFloor + 1): for i in range(0, numBayX): for k in range(0, numBayY+1): nodeTag2 = nodeTag1 + (numBayY+1) iNode = nodeCoord(nodeTag1) jNode = nodeCoord(nodeTag2) element('elasticBeamColumn', eleTag, nodeTag1, nodeTag2, 50., E, 1000., 1000., 2150., 2150., 2, '-mass', M, massType) eleTag += 1 nodeTag1 += 1

nodeTag1 += (numBayY+1)

nodeTag1 = 1+ (numBayX+1)*(numBayY+1)

add beam elements

for j in range(1, numFloor + 1): for i in range(0, numBayY+1): for k in range(0, numBayX): nodeTag2 = nodeTag1 + 1 iNode = nodeCoord(nodeTag1) jNode = nodeCoord(nodeTag2) element('elasticBeamColumn', eleTag, nodeTag1, nodeTag2, 50., E, 1000., 1000., 2150., 2150., 2, '-mass', M, massType) eleTag += 1 nodeTag1 += 1 nodeTag1 += 1

calculate eigenvalues & print results

numEigen = 7 eigenValues = eigen(numEigen) PI = 2 * asin(1.0)

#

Display Model

plot_model()

plot_model(<"nodes">,<"elements">,)

Display specific mode shape

plot_modeshape(5)

Define Static Analysis

timeSeries('Linear', 1) pattern('Plain', 1, 1) load(72, 1, 0, 0, 0, 0, 0) analysis('Static')

Save a recorder for node displacements before running the analysis

fname = 'nodeDisp.txt' recordNodeDisp(fname)

Run Analysis

analyze(10)

Plot the deformed shape using the recorded displacements at time step # 10.

plot_deformedshape(fname, tstep = 10, scale = 200)

u-anurag commented 4 years ago

Did you try to close the plotting window showing the 3D Frame structure? Once you close the first window, the program will plot the mode shape.

Sadia328 commented 4 years ago

Yes followed your advice and got the result in Python shell, but its giving error in spyder. Why is it so? image

u-anurag commented 4 years ago

It should work equally well in Spyder. What is the error in Spyder?

Sadia328 commented 4 years ago

This is the error. image

u-anurag commented 4 years ago

It works without any error for me. Make sure you have installed the Spyder in the same virtual environment as OpenSeesPy. I ran the example script as it is.

image

Sadia328 commented 4 years ago

Now it's working actually the problem was with graphics, So from preference>ipython console>graphics> I assigned graphics backend as automatic. Then it started working fine

On Wed, Sep 16, 2020, 6:38 PM Anurag Upadhyay notifications@github.com wrote:

It works without any error for me. Make sure you have installed the Spyder in the same virtual environment as OpenSeesPy. I ran the example script as it is.

[image: image] https://user-images.githubusercontent.com/35711550/93344870-6ad7e680-f7ef-11ea-80fd-c8a9ecb366f8.png

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/zhuminjie/OpenSeesPyDoc/issues/202#issuecomment-693410896, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQ5EZPEXVMRJNIFWLWUAT4LSGC5TVANCNFSM4RERLFOQ .