ada-py


Nameada-py JSON
Version 0.2.12 PyPI version JSON
download
home_page
SummaryAssembly for Design & Analysis - A python library for structural analysis and design
upload_time2024-03-11 16:21:51
maintainer
docs_urlNone
author
requires_python>=3.10
license
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # ADA - Assembly for Design & Analysis

[![Anaconda-Server Badge](https://anaconda.org/krande/ada-py/badges/version.svg)](https://anaconda.org/krande/ada-py)
[![Anaconda-Server Badge](https://anaconda.org/krande/ada-py/badges/latest_release_date.svg)](https://anaconda.org/krande/ada-py)
[![Anaconda-Server Badge](https://anaconda.org/krande/ada-py/badges/platforms.svg)](https://anaconda.org/krande/ada-py)
[![Anaconda-Server Badge](https://anaconda.org/krande/ada-py/badges/downloads.svg)](https://anaconda.org/krande/ada-py)
[![PyPi Badge](https://img.shields.io/pypi/v/ada-py)](https://pypi.org/project/ada-py/)

A python library for working with structural analysis and design. This library should be considered as experimental.

The recommended way of installing ada-py is by creating a new isolated environment for the installation like so:

```
conda create -n adaenv -c conda-forge -c krande ada-py
```

or if you wish to download the latest build from any branch passing all unittests you can do

```
conda create -n adaenv -c conda-forge -c krande/label/dev ada-py
```

Here are some of the goals with `ada-py`:

* Support reading, writing and modifying FE models and post-processing FE results
* Support open source and commercial FE packages (based on what I use/would like to use regularly)
* Support scriptable FE meshing
* Support reading/writing CAD/BIM formats (STEP/IFC) & mesh formats (GLTF)
* Use a CSG (Constructive Solid Geometry) core primitives library for boolean operations based on the IFC/STEP standards
* Provide the building blocks for advanced parametric and procedural 3d model design and simulation workflows
* The library should always strive for user ergonomics.

## Quick Links

Try ada-py online with code-aster and calculix pre-installed

[![Binder-main](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/Krande/adapy/main)


* Feel free to start/join any informal topic related to adapy [here](https://github.com/Krande/adapy/discussions).
* Issues related to adapy can be raised [here](https://github.com/Krande/adapy/issues)


## Usage
Some examples of using the ada-py package 


### Create an IFC file

The following code

```python
from ada import Assembly, Part, Beam

a = Assembly("MyAssembly") / (Part("MyPart") / Beam("MyBeam", (0, 0, 0), (1, 0, 0), "IPE300"))
a.to_ifc("C:/temp/myifc.ifc")
```

creates an Ifc file containing an IfcBeam with the following hierarchy 
    
    MyAssembly (IfSite)
        MyPart (IfcBuildingStorey)
            MyBeam (IfcBeam)

![Beam Visualized in BlenderBIM](docs/_static/figures/my_beam.png)

The resulting IfcBeam (and corresponding hierarchy) shown in the figure above is taken from the awesome 
[blender](https://blender.org) plugin [blenderbim](https://blenderbim.org/).

### Convert between FEM formats

Here is an example showing the code for converting a sesam FEM file to abaqus and code aster

_Note! Reading FEM load and step information is not supported, but might be added in the future._

```python
import ada

a = ada.from_fem('path_to_your_sesam_file.FEM')
a.to_fem('name_of_my_analysis_file_deck_directory_abaqus', 'abaqus')
a.to_fem('name_of_my_analysis_file_deck_directory_code_aster', 'code_aster')
```

Current read support is: abaqus, code aster and sesam  
Current write support is: abaqus, code aster and sesam, calculix and usfos

### Create and execute a FEM analysis in Calculix, Code Aster and Abaqus

This example uses a function `beam_ex1` from [here](src/ada/param_models/fem_models.py) that returns an
Assembly object with a single `Beam` with a few holes in it (to demonstrate a small portion of the steel detailing 
capabilities in ada and IFC) converted to a shell element mesh using a FE mesh recipe `create_beam_mesh` found 
[here](ada/fem/io/mesh/recipes.py). 

```python
from ada.param_models.fem_models import beam_ex1

a = beam_ex1()

a.to_fem("MyCantilever_abaqus", "abaqus", overwrite=True, execute=True, run_ext=True)
a.to_fem("MyCantilever_calculix", "calculix", overwrite=True, execute=True)
a.to_fem("MyCantilever_code_aster", "code_aster", overwrite=True, execute=True)
```

after the code is executed you can look at the results using supported post-processing software or directly
in python using Jupyter notebook/lab (currently only supported for Code Aster) for the FEA results.

<img src="docs/_static/figures/fem_beam_paraview.png" alt="Calculix Results" height="220"/>
<img src="docs/_static/figures/fem_beam_abaqus.png" alt="Abaqus Results" height="220"/>
<img src="docs/_static/figures/code_aster_jupyter_displ.png" alt="Code Aster (jupyter) results" height="220"/>


To access the stress and displacement data directly using python here is a way you can use meshio to read the results 
from Calculix and Code Aster (continuing on the previous example).

```python
from ada.config import Settings
import meshio

vtu = Settings.scratch_dir / "MyCantilever_calculix" / "MyCantilever_calculix.vtu"
mesh = meshio.read(vtu)

# Displacements in [X, Y, Z] at point @ index=-1
print('Calculix:',mesh.point_data['U'][-1])

rmed = Settings.scratch_dir / "MyCantilever_code_aster" / "MyCantilever_code_aster.rmed"
ca_mesh = meshio.read(rmed, 'med')

# Displacements in [X, Y, Z] at point @ index=-1
print('Code Aster:',ca_mesh.point_data['DISP[10] - 1'][-1][:3])
```

**Note!**

The above example assumes you have installed Abaqus, Calculix and Code Aster locally on your computer.

To set correct paths to your installations of FE software you wish to use there are a few ways of doing so.

1. Add directory path of FE executable/batch to your system path.
2. Add directory paths to system environment variables. This can be done by using the control panel or 
   running the following from a cmd prompt with administrator rights:
    
```cmd
:: Windows
setx ADA_abaqus_exe <absolute path to abaqus.bat>
setx ADA_calculix_exe <absolute path to ccx.exe>
setx ADA_code_aster_exe <absolute path to as_run.bat>

:: Linux?

:: Mac?
```

Note! It is very important that any paths containing whitespaces be converted to "shortened paths". To shorten a path
on windows you can use the utility [pathcopycopy](https://pathcopycopy.github.io/).

For installation files of open source FEM software such as Calculix and Code Aster, here are some links:

* https://github.com/calculix/cae/releases (calculix CAE for windows/linux)
* https://code-aster-windows.com/download/ (Code Aster for Windows Salome Meca v9.3.0)
* https://www.code-aster.org/spip.php?rubrique21 (Code Aster for Linux)
* https://salome-platform.org/downloads/current-version (Salome v9.6.0 for windows/linux)
* https://prepomax.fs.um.si/downloads/ (PreProMax -> Calculix preprocessor)


**Note!** pip is not a recommended installation method due to an unstable behaviour often 
manifested as DLL import errors related to the vtk package.

## Acknowledgements

This project would never have been possible without the existing open source python and c++ libraries. 
Although listed in the package dependencies (which is a long list), here are some of the packages that are at the very 
core of adapy;

* IfcOpenShell
* OpenCascade
* PythonOCC-Core
* Gmsh
* Trimesh

A huge thanks to all involved in the development of the packages mentioned here and in the list of packages adapy
depends on.

If you feel that a certain package listed in the adapy dependencies should be listed here please let me know and I will 
update the list :)


## Project Responsible ###

	Kristoffer H. Andersen

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "ada-py",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": "",
    "keywords": "",
    "author": "",
    "author_email": "\"Kristoffer H. Andersen\" <kristoffer_andersen@outlook.com>",
    "download_url": "https://files.pythonhosted.org/packages/9f/b2/839a235b07b4d617333d033ffb3d1e95bf4feb7f15a0de0bd60fe97bb369/ada-py-0.2.12.tar.gz",
    "platform": null,
    "description": "# ADA - Assembly for Design & Analysis\n\n[![Anaconda-Server Badge](https://anaconda.org/krande/ada-py/badges/version.svg)](https://anaconda.org/krande/ada-py)\n[![Anaconda-Server Badge](https://anaconda.org/krande/ada-py/badges/latest_release_date.svg)](https://anaconda.org/krande/ada-py)\n[![Anaconda-Server Badge](https://anaconda.org/krande/ada-py/badges/platforms.svg)](https://anaconda.org/krande/ada-py)\n[![Anaconda-Server Badge](https://anaconda.org/krande/ada-py/badges/downloads.svg)](https://anaconda.org/krande/ada-py)\n[![PyPi Badge](https://img.shields.io/pypi/v/ada-py)](https://pypi.org/project/ada-py/)\n\nA python library for working with structural analysis and design. This library should be considered as experimental.\n\nThe recommended way of installing ada-py is by creating a new isolated environment for the installation like so:\n\n```\nconda create -n adaenv -c conda-forge -c krande ada-py\n```\n\nor if you wish to download the latest build from any branch passing all unittests you can do\n\n```\nconda create -n adaenv -c conda-forge -c krande/label/dev ada-py\n```\n\nHere are some of the goals with `ada-py`:\n\n* Support reading, writing and modifying FE models and post-processing FE results\n* Support open source and commercial FE packages (based on what I use/would like to use regularly)\n* Support scriptable FE meshing\n* Support reading/writing CAD/BIM formats (STEP/IFC) & mesh formats (GLTF)\n* Use a CSG (Constructive Solid Geometry) core primitives library for boolean operations based on the IFC/STEP standards\n* Provide the building blocks for advanced parametric and procedural 3d model design and simulation workflows\n* The library should always strive for user ergonomics.\n\n## Quick Links\n\nTry ada-py online with code-aster and calculix pre-installed\n\n[![Binder-main](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/Krande/adapy/main)\n\n\n* Feel free to start/join any informal topic related to adapy [here](https://github.com/Krande/adapy/discussions).\n* Issues related to adapy can be raised [here](https://github.com/Krande/adapy/issues)\n\n\n## Usage\nSome examples of using the ada-py package \n\n\n### Create an IFC file\n\nThe following code\n\n```python\nfrom ada import Assembly, Part, Beam\n\na = Assembly(\"MyAssembly\") / (Part(\"MyPart\") / Beam(\"MyBeam\", (0, 0, 0), (1, 0, 0), \"IPE300\"))\na.to_ifc(\"C:/temp/myifc.ifc\")\n```\n\ncreates an Ifc file containing an IfcBeam with the following hierarchy \n    \n    MyAssembly (IfSite)\n        MyPart (IfcBuildingStorey)\n            MyBeam (IfcBeam)\n\n![Beam Visualized in BlenderBIM](docs/_static/figures/my_beam.png)\n\nThe resulting IfcBeam (and corresponding hierarchy) shown in the figure above is taken from the awesome \n[blender](https://blender.org) plugin [blenderbim](https://blenderbim.org/).\n\n### Convert between FEM formats\n\nHere is an example showing the code for converting a sesam FEM file to abaqus and code aster\n\n_Note! Reading FEM load and step information is not supported, but might be added in the future._\n\n```python\nimport ada\n\na = ada.from_fem('path_to_your_sesam_file.FEM')\na.to_fem('name_of_my_analysis_file_deck_directory_abaqus', 'abaqus')\na.to_fem('name_of_my_analysis_file_deck_directory_code_aster', 'code_aster')\n```\n\nCurrent read support is: abaqus, code aster and sesam  \nCurrent write support is: abaqus, code aster and sesam, calculix and usfos\n\n### Create and execute a FEM analysis in Calculix, Code Aster and Abaqus\n\nThis example uses a function `beam_ex1` from [here](src/ada/param_models/fem_models.py) that returns an\nAssembly object with a single `Beam` with a few holes in it (to demonstrate a small portion of the steel detailing \ncapabilities in ada and IFC) converted to a shell element mesh using a FE mesh recipe `create_beam_mesh` found \n[here](ada/fem/io/mesh/recipes.py). \n\n```python\nfrom ada.param_models.fem_models import beam_ex1\n\na = beam_ex1()\n\na.to_fem(\"MyCantilever_abaqus\", \"abaqus\", overwrite=True, execute=True, run_ext=True)\na.to_fem(\"MyCantilever_calculix\", \"calculix\", overwrite=True, execute=True)\na.to_fem(\"MyCantilever_code_aster\", \"code_aster\", overwrite=True, execute=True)\n```\n\nafter the code is executed you can look at the results using supported post-processing software or directly\nin python using Jupyter notebook/lab (currently only supported for Code Aster) for the FEA results.\n\n<img src=\"docs/_static/figures/fem_beam_paraview.png\" alt=\"Calculix Results\" height=\"220\"/>\n<img src=\"docs/_static/figures/fem_beam_abaqus.png\" alt=\"Abaqus Results\" height=\"220\"/>\n<img src=\"docs/_static/figures/code_aster_jupyter_displ.png\" alt=\"Code Aster (jupyter) results\" height=\"220\"/>\n\n\nTo access the stress and displacement data directly using python here is a way you can use meshio to read the results \nfrom Calculix and Code Aster (continuing on the previous example).\n\n```python\nfrom ada.config import Settings\nimport meshio\n\nvtu = Settings.scratch_dir / \"MyCantilever_calculix\" / \"MyCantilever_calculix.vtu\"\nmesh = meshio.read(vtu)\n\n# Displacements in [X, Y, Z] at point @ index=-1\nprint('Calculix:',mesh.point_data['U'][-1])\n\nrmed = Settings.scratch_dir / \"MyCantilever_code_aster\" / \"MyCantilever_code_aster.rmed\"\nca_mesh = meshio.read(rmed, 'med')\n\n# Displacements in [X, Y, Z] at point @ index=-1\nprint('Code Aster:',ca_mesh.point_data['DISP[10] - 1'][-1][:3])\n```\n\n**Note!**\n\nThe above example assumes you have installed Abaqus, Calculix and Code Aster locally on your computer.\n\nTo set correct paths to your installations of FE software you wish to use there are a few ways of doing so.\n\n1. Add directory path of FE executable/batch to your system path.\n2. Add directory paths to system environment variables. This can be done by using the control panel or \n   running the following from a cmd prompt with administrator rights:\n    \n```cmd\n:: Windows\nsetx ADA_abaqus_exe <absolute path to abaqus.bat>\nsetx ADA_calculix_exe <absolute path to ccx.exe>\nsetx ADA_code_aster_exe <absolute path to as_run.bat>\n\n:: Linux?\n\n:: Mac?\n```\n\nNote! It is very important that any paths containing whitespaces be converted to \"shortened paths\". To shorten a path\non windows you can use the utility [pathcopycopy](https://pathcopycopy.github.io/).\n\nFor installation files of open source FEM software such as Calculix and Code Aster, here are some links:\n\n* https://github.com/calculix/cae/releases (calculix CAE for windows/linux)\n* https://code-aster-windows.com/download/ (Code Aster for Windows Salome Meca v9.3.0)\n* https://www.code-aster.org/spip.php?rubrique21 (Code Aster for Linux)\n* https://salome-platform.org/downloads/current-version (Salome v9.6.0 for windows/linux)\n* https://prepomax.fs.um.si/downloads/ (PreProMax -> Calculix preprocessor)\n\n\n**Note!** pip is not a recommended installation method due to an unstable behaviour often \nmanifested as DLL import errors related to the vtk package.\n\n## Acknowledgements\n\nThis project would never have been possible without the existing open source python and c++ libraries. \nAlthough listed in the package dependencies (which is a long list), here are some of the packages that are at the very \ncore of adapy;\n\n* IfcOpenShell\n* OpenCascade\n* PythonOCC-Core\n* Gmsh\n* Trimesh\n\nA huge thanks to all involved in the development of the packages mentioned here and in the list of packages adapy\ndepends on.\n\nIf you feel that a certain package listed in the adapy dependencies should be listed here please let me know and I will \nupdate the list :)\n\n\n## Project Responsible ###\n\n\tKristoffer H. Andersen\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Assembly for Design & Analysis - A python library for structural analysis and design",
    "version": "0.2.12",
    "project_urls": {
        "Bug Tracker": "https://github.com/Krande/adapy/issues",
        "Homepage": "https://github.com/Krande/adapy"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "127538b80a9cfea712efb36faaf4cd3a493525bf1b93220209f5dd4a665552ae",
                "md5": "89b5e65d0274612cb37391472b40a1a3",
                "sha256": "87c70d0f5d15838989a1238698187f7caf4a56cad1f10bc51ce3295c26d44433"
            },
            "downloads": -1,
            "filename": "ada_py-0.2.12-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "89b5e65d0274612cb37391472b40a1a3",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 906961,
            "upload_time": "2024-03-11T16:21:49",
            "upload_time_iso_8601": "2024-03-11T16:21:49.123753Z",
            "url": "https://files.pythonhosted.org/packages/12/75/38b80a9cfea712efb36faaf4cd3a493525bf1b93220209f5dd4a665552ae/ada_py-0.2.12-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9fb2839a235b07b4d617333d033ffb3d1e95bf4feb7f15a0de0bd60fe97bb369",
                "md5": "46027c1b3f3f1f4993102c265ae7fee9",
                "sha256": "81c4005394e081fe2368f74618ee28c97db6dad221f5379e04c6a6d1c531b588"
            },
            "downloads": -1,
            "filename": "ada-py-0.2.12.tar.gz",
            "has_sig": false,
            "md5_digest": "46027c1b3f3f1f4993102c265ae7fee9",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 781891,
            "upload_time": "2024-03-11T16:21:51",
            "upload_time_iso_8601": "2024-03-11T16:21:51.792899Z",
            "url": "https://files.pythonhosted.org/packages/9f/b2/839a235b07b4d617333d033ffb3d1e95bf4feb7f15a0de0bd60fe97bb369/ada-py-0.2.12.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-11 16:21:51",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Krande",
    "github_project": "adapy",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "ada-py"
}
        
Elapsed time: 0.21323s