Giter Club home page Giter Club logo

opsvis's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

opsvis's Issues

License clarification

The license according to LICENSE is GPL-3.0, but in setup.cfg it says the license is MIT.

Example "demo_cantilever_3el_3d.py" with ElasticTimoshenkoBeam element

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

apply beamUniform eleload to a 3D element twice, the plot will be wrong

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

interpFlag not active?

Working on a column buckling model--two frame elements and some zero length springs. With the default interpFlag=1
image
With interpFlag=0 to remove the cubic interpolation, there is no displaced shape at all
image

Error while plotting deformation for ElasticTimoshenkoBeam elements

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)

Suggestions...

Hi @sewkokot ! Thanks as ever for the great work. I have a few suggestions:

  • At a high level, is there a roadmap that contributors could pull tasks off to work on?
  • Would there be a benefit in making it more OO? I'm on the fence on this one...
    • Pro: might be easier to set module-wide preferences for all plots, for example.
    • Con: works fine as it is!
  • Would you mind having an ax argument to every function so that it plots to an existing axes, if supplied?
  • What other tweaks/changes are you envisioning?

Looking forward to contributing!

Default marker type for non-standard supports in 3D

Running into a crash in this section:

elif ndim == 3:
For grids (and other structures), there are often some supports that are arbitrary restraints of DOFs and not just "fixed" or "pinned". The code in here has no default for 3D structures for m_type that is for some support that is neither pin nor fixed and it crashes. Thanks!

Idea: Adding interactivity to show model insights on hover

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.

demo

Best regards,
Ajaya Khatri

[Bug] Load arrows from plot_supports_and_loads_2d() not behaving for large model dimensions

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:

  1. The arrowheads are deformed/practically not visible, regardless of whether the scaling factor sfac is appropriate.
  2. The auto-calculated 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.
Model

  1. Even if I set a manual sfac, the arrowheads are practically invisible:
    Arrowhead
  2. If I let the function auto-calculate sfac, then length of the arrows become much larger than the size of the model.
    sfac issue

However, when I redefine the member lengths in meters, neither of these issues appear.
Small dims

Edge case in plotting deformations

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.:
image

Manually setting the scale to 1000 gives the very nice:
image

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

def plot_defo(sfac=False, nep=17, unDefoFlag=1, fmt_defo=fmt_defo,
should actually parse the member interpolated displacements too. If the code in the loop starting
for i, ele_tag in enumerate(ele_tags):
was extracted to a function, this might work easily.

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.

"list index out of range" error when using big material tag numbers

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 to plot result

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., 3., 5.

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

plt.figure()

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')

Rendering with only nodes, no elements

I think it's an easy fix for cases where there are only nodes and no elements

ops.node(1,0,-h/2)
ops.node(2,0,h/2)
ops.node(3,L,h/2)
ops.node(4,L,-h/2)

opsv.plot_model(node_labels=True)

image

sig_out_per_node() Function

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.

  1. Does this function use all four guass points in each element to represent the contours?
  2. Is there any function to plot the displacement or strain contours like this?

In Advance, I am really grateful for your help!

Plotting errors

i am getting some errors with plotting with vfo and more
AttributeError: module 'vfo.internal_plotting_functions' has no attribute '_getAxisInfo'

[Feature request] Return figure and axes objects for each plot function

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.

UnboundLocalError

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.

Error when there is file called 'model.py' on the same folder

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.

Plot mode shape error in ops_vis module

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)`

plot_mode_shape of model with both elasticElement and truss element

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

image

sig_out_per_node()

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.

image

Show load as magnitude because the direction is already shown

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.

image

Elastic Beam Column Timoshenko elements not (yet) supported

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!

circular patch fiber section not included in the fib_sec_list_to_cmds function

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.

Problem when plotting the supports

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.
comparison
The support at the left bottom should be a square (see the green arrows). I think the problem is caused by the following lines.

if ndim < 3:
if node_dofs[0] == -1 and node_dofs[1] == -1:
marker_type = '^m'
elif node_dofs[0] == -1 or node_dofs[1] == -1:
marker_type = 'om'
else:
if node_dofs[0] == -1 and node_dofs[1] == -1 and node_dofs[2] == -1:
marker_type = 'sm'
elif node_dofs[0] == -1 and node_dofs[1] == -1:
marker_type = '^m'
elif node_dofs[0] == -1 or node_dofs[1] == -1:
marker_type = 'om'

In this case, 'ndim' is 2 so both fixed and pinned nodes will be the triangle. I think these lines can't fit the needs of both 1 and 2 dimension cases correctly. It will be helpful if you can rewrite this part (or activate 'alternative plot of supports'). Thanks!

Request: improving plot_model function

Hi there,

Thanks for the recent update. I was wondering if you could include a couple of options in plot_model function.

  1. An option to remove all the nodes or elements from 2D or 3D plot (not node or element labels) to see just nodes or elements in the model.
  2. An option for a section cut (2D elevation view - e.g. X=0m, Y=all, Z=all) in 3D model.

Question of Simple 2D Analysis

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.
load

And after analysis, I got these plots of force distribution by opsvis module.
shear
moment

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?

test2D.zip

plot_defo - assumes zero length and two node link elements have ndf=3

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()

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.