sewkokot / opsvis Goto Github PK
View Code? Open in Web Editor NEWOpenSeesPy postprocessing and plotting module
License: GNU General Public License v3.0
OpenSeesPy postprocessing and plotting module
License: GNU General Public License v3.0
The license according to LICENSE
is GPL-3.0, but in setup.cfg
it says the license is MIT.
Hello, in the example "demo_cantilever_3el_3d.py" I tried to replace the elasticBeamColumn elements with the 3D ElasticTimoshenkoBeam element just for check it, but the command opsv.plot_model() did not work for this 3D element.
I just modified in the code:
ops.element('ElasticTimoshenkoBeam', 1, 1, 2, E, G, A, J, Iy, Iz, A, A, gTTagz)
ops.element('ElasticTimoshenkoBeam', 2, 2, 3, E, G, A, J, Iy, Iz, A, A, gTTagx)
ops.element('ElasticTimoshenkoBeam', 3, 3, 4, E, G, A, J, Iy, Iz, A, A, gTTagy)
Run in VSCode
Python 3.9.13
Openseespy 3.4.0.5
Opsvis 1.0.21
demo_cantilever_3el_3d.zip
when apply one beamUniform eleload to a 3D element like this:ops.eleLoad('-ele', 1, '-type', '-beamUniform', -200,0,0),the .section_force_diagram_3d('My', sfacM) is right ;but when i apply two beamUniform eleload to one 3D element like this:ops.eleLoad('-ele', 1, '-type', '-beamUniform', -200,0,0),ops.eleLoad('-ele', 1, '-type', '-beamUniform', -200,0,0),the .section_force_diagram_3d('My', sfacM) will be wrong. i found the problem is when you calculate the j node force from i node force,you You only considered the last uniform load, thanks for help to solve this issue
I am getting the following error with the example provided at https://opsvis.readthedocs.io/en/latest/ex_plot_fiber_section.html could anyone help me out?
File ~.conda\envs\py39\lib\site-packages\opsvis\fibsec.py:129 in plot_fiber_section
poly = Polygon(zy, True, ec='k', fc=matcolor[matTag-1])
TypeError: init() takes 2 positional arguments but 3 were given
The opsvis.plot_defo
function breaks when it encounter an ElasticTimoshenkoBeam element, while everything works fine when the ElasticBeamColumn element is used.
I attach the traceback.
opsvis.plot_defo()
File "venv/lib/python3.9/site-packages/opsvis/opsvis.py", line 1988, in plot_defo
_plot_defo_mode_3d(0, sfac, nep, unDefoFlag, fmt_defo, fmt_undefo,
File "venv/lib/python3.9/site-packages/opsvis/opsvis.py", line 1527, in _plot_defo_mode_3d
xcd, ycd, zcd = beam_defo_interp_3d(ex, ey, ez, g,
File "venv/lib/python3.9/site-packages/opsvis/opsvis.py", line 2539, in beam_defo_interp_3d
ul = G @ u
ValueError: matmul: Input operand 1 has a mismatch in its core dimension 0, with gufunc signature (n?,k),(k,m?)->(n?,m?) (size 12 is different from 9)
Hi @sewkokot ! Thanks as ever for the great work. I have a few suggestions:
ax
argument to every function so that it plots to an existing axes, if supplied?Looking forward to contributing!
Running into a crash in this section:
Line 474 in 04c12f7
m_type
that is for some support that is neither pin nor fixed and it crashes. Thanks!Hi @sewkokot !
Thank you for creating and maintaining this module. It has been a tremendous help in my projects.
I have an idea to enhance the interactivity of the module. Including an option (an optional feature similar to toggling the visibility of axes) that displays insights about the model when users hover over nodes and elements would be beneficial. I have recently developed a script that achieves this and can be seamlessly integrated into opsvis; it takes Matplotlib's Axes (ax) as an argument. This script utilizes a JSON file from printModel
function to obtain information on the model's geometry (nodes and elements). In addition, users can add custom texts to any nodes or elements.
What do you think about this feature? I am happy to provide the code and assist with the integration.
Best regards,
Ajaya Khatri
Hi, it seems that the current version of opsvis(1.0.2) called an unknown attribute 'getNDM' from openseespy?
I had the error when i run 'opsv.plot_defo()'.
May you can fix it.
Thanks so much.
plot_supports_and_loads_2d()
load arrows do not behave as expected when the dimensions of the model are large, which occurs when inch or mm units are used. Specifically, there are two issues:
sfac
is appropriate.sfac
does not seem to be in-scale.The following model is used an example to illustrate the issues. The member lengths are defined in millimeters, so dimensions are on the order of 10^4. Similar issues exist when inch units are used, which would lead to dimensions on the order of 10^3.
sfac
, the arrowheads are practically invisible:sfac
, then length of the arrows become much larger than the size of the model.However, when I redefine the member lengths in meters, neither of these issues appear.
Hi @sewkokot !
I'm using opsvis
as the back end visualization for https://github.com/ccaprani/ospgrid . A grid is a plane 3D structure, and some grids only experience joint rotation without translation, e.g.:
Manually setting the scale to 1000 gives the very nice:
However, the automatic scale finding only parses joint translations, and so without manually setting the scale factor we end up with an inf
scale factor. It seems that the automatic scale factor calculation in
Line 1897 in 864e637
Line 1512 in 864e637
Anyway, MWE using ospgrid
you can run:
import ospgrid as ospg
import ospvis as ospv
gs = "AY-5:0,BN0:0,CY5:0,DF0:-5,EF0:5_B0:-50:0_AB,BC,DB,BE"
grid = ospg.make_grid(gs)
grid.analyze()
ospv.plot_defo(sfac=False, endDispFlag=1)
I'm happy to give this a go, but since it's going to bash around your code architecture to solve, I'd prefer to ask your thoughts first.
This error happens when using big material tag numbers that are larger than the size of matcolor list.
Sometimes using this kind of tags (101, 102 …) is useful for recognizing materials, elements, sections …etc. However, the matcolor list could not be that long, obviously, which lead to this error.
This is a small example.
import matplotlib.pyplot as plt
import opsvis
matTag = 101
fiber_section_ = [
['section', 'Fiber', 1, '-GJ', 1e9],
["patch", 'rect', matTag, 2, 10, *[-200, -300] , *[200, 300]],
]
matcolor = ['c',]
opsvis.plot_fiber_section(fiber_section_, matcolor=matcolor)
plt.axis('equal')
plt.show()
error when build 3dmodel use ElasticTimoshenkoBeam ,
the error is:
IndexError: index 0 is out of bounds for axis 1 with size 0 ,ax.quiver(xt, yt, zt, g[0, 0], g[0, 1], g[0, 2], color='g',
model example is:
import openseespy.opensees as ops
import opsvis as opsv
import matplotlib.pyplot as plt
ops.wipe()
ops.model('basic', '-ndm', 3, '-ndf', 6)
b = 0.2
h = 0.4
A, Iz, Iy, J = 0.04, 0.0010667, 0.0002667, 0.01172
Avy=0.002
Avz=0.002
E = 25.0e6
G = 9615384.6
Lx, Ly, Lz = 4., 4., 4.
ops.node(1, 0., 0., 0.)
ops.node(2, 0., 0., Lz)
ops.node(3, Lx, 0., Lz)
ops.node(4, Lx, Ly, Lz)
ops.fix(1, 1, 1, 1, 1, 1, 1)
lmass = 200.
ops.mass(2, lmass, lmass, lmass, 0.001, 0.001, 0.001)
ops.mass(3, lmass, lmass, lmass, 0.001, 0.001, 0.001)
ops.mass(4, lmass, lmass, lmass, 0.001, 0.001, 0.001)
gTTagz = 1
gTTagx = 2
gTTagy = 3
coordTransf = 'Linear'
ops.geomTransf(coordTransf, gTTagz, 0., -1., 0.)
ops.geomTransf(coordTransf, gTTagx, 0., -1., 0.)
ops.geomTransf(coordTransf, gTTagy, 1., 0., 0.)
ops.element('ElasticTimoshenkoBeam', 1, 1, 2, E, G, A, J, Iy, Iz,Avy,Avz,gTTagz)
ops.element('ElasticTimoshenkoBeam', 2, 2, 3, E, G, A, J, Iy, Iz,Avy,Avz,gTTagx)
ops.element('ElasticTimoshenkoBeam', 3, 3, 4, E, G, A, J, Iy, Iz,Avy,Avz,gTTagy)
Ew = {}
Px = -4.e1
Py = -2.5e1
Pz = -3.e1
ops.timeSeries('Constant', 1)
ops.pattern('Plain', 1, 1)
ops.load(4, Px, Py, Pz, 0., 0., 0.)
ops.constraints('Transformation')
ops.numberer('RCM')
ops.system('BandGeneral')
ops.test('NormDispIncr', 1.0e-6, 6, 2)
ops.algorithm('Linear')
ops.integrator('LoadControl', 1)
ops.analysis('Static')
ops.analyze(1)
sfacN = 1.e-2
sfacVy = 5.e-2
sfacVz = 1.e-2
sfacMy = 1.e-2
sfacMz = 1.e-2
sfacT = 1.e-2
opsv.section_force_diagram_3d('N', sfacN)
plt.title('Axial force N')
opsv.section_force_diagram_3d('Vy', sfacVy)
plt.title('Transverse force Vy')
opsv.section_force_diagram_3d('Vz', sfacVz)
plt.title('Transverse force Vz')
opsv.section_force_diagram_3d('My', sfacMy)
plt.title('Bending moments My')
opsv.section_force_diagram_3d('Mz', sfacMz)
plt.title('Bending moments Mz')
opsv.section_force_diagram_3d('T', sfacT)
plt.title('Torsional moment T')
Hello,
I am trying to model soil continuum using quad element in Openseespy. I plotted the stress contour plot using the sig_out_per_node() function. I have two questions regarding this function.
In Advance, I am really grateful for your help!
i am getting some errors with plotting with vfo and more
AttributeError: module 'vfo.internal_plotting_functions' has no attribute '_getAxisInfo'
Certain plot customizations are much more difficult or practically impossible without access to the figure (fig
) and axis (ax
) objects. Using matplotlib
's gcf()
and gca()
is possible, but relying on these limits how opsvis
output can be used within a larger context.
Can the fig
and ax
objects be returned with each of the plot functions? I understand that there may be a major rewrite that's about to be pushed; otherwise I would create a PR to return these objects.
The current code does not support ElasticTimoshenkoBeam.
In fact this element does not satisfy the if
clause at https://github.com/sewkokot/opsvis/blob/master/src/opsvis/opsvis.py#L558.
Is it planned to add support to it?
The current plot_model
function calls on two functions from OpenSeesPY
that do not exist. Can you please see to this?
The non-existent functions are:
ops.getNDM()[0]
ops.getFixedNodes()
Can you update these functions to reflect the current updates on OpenSeesPy
.
@sewkokot It appears zero length elements are not included in the plot_defo() function. Is this correct? I can do a PR to add the functionality, or this may be something you plan for the next release? Let me know what you think!
Please guide me with this error!!!
I face this error when using: "opsv.plot_model()"
"UnboundLocalError: local variable 'm_type' referenced before assignment"
the code line that I used:
"opsv.plot_model(node_labels=1,element_labels=0,node_supports=True,fig_wi_he=(40,15),fmt_model=
{'color': [0.5,0.5,0.5],'linestyle':'solid','linewidth':1.2,'marker':'.','markersize':5})"
Thank you for your time.
Hello,
I faced an error when I have a file called model.py on my current working directory when I am using opsvis. While this is easily fixed (I changed my OpenSees model name to modelPy.py), is there a chance that model.py import in the package to be replaced with something like modelOpsvis or more esoteric name to prevent the chance of import conflict? I understand that this is inevitable because the list of possible English word to be used for model naming is limited, but model.py is a quite common filename.
Hi there,
I could not plot the mode shapes of my model with zero length elements. That's why, I added an if statement to the function to exclude zerolenght elements. Please advise if that is a proper solution. If so please update the ops_vis module.
Thanks
if statement -> if not ((ex[1] - ex[0]) == 0 and (ey[1] - ey[0]) == 0 and (ez[1] - ez[0]) == 0):
`ValueError: matmul: Input operand 1 has a mismatch in its core dimension 0, with gufunc signature (n?,k),(k,m?)->(n?,m?) (size 12 is different from 9)
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
C:\Users\----\AppData\Local\Temp/ipykernel_14848/1451441718.py in <module>
14 for mode in modes:
15 # opsv.plot_mode_shape(int(mode), sfac, 19, fmt_interp='b-', az_el=(0, 90), fig_wi_he=fig_wi_he, endDispFlag=0)
---> 16 opsv.plot_mode_shape(int(mode), sfac, 19, fmt_interp='r--', fig_wi_he=fig_wi_he, endDispFlag=0)
17 # opsv.plot_mode_shape(int(mode), sfac, 19, fmt_interp='r--', fmt_undefo = dict(color='gray', linestyle='solid'), fig_wi_he=fig_wi_he, endDispFlag=0)
18 plt.axis('off')
~\anaconda3\lib\site-packages\openseespy\postprocessing\ops_vis.py in plot_mode_shape(modeNo, sfac, nep, unDefoFlag, fmt_undefo, interpFlag, endDispFlag, fmt_interp, fmt_nodes, Eo, az_el, fig_wi_he, fig_lbrt)
2090 sfac = ratio * dlmax/edmax
2091
-> 2092 _plot_defo_mode_3d(modeNo, sfac, nep, unDefoFlag, fmt_undefo,
2093 interpFlag, endDispFlag, fmt_interp, fmt_nodes,
2094 az_el, fig_wi_he, fig_lbrt)
~\anaconda3\lib\site-packages\openseespy\postprocessing\ops_vis.py in _plot_defo_mode_3d(modeNo, sfac, nep, unDefoFlag, fmt_undefo, interpFlag, endDispFlag, fmt_interp, fmt_nodes, az_el, fig_wi_he, fig_lbrt)
1289 # interpolated displacement field
1290 if interpFlag:
-> 1291 xcd, ycd, zcd = beam_defo_interp_3d(ex, ey, ez, g,
1292 ed, sfac, nep)
1293 ax.plot(xcd, ycd, zcd, fmt_interp)
~\anaconda3\lib\site-packages\openseespy\postprocessing\ops_vis.py in beam_defo_interp_3d(ex, ey, ez, g, u, sfac, nep)
2187 """
2188 G, L = rot_transf_3d(ex, ey, ez, g)
-> 2189 ul = G @ u
2190
2191 _, crd_yc = beam_defo_interp_2d(np.array([0., L]),
ValueError: matmul: Input operand 1 has a mismatch in its core dimension 0, with gufunc signature (n?,k),(k,m?)->(n?,m?) (size 12 is different from 9)`
hello, sir
it seems when a model is constructed with both elasticBeamColumn element and truss element, there is some problem when plot the mode shape, as shown by the following snaphsot:
the eigen vector has 6 elements, but is assigned to a vector with 3 position.
Is it ok to make the situation compatible? thanks
Hello everyone;
I want to show stress some quad elements. sig_out_per_node() takes account all elements. But I want to take just some elements.
For example:
In opsvis web site, there is an example "Plot stress distribution of a plane stress quad model" . There are 25 node and 16 element in this example. sxx, syy or sxy values are seen in figures for all 16 elements. But I want to just upper two rows, the most critical elements (elements:3,7,11,15; 4,8,12,16 )
Can I do this like bellow?
ele_tags=[3,7,11,15, 4,8,12,16]
sig_out_per_node(ele_tags )
Thanks for your atentions.
Dear Dr. Kokot,
I think there is a problem with the order of (y, z) coordinates in the Wedge instantiation for the 'circ' patch visualization.
Thank you.
The plot_loads_2d function shows the proper direction of loads of negative magnitude, but the label still shows a negative value, implying a possible "double negative" interpretation, e.g., the -18.893 downward load shown below. My suggestion is to use abs() on the numbers after flipping the load arrows.
It appears the plot_defo will kick back an error "element not supported yet". Other plots (section_force_diagram_2d) seem to just silently plot the frame but no results are superimposed.
Appreciate your efforts -- having a lot of fun playing with what Opsvis can do!
Hello sir,
As indicated in the title, the circular fiber commands used in plot_fiber_section
are not accounted in the fib_sec_list_to_cmds
function, both with patch
and layer
type. So if I use the circular patch command to create a fiber section, it won't be created if I use fib_sec_list_to_cmds
to do the work. It will lead to some unexpected results and the user can't notice it.
And for integrity, maybe a single fiber
command should also be considered.
Hello,
the example "Animation of dynamic analysis and mode shapes of a 2d Portal Frame", when run doesn't plot any graphs.
Run in sypder
Python = 3.9
Openseespy = 3.4.0.2
Opsvis = 1.0.20
Hi,
I tried to use 'plot_supports_and_loads_2d()' and I got this problem when I ran the example 2d Portal Frame from https://opsvis.readthedocs.io/en/latest/ex_2d_portal_frame.html. Here is the comparison of the fig from opsvis’s documentation and my result.
The support at the left bottom should be a square (see the green arrows). I think the problem is caused by the following lines.
opsvis/docs/src/opsvis/opsvis.py
Lines 3828 to 3839 in 5a830ec
It appears plot_model_2d checks number of element nodes (nen) to determine what to plot, but plot_model_3d checks specific element types instead of nen, so, for example ShellMITC4 elements are not plotted in 3d.
Hi there,
Thanks for the recent update. I was wondering if you could include a couple of options in plot_model function.
Now I tried very simple structural analysis which has only single element.
The element has uniformed load and point load which is apllied at the center of the element.
Setting of loads shows below.
And after analysis, I got these plots of force distribution by opsvis module.
I think these plots look like a little bit strange.
The element has uniformed load, therefore the distribusion of shear force must have some gradient.
Moreover the moment at node 2 must be nearly equal of zero because node 2 is free to rotate.
The values of element's force gotten by openseespy.opensees.eleFroce(1) shows below.
[0.0, 0.9999999999999999, -5.551115123125783e-17, 0.0, 1.0, -2.7755575615628914e-17]
The opsvis module seem to display values different from result of analysis.
Actually I think the analysis itself goes well because the values gotten by openseespy module are correct with theory.
Is this any bug in opsvis module? Or did I get it a wrong way to use this module?
plot_defo_2d
assumes ndf=3 and thus fails on this MWE
import openseespy.opensees as ops
import opsvis as opsv
B = 1.0
ops.wipe()
ops.model('basic','-ndm',2,'-ndf',2)
ops.node(1,0,0); ops.fix(1,0,1)
ops.node(2,B,0); ops.fix(2,0,1)
ops.node(3,0,B)
ops.node(4,B,B)
ops.node(5,0,2*B)
ops.node(6,B,2*B)
ops.nDMaterial('ElasticIsotropic',1,4000,0.4,0.01)
ops.element('quad',1,1,2,4,3,1.0,'PlaneStrain',1)
ops.element('quad',2,3,4,6,5,1.0,'PlaneStrain',1)
ops.node(0,0,0); ops.fix(0,1,1)
ops.uniaxialMaterial('Elastic',1,0.0,100)
ops.element('zeroLength',0,0,1,'-mat',1,'-dir',1)
ops.timeSeries('Constant',1)
ops.pattern('Plain',1,1)
ops.load(5,0.1,-1.0)
ops.load(6,0,-1.0)
ops.analysis('Transient','-noWarnings')
ops.analyze(1,0.01)
opsv.plot_model()
opsv.plot_defo()
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.