hyper-surrogate 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. hyper_surrogate-0.1.0/.editorconfig +5 -0
  2. hyper_surrogate-0.1.0/.github/actions/setup-uv-env/action.yml +25 -0
  3. hyper_surrogate-0.1.0/.github/workflows/main.yml +73 -0
  4. hyper_surrogate-0.1.0/.github/workflows/on-release-main.yml +65 -0
  5. hyper_surrogate-0.1.0/.github/workflows/validate-codecov-config.yml +15 -0
  6. hyper_surrogate-0.1.0/.gitignore +182 -0
  7. hyper_surrogate-0.1.0/.pre-commit-config.yaml +24 -0
  8. hyper_surrogate-0.1.0/CONTRIBUTING.md +133 -0
  9. hyper_surrogate-0.1.0/LICENSE +21 -0
  10. hyper_surrogate-0.1.0/Makefile +54 -0
  11. hyper_surrogate-0.1.0/PKG-INFO +74 -0
  12. hyper_surrogate-0.1.0/README.md +55 -0
  13. hyper_surrogate-0.1.0/codecov.yaml +13 -0
  14. hyper_surrogate-0.1.0/docs/about.md +26 -0
  15. hyper_surrogate-0.1.0/docs/custom.js +10 -0
  16. hyper_surrogate-0.1.0/docs/examples.md +140 -0
  17. hyper_surrogate-0.1.0/docs/index.md +8 -0
  18. hyper_surrogate-0.1.0/docs/installation.md +44 -0
  19. hyper_surrogate-0.1.0/docs/modules.md +33 -0
  20. hyper_surrogate-0.1.0/docs/tutorial1.ipynb +338 -0
  21. hyper_surrogate-0.1.0/hyper_surrogate/__init__.py +35 -0
  22. hyper_surrogate-0.1.0/hyper_surrogate/data/__init__.py +4 -0
  23. hyper_surrogate-0.1.0/hyper_surrogate/data/dataset.py +169 -0
  24. hyper_surrogate-0.1.0/hyper_surrogate/data/deformation.py +69 -0
  25. hyper_surrogate-0.1.0/hyper_surrogate/export/__init__.py +7 -0
  26. hyper_surrogate-0.1.0/hyper_surrogate/export/fortran/__init__.py +0 -0
  27. hyper_surrogate-0.1.0/hyper_surrogate/export/fortran/analytical.py +234 -0
  28. hyper_surrogate-0.1.0/hyper_surrogate/export/fortran/emitter.py +209 -0
  29. hyper_surrogate-0.1.0/hyper_surrogate/export/weights.py +79 -0
  30. hyper_surrogate-0.1.0/hyper_surrogate/mechanics/__init__.py +5 -0
  31. hyper_surrogate-0.1.0/hyper_surrogate/mechanics/kinematics.py +211 -0
  32. hyper_surrogate-0.1.0/hyper_surrogate/mechanics/materials.py +169 -0
  33. hyper_surrogate-0.1.0/hyper_surrogate/mechanics/symbolic.py +408 -0
  34. hyper_surrogate-0.1.0/hyper_surrogate/models/__init__.py +7 -0
  35. hyper_surrogate-0.1.0/hyper_surrogate/models/base.py +30 -0
  36. hyper_surrogate-0.1.0/hyper_surrogate/models/icnn.py +98 -0
  37. hyper_surrogate-0.1.0/hyper_surrogate/models/mlp.py +67 -0
  38. hyper_surrogate-0.1.0/hyper_surrogate/reporting/__init__.py +3 -0
  39. hyper_surrogate-0.1.0/hyper_surrogate/reporting/reporter.py +106 -0
  40. hyper_surrogate-0.1.0/hyper_surrogate/training/__init__.py +7 -0
  41. hyper_surrogate-0.1.0/hyper_surrogate/training/losses.py +42 -0
  42. hyper_surrogate-0.1.0/hyper_surrogate/training/trainer.py +114 -0
  43. hyper_surrogate-0.1.0/mkdocs.yml +75 -0
  44. hyper_surrogate-0.1.0/notebooks/generate_deformation.ipynb +86 -0
  45. hyper_surrogate-0.1.0/pyproject.toml +127 -0
  46. hyper_surrogate-0.1.0/tests/mock_data.py +527 -0
  47. hyper_surrogate-0.1.0/tests/test_data_dataset.py +78 -0
  48. hyper_surrogate-0.1.0/tests/test_data_deformation.py +49 -0
  49. hyper_surrogate-0.1.0/tests/test_export_weights.py +42 -0
  50. hyper_surrogate-0.1.0/tests/test_fortran_emitter.py +45 -0
  51. hyper_surrogate-0.1.0/tests/test_integration.py +60 -0
  52. hyper_surrogate-0.1.0/tests/test_kinematics.py +117 -0
  53. hyper_surrogate-0.1.0/tests/test_material.py +89 -0
  54. hyper_surrogate-0.1.0/tests/test_mechanics_materials.py +35 -0
  55. hyper_surrogate-0.1.0/tests/test_models_icnn.py +56 -0
  56. hyper_surrogate-0.1.0/tests/test_models_mlp.py +33 -0
  57. hyper_surrogate-0.1.0/tests/test_neohooke.py +141 -0
  58. hyper_surrogate-0.1.0/tests/test_reporter.py +41 -0
  59. hyper_surrogate-0.1.0/tests/test_symbolic_rules.py +248 -0
  60. hyper_surrogate-0.1.0/tests/test_training_losses.py +34 -0
  61. hyper_surrogate-0.1.0/tests/test_training_trainer.py +35 -0
  62. hyper_surrogate-0.1.0/tests/test_umat_handler.py +62 -0
  63. hyper_surrogate-0.1.0/uv.lock +3079 -0
@@ -0,0 +1,5 @@
1
+ max_line_length = 120
2
+
3
+ [*.json]
4
+ indent_style = space
5
+ indent_size = 4
@@ -0,0 +1,25 @@
1
+ name: "setup-uv-env"
2
+ description: "Composite action to setup Python and uv environment."
3
+
4
+ inputs:
5
+ python-version:
6
+ required: false
7
+ description: "The python version to use"
8
+ default: "3.12"
9
+
10
+ runs:
11
+ using: "composite"
12
+ steps:
13
+ - name: Install uv
14
+ uses: astral-sh/setup-uv@v4
15
+ with:
16
+ enable-cache: true
17
+
18
+ - name: Set up python
19
+ uses: actions/setup-python@v5
20
+ with:
21
+ python-version: ${{ inputs.python-version }}
22
+
23
+ - name: Install dependencies
24
+ run: uv sync --all-groups
25
+ shell: bash
@@ -0,0 +1,73 @@
1
+ name: Main
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ pull_request:
8
+ types: [opened, synchronize, reopened, ready_for_review]
9
+
10
+ jobs:
11
+ quality:
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - name: Check out
15
+ uses: actions/checkout@v4
16
+
17
+ - name: Set up the environment
18
+ uses: ./.github/actions/setup-uv-env
19
+
20
+ - name: Run checks
21
+ run: make check
22
+
23
+ tests:
24
+ runs-on: ubuntu-latest
25
+ strategy:
26
+ matrix:
27
+ python-version: ["3.12", "3.13"]
28
+ fail-fast: false
29
+ steps:
30
+ - name: Check out
31
+ uses: actions/checkout@v4
32
+
33
+ - name: Install uv
34
+ uses: astral-sh/setup-uv@v4
35
+ with:
36
+ enable-cache: true
37
+
38
+ - name: Set up python
39
+ uses: actions/setup-python@v5
40
+ with:
41
+ python-version: ${{ matrix.python-version }}
42
+
43
+ - name: Install dependencies
44
+ run: uv sync --all-groups --extra ml
45
+
46
+ - name: Run tests (fast on PR, all on main)
47
+ run: |
48
+ if [ "${{ github.event_name }}" = "push" ]; then
49
+ uv run pytest --doctest-modules tests -m "" --cov --cov-config=pyproject.toml --cov-report=xml
50
+ else
51
+ uv run pytest --doctest-modules tests --cov --cov-config=pyproject.toml --cov-report=xml
52
+ fi
53
+
54
+ - name: Run mypy
55
+ run: uv run mypy
56
+
57
+ - name: Upload coverage reports to Codecov on Python 3.13
58
+ uses: codecov/codecov-action@v4
59
+ if: ${{ matrix.python-version == '3.13' }}
60
+ with:
61
+ token: ${{ secrets.CODECOV_TOKEN }}
62
+
63
+ check-docs:
64
+ runs-on: ubuntu-latest
65
+ steps:
66
+ - name: Check out
67
+ uses: actions/checkout@v4
68
+
69
+ - name: Set up the environment
70
+ uses: ./.github/actions/setup-uv-env
71
+
72
+ - name: Check if documentation can be built
73
+ run: uv run mkdocs build -s
@@ -0,0 +1,65 @@
1
+ name: release-main
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+ branches: [main]
7
+
8
+ jobs:
9
+ publish:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - name: Check out
13
+ uses: actions/checkout@v4
14
+
15
+ - name: Set up the environment
16
+ uses: ./.github/actions/setup-uv-env
17
+
18
+ - name: Export tag
19
+ id: vars
20
+ run: echo tag=${GITHUB_REF#refs/*/} >> $GITHUB_OUTPUT
21
+
22
+ - name: Build and publish
23
+ run: |
24
+ sed -i "s/^version = .*/version = \"$RELEASE_VERSION\"/" pyproject.toml
25
+ make build-and-publish
26
+ env:
27
+ UV_PUBLISH_TOKEN: ${{ secrets.PYPI_TOKEN }}
28
+ RELEASE_VERSION: ${{ steps.vars.outputs.tag }}
29
+
30
+ build-and-upload-docs:
31
+ needs: publish
32
+ environment:
33
+ name: github-pages
34
+ url: ${{ steps.deployment.outputs.page_url }}
35
+ runs-on: ubuntu-latest
36
+ steps:
37
+ - name: Check out
38
+ uses: actions/checkout@v4
39
+
40
+ - name: Set up the environment
41
+ uses: ./.github/actions/setup-uv-env
42
+
43
+ - name: Build documentation
44
+ run: uv run mkdocs build --clean
45
+
46
+ - name: Upload Pages artifact for deployment
47
+ uses: actions/upload-pages-artifact@v3
48
+ with:
49
+ path: site
50
+
51
+ deploy-docs:
52
+ needs: build-and-upload-docs
53
+ permissions:
54
+ pages: write
55
+ id-token: write
56
+
57
+ environment:
58
+ name: github-pages
59
+ url: ${{ steps.deployment.outputs.page_url }}
60
+
61
+ runs-on: ubuntu-latest
62
+ steps:
63
+ - name: Deploy to GitHub Pages
64
+ id: deployment
65
+ uses: actions/deploy-pages@v4
@@ -0,0 +1,15 @@
1
+ name: validate-codecov-config
2
+
3
+ on:
4
+ pull_request:
5
+ paths: [codecov.yaml]
6
+ push:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ validate-codecov-config:
11
+ runs-on: ubuntu-22.04
12
+ steps:
13
+ - uses: actions/checkout@v4
14
+ - name: Validate codecov configuration
15
+ run: curl -sSL --fail-with-body --data-binary @codecov.yaml https://codecov.io/validate
@@ -0,0 +1,182 @@
1
+ docs/source
2
+ .worktrees/
3
+ .DS_Store
4
+
5
+ # Demo artifacts (not part of the library)
6
+ demo.py
7
+ create_demo_animation.py
8
+ create_preview.py
9
+ record_demo.sh
10
+ DEMO_README.md
11
+ hyper_surrogate_demo.*
12
+
13
+ # Fortran build artifacts
14
+ scripts/
15
+ examples/outputs/
16
+
17
+ # From https://raw.githubusercontent.com/github/gitignore/main/Python.gitignore
18
+
19
+ # Byte-compiled / optimized / DLL files
20
+ __pycache__/
21
+ *.py[cod]
22
+ *$py.class
23
+
24
+ # C extensions
25
+ *.so
26
+
27
+ # Distribution / packaging
28
+ .Python
29
+ build/
30
+ develop-eggs/
31
+ dist/
32
+ downloads/
33
+ eggs/
34
+ .eggs/
35
+ lib/
36
+ lib64/
37
+ parts/
38
+ sdist/
39
+ var/
40
+ wheels/
41
+ share/python-wheels/
42
+ *.egg-info/
43
+ .installed.cfg
44
+ *.egg
45
+ MANIFEST
46
+
47
+ # PyInstaller
48
+ # Usually these files are written by a python script from a template
49
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
50
+ *.manifest
51
+ *.spec
52
+
53
+ # Installer logs
54
+ pip-log.txt
55
+ pip-delete-this-directory.txt
56
+
57
+ # Unit test / coverage reports
58
+ htmlcov/
59
+ .tox/
60
+ .nox/
61
+ .coverage
62
+ .coverage.*
63
+ .cache
64
+ nosetests.xml
65
+ coverage.xml
66
+ *.cover
67
+ *.py,cover
68
+ .hypothesis/
69
+ .pytest_cache/
70
+ cover/
71
+
72
+ # Translations
73
+ *.mo
74
+ *.pot
75
+
76
+ # Django stuff:
77
+ *.log
78
+ local_settings.py
79
+ db.sqlite3
80
+ db.sqlite3-journal
81
+
82
+ # Flask stuff:
83
+ instance/
84
+ .webassets-cache
85
+
86
+ # Scrapy stuff:
87
+ .scrapy
88
+
89
+ # Sphinx documentation
90
+ docs/_build/
91
+
92
+ # PyBuilder
93
+ .pybuilder/
94
+ target/
95
+
96
+ # Jupyter Notebook
97
+ .ipynb_checkpoints
98
+
99
+ # IPython
100
+ profile_default/
101
+ ipython_config.py
102
+
103
+ # pyenv
104
+ # For a library or package, you might want to ignore these files since the code is
105
+ # intended to run in multiple environments; otherwise, check them in:
106
+ # .python-version
107
+
108
+ # pipenv
109
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
110
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
111
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
112
+ # install all needed dependencies.
113
+ #Pipfile.lock
114
+
115
+ # poetry
116
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
117
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
118
+ # commonly ignored for libraries.
119
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
120
+ #poetry.lock
121
+
122
+ # pdm
123
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
124
+ #pdm.lock
125
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
126
+ # in version control.
127
+ # https://pdm.fming.dev/#use-with-ide
128
+ .pdm.toml
129
+
130
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
131
+ __pypackages__/
132
+
133
+ # Celery stuff
134
+ celerybeat-schedule
135
+ celerybeat.pid
136
+
137
+ # SageMath parsed files
138
+ *.sage.py
139
+
140
+ # Environments
141
+ .env
142
+ .venv
143
+ env/
144
+ venv/
145
+ ENV/
146
+ env.bak/
147
+ venv.bak/
148
+
149
+ # Spyder project settings
150
+ .spyderproject
151
+ .spyproject
152
+
153
+ # Rope project settings
154
+ .ropeproject
155
+
156
+ # mkdocs documentation
157
+ /site
158
+
159
+ # mypy
160
+ .mypy_cache/
161
+ .dmypy.json
162
+ dmypy.json
163
+
164
+ # Pyre type checker
165
+ .pyre/
166
+
167
+ # pytype static type analyzer
168
+ .pytype/
169
+
170
+ # Cython debug symbols
171
+ cython_debug/
172
+
173
+ # Vscode config files
174
+ .vscode/
175
+
176
+ # PyCharm
177
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
178
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
179
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
180
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
181
+ #.idea/
182
+ .qodo
@@ -0,0 +1,24 @@
1
+ repos:
2
+ - repo: https://github.com/pre-commit/pre-commit-hooks
3
+ rev: "v4.6.0"
4
+ hooks:
5
+ - id: check-case-conflict
6
+ - id: check-merge-conflict
7
+ - id: check-toml
8
+ - id: check-yaml
9
+ - id: end-of-file-fixer
10
+ - id: trailing-whitespace
11
+
12
+ - repo: https://github.com/astral-sh/ruff-pre-commit
13
+ rev: "v0.6.5"
14
+ hooks:
15
+ - id: ruff
16
+ args: [--exit-non-zero-on-fix]
17
+ - id: ruff-format
18
+
19
+ - repo: https://github.com/pre-commit/mirrors-prettier
20
+ rev: "v3.1.0"
21
+ hooks:
22
+ - id: prettier
23
+ additional_dependencies:
24
+ - prettier@3.2.5 # SEE: https://github.com/pre-commit/pre-commit/issues/3133
@@ -0,0 +1,133 @@
1
+ # Contributing to `hyper-surrogate`
2
+
3
+ Contributions are welcome, and they are greatly appreciated!
4
+ Every little bit helps, and credit will always be given.
5
+
6
+ You can contribute in many ways:
7
+
8
+ # Types of Contributions
9
+
10
+ ## Report Bugs
11
+
12
+ Report bugs at https://github.com/jpsferreira/hyper-surrogate/issues
13
+
14
+ If you are reporting a bug, please include:
15
+
16
+ - Your operating system name and version.
17
+ - Any details about your local setup that might be helpful in troubleshooting.
18
+ - Detailed steps to reproduce the bug.
19
+
20
+ ## Fix Bugs
21
+
22
+ Look through the GitHub issues for bugs.
23
+ Anything tagged with "bug" and "help wanted" is open to whoever wants to implement a fix for it.
24
+
25
+ ## Implement Features
26
+
27
+ Look through the GitHub issues for features.
28
+ Anything tagged with "enhancement" and "help wanted" is open to whoever wants to implement it.
29
+
30
+ ## Write Documentation
31
+
32
+ Cookiecutter PyPackage could always use more documentation, whether as part of the official docs, in docstrings, or even on the web in blog posts, articles, and such.
33
+
34
+ ## Submit Feedback
35
+
36
+ The best way to send feedback is to file an issue at https://github.com/jpsferreira/hyper-surrogate/issues.
37
+
38
+ If you are proposing a new feature:
39
+
40
+ - Explain in detail how it would work.
41
+ - Keep the scope as narrow as possible, to make it easier to implement.
42
+ - Remember that this is a volunteer-driven project, and that contributions
43
+ are welcome :)
44
+
45
+ # Get Started!
46
+
47
+ Ready to contribute? Here's how to set up `hyper-surrogate` for local development.
48
+ Please note this documentation assumes you already have `poetry` and `Git` installed and ready to go.
49
+
50
+ 1. Fork the `hyper-surrogate` repo on GitHub.
51
+
52
+ 2. Clone your fork locally:
53
+
54
+ ```bash
55
+ cd <directory_in_which_repo_should_be_created>
56
+ git clone git@github.com:YOUR_NAME/hyper-surrogate.git
57
+ ```
58
+
59
+ 3. Now we need to install the environment. Navigate into the directory
60
+
61
+ ```bash
62
+ cd hyper-surrogate
63
+ ```
64
+
65
+ If you are using `pyenv`, select a version to use locally. (See installed versions with `pyenv versions`)
66
+
67
+ ```bash
68
+ pyenv local <x.y.z>
69
+ ```
70
+
71
+ Then, install and activate the environment with:
72
+
73
+ ```bash
74
+ poetry install
75
+ poetry shell
76
+ ```
77
+
78
+ 4. Install pre-commit to run linters/formatters at commit time:
79
+
80
+ ```bash
81
+ poetry run pre-commit install
82
+ ```
83
+
84
+ 5. Create a branch for local development:
85
+
86
+ ```bash
87
+ git checkout -b name-of-your-bugfix-or-feature
88
+ ```
89
+
90
+ Now you can make your changes locally.
91
+
92
+ 6. Don't forget to add test cases for your added functionality to the `tests` directory.
93
+
94
+ 7. When you're done making changes, check that your changes pass the formatting tests.
95
+
96
+ ```bash
97
+ make check
98
+ ```
99
+
100
+ Now, validate that all unit tests are passing:
101
+
102
+ ```bash
103
+ make test
104
+ ```
105
+
106
+ 9. Before raising a pull request you should also run tox.
107
+ This will run the tests across different versions of Python:
108
+
109
+ ```bash
110
+ tox
111
+ ```
112
+
113
+ This requires you to have multiple versions of python installed.
114
+ This step is also triggered in the CI/CD pipeline, so you could also choose to skip this step locally.
115
+
116
+ 10. Commit your changes and push your branch to GitHub:
117
+
118
+ ```bash
119
+ git add .
120
+ git commit -m "Your detailed description of your changes."
121
+ git push origin name-of-your-bugfix-or-feature
122
+ ```
123
+
124
+ 11. Submit a pull request through the GitHub website.
125
+
126
+ # Pull Request Guidelines
127
+
128
+ Before you submit a pull request, check that it meets these guidelines:
129
+
130
+ 1. The pull request should include tests.
131
+
132
+ 2. If the pull request adds functionality, the docs should be updated.
133
+ Put your new functionality into a function with a docstring, and add the feature to the list in `README.md`.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024, Joao Ferreira
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,54 @@
1
+ .PHONY: install
2
+ install: ## Install the environment and pre-commit hooks
3
+ @echo "🚀 Creating virtual environment using uv"
4
+ @uv sync --all-groups
5
+ @uv run pre-commit install
6
+
7
+ .PHONY: check
8
+ check: ## Run code quality tools.
9
+ @echo "🚀 Checking lockfile consistency with 'pyproject.toml': Running uv lock --check"
10
+ @uv lock --check
11
+ @echo "🚀 Linting code: Running pre-commit"
12
+ @uv run pre-commit run -a
13
+ @echo "🚀 Static type checking: Running mypy"
14
+ @uv run mypy
15
+ @echo "🚀 Checking for obsolete dependencies: Running deptry"
16
+ @uv run deptry .
17
+
18
+ .PHONY: test
19
+ test: ## Test the code with pytest
20
+ @echo "🚀 Testing code: Running pytest"
21
+ @uv run pytest --cov --cov-config=pyproject.toml --cov-report=xml
22
+
23
+ .PHONY: build
24
+ build: clean-build ## Build wheel file
25
+ @echo "🚀 Creating wheel file"
26
+ @uv build
27
+
28
+ .PHONY: clean-build
29
+ clean-build: ## clean build artifacts
30
+ @rm -rf dist
31
+
32
+ .PHONY: publish
33
+ publish: ## publish a release to pypi.
34
+ @echo "🚀 Publishing: Dry run."
35
+ @uv publish --dry-run
36
+ @echo "🚀 Publishing."
37
+ @uv publish
38
+
39
+ .PHONY: build-and-publish
40
+ build-and-publish: build publish ## Build and publish.
41
+
42
+ .PHONY: docs-test
43
+ docs-test: ## Test if documentation can be built without warnings or errors
44
+ @uv run mkdocs build -s
45
+
46
+ .PHONY: docs
47
+ docs: ## Build and serve the documentation
48
+ @uv run mkdocs serve
49
+
50
+ .PHONY: help
51
+ help:
52
+ @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
53
+
54
+ .DEFAULT_GOAL := help
@@ -0,0 +1,74 @@
1
+ Metadata-Version: 2.4
2
+ Name: hyper-surrogate
3
+ Version: 0.1.0
4
+ Summary: Hyperelastic Surrogates
5
+ Project-URL: repository, https://github.com/jpsferreira/hyper-surrogate
6
+ Project-URL: documentation, https://jpsferreira.github.io/hyper-surrogate/
7
+ Author-email: Joao Ferreira <fj.ferreira@fe.up.pt>
8
+ License-File: LICENSE
9
+ Requires-Python: >=3.12
10
+ Requires-Dist: matplotlib>=3.8.3
11
+ Requires-Dist: numpy>=1.26.4
12
+ Requires-Dist: pandas>=2.2.3
13
+ Requires-Dist: seaborn>=0.13.2
14
+ Requires-Dist: sympy>=1.12
15
+ Requires-Dist: tqdm>=4.66.5
16
+ Provides-Extra: ml
17
+ Requires-Dist: torch>=2.0; extra == 'ml'
18
+ Description-Content-Type: text/markdown
19
+
20
+ # hyper-surrogate
21
+
22
+ [![Release](https://img.shields.io/github/v/release/jpsferreira/hyper-surrogate)](https://img.shields.io/github/v/release/jpsferreira/hyper-surrogate)
23
+ [![Build status](https://img.shields.io/github/actions/workflow/status/jpsferreira/hyper-surrogate/main.yml?branch=main)](https://github.com/jpsferreira/hyper-surrogate/actions/workflows/main.yml?query=branch%3Amain)
24
+ [![codecov](https://codecov.io/gh/jpsferreira/hyper-surrogate/branch/main/graph/badge.svg)](https://codecov.io/gh/jpsferreira/hyper-surrogate)
25
+ [![License](https://img.shields.io/github/license/jpsferreira/hyper-surrogate)](https://img.shields.io/github/license/jpsferreira/hyper-surrogate)
26
+
27
+ Data-driven surrogates for hyperelastic constitutive models in finite element analysis.
28
+
29
+ - **Github repository**: <https://github.com/jpsferreira/hyper-surrogate/>
30
+ - **Documentation**: <https://jpsferreira.github.io/hyper-surrogate/>
31
+
32
+ ## Features
33
+
34
+ - **Symbolic mechanics** -- Automatic PK2 stress and stiffness tensor derivation via SymPy
35
+ - **ML surrogates** -- MLP and Input-Convex Neural Network (ICNN) models for constitutive response approximation
36
+ - **Fortran export** -- Transpile trained models to standalone Fortran 90 subroutines with baked-in weights
37
+ - **Analytical UMAT** -- Generate optimized Fortran UMAT subroutines from symbolic expressions
38
+
39
+ ## Quick start
40
+
41
+ ```python
42
+ import hyper_surrogate as hs
43
+
44
+ # Define material and generate training data
45
+ material = hs.NeoHooke({"C10": 0.5, "KBULK": 1000.0})
46
+ train_ds, val_ds, in_norm, out_norm = hs.create_datasets(
47
+ material, n_samples=5000, input_type="invariants", target_type="pk2_voigt",
48
+ )
49
+
50
+ # Train an MLP surrogate
51
+ model = hs.MLP(input_dim=3, output_dim=6, hidden_dims=[32, 32], activation="tanh")
52
+ result = hs.Trainer(model, train_ds, val_ds, loss_fn=hs.StressLoss(), max_epochs=500).fit()
53
+
54
+ # Export to Fortran 90
55
+ exported = hs.extract_weights(result.model, in_norm, out_norm)
56
+ hs.FortranEmitter(exported).write("nn_surrogate.f90")
57
+ ```
58
+
59
+ See the [examples](https://jpsferreira.github.io/hyper-surrogate/examples/) for more usage patterns.
60
+
61
+ ## Installation
62
+
63
+ ```bash
64
+ pip install hyper-surrogate # core (NumPy, SymPy)
65
+ pip install hyper-surrogate[ml] # with PyTorch for ML surrogates
66
+ ```
67
+
68
+ From source with [uv](https://docs.astral.sh/uv/):
69
+
70
+ ```bash
71
+ git clone https://github.com/jpsferreira/hyper-surrogate.git
72
+ cd hyper-surrogate
73
+ uv sync --all-groups --extra ml
74
+ ```