Skip to content

Structural analysis suite for construction sequencing

License

Notifications You must be signed in to change notification settings

yijiangh/conmech

Repository files navigation

conmech

Travis CI Appveyor CI Documentation Status License MIT PyPI - Python Version Coveralls

conmech is a stiffness checker that performs elastic deformation analysis for 3D frame structures. It is designed for construction sequencing applications, which involves testing the partially assembled structure (subset of the element permutation) many times.

For now, conmech only supports first-order linear FEM simulations of 2D/3D frame structures (similar to the Analyze component in Karamba), but stay tune for a shell analysis backend coming soon ☕!

conmech has a high-performing C++ backend (written in C++11 and wrapped friendly with Python via pybind11) and a flexible, but less performative numpy backend.

🚧 The C++ backend is under development to keep up with the latest feature implemented in the numpy backend. Please use the numpy backend until the next release.

Usage

Input model

There are two ways to specify and input a structural model (geometry, material, cross sections, joint releases, support conditions, and loads) to conmech:

  1. directly input data following class structures specified in pyconmech.frame_analysis.io_base (See the following python script for an example)
  2. write your data in a JSON format and input the file path to conmech (See file examples here.

The easiest way to generate the model JSON file by exporting from a Karamba3D model in Rhino-Grasshopper. A example GH export file is provided:

karamba_model_export

You can also parse your model JSON file back to Rhino/GH for visualization/debugging by using the parse GH example file.

Analysis

After you have the input model ready, analysis is straight-forward:

from pyconmech import StiffnessChecker
from pyconmech.frame_analysis import PointLoad, GravityLoad, LoadCase

sc = StiffnessChecker.from_json(json_file_path=frame_file_path, checker_engine="numpy", verbose=True)
gravity_load = GravityLoad([0,0,-1])
loadcase = LoadCase(gravity_load=gravity_load)
sc.set_loads(loadcase)

# if the structure's nodal deformation exceeds 1e-3 meter,
# we want the checker to return `sol_success = False`
trans_tol = 1e-3
sc.set_nodal_displacement_tol(trans_tol=trans_tol)

# existing elements' indices
# leave to [] if want to solve the entire structure
existing_ids = [0,4,88,6]

# False if the analysis result does not satisfy the criteria above, or the stiffness solving fails (due to mechanism, etc.)
sol_success = sc.solve(existing_ids)

# Get all the analysis information:
# nodal deformation, fixity reactions, element reactions
success, nD, fR, eR = sc.get_solved_results()

See the following python script for an example to construct and analyze a structure programmingly.

Installation

python -m pip install pyconmech --user
# or python3 if default python is 2.x (OSX or Linux)
# try the following flags when updating: --user --upgrade --force

Build from source

Build python bindings

Prerequisites

The following dependencies come from pybind11 for building the python wrappers.

On Unix (Linux, OS X)

  • A compiler with C++11 support
  • CMake >= 3.1

On Windows

  • Visual Studio 2015 (required for all Python versions, see notes below)
  • CMake >= 3.1

Then, clone this repository and pip install.

cd conmech
python -m pip install .
# or python3 if default python is 2.x (OSX or Linux)
# try the following flags when updating: --user --upgrade --force

With the setup.py file included in the base folder, the pip install command will invoke CMake and build the pybind11 module as specified in CMakeLists.txt.

Note:

conmech's python bindings are built with a CMake-based build system via pybind11. Take a look at cmake_example for pybind11 if you want to learn more about this.

conmech depends on Eigen for linear algebra and nlohmann::json for json (de-)serialization, both of which are handled automatically by cmake for downloading.

Build C++ code

mkdir build
cd build
cmake ..
make -j2 # Unix

Or on Windows, replace the last line with

cmake --build .

References

Credits

Yijiang Huang. Conmech. https://pypi.org/project/pyconmech/. 2020.

This package was initiated and maintained by Yijiang Huang @yijiangh and other contributors.

References

The following textbook is an excellent resource for learning 2D/3D truss/frame analysis, many of conmech's unit tests are using examples in this textbook as analytical benchmarks:

McGuire, W., R. H. Gallagher, and R. D. Ziemian. "Structural Analysis, Title: Matrix Structural Analysis." (2015).

Related repos

Frame3dd: A static and dynamic structural analysis software of 2D and 3D frames and trusses with elastic and geometric stiffness written in C.