Slientruss3d : Python for stable truss analysis tool

Overview

slientruss3d : Python for stable truss analysis tool

Python Version GitHub release

Desciption

slientruss3d is a python package which can solve the resistances, internal forces and joint dispalcements in a stable 2D or 3D truss by direct stiffness method.This repo is writen by :

Taiwan                                          (臺灣)
Department of Civil Engineering                 (土木工程學系)
National Yang Ming Chiao Tung University (NYCU) (國立陽明交通大學)
Shih-Chi Cheng                                  (鄭適其)

How to use ?

First, download the slientruss3d package:

pip install slientruss3d 

The following is one of the example codes in example.py. You could decide to either just type all the data about the truss in .py file or read the data in .json file by changing the value of variable IS_READ_FROM_JSON. You could switch the dimension of truss by changing the value of variable TRUSS_DIMENSION (Only can be 2 or 3).

from slientruss3d.truss import Truss, Member
from slientruss3d.type  import SupportType, MemberType
from slientruss3d.plot  import TrussPlotter


def TestExample():
    # -------------------- Global variables --------------------
    # Files settings:
    TEST_FILE_NUMBER        = 25
    TEST_LOAD_CASE          = 0
    TEST_INPUT_FILE         = f"./data/bar-{TEST_FILE_NUMBER}_input_{TEST_LOAD_CASE}.json"
    TEST_OUTPUT_FILE        = f"./data/bar-{TEST_FILE_NUMBER}_output_{TEST_LOAD_CASE}.json"
    TEST_PLOT_SAVE_PATH     = f"./plot/bar-{TEST_FILE_NUMBER}_plot_{TEST_LOAD_CASE}.png"

    # Some settings:
    TRUSS_DIMENSION         = 3
    IS_READ_FROM_JSON       = True
    IS_PLOT_TRUSS           = True
    IS_SAVE_PLOT            = True
    
    # Plot layout settings:
    IS_EQUAL_AXIS           = True   # Whether to use actual aspect ratio in the truss figure or not.
    MAX_SCALED_DISPLACEMENT = 15     # Scale the max value of all dimensions of displacements.
    MAX_SCALED_FORCE        = 50     # Scale the max value of all dimensions of force arrows.
    POINT_SIZE_SCALE_FACTOR = 1      # Scale the default size of joint point in the truss figure.
    ARROW_SIZE_SCALE_FACTOR = 1      # Scale the default size of force arrow in the truss figure.
    # ----------------------------------------------------------

    # Truss object:
    truss = Truss(dim=TRUSS_DIMENSION)

    # Read data in [.json] or in this [.py]:
    if IS_READ_FROM_JSON:
        truss.LoadFromJSON(TEST_INPUT_FILE)
    else:
        joints     = [(0, 0, 0), (36, 0, 0), (36, 18, 0), (0, 20, 0), (12, 10, 18)]
        supports   = [SupportType.PIN, SupportType.PIN, SupportType.PIN, SupportType.PIN, SupportType.NO]
        forces     = [(4, (0, -10000, 0))]
        members    = [(0, 4), (1, 4), (2, 4), (3, 4)]
        memberType = MemberType(1, 1e7, 1)
        
        for i, (joint, support) in enumerate(zip(joints, supports)):
            truss.AddNewJoint(i, joint, support)
            
        for i, force in forces:
            truss.AddExternalForce(i, force)
        
        for i, (jointID0, jointID1) in enumerate(members):
            truss.AddNewMember(i, jointID0, jointID1, Member(joints[jointID0], joints[jointID1], 3, memberType))

    # Do direct stiffness method:
    displace, internal, external = truss.Solve()

    # Dump all the structural analysis results into a .json file:
    truss.DumpIntoJSON(TEST_OUTPUT_FILE)

    # Show or save the structural analysis result figure:
    if IS_PLOT_TRUSS:
        TrussPlotter(truss,
                     isEqualAxis=IS_EQUAL_AXIS,
                     maxScaledDisplace=MAX_SCALED_DISPLACEMENT, 
                     maxScaledForce=MAX_SCALED_FORCE,
                     pointScale=POINT_SIZE_SCALE_FACTOR,
                     arrowScale=ARROW_SIZE_SCALE_FACTOR).Plot(IS_SAVE_PLOT, TEST_PLOT_SAVE_PATH)
    
    return displace, internal, external


if __name__ == '__main__':
    
    displace, internal, external = TestExample()

Format of JSON

The input data of truss in the .json file must follow this format :
( support_type can be one of ["NO", "PIN", "ROLLER_X", "ROLLER_Y", "ROLLER_Z"], and "ROLLER_Z" only can be used in 3D truss.)

{
    // Joints 
    // {"joint_ID" : [positionX, positionY, positionZ, support_type]}
    "joint": {
        "0": [[0 , 0 , 0 ], "PIN"     ],  
        "1": [[36, 0 , 0 ], "PIN"     ],
        "2": [[36, 18, 0 ], "ROLLER_Z"],
        "3": [[0 , 20, 0 ], "PIN"     ],
        "4": [[12, 10, 18], "NO"      ]
    },

    // External forces
    // {"joint_ID" : [forceX, forceY, forceZ]}
    "force": {
        "4": [0, 7000, -10000]
    },

    // Members
    // {"member_ID" : [[joint_ID_0, joint_ID_1], [area, Young's modulus, density]]}
    "member": {
        "0": [[0, 4], [1, 1e7, 1]],
        "1": [[1, 4], [1, 1e7, 1]],
        "2": [[2, 4], [1, 1e6, 1]],
        "3": [[3, 4], [1, 1e7, 1]],
        "4": [[0, 2], [1, 1e6, 1]],
        "5": [[1, 2], [1, 1e7, 1]]
    }
}

And the format of ouput .json file will be like :

{
    // Joints
    "joint": {
        "0": [[0 , 0 , 0 ], "PIN"     ], 
        "1": [[36, 0 , 0 ], "PIN"     ], 
        "2": [[36, 18, 0 ], "ROLLER_Z"], 
        "3": [[0 , 20, 0 ], "PIN"     ], 
        "4": [[12, 10, 18], "NO"      ]
    }, 

    // External forces
    "force": {
        "4": [0, 7000, -10000]
    }, 

    // Members
    "member": {
        "0": [[0, 4], [1, 10000000, 1]], 
        "1": [[1, 4], [1, 10000000, 1]], 
        "2": [[2, 4], [1, 1000000 , 1]], 
        "3": [[3, 4], [1, 10000000, 1]], 
        "4": [[0, 2], [1, 1000000 , 1]], 
        "5": [[1, 2], [1, 10000000, 1]]
    }, 

    // Solved displacement of each joint
    "displace": {
        "0": [0                   ,  0                     ,  0                   ], 
        "1": [0                   ,  0                     ,  0                   ], 
        "2": [0.03134498120304671 , -0.00018634976892802215,  0                   ], 
        "3": [0                   ,  0                     ,  0                   ], 
        "4": [0.022796692569021636,  0.05676049798868429   , -0.029124752172511904]
    }, 

    // External forces with solved resistances
    "external": {
        "0": [-3430.530131923594 , -2651.7198111274147, -4214.046353245278 ],
        "1": [-3823.2785480177026,  1696.5603777451659,  2867.4589110132774],
        "2": [ 0                 ,  0                 ,  465.8744223200557 ],
        "3": [ 7253.808679941296 , -6044.840566617749 ,  10880.713019911946],
        "4": [ 0                 ,  7000              , -10000             ]
    },

    // Solved internal force in each member (Tension is positive, Compression is negative)
    "internal": {
        "0":  5579.573091723386 , 
        "1": -5037.6118087489085, 
        "2": -803.590657623974  , 
        "3": -14406.517749362636, 
        "4":  694.4845848573933 , 
        "5": -103.52764940445674
    }, 

    // The total weight of this truss (note that the default density is 1.0)
    "weight": 168.585850740452
}

Time consuming

The following are time consuming tests for doing structural analysis for each truss (Each testing runs for 30 times and takes average !).

  • 6-bar truss   : 0.00043(s)
  • 10-bar truss  : 0.00063(s)
  • 25-bar truss  : 0.00176(s)
  • 72-bar truss  : 0.00443(s)
  • 120-bar truss : 0.00728(s)
  • 942-bar truss : 0.07440(s)

Testing on :

Intel(R) Core(TM) i7-10750H CPU @ 2.60GHz

Result figures

You could use slientruss3d.plot.TrussPlotter to plot the result of structural analysis for your truss. See the following example in example.py:

from slientruss3d.truss import Truss
from slientruss3d.plot  import TrussPlotter


def TestPlot():
    # Global variables 
    TEST_FILE_NUMBER        = 25
    TEST_LOAD_CASE          = 0
    TEST_INPUT_FILE         = f"./data/bar-{TEST_FILE_NUMBER}_output_{TEST_LOAD_CASE}.json"
    TEST_PLOT_SAVE_PATH     = f"./plot/bar-{TEST_FILE_NUMBER}_plot_{TEST_LOAD_CASE}.png"
    TRUSS_DIMENSION         = 3
    IS_EQUAL_AXIS           = True
    IS_SAVE_PLOT            = False
    MAX_SCALED_DISPLACEMENT = 15 
    MAX_SCALED_FORCE        = 50   
    POINT_SIZE_SCALE_FACTOR = 1
    ARROW_SIZE_SCALE_FACTOR = 1

    # Truss object:
    truss = Truss(dim=TRUSS_DIMENSION)

    # You could directly read the output .json file.
    truss.LoadFromJSON(TEST_INPUT_FILE, isOutputFile=True)

    # Show or save the structural analysis result figure:
    TrussPlotter(truss,
                 isEqualAxis=IS_EQUAL_AXIS,
                 maxScaledDisplace=MAX_SCALED_DISPLACEMENT, 
                 maxScaledForce=MAX_SCALED_FORCE,
                 pointScale=POINT_SIZE_SCALE_FACTOR,
                 arrowScale=ARROW_SIZE_SCALE_FACTOR).Plot(IS_SAVE_PLOT, TEST_PLOT_SAVE_PATH)
  • Green Arrow   : Resistance
  • Purple Arrow  : External Force
  • Black Line    : Member
  • Blue Dashline : Displaced member with tension
  • Red Dashline  : Displaced member with compression
  • Pink Circle   : Joint
  • Blue Circle   : Roller
  • Blue Triangle : Pin

Input : ./data/bar-6_output_0.json 0


Input : ./data/bar-10_output_0.json 1


Input : ./data/bar-25_output_0.json 1


Input : ./data/bar-72_output_1.json 1


Input : ./data/bar-120_output_0.json 1


Input : ./data/bar-942_output_0.json 1

You might also like...
Analysis of ROM image for Norsk Data VDU 301 S
Analysis of ROM image for Norsk Data VDU 301 S

This repository is meant to analyze the ROM images from Norsk Data VDU 301 S as provided at by Torfinn. To combine the two ROM image halves and extrac

Code needed for hybrid land cover change analysis for NASA IDS project

Documentation for the NASA IDS change analysis Poley 10/21/2021 Required python packages: whitebox numpy rasterio rasterio.mask os glob math itertools

A Snakemake workflow for standardised sc/snRNAseq analysis

single_snake_sequencing - sc/snRNAseq Snakemake Workflow A Snakemake workflow for standardised sc/snRNAseq analysis. Every single cell analysis is sli

Multifunctional Analysis of Regions through Input-Output

MARIO Multifunctional Analysis of Regions through Input-Output. (Documents) What is it MARIO is a python package for handling input-output tables and

Our Ping Pong Project of numerical analysis, 2nd year IC B2 INSA Toulouse

Ping Pong Project The objective of this project was to determine the moment of impact of the ball with the ground. To do this, we used different model

Ningyu Jia(nj2459)/Mengyin Ma(mm5937) Call Analysis group project(Group 36)

Group and Section Group 36 Section 001 name and UNI Name UNI Ningyu Jia nj2459 Mengyin Ma mm5937 code explanation Parking.py (1) Calculate the rate of

Student Enrollment Analysis System

SEAS Student Enrollment Analysis System Steps to start working: create a user name "seas", host name: local, password: seas, mark all checkbox - go C

A simple and efficient computing package for Genshin Impact gacha analysis

GGanalysisLite计算包 这个版本的计算包追求计算速度,而GGanalysis包有着更多计算功能。 GGanalysisLite包通过卷积计算分布列,通过FFT和快速幂加速卷积计算。 测试玩家得到的排名值rank的数学意义是:与抽了同样数量五星的其他玩家相比,测试玩家花费的抽数大于等于比例

Scripts for BGC analysis in large MAGs and results of their application to soil metagenomes within Chernevaya Taiga RSF-funded project

Scripts for BGC analysis in large MAGs and results of their application to soil metagenomes within Chernevaya Taiga RSF-funded project

Comments
  • AttributeError: 'Arrow3D' object has no attribute 'do_3d_projection' when running example.py

    AttributeError: 'Arrow3D' object has no attribute 'do_3d_projection' when running example.py

    Hello, when running the example.py with the current stable matplotlib==3.5.2, I get this error: AttributeError: 'Arrow3D' object has no attribute 'do_3d_projection',

    It works with matplotlib==3.4 though.

    Results when running "python3 example.py": numCube : 4, i : 1Traceback (most recent call last): File "/home/dave/Python_Stable_3D_Truss_Analysis/example.py", line 236, in TestGenerateCubeTruss() File "/home/dave/Python_Stable_3D_Truss_Analysis/example.py", line 218, in TestGenerateCubeTruss trussList = GenerateRandomCubeTrusses(gridRange=GRID_RANGE, File "/home/dave/Python_Stable_3D_Truss_Analysis/slientruss3d/generate.py", line 324, in GenerateRandomCubeTrusses TrussPlotter(truss, File "/home/dave/Python_Stable_3D_Truss_Analysis/slientruss3d/plot.py", line 125, in Plot plt.savefig(savePath) File "/usr/lib/python3/dist-packages/matplotlib/pyplot.py", line 958, in savefig res = fig.savefig(*args, **kwargs) File "/usr/lib/python3/dist-packages/matplotlib/figure.py", line 3019, in savefig self.canvas.print_figure(fname, **kwargs) File "/usr/lib/python3/dist-packages/matplotlib/backend_bases.py", line 2319, in print_figure result = print_method( File "/usr/lib/python3/dist-packages/matplotlib/backend_bases.py", line 1648, in wrapper return func(*args, **kwargs) File "/usr/lib/python3/dist-packages/matplotlib/_api/deprecation.py", line 412, in wrapper return func(*inner_args, **inner_kwargs) File "/usr/lib/python3/dist-packages/matplotlib/backends/backend_agg.py", line 540, in print_png FigureCanvasAgg.draw(self) File "/usr/lib/python3/dist-packages/matplotlib/backends/backend_agg.py", line 436, in draw self.figure.draw(self.renderer) File "/usr/lib/python3/dist-packages/matplotlib/artist.py", line 73, in draw_wrapper result = draw(artist, renderer, *args, **kwargs) File "/usr/lib/python3/dist-packages/matplotlib/artist.py", line 50, in draw_wrapper return draw(artist, renderer) File "/usr/lib/python3/dist-packages/matplotlib/figure.py", line 2810, in draw mimage._draw_list_compositing_images( File "/usr/lib/python3/dist-packages/matplotlib/image.py", line 132, in _draw_list_compositing_images a.draw(renderer) File "/usr/lib/python3/dist-packages/matplotlib/artist.py", line 50, in draw_wrapper return draw(artist, renderer) File "/usr/lib/python3/dist-packages/mpl_toolkits/mplot3d/axes3d.py", line 451, in draw for artist in sorted(collections_and_patches, File "/usr/lib/python3/dist-packages/mpl_toolkits/mplot3d/axes3d.py", line 426, in do_3d_projection signature = inspect.signature(artist.do_3d_projection) AttributeError: 'Arrow3D' object has no attribute 'do_3d_projection'

    opened by dave-schaefer 2
Releases(v2.0.3)
My solutions for the 2021's Advent of Code

Advent of Code 2021 My solutions for Advent of Code 2021. This year I am practicing Python 🐍 and also trying to develop my own language, Chocolate 🍫

Jakob Erzar 2 Dec 15, 2021
A program that makes all 47 textures of Optifine CTM only using 2 textures

A program that makes all 47 textures of Optifine CTM only using 2 textures

1 Jan 22, 2022
An experimental Python-to-C transpiler and domain specific language for embedded high-performance computing

An experimental Python-to-C transpiler and domain specific language for embedded high-performance computing

Andrea Zanelli 562 Dec 28, 2022
PyWorkflow(PyWF) - A Python Binding of C++ Workflow

PyWorkflow(PyWF) - A Python Binding of C++ Workflow 概览 C++ Workflow是一个高性能的异步引擎,本项目着力于实现一个Python版的Workflow,让Python用户也能享受Workflow带来的绝佳体验。

Sogou-inc 108 Dec 01, 2022
Collatz Sanısını Test Eden Ve Kanıtlayan Bir Python Programı

Collatz Sanısı Collatz Sanısını Test Eden Ve Kanıtlayan Bir Python Programı. Kullanım Terminalde: 1- git clone https://github.com/detherminal/Collatz-

Cemal Mert 2 May 07, 2022
FBChecker Account using python , package requests and web old facebook

fbcek FBChecker Account using python , package requests and web old facebook using python 3.x apt upgrade -y apt update -y pkg install bash -y pkg ins

XnuxersXploitXen 5 Dec 24, 2022
String Spy is a project aimed at improving MacOS defenses.

String Spy is a project aimed at improving MacOS defenses. It allows users to constantly monitor all running processes for user-defined strings, and if it detects a process with such a string it will

10 Dec 13, 2022
Files relating to polymtl university

This is a tool I developed quickly, which allows users to visualize class availability by day of the week for a given program at polymtl. The schedule

PN 3 Mar 15, 2022
A toy repo illustrating a minimal installable Python package

MyToy: a minimal Python package This repository contains a minimal, toy Python package with a few files as illustration for students of how to lay out

Fernando Perez 19 Apr 24, 2022
A command-line utility that creates projects from cookiecutters (project templates), e.g. Python package projects, VueJS projects.

Cookiecutter A command-line utility that creates projects from cookiecutters (project templates), e.g. creating a Python package project from a Python

18.6k Jan 02, 2023
A Tandy Color Computer 1, 2, and 3 assembler written in Python

CoCo Assembler and File Utility Table of Contents What is it? Requirements License Installing Assembler Assembler Usage Input File Format Print Symbol

Craig Thomas 16 Nov 03, 2022
A MCPI hack with many features.

Morpheus 2.0 A MCPI hack with many features To Use: You will need to install the keyboard, pysimplegui, and MCPI python modules and you will need to e

11 Oct 11, 2022
The best way to learn Python is by practicing examples. The repository contains examples of basic concepts of Python. You are advised to take the references from these examples and try them on your own.

90_Python_Exercises_and_Challenges The best way to learn Python is by practicing examples. This repository contains the examples on basic and advance

Milaan Parmar / Милан пармар / _米兰 帕尔马 205 Jan 06, 2023
Python bindings for `ign-msgs` and `ign-transport`

Python Ignition This project aims to provide Python bindings for ignition-msgs and ignition-transport. It is a work in progress... C++ and Python libr

Rhys Mainwaring 3 Nov 08, 2022
Python tools for working with Orbit Ephemeris Messages (OEMs).

Python Orbit Ephemeris Message tools Python tools for working with Orbit Ephemeris Messages (OEMs). Development Status Installation The oem package is

Brad Sease 4 Apr 06, 2022
Add your recently blog and douban states in your GitHub Profile

Add your recently blog and douban states in your GitHub Profile

Bingjie Yan 4 Dec 12, 2022
Saturne best tools pour baiser tout le système de discord

Installation | Important | Discord 🌟 Comme Saturne est gratuit, les dons sont vraiment appréciables et maintiennent le développement! Caractéristique

GalackQSM 8 Oct 02, 2022
CHIP-8 interpreter written in Python

chip8py CHIP-8 interpreter written in Python Contents About Installation Usage License About CHIP-8 is an interpreted language developed during the 19

Robert Olaru 1 Nov 09, 2021
Job Guy Backend

جاب‌گای چیست؟ اونجا وضعیت چطوریه؟ یه سوال به همین کلیت و ابهام معمولا وقتی برای یه شرکت رزومه می‌فرستیم این سوال کلی و بزرگ برای همه پیش میاد.اونجا وض

Jobguy.work 217 Dec 25, 2022
A random cat fact python module

A random cat fact python module

Fayas Noushad 4 Nov 28, 2021