PyHom: a Python library for homogenization
Project description
Pyhom
In this repository, we present "PyHom: a Python library for homogenization".
This library is conceived for calculating the effective conductivity properties of composite materials with complex microstructures in a 2D framework. The backbone of the code relies on the theory described in [Cruz-González et al., 2024], and uses not only existing image processing modules, but also functionality and packages built by the authors. The main interest is using PyHom as a toolbox to study the core issues in the application of IDD and the IDD-based PCW.
For more information, please refer to the paper
- Cruz-González, O., Cornaggia, R., Dartois, S., and Brenner, R. (2024). Accounting for spatial distribution in mean-field homogenization of particulate composites. International Journal of Solids and Structures, 294:112747. DOI 10.1016/j.ijsolstr.2024.112747
Keywords:
Microstructures, Particulate reinforced composites, Homogenization, RSA, Voronoï Diagram, Spatial distribution, Mean Field estimates, FFT-based solver.
Updates
-
pyhomis now officially available on the Python Package Index. You can view the project on PyPI here https://pypi.org/project/pyhom/. (Sep 26, 2025) -
pyhom_core: Calculate the normalized effective conductivity properties of composite materials in 2D by varying the conductivity contrast parametergamma. (Dec 17, 2024)
Installation
Recommended Method: Install from PyPI
-
Ensure you have Python 3.10 and pip installed.
-
Run the following command:
pip install pyhom
Alternative Method: For Developers
-
Python 3.10 and Git installed on your system.
-
Clone the repository in a local directory.
git clone https://github.com/olcruzgonzalez/pyhom.git
cd pyhom
- Create and activate a virtual environment
- On Linux/macOS:
python3.10 -m venv myenv
source myenv/bin/activate
- On Windows:
py -3.10 -m venv myenv
myenv/Scripts/Activate.ps1
- Install dependencies
(myenv) pip install -r requirements.txt
- Use the library.
Basic Usage
In this section, we show how to use the library through some practical examples.
For demonstrating the most basic functionality of the python_core modulus, please, create a script basic_usage.py and use the following template:
# basic_usage.py
from pyhom.pyhom_core import Core
if __name__ == '__main__':
coreJob = Core()
coreJob.input_data(output_dir = 'results', input_file_path = 'input.yaml')
coreJob.run()
💡 Notice that the only requirement to launch the code is to pass a YAML file as input. It defines various parameters related to the configuration of inclusions, cell properties, and other related settings.
Create a YAML file input.yaml and use the following template:
#-----------------------------------------------
# Input Parameters - PyHom Core
#---------------------------------------------
N_incl: 10 # Number of inclusions.
# default varying parameter
gamma: [2,5,10,20,50,100]
# fixed parameters
c_incl: [0.05]
e_incl: [1]
theta_incl: '[0*np.pi/180]'
e_cell_RSA: [0.5]
theta_cell_RSA: '[0*np.pi/180]'
size_factor: [0.375]
security_factor: 1.02
# Further information
meta_x_incl:
value: false
path: null
meta_image:
value: false
path: null
hasReproducibility:
value: False
seed: null
Launch the code
python basic_usage.py
Built-in examples
We have incorporated built-in examples for different input_core.yaml files (see src/pyhom/built-in).
To do this, simply add the following line to basic_usage.py script. Notice that labelNumber is an integer between 1 and 8.
# basic_usage.py
from pyhom.pyhom_core import Core
if __name__ == '__main__':
coreJob = Core()
coreJob.get_built_in_dataset(labelNumber = "1") # NEW LINE !
coreJob.input_data(output_dir = 'results', input_file_path = 'built-in_input/labelNumber_1/input_core.yaml') # UPDATE input_file_path!
coreJob.run()
License
The template is available as open source under the terms of the MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyhom-1.0.7.tar.gz.
File metadata
- Download URL: pyhom-1.0.7.tar.gz
- Upload date:
- Size: 83.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
240c06539d52fc7d4da74dc95b206a5ab441cb9b216e4953bbbc0d983cf4b535
|
|
| MD5 |
6488eb9f8fc7fd10e80a8e6fef10ae55
|
|
| BLAKE2b-256 |
f49e724bd6e791cf3c83fc85fa74788323acee6020a9c42b7a7ebc1221b2a970
|
File details
Details for the file pyhom-1.0.7-py3-none-any.whl.
File metadata
- Download URL: pyhom-1.0.7-py3-none-any.whl
- Upload date:
- Size: 84.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0df798c404f2172e299b2bba6369874b2e8b92f4575af3e824e833af3971cc46
|
|
| MD5 |
3a6325a1a00fb615bbce65f050839f1c
|
|
| BLAKE2b-256 |
a3216a22c3dfdc46e1969e04e16f205dc08ce5b183e68da15e958b075a4ecb8b
|