Metadata-Version: 2.4
Name: compgen
Version: 0.1.0
Summary: Python toolkit for generating simulation data for two phase composite materials.
Author: Mark Messner, Tianchen Hu, Fabio Sozio
License-Expression: MIT
Project-URL: Homepage, https://github.com/applied-material-modeling/compgen
Project-URL: Repository, https://github.com/applied-material-modeling/compgen
Project-URL: Issues, https://github.com/applied-material-modeling/compgen/issues
Keywords: composite materials,microstructure,finite element,homogenization,MOOSE,dataset generation
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: POSIX
Classifier: Operating System :: MacOS
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Scientific/Engineering
Classifier: Topic :: Scientific/Engineering :: Physics
Requires-Python: >=3.13
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy
Requires-Dist: scipy
Requires-Dist: h5py
Requires-Dist: scikit-image
Requires-Dist: gstools
Requires-Dist: multiprocess
Requires-Dist: pyvista
Requires-Dist: exodusii==26.10.29
Provides-Extra: mcrpy
Requires-Dist: mcrpy; extra == "mcrpy"
Provides-Extra: demos
Requires-Dist: matplotlib; extra == "demos"
Provides-Extra: dev
Requires-Dist: black==26.3.0; extra == "dev"
Requires-Dist: pytest==9.0.2; extra == "dev"
Requires-Dist: pylint==4.0.5; extra == "dev"
Requires-Dist: pre-commit==4.7.0; extra == "dev"
Dynamic: license-file

# compgen

## Summary
compgen is a Python toolkit for generating simulation data for two phase composite materials.  It will generate structures, invoke physics codes to simulate the response for a variety of material properties, and write summaries of the results.

## Install
compgen requires Python 3.13 or newer.

1. (Optional) Create and activate a virtual environment.
2. Install the package:
   - `pip install compgen`
   - To use the reconstruction generator, `pip install compgen[mcrpy]`.  mcrpy depends on TensorFlow, which currently supports Python up to 3.13, so use Python 3.13 for this option.
   - To develop compgen, or to run the tests and demos, clone this repository and run `pip install -e .[dev,demos]` from its root.
3. Install the mesher and physics codes you want to use:
    1. [MOOSE](https://mooseframework.inl.gov/)
    2. [SCULPT](https://www.sandia.gov/files/cubit/documents/SculptSANDReport.pdf)

## Inputs

compgen pipes together several steps to generate results:
1. Generate a composite structure -- the distribution of two materials A and B over a periodic domain.  We use pixelated fixed grids to define this distribution.
2. Make an unstructured finite element mesh of the fixed grid representation, smoothing interfaces.  This might involve first filtering the fixed grid representation, then calling a mesh generator.
3. Setup input files for the physics codes describing the problem physics and boundary conditions.
4. Actually run the physics code.  This might require multiple calls, for example if we're interested in properties in different loading directions.
5. Post process the output from the physics code into a common format.  We use an [HDF5 format](https://github.com/applied-material-modeling/compgen/blob/main/doc/data.md).

compgen provides a simple API (`runner.run`) for doing all of this based on json input files.  You need two input files to invoke the runner:
1. A problem file defining the steps outlined above -- which structure generator, mesh, physics, solver, etc.
2. A system file letting compgen know how to run external tools (meshers and physics codes).

There are examples of each file type to make up the 2D and 3D demos, described below.

## Tests and demos

First set environment variables:
1. `MOOSE_DIR` to the root directory of your moose installation
2. `CUBIT_DIR` to the root directory of your CUBIT directory, if you want to run the demos using sculpt.  This is not necessary for the verification tests.

## Run the tests

Run the tests with `pytest`.  The general tests in the `tests` directory do not require MOOSE and are quick and cheap to run.  The verification tests in `tests/verification` are more expensive and require MOOSE.

## Run the demos

There are complete demos that generate random structures, call MOOSE to solve for some material properties, and store the results.  These demos live in `demos/complete`.  The subdirectories first split
the problems into different physics/types of material properties and then into 2D and 3D examples.

## License headers

Every source file (`*.py` and the MOOSE `*.i` templates) must start with the contents of `LICENSE` as a comment header.  CI enforces this.

- `python scripts/add_license.py` adds the header to any tracked source file that is missing it (or pass specific files as arguments).
- `python scripts/check_license.py` reports files missing the header and exits non-zero if there are any.

## Pre-commit hooks

The license check, black, and pylint run as [pre-commit](https://pre-commit.com) hooks on the files staged for each commit.  To enable them, install the dev dependencies and then install the hooks once per clone:

```
pip install -e .[dev]
pre-commit install
```

To run the hooks by hand against every file, use `pre-commit run --all-files`.
