Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update docs #2

Open
wants to merge 19 commits into
base: test
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
b56d525
Refactor structures function to improve parameter type hints and enha…
kssgarcia Dec 27, 2024
f57e653
No code changes made; skipping commit.
kssgarcia Dec 27, 2024
6911b7d
Fix node coordinate indexing in calculate_element_centers function fo…
kssgarcia Dec 27, 2024
7c29bcc
Replace DME function calls with node2dof for system assembly in optim…
kssgarcia Dec 27, 2024
a46cee9
Add GitHub release creation step to workflow for automated versioning
kssgarcia Dec 27, 2024
5fba155
Add example notebook for Evolutionary Structural Optimization (ESO) w…
kssgarcia Jan 1, 2025
4bc4b3f
Remove unused matplotlib widget backend import from optimize.py
kssgarcia Jan 1, 2025
bfa3e29
Refactor import statements to use solidspy_opt namespace for consistency
kssgarcia Jan 1, 2025
18457b9
Update test cases in test_optimize.py to use larger mesh sizes for 2D…
kssgarcia Jan 2, 2025
9377aa8
Update test cases in test_optimize.py to adjust positions for better …
kssgarcia Jan 2, 2025
b861676
Update GitHub Actions workflow to install SolidsPy from test PyPI and…
kssgarcia Jan 2, 2025
b1107fb
Update test cases in test_optimize.py to use larger mesh sizes and ad…
kssgarcia Jan 2, 2025
a4d1176
Update documentation to reflect module changes and include 'optimize'…
kssgarcia Jan 3, 2025
627e5d5
Update documentation to reflect new module structure and include 'opt…
kssgarcia Jan 3, 2025
0100432
Fix typo in documentation: update 'modes.py' to 'models.py'
kssgarcia Jan 3, 2025
2f2b280
Update documentation configuration and module references in Sphinx
kssgarcia Jan 3, 2025
fa76189
Add README.md for SolidsPy project and update README.rst with images
kssgarcia Jan 3, 2025
624c901
Remove outdated tutorials and update license years; rename documentat…
kssgarcia Jan 3, 2025
6bcc1ec
Update GitHub Actions to use create-release@v1
kssgarcia Jan 3, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ jobs:
python -m pip install --upgrade pip
pip install build
pip install -e .[dev]
- name: Install SolidsPy
run: |
pip install --upgrade pip
pip install --index-url https://test.pypi.org/simple/ \
--extra-index-url https://pypi.org/simple \
SolidsPyKevin

- name: Run tests with coverage
run: |
Expand Down Expand Up @@ -168,4 +174,14 @@ jobs:
# run: |
# for pkg in dist/*/*.tar.bz2; do
# conda run -n base anaconda upload "$pkg" --force
# done
# done
- name: Create GitHub Release
uses: actions/create-release@v1
with:
tag_name: "v${{ env.VERSION }}"
release_name: "v${{ env.VERSION }}"
body: "Automated release for version ${{ env.VERSION }}"
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2015 - 2018 Kevin Sepúlveda-García and Nicolás Guarín-Zapata
Copyright (c) 2025 - 2027 Kevin Sepúlveda-García and Nicolás Guarín-Zapata

Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
Expand Down
125 changes: 125 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
# SolidsPy: 2D/3D-Finite Element Analysis with Python

| ![Animation 1](assets/anim1.gif) | ![Animation 2](assets/anim2.gif) |
|----------------------------------|----------------------------------|

[![PyPI version](https://img.shields.io/pypi/v/solidspy.svg)](https://pypi.python.org/pypi/solidspy-opt)
[![Documentation Status](https://readthedocs.org/projects/solidspy-opt/badge/?version=latest)](https://solidspy-opt.readthedocs.io/en/latest/)
[![Downloads frequency](https://img.shields.io/pypi/dm/solidspy)](https://pypistats.org/packages/solidspy-opt)

A simple topology optimization code for 2D/3D elasticity problems. **SolidsPy-Opt** uses as input easy-to-create text files (or Python data structures) defining a model in terms of nodal, element, material, and load data. It extends or modifies functionality from the original [SolidsPy](https://github.com/AppliedMechanics-EAFIT/SolidsPy) to support topology optimization workflows.

- Documentation: http://solidspy-opt.readthedocs.io
- GitHub: https://github.com/AppliedMechanics-EAFIT/SolidsPy-Opt
- PyPI: https://pypi.org/project/solidspy-opt/
- Free and open source software: [MIT license](http://en.wikipedia.org/wiki/MIT_License)

## Features

* Built upon an open-source Python ecosystem.
* Easy to use and modify for **topology optimization** tasks.
* Extends SolidsPy features to include optimization of material layout (topology optimization).
* Created with academic and research goals in mind.
* Can be used to teach or illustrate:
- Computational Modeling
- Topology Optimization
- Other advanced engineering topics

## Installation

The code is written in Python, depending on `numpy`, `scipy`, and `SolidsPy`. It has been tested under Windows, Mac and Linux.

To install *SolidsPy-Opt*, open a terminal and type:

```bash
pip install solidspy-opt
```

For generating mesh files from [Gmsh](http://gmsh.info/), install [meshio](https://github.com/nschloe/meshio):

```bash
pip install meshio
```

## How to run a simple model

Below is a minimal example showing how you might set up and run a 2D topology optimization analysis in *SolidsPy-Opt*.

```python
import numpy as np
import matplotlib.pyplot as plt

from solidspy_opt.optimize import ESO_stress
from solidspy_opt.utils import structure_3d, structures

# Define the load directions and positions on the top face
load_directions_3d = np.array([
[0, 1, 0], # Load in the Y direction
[1, 0, 0], # Load in the X direction
[0, 0, -1] # Load in the negative Z direction
])
load_positions_3d = np.array([
[5, 5, 9], # Position near the center of the top face
[1, 1, 9], # Position near one corner of the top face
[8, 8, 9] # Position near another corner of the top face
])

# Generate the nodes, materials, elements, loads, and BC indexes
nodes_3d, mats_3d, els_3d, loads_3d, idx_BC_3d = structure_3d(
L=10, # length in X
H=10, # length in Y
W=10, # length in Z
E=206.8e9, # Young's modulus
v=0.28, # Poisson's ratio
nx=10, # number of divisions in X
ny=10, # number of divisions in Y
nz=10, # number of divisions in Z
dirs=load_directions_3d,
positions=load_positions_3d
)

# Run the ESO optimization
els_opt_3d, nodes_opt_3d, UC_3d, E_nodes_3d, S_nodes_3d = ESO_stress(
nodes=nodes_3d,
els=els_3d,
mats=mats_3d,
loads=loads_3d,
idx_BC=idx_BC_3d,
niter=200,
RR=0.005, # Initial removal ratio
ER=0.05, # Removal ratio increment
volfrac=0.5, # Target volume fraction
plot=True, # Whether to plot with solidspy's 3D plot function
dim_problem=3,
nnodes=8 # 8-node hexahedron
)
```

Save the script (for example, as `example_solidspy_opt.py`) and run it:

```bash
python example_solidspy_opt.py
```

## License

This project is licensed under the [MIT license](http://en.wikipedia.org/wiki/MIT_License). All documentation is licensed under the [Creative Commons Attribution License](http://creativecommons.org/licenses/by/4.0/).

## Citation

If you use **SolidsPy-Opt** in your research or publications, please cite it. A BibTeX entry for LaTeX users might look like:

```bibtex
@software{solidspy_opt,
title = {SolidsPy-Opt: 2D/3D-Finite Element and Topology Optimization Analysis with Python},
author = {Sepúlveda-García, Kevin and Guarin-Zapata, Nicolas},
year = 2025,
version = {0.1.0},
keywords = {finite-elements, scientific-computing, deep learning, topology, optimization},
license = {MIT License},
url = {https://github.com/AppliedMechanics-EAFIT/SolidsPy-Opt},
abstract = {SolidsPy-Opt is a Python package designed to perform
topology optimization of 2D/3D solids by leveraging SolidsPy
finite-element package and advanced computational tools.}
}
```
156 changes: 65 additions & 91 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
SolidsPy-Opt: 2D Topology Optimization with Python
==================================================
SolidsPy: 2D/3D-Finite Element Analysis with Python
===================================================

.. figure:: https://raw.githubusercontent.com/AppliedMechanics-EAFIT/SolidsPy/master/docs/img/wrench.png
:alt: Wrench under bending.
.. list-table::
:header-rows: 0
:widths: 50 50

* - .. image:: assets/anim1.gif
:alt: Animation 1
:width: 300px
- .. image:: assets/anim2.gif
:alt: Animation 2
:width: 300px

.. image:: https://img.shields.io/pypi/v/solidspy.svg
:target: https://pypi.python.org/pypi/solidspy-opt
Expand All @@ -16,8 +24,8 @@ SolidsPy-Opt: 2D Topology Optimization with Python
:target: https://pypistats.org/packages/solidspy-opt
:alt: Downloads frequency

A simple finite element analysis (FEA) and topology optimization code for
2D elasticity problems. **SolidsPy-Opt** uses as input easy-to-create text
A simple opology optimization code for
2D/3D elasticity problems. **SolidsPy-Opt** uses as input easy-to-create text
files (or Python data structures) defining a model in terms of nodal,
element, material, and load data. It extends or modifies functionality
from the original `SolidsPy <https://github.com/AppliedMechanics-EAFIT/SolidsPy>`__
Expand All @@ -36,20 +44,14 @@ Features

* Easy to use and modify for **topology optimization** tasks.

* Handles 2D elasticity, displacement, strain, and stress solutions, and
extends these workflows to include optimization of material layout
* Extends SolidsPy features to include optimization of material layout
(topology optimization).

* Organized in independent modules for pre-processing, assembly, optimization,
and post-processing, allowing the user to easily modify or add new
features (e.g., new elements or custom optimization strategies).

* Created with academic and research goals in mind.

* Can be used to teach or illustrate:

- Computational Modeling
- Finite Element Methods
- Topology Optimization
- Other advanced engineering topics

Expand All @@ -58,23 +60,14 @@ Installation
------------

The code is written in Python, depending on ``numpy``, ``scipy``, and
``sympy`` (and possibly other libraries if your optimization approach
requires them). It has been tested under Windows, Mac, Linux, and Android
environments.
``SolidsPy``. It has been tested under Windows, Mac and Linux.

To install *SolidsPy-Opt*, open a terminal and type:

::

pip install solidspy-opt

If you also need an interactive GUI for file selection, you can install
`easygui <http://easygui.readthedocs.org/en/master/>`__:

::

pip install easygui

For generating mesh files from
`Gmsh <http://gmsh.info/>`__, install
`meshio <https://github.com/nschloe/meshio>`__:
Expand All @@ -88,76 +81,57 @@ How to run a simple model
-------------------------

Below is a minimal example showing how you might set up and run a
2D finite element + topology optimization analysis in *SolidsPy-Opt*.
(Adapt it to your actual code structure and function names.)
2D topology optimization analysis in *SolidsPy-Opt*.

.. code:: python

import numpy as np
import matplotlib.pyplot as plt
# Hypothetical module import for SolidsPy-Opt:
from solidspy_opt.solids_GUI import solids_opt_auto

# Define the data (nodes, constraints, elements, materials, loads, etc.)
nodes = np.array([
[0, 0.00, 0.00],
[1, 2.00, 0.00],
[2, 2.00, 2.00],
[3, 0.00, 2.00],
[4, 1.00, 0.00],
[5, 2.00, 1.00],
[6, 1.00, 2.00],
[7, 0.00, 1.00],
[8, 1.00, 1.00]])

cons = np.array([
[0, -1],
[0, -1],
[0, 0],
[0, 0],
[-1, -1],
[0, 0],
[0, 0],
[0, 0],
[0, 0]])

elements = np.array([
[0, 1, 0, 0, 4, 8, 7],
[1, 1, 0, 4, 1, 5, 8],
[2, 1, 0, 7, 8, 6, 3],
[3, 1, 0, 8, 5, 2, 6]])

mats = np.array([[1.0, 0.3]])

loads = np.array([
[2, 0.0, 1.0],
[3, 0.0, 1.0],
[6, 0.0, 2.0]])

data = {
"nodes": nodes,
"cons": cons,
"elements": elements,
"mats": mats,
"loads": loads
# Potentially additional data for optimization:
# "vol_frac": 0.5,
# "penal": 3.0,
# "filter_radius": 1.2,
# etc.
}

# Run the simulation + topology optimization
disp, topo_density = solids_opt_auto(data)

# Plot results
plt.figure()
# Hypothetical function that plots the density distribution
plt.imshow(topo_density.reshape(2,2))
plt.title("Topology Density")
plt.colorbar()
plt.show()

from solidspy_opt.optimize import ESO_stress
from solidspy_opt.utils import structure_3d, structures

# Define the load directions and positions on the top face
load_directions_3d = np.array([
[0, 1, 0], # Load in the Y direction
[1, 0, 0], # Load in the X direction
[0, 0, -1] # Load in the negative Z direction
])
load_positions_3d = np.array([
[5, 5, 9], # Position near the center of the top face
[1, 1, 9], # Position near one corner of the top face
[8, 8, 9] # Position near another corner of the top face
])

# Generate the nodes, materials, elements, loads, and BC indexes
nodes_3d, mats_3d, els_3d, loads_3d, idx_BC_3d = structure_3d(
L=10, # length in X
H=10, # length in Y
W=10, # length in Z
E=206.8e9, # Young's modulus
v=0.28, # Poisson's ratio
nx=10, # number of divisions in X
ny=10, # number of divisions in Y
nz=10, # number of divisions in Z
dirs=load_directions_3d,
positions=load_positions_3d
)

# Run the ESO optimization
els_opt_3d, nodes_opt_3d, UC_3d, E_nodes_3d, S_nodes_3d = ESO_stress(
nodes=nodes_3d,
els=els_3d,
mats=mats_3d,
loads=loads_3d,
idx_BC=idx_BC_3d,
niter=200,
RR=0.005, # Initial removal ratio
ER=0.05, # Removal ratio increment
volfrac=0.5, # Target volume fraction
plot=True, # Whether to plot with solidspy's 3D plot function
dim_problem=3,
nnodes=8 # 8-node hexahedron
)

Save the script (for example, as ``example_solidspy_opt.py``) and run it:

Expand All @@ -184,14 +158,14 @@ A BibTeX entry for LaTeX users might look like:
.. code:: bibtex

@software{solidspy_opt,
title = {SolidsPy-Opt: 2D-Finite Element and Topology Optimization Analysis with Python},
title = {SolidsPy-Opt: 2D/3D-Finite Element and Topology Optimization Analysis with Python},
author = {Sepúlveda-García, Kevin and Guarin-Zapata, Nicolas},
year = 2024,
year = 2025,
version = {0.1.0},
keywords = {finite-elements, scientific-computing, deep learning, topology, optimization},
license = {MIT License},
url = {https://github.com/AppliedMechanics-EAFIT/SolidsPy-Opt},
abstract = {SolidsPy-Opt is a Python package designed to perform
topology optimization of 2D solids by leveraging
finite-element methods and advanced computational tools.}
topology optimization of 2D/3D solids by leveraging SolidsPy
finite-element package and advanced computational tools.}
}
Binary file added assets/anim1.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/anim2.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 0 additions & 12 deletions docs/advanced.rst

This file was deleted.

Binary file removed docs/advanced/img/membrane_eigs.png
Binary file not shown.
Binary file removed docs/advanced/img/membrane_mode1.png
Binary file not shown.
Loading