Code Monkey home page Code Monkey logo

trusspy's Introduction

Truss Solver for Python.

PyPI version shields.io Binder Open In Colab Documentation Status License: GPL v3 Made with love in Graz (Austria) codecov DOI Codestyle black

TrussPy is a 3D Truss-Solver written in Py-thon which is capable of material and geometric nonlinearities. It uses an object-oriented approach to structure the code in meaningful classes, attributes and methods. TrussPy contains both multistep functionality (multiple loadcase analysis with sequenced external forces) and an adaptive method to control incremental stepwidths. A simple post-processing inside TrussPy is directly available via Matplotlib. Model Plots whether in undeformed or deformed configuration with optional contour plots on element forces are easy to show. They may also be generated for a series of increments and saved as a GIF Movie. Last but not least History (a.k.a. x-y) Plots for a series of increments or Path Plots along a given node path may be generated for nodal properties (displacements, forces) or global quantities like the Load-Proportionality-Factor (LPF).

Official Documentation: http://trusspy.readthedocs.io/

Installation

Use pip to install TrussPy

pip install trusspy

Example

import trusspy as tp

M = tp.Model()

# create nodes
with M.Nodes as MN:
    MN.add_node(1, (0, 0, 0))
    MN.add_node(2, (1, 0, 0))

# create element
with M.Elements as ME:
    ME.add_element(1, [1, 2])
    ME.assign_material("all", [1])
    ME.assign_geometry("all", [1])

# create displacement (U) boundary conditions
with M.Boundaries as MB:
    MB.add_bound_U(1, (0, 0, 0))
    MB.add_bound_U(2, (1, 0, 0))

# create external forces
with M.ExtForces as MF:
    MF.add_force(2, (1, 0, 0))

# build model, run, show results
M.build()
M.run()

# plot results of last increment
M.plot_model(inc=-1, contour="force")

Online Notebook

Try TrussPy without installation in an Interactive Online Notebook.

Changelog

All notable changes to this project will be documented in this file. The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.

License

TrussPy - Truss Solver for Python (C) 2023 Andreas Dutzler, Graz (Austria).

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.

trusspy's People

Contributors

adtzlr avatar fran-retfie avatar

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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

trusspy's Issues

The keyword `fps` is no longer supported. Use `duration`(in ms) instead

Output exceeds the size limit. Open the full output data in a text editor---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[40], line 2
1 # show results
----> 2 M.plot_movie(
3 config=["deformed"],
4 view="xz",
5 contour="force",
6 lim_scale=(-0.5, 3.5, -2, 2),
7 force_scale=1.0,
8 cbar_limits=[-1, 1],
9 )

File [~(removedforprivacy)....site-packages/trusspy/model.py:712), in Model.plot_movie(self, config, view, contour, lim_scale, force_scale, nodesize, cbar_limits, incs)
701 def plot_movie(
702 self,
703 config="both",
(...)
710 incs="all",
711 ):
--> 712 p_movie(
713 self,
714 config,
715 view,
716 contour,
...
326 save_args = {
327 "format": format or Image.registered_extensions()[extension],
328 }

TypeError: The keyword fps is no longer supported. Use duration(in ms) instead, e.g. fps=50 == duration=20 (1000 * 1/50).

`plot_model()` raises `ValueError`

due to missing a ax argument in plt.colorbar():

ValueError: Unable to determine Axes to steal space for Colorbar. 
Either provide the *cax* argument to use as the Axes for the Colorbar, 
provide the *ax* argument to steal space from it, or add *mappable* to an Axes.

(Python 3.10, Win10)

Proper dimension switch 2D/3D

For now only 3D-input is possible but quite anything is prepared for 2D mode. replace all static "3" to self.ndim to get dynamic analyis dimension.

Reduce "side-effects" in functions

During function calls, several class Attributes are updated. Therefore some function definitions have "side-effects" to the model. They may generate Errors which are hard to debug.

No arrows in 3D view

As matplotlib provides no arrows in 3D mode by default, trusspy can't display arrows for force and coordinate vectors.

Simplify `Model.plot_model()`

  • remove the config argument (undeformed configuration should be shown for inc=0)
  • don't allow force_scale=None (must be float)

A0 and E0

Hi, I'd be grateful if you could help me figure out how should I assign A0 and E0, and generally, all variables which have been defined relatively when I use the excel sheet as inputs. Regards,
truss1.xlsx

Docs are broken

The documentation is currently offline due to a rename of the default branch.

New docs will be deployed on readthedocs soon.

  • Re-upload to readthedocs
  • Re-add apidoc

[Python] Usage of __slots__ or @dataclass(slots=True) in python classes for reducing memory usage and performance improvement

I saw the Pycon 2016 talk from Nina Zakharenko about Memory Management in Python and at the 21:19 min, she introduced the dunker slots attribute to define the attributes. Because with that, you can't assign at runtime new attributes to the class instance. This reduces the memory usage and improves performance.

To reduce boilerplate, there is also the possibility to use @dataclass(slots=True) as shown in this video, see also the python documentation → https://docs.python.org/3.10/library/dataclasses.html

Plot supports based on boundary conditions

Add an option to draw supports (roller, pinned) inside the model plot. As TrussPy is 3D-based this seems a quite complicated task: Which symbols should be used? The Classic symbols in each direction? Which plane should be used to draw the symbols? Is it possible that the 2D plots are still projections of the 3D scene or are special considerations based on 2D/3D needed?

No such file or directory: 'pandoc'

Python version: 3.11
Trusspy Version: trusspy 20221217

I got error below while running https://github.com/adtzlr/trusspy/tree/master/tests/eADV_A_model_python.py

FileNotFoundError Traceback (most recent call last)
File /opt/homebrew/lib/python3.11/site-packages/trusspy/model.py:418, in Model.run(self)
416 if self.logfile:
417 sys.stdout = self.stdout
--> 418 sp_run(['pandoc', self.logfile_name+'.md', '-t', 'latex', '-o', self.logfile_name+'.pdf'])
419 if self.Settings.logpdf: sp_run(['pandoc', self.logfile_name+'.md', '-t', 'html', '-s', '-o', self.logfile_name+'.html'])
File /opt/homebrew/Cellar/python@3.11/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/subprocess.py:548, in run(input, capture_output, timeout, check, *popenargs, **kwargs)
545 kwargs['stdout'] = PIPE
...
1900 err_msg = os.strerror(errno_num)
-> 1901 raise child_exception_type(errno_num, err_msg, err_filename)
1902 raise child_exception_type(err_msg)
FileNotFoundError: [Errno 2] No such file or directory: 'pandoc'

Was wondering how to solve it. Any suggestion would be appreciated. Thank you so much!

where are element and node forces stored in the simulation?

Hi! I was easily managing to get trusspy running on linux - thanks a lot :) I'm trying to simulate some pretty simple static structures and I want to read out the individual element and reaction forces. I looked into a few of the object's properties - however the complexity of the data structure was a bit overwhelming and didn't find the forces :)

could you give me a hint where to look for the reaction forces for each node and the forces inside each element?

Martin

Example not working

Hi, I was interested in using this library. However, when I tried running the example, an error showing 'Model' object has no attribute 'External Forces'

plot movie (gif): wrong frame ordering on binder

The png's seem to be unordered if example 101 is executed on binder. On my local machine (Windows) everything is ok. Probably binder is running on Linux and files are sorted differently there. It is assumed that the gif generation is also broken if TrussPy is executed locally on a Linux machine.

[Question] Which units should be used?

Which units should be used for:

  • Length: m ?
  • Area: m² ?
  • Force: kN ?
  • E-modulus: kN/m² ?
  • Degree: rad ?

So what units should the numbers I write in the functions have?

Setup GitHub Actions

Preliminary Work

  • Run tests with tox

Tasks

  • Automate publish on PyPI if a release is created
  • Run tests and use codecov.io (needs preliminary tasks)

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.