Git Product home page Git Product logo

Comments (33)

cslotboom avatar cslotboom commented on May 26, 2024 2

Sounds good, lets continue the discussion there.

from openseespy.

zhuminjie avatar zhuminjie commented on May 26, 2024 1

Just let you guys know I change the name of the repo, try to put related things in one place.

Hopefully, it does not affect anything.

@u-anurag @gaaraujo @siwalan @sewkokot

from openseespy.

gaaraujo avatar gaaraujo commented on May 26, 2024

Hello @u-anurag,
Yes, I am really interested in collaborating. My comments:

  1. Yes. I think the recordNodeDisp() function that I added should become a recordPlot() function that saves all the inputs for the other functions. That way the user just have to call it before running the analysis and we control the format.

  2. In the particular case of plot_eleforces, I am thinking of axial force, shear and moment diagrams for beam-columns. For shells and solids, a colored contour plot for stresses or strains would be nice.

  3. We are not in a hurry. Let us take our time to do something good, simple and user-friendly.

from openseespy.

siwalan avatar siwalan commented on May 26, 2024

Just wondering, what kind of plotting library will be used for the development of OpenSeesPy plotting function? I think we must decide on what kind of plotting library that should be used.

I just recently discovered Altair Plotting library, which I found to be more pleasant compared to the ubiquitous matplotlib. It also have the benefit of interactivity (at least when you use Jupyter).

I suggest that future development of the project should consider the usage of Altair, or any other plotting library instead of just using matplotlib.

Cheers

from openseespy.

u-anurag avatar u-anurag commented on May 26, 2024

@gaaraujo No hurries!
@siwalan Let's stick to Matplotlib so we don't have to install additional libraries.

from openseespy.

siwalan avatar siwalan commented on May 26, 2024

Touché, using matplotlib would mean less pip install for most people.

I think I can help with the stress-strain diagram, since I have several experiences in automatically generating σ-ε diagram few months ago. Although I must embarrassingly admit, that I never used opensessPy, I only used the .tcl OG OpenSees so I think I need to do quick orientation first before I can start contributing.

Cheers.

from openseespy.

u-anurag avatar u-anurag commented on May 26, 2024

@siwalan that is great! Since the plotting commands will read the data from an output file, you don't need to worry about learning openseespy to start plotting. The recorders work the same way in both OpenSees Tcl and Py. You can use recorders in OpenSees Tcl and create stress-strain plot functions.

from openseespy.

sewkokot avatar sewkokot commented on May 26, 2024

Related to this discussion look at my PR:

#18

from openseespy.

siwalan avatar siwalan commented on May 26, 2024

Anyway @u-anurag, If I remember correctly. Isn't the recorder only record the result? To create a diagram we going to need the original model data.

My previous method was to have the plotter read an excel file full of the model data and matching the recorder file output name with the model name column in the excel file, and get the rest of the model data. I am wondering how we can get the model data, assuming that the plotting functions takes a recorder result file and can exist outside the initial model-analysis script.

Cheers.

from openseespy.

gaaraujo avatar gaaraujo commented on May 26, 2024

Related to this discussion look at my PR:

#18

This is a very good starting point! We just need to set a format and make all the functions to be able to work together.

My thoughts are the following:

  1. I like how the current plot_model() function renders the model, specially for shells and solids. The interpolating function is nice. We could take that into the current function.
  2. If we ignore the beamPointLoad command, I think you can estimate the distributed load from the moments and shear forces at the element ends. If V forces are not equal to the sum of the moments divided by L, the difference in shear forces is w*L/2.

from openseespy.

gaaraujo avatar gaaraujo commented on May 26, 2024

Anyway @u-anurag, If I remember correctly. Isn't the recorder only record the result? To create a diagram we going to need the original model data.

My previous method was to have the plotter read an excel file full of the model data and matching the recorder file output name with the model name column in the excel file, and get the rest of the model data. I am wondering how we can get the model data, assuming that the plotting functions takes a recorder result file and can exist outside the initial model-analysis script.

Cheers.

I think our first iteration should rely on the fact that the user is running everything in the same script.

from openseespy.

sewkokot avatar sewkokot commented on May 26, 2024

For time history analysis, instead of using recorders and saving data to files and then reading it back for the purpose of plotting, we can collect subsequent deformation snapshots in a 3d Python array (can consume a lot of memory though) using the following loop:

...
t0 = 0.
tk = 1.

dt = 0.002
n_steps = int((tk-t0)/dt)

tsTag = 1
ops.timeSeries('Trig', tsTag, t0, tk, Tp, '-factor', P0)

patTag = 1
ops.pattern('Plain', patTag, tsTag)
ops.load(2, 1., 0., 0.)

ops.constraints('Transformation')
ops.numberer('RCM')
ops.test('NormDispIncr', 1.0e-6, 10, 1)
ops.algorithm('Linear')  # change this
ops.system('ProfileSPD')
ops.integrator('Newmark', 0.5, 0.25)
ops.analysis('Transient')

# a list of selected nodes and dof for plotting (can be skiped) 
node_dir_L = [[2, 0],
              [4, 0],
              [6, 1]]

n_dirs = len(node_dir_L)
el_tags = ops.getEleTags()
nel = len(el_tags)

# 3d array of deformation
Eds = np.zeros((n_steps, nel, 6))

u_Sel = np.zeros((n_dirs, n_steps))

timeV = np.zeros(n_steps)

# loop for transient analysis and collecting data
for step in range(n_steps):
    ops.analyze(1, dt)
    timeV[step] = ops.getTime()
    # collect displacements
    for j, node_dir in enumerate(node_dir_L):
        u_Sel[j, step] = ops.nodeDisp(node_dir[0])[node_dir[1]]
    # collect disp for element nodes
    for el_i, ele_tag in enumerate(el_tags):
        nd1, nd2 = ops.eleNodes(ele_tag)
        Eds[step, el_i, :] = np.array([ops.nodeDisp(nd1)[0],
                                       ops.nodeDisp(nd1)[1],
                                       ops.nodeDisp(nd1)[2],
                                       ops.nodeDisp(nd2)[0],
                                       ops.nodeDisp(nd2)[1],
                                       ops.nodeDisp(nd2)[2]])
...

from openseespy.

u-anurag avatar u-anurag commented on May 26, 2024

@sewkokot these are some really good functions. Is it possible to add these to the existing code? I have never run into memory or speed issues even while visualizing model with 2000 nodes.

The purpose of the plotting library should be to get all the output from OpenSees solver and just plot them. My thought is we shouldn't deal with calculating results (moment and shear) in the plotting library. If possible, we get these results from the solver and just plot them here. Interpolating in order to plot the output should be OK.

Recording results in a file would give the flexibility of plotting results of a parametric study when the output is saved as "Model1_ODB", "Model2_ODB" etc., without running the analysis again and again. Storing the output as Numpy arrays is fine for small models.

@gaaraujo I agree with you that we can incorporate these new functions to the existing library since people are already using it.

@siwalan plot_model() function has the model data (nodes and elements) that can be saved in a txt file in the same _ODB folder to read later.

from openseespy.

sewkokot avatar sewkokot commented on May 26, 2024

Is it possible to add these to the existing code?

@u-anurag, Yes, you can pick whatever functionality is useful.

For my part, with larger models I experienced that matplotlib (under Linux) can be slow, but it can depend on many factors.

from openseespy.

sewkokot avatar sewkokot commented on May 26, 2024

We can borrow ideas from https://github.com/CALFEM/calfem-python
Their license is MIT license, so it allows us "... to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute..."

In particular the following manual is of interest:

https://github.com/CALFEM/calfem-python/raw/master/manual-mesh-module.pdf

and explains why they pick gmsh and visvis libraries for meshing and visualization.

from openseespy.

u-anurag avatar u-anurag commented on May 26, 2024

@sewkokot Thank you for sharing the link. I'll take a look and discuss later.

from openseespy.

zhuminjie avatar zhuminjie commented on May 26, 2024

Great guys! It's wonderful to see the joined forces here. I agree that let's focus on matplotlib right now. People may be in a restricted system and matplotlib is the minimum we support for plotting.

from openseespy.

sewkokot avatar sewkokot commented on May 26, 2024

The purpose of the plotting library should be to get all the output from OpenSees solver and just plot them. My thought is we shouldn't deal with calculating results (moment and shear) in the plotting library. If possible, we get these results from the solver and just plot them here.

I agree, I can adapt the functions accordingly to do post-processing calculations only when necessary. From Opensees solver we get element local forces (N, V, M) at element ends, and if we want to plot the section forces distribution when element loads (-beamUniform in this case) are present we still have to calculate them. I imagine this feature as helpful for educational purposes for elastic beam column elements only. In the current implementation of ops_vis.py though, the section forces distribution in an element is calculated entirely from nodal displacements with the information on element loads (Wy, Wx). I can modify it to use element nodal local forces and uniform loads instead.

from openseespy.

u-anurag avatar u-anurag commented on May 26, 2024

if we want to plot the section forces distribution when element loads (-beamUniform in this case) are present we still have to calculate them.

Is this the distribution of forces at each section/integration point along the element length or distribution of force/stress in each fiber across a particular section? I agree that this is a really good feature for classroom teaching but calculating force distribution in python will not support any future version of OpenSees or existing (Tcl). Better to implement it in the solver. It should be fine to implement it temporarily but it is only for elastic beam-column elements. Any thoughts @zhuminjie?

The function plot_section() requires the fiber section to be defined in a specific way. I like this style better than the one used in OpenSeesPy since it clusters all the fiber definitions under the specific section tag. It is easy to understand the script. Changing the style may be good if we force users to adopt this style but it will have consequences for users with already working scripts. We could think of a way to get this information from the section definition (numFibers() or FiberSection::Print).

from openseespy.

sewkokot avatar sewkokot commented on May 26, 2024

Is this the distribution of forces at each section/integration point along the element length or distribution of force/stress in each fiber across a particular section?

These are section forces (N, V, M) distribution along an elastic beam. I updated the beam_sf_2d function to use only OpenSees commands. See the comment in the PR for details.

Sometimes first-year students ask me if OpenSees can draw section forces diagrams to check their manual calculations, so I find this feature useful for them.

from openseespy.

u-anurag avatar u-anurag commented on May 26, 2024

Yes, it is very useful for classroom teaching. Do you want to merge your code in the existing plotting library ("Get_Rendering") or keep it as a separate library?

from openseespy.

u-anurag avatar u-anurag commented on May 26, 2024

@gaaraujo @sewkokot @siwalan Let's add all the new code in this repo so we can all check it before merging it with the official. This will also save everyone's PRs to the official repo after merging.

https://github.com/u-anurag/openseespy-pip

from openseespy.

ccaprani avatar ccaprani commented on May 26, 2024

Would like to contribute a few patches, but (python+git) newbie question: I installed this repo in development mode (pip install -e <local path>) and I get the error No module named 'openseespy.opensees.win.opensees' I understand this is because of the separation of the OpenSees python interpreter from the OpenSeesPy-pip development, but how can I get a working development install? Thanks.

e.g. Line 525 of Get-Rendering.py needs the ndim specified for single static analysis:
nodeDispArray = np.loadtxt(filename, skiprows=0, ndmin=2)

from openseespy.

zhuminjie avatar zhuminjie commented on May 26, 2024

Can you open another issue for the installation?

from openseespy.

cslotboom avatar cslotboom commented on May 26, 2024

Hey, so following up on #33.

Before I port my function over the animations, it's probably a good idea to understand some of the guiding philosophy behind the OpenSeesPy plot functions. There are some differences between the existing functions and how I've implemented things that might make a straight port undesirable.

Something I think is worth getting into is when the user can call the plot functions. For example, the current functions only work if the OpenSeesPy model is active. We could get around this by saving a copy of the initial node positions and element connectivity.

Saving files is a little messy, but it would allow more flexibility for users.

In my functions, I have some functionality to save outputs about nodes/elements. My feeling is that while it's a little messy, saving data is are already necessary to plot model displacements. We'll likely have to deal with some file management in the future no matter what.

@u-anurag
By the way, as per your recommendation, I was able to implement a slider for the animation!

from openseespy.

u-anurag avatar u-anurag commented on May 26, 2024

@u-anurag
By the way, as per your recommendation, I was able to implement a slider for the animation!
That sounds great.

Yes, we should implement some kind of output folder with a unique name to save necessary files in a standardized output format (see the first post for an example). We should be able to keep the current functions (plot_model and plot_modeshape) that can plot without saving any output files if users don't want to go that route.

Saving an Output Database will enable users to plot the output anytime without running the model again, especially large models. Commands to read specific output data files from that folder and then visualize that output will be a great addition.

As you mentioned, saving files is messy. Especially, saving element connectivity data with the model is a mixture of beam-column elements and shell/brick etc.

Take your time in implementing animation with the existing functions. You should be able to use existing internal functions (https://openseespydoc.readthedocs.io/en/latest/src/Plotting_Development_Guide.html) in the animation loop.

from openseespy.

cslotboom avatar cslotboom commented on May 26, 2024

Okay, good to know, I am on board with that.
I also think it's a good idea to keep those functions, I'm on board there.

Saving an Output Database.

As in a OpenSees database object?

As you mentioned, saving files is messy. Especially, saving element connectivity data with the model is a mixture of beam-column elements and shell/brick etc.

Yeah, it's a little tricky. What I do right now is save separate files for each element type. I'm not sure if anyone could suggest a better way..

For example, for 4 node elements the data is saved in a csv as follows:

[ele1_tag, ele1_node1, ele1_node2, ... , ele1_node4]
[ele2_tag, ele2_node1, ele2_node2, ... , ele2_node4]
....
[eleN_tag, eleN_node1, eleN_node2, ... , eleN_node4]

Then internally, I read every everything to an list.
elements = [*elements2Node, *elements3Node, ... etc.]

The folder also has a node file:

[node1_tag, node1_x, node2_y]
...
[nodeN_tag, nodeN_x, nodeN_y]

Take your time in implementing animation with the existing functions. You should be able to use existing internal functions (https://openseespydoc.readthedocs.io/en/latest/src/Plotting_Development_Guide.html) in the animation loop.

The challenge is that I update the data of existing model objects to animate.
For example, for the node coordinates, there is an object saved called figNodes. Then when I animate, I just update the data of this object - we don't actually have to replot anything.

figNodes = ax.plot(x, y, **Style.node)
... Other code ...
figNodes.set_data_3d(CurrentNodeCoords[:,0], CurrentNodeCoords[:,1], CurrentNodeCoords[:,2])

How would you feel about returning plot objects with the internal model functions?

from openseespy.

u-anurag avatar u-anurag commented on May 26, 2024

What I do right now is save separate files for each element type. I'm not sure if anyone could
suggest a better way..

If we save node connectivity all the element types in the same file (.out), numpy.loadtxt will not work . We can use Pandas to read the data file with uneven rows, or read the .out file as text and store the data in arrays.

How would you feel about returning plot objects with the internal model functions?

That should work for animation.

from openseespy.

u-anurag avatar u-anurag commented on May 26, 2024

@cslotboom I have created a branch just to work on Plotting functions. Let's collaborate here so we can save Minjie some effort by creating fewer PRs to the main repo. I have invited you as a collaborator.

https://github.com/u-anurag/OpenSeesPy

from openseespy.

u-anurag avatar u-anurag commented on May 26, 2024

@gaaraujo I know that you had created an animation using the existing Get_Rendering library when you added plot_deformedshape() function. How did you handle it? If you are interested in adding/contributing, please take a look at this branch where we intend to add more functionality to the visualization library.
https://github.com/u-anurag/OpenSeesPy

from openseespy.

zhuminjie avatar zhuminjie commented on May 26, 2024

Do you still need this issue for discussion?

from openseespy.

u-anurag avatar u-anurag commented on May 26, 2024

We can close it. I'll put a link to this issue in the documentation for future developers.

from openseespy.

zhuminjie avatar zhuminjie commented on May 26, 2024

Sound great! @u-anurag

from openseespy.

Related Issues (20)

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.