tommos 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 (123) hide show
  1. tommos-0.1.0/.github/scripts/repair_linux_wheel.sh +77 -0
  2. tommos-0.1.0/.github/workflows/release.yml +85 -0
  3. tommos-0.1.0/.github/workflows/test.yml +40 -0
  4. tommos-0.1.0/.github/workflows/wheels.yml +108 -0
  5. tommos-0.1.0/.gitignore +44 -0
  6. tommos-0.1.0/.pre-commit-config.yaml +22 -0
  7. tommos-0.1.0/.zenodo.json +64 -0
  8. tommos-0.1.0/AGENTS.md +70 -0
  9. tommos-0.1.0/LICENSE +21 -0
  10. tommos-0.1.0/PKG-INFO +527 -0
  11. tommos-0.1.0/README.md +506 -0
  12. tommos-0.1.0/benchmarking/CMakeLists.txt +44 -0
  13. tommos-0.1.0/benchmarking/analyze_trace.py +133 -0
  14. tommos-0.1.0/benchmarking/compare_minimizers.py +283 -0
  15. tommos-0.1.0/benchmarking/generate_report.py +129 -0
  16. tommos-0.1.0/benchmarking/generate_test_mesh.py +17 -0
  17. tommos-0.1.0/benchmarking/install_cpp.md +76 -0
  18. tommos-0.1.0/benchmarking/profile_compilation.py +182 -0
  19. tommos-0.1.0/benchmarking/profile_energy.py +130 -0
  20. tommos-0.1.0/benchmarking/profile_energy_jax.py +115 -0
  21. tommos-0.1.0/benchmarking/run_benchmarks.sh +36 -0
  22. tommos-0.1.0/benchmarking/run_comparison_benchmark.sh +25 -0
  23. tommos-0.1.0/benchmarking/src_cpp/energy_kernels.cpp +70 -0
  24. tommos-0.1.0/benchmarking/src_cpp/energy_kernels.hpp +45 -0
  25. tommos-0.1.0/benchmarking/src_cpp/fem_utils.cpp +258 -0
  26. tommos-0.1.0/benchmarking/src_cpp/fem_utils.hpp +93 -0
  27. tommos-0.1.0/benchmarking/src_cpp/poisson_solve.cpp +54 -0
  28. tommos-0.1.0/benchmarking/src_cpp/poisson_solve.hpp +49 -0
  29. tommos-0.1.0/benchmarking/src_cpp/profile_energy.cpp +134 -0
  30. tommos-0.1.0/benchmarking/src_cpp/test_energy.cpp +151 -0
  31. tommos-0.1.0/benchmarking/src_cpp/test_poisson_convergence.cpp +91 -0
  32. tommos-0.1.0/benchmarking/test_poisson_convergence.py +106 -0
  33. tommos-0.1.0/develop/strain/lsdyna/export_vtk.py +336 -0
  34. tommos-0.1.0/develop/strain/plot_greene_results.py +62 -0
  35. tommos-0.1.0/develop/strain/test_stoner_wohlfarth_me.py +274 -0
  36. tommos-0.1.0/doc/arrays.md +28 -0
  37. tommos-0.1.0/doc/cg_comparison.tex +191 -0
  38. tommos-0.1.0/doc/commits_since_july_13.md +32 -0
  39. tommos-0.1.0/doc/compare2.md +374 -0
  40. tommos-0.1.0/doc/developer_notes/PERFORMANCE_TUNING.md +68 -0
  41. tommos-0.1.0/doc/developer_notes/PROGRESS_SUMMARY.md +44 -0
  42. tommos-0.1.0/doc/magnetoelastic_derivation.tex +76 -0
  43. tommos-0.1.0/doc/multi_gpu_analysis.tex +94 -0
  44. tommos-0.1.0/doc/paper.tex +304 -0
  45. tommos-0.1.0/doc/references.bib +425 -0
  46. tommos-0.1.0/docs/slurm.md +75 -0
  47. tommos-0.1.0/examples/benchmark_1/benchmark1_workflow.py +1850 -0
  48. tommos-0.1.0/examples/benchmark_1/isotrop_down/isotrop.krn +11 -0
  49. tommos-0.1.0/examples/benchmark_1/isotrop_down/isotrop.p2 +25 -0
  50. tommos-0.1.0/examples/benchmark_1/isotrop_up/isotrop.krn +11 -0
  51. tommos-0.1.0/examples/benchmark_1/isotrop_up/isotrop.p2 +25 -0
  52. tommos-0.1.0/examples/evaluate_materials/K1MsAx_space/plot_k1_js_space.py +190 -0
  53. tommos-0.1.0/examples/evaluate_materials/analyze_evaluations.py +327 -0
  54. tommos-0.1.0/examples/evaluate_materials/clean_evaluations.sh +14 -0
  55. tommos-0.1.0/examples/evaluate_materials/compute_evaluations.py +103 -0
  56. tommos-0.1.0/examples/evaluate_materials/evaluate_properties.py +58 -0
  57. tommos-0.1.0/examples/evaluate_materials/generate_structures.py +73 -0
  58. tommos-0.1.0/examples/evaluate_materials/run_evaluate_properties.slurm +76 -0
  59. tommos-0.1.0/examples/evaluate_materials/run_generate_structures.slurm +18 -0
  60. tommos-0.1.0/examples/sensor_loop/OOMMF_results_from_definition_of_benchmark2/BENCHMARK_PARAMETERS_README.md +487 -0
  61. tommos-0.1.0/examples/sensor_loop/OOMMF_results_from_definition_of_benchmark2/plot_oommf_sweeps.py +979 -0
  62. tommos-0.1.0/examples/sensor_loop/README.md +291 -0
  63. tommos-0.1.0/examples/sensor_loop/clean.sh +18 -0
  64. tommos-0.1.0/examples/sensor_loop/clean_all.sh +28 -0
  65. tommos-0.1.0/examples/sensor_loop/plot_comparison.py +103 -0
  66. tommos-0.1.0/examples/sensor_loop/run_case_a_down.slurm +27 -0
  67. tommos-0.1.0/examples/sensor_loop/run_sensor_workflow_cpu.slurm +44 -0
  68. tommos-0.1.0/examples/sensor_loop/run_sensor_workflow_gpu.slurm +27 -0
  69. tommos-0.1.0/examples/sensor_loop/sensor_loop_evaluation.py +1603 -0
  70. tommos-0.1.0/examples/sensor_loop/sensor_loop_step_by_step.py +943 -0
  71. tommos-0.1.0/pyproject.toml +141 -0
  72. tommos-0.1.0/samples/cube_20nm.krn +2 -0
  73. tommos-0.1.0/samples/cube_20nm.p2 +22 -0
  74. tommos-0.1.0/samples/mesh_sensor.sh +7 -0
  75. tommos-0.1.0/samples/run_cube.sh +31 -0
  76. tommos-0.1.0/samples/sphereR10nm/readme.md +37 -0
  77. tommos-0.1.0/samples/sphereR10nm/run_sphereR10nm.sh +11 -0
  78. tommos-0.1.0/samples/sphereR10nm/sphereR10nm.krn +1 -0
  79. tommos-0.1.0/samples/sphereR10nm/sphereR10nm.p2 +24 -0
  80. tommos-0.1.0/samples/sphereR20nm/readme.md +37 -0
  81. tommos-0.1.0/samples/sphereR20nm/run_sphereR20nm.sh +11 -0
  82. tommos-0.1.0/samples/sphereR20nm/sphereR20nm.krn +1 -0
  83. tommos-0.1.0/samples/sphereR20nm/sphereR20nm.p2 +24 -0
  84. tommos-0.1.0/src/cpp/CMakeLists.txt +53 -0
  85. tommos-0.1.0/src/cpp/cpp_mkl_minimizer.cpp +771 -0
  86. tommos-0.1.0/src/tommos/__init__.py +1 -0
  87. tommos-0.1.0/src/tommos/add_shell.py +1104 -0
  88. tommos-0.1.0/src/tommos/amg_utils.py +1282 -0
  89. tommos-0.1.0/src/tommos/cli.py +74 -0
  90. tommos-0.1.0/src/tommos/cpp_minimizer.py +177 -0
  91. tommos-0.1.0/src/tommos/energy_kernels.py +156 -0
  92. tommos-0.1.0/src/tommos/extract_nucleation.py +54 -0
  93. tommos-0.1.0/src/tommos/fem_utils.py +117 -0
  94. tommos-0.1.0/src/tommos/hysteresis_loop.py +587 -0
  95. tommos-0.1.0/src/tommos/io_utils.py +323 -0
  96. tommos-0.1.0/src/tommos/jax_utils.py +32 -0
  97. tommos-0.1.0/src/tommos/loop.py +1333 -0
  98. tommos-0.1.0/src/tommos/make_krn.py +162 -0
  99. tommos-0.1.0/src/tommos/memory_profiler.py +51 -0
  100. tommos-0.1.0/src/tommos/mesh.py +2583 -0
  101. tommos-0.1.0/src/tommos/mesh_convert.py +174 -0
  102. tommos-0.1.0/src/tommos/minimizers.py +990 -0
  103. tommos-0.1.0/src/tommos/plot_hysteresis.py +44 -0
  104. tommos-0.1.0/src/tommos/poisson_solve.py +469 -0
  105. tommos-0.1.0/src/tommos/reorder_mesh.py +168 -0
  106. tommos-0.1.0/src/tommos/salomeMeshToNpz.py +64 -0
  107. tommos-0.1.0/tests/cube_20nm.krn +2 -0
  108. tommos-0.1.0/tests/cube_20nm.p2 +21 -0
  109. tommos-0.1.0/tests/run_multi_gpu.slurm +21 -0
  110. tommos-0.1.0/tests/test_cli.py +93 -0
  111. tommos-0.1.0/tests/test_compare_kernels.py +375 -0
  112. tommos-0.1.0/tests/test_cpp_minimizer.py +197 -0
  113. tommos-0.1.0/tests/test_demag_runs.sh +193 -0
  114. tommos-0.1.0/tests/test_distributed_csr.py +68 -0
  115. tommos-0.1.0/tests/test_energy.py +192 -0
  116. tommos-0.1.0/tests/test_gradients.py +311 -0
  117. tommos-0.1.0/tests/test_mkl.py +75 -0
  118. tommos-0.1.0/tests/test_mkl_jit.py +44 -0
  119. tommos-0.1.0/tests/test_py_minimizer.py +217 -0
  120. tommos-0.1.0/viz/plot_combined.py +49 -0
  121. tommos-0.1.0/viz/visualize_lbfgs.py +39 -0
  122. tommos-0.1.0/viz/visualize_mesh_slice.py +140 -0
  123. tommos-0.1.0/viz/visualize_switching.py +62 -0
@@ -0,0 +1,77 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ if [[ "$#" -ne 2 ]]; then
5
+ echo "usage: repair_linux_wheel.sh WHEEL DEST_DIR" >&2
6
+ exit 2
7
+ fi
8
+
9
+ INPUT_WHEEL="$1"
10
+ DEST_DIR="$2"
11
+ if [[ ! -f "$INPUT_WHEEL" ]]; then
12
+ echo "input wheel does not exist: $INPUT_WHEEL" >&2
13
+ exit 2
14
+ fi
15
+
16
+ mkdir -p "$DEST_DIR"
17
+ WORK_DIR="$(mktemp -d "${TMPDIR:-/tmp}/tommos-wheel-repair.XXXXXX")"
18
+ trap 'rm -rf "$WORK_DIR"' EXIT
19
+
20
+ AUDITWHEEL_DIR="$WORK_DIR/auditwheel"
21
+ UNPACK_DIR="$WORK_DIR/unpacked"
22
+ mkdir -p "$AUDITWHEEL_DIR" "$UNPACK_DIR"
23
+
24
+ auditwheel repair \
25
+ --plat manylinux_2_28_x86_64 \
26
+ --exclude libmkl_rt.so.3 \
27
+ --wheel-dir "$AUDITWHEEL_DIR" \
28
+ "$INPUT_WHEEL"
29
+
30
+ shopt -s nullglob
31
+ REPAIRED_WHEELS=("$AUDITWHEEL_DIR"/*.whl)
32
+ if [[ "${#REPAIRED_WHEELS[@]}" -ne 1 ]]; then
33
+ echo "expected exactly one auditwheel output, found ${#REPAIRED_WHEELS[@]}" >&2
34
+ exit 1
35
+ fi
36
+
37
+ python -m wheel unpack --dest "$UNPACK_DIR" "${REPAIRED_WHEELS[0]}"
38
+ UNPACKED_ROOTS=("$UNPACK_DIR"/*/)
39
+ if [[ "${#UNPACKED_ROOTS[@]}" -ne 1 ]]; then
40
+ echo "expected exactly one unpacked wheel root, found ${#UNPACKED_ROOTS[@]}" >&2
41
+ exit 1
42
+ fi
43
+
44
+ UNPACKED_ROOT="${UNPACKED_ROOTS[0]}"
45
+ NATIVE_EXTENSION="$UNPACKED_ROOT/tommos/_native/libcpp_mkl_minimizer.so"
46
+ if [[ ! -f "$NATIVE_EXTENSION" ]]; then
47
+ echo "repaired wheel is missing $NATIVE_EXTENSION" >&2
48
+ exit 1
49
+ fi
50
+
51
+ patchelf \
52
+ --add-rpath '$ORIGIN/../../../..' \
53
+ "$NATIVE_EXTENSION"
54
+
55
+ ACTUAL_RUNPATH="$(patchelf --print-rpath "$NATIVE_EXTENSION")"
56
+ IFS=: read -r -a RUNPATH_COMPONENTS <<<"$ACTUAL_RUNPATH"
57
+ for REQUIRED_COMPONENT in '$ORIGIN/../../tommos.libs' '$ORIGIN/../../../..'; do
58
+ COMPONENT_FOUND=false
59
+ for COMPONENT in "${RUNPATH_COMPONENTS[@]}"; do
60
+ if [[ "$COMPONENT" == "$REQUIRED_COMPONENT" ]]; then
61
+ COMPONENT_FOUND=true
62
+ break
63
+ fi
64
+ done
65
+ if [[ "$COMPONENT_FOUND" != true ]]; then
66
+ echo "repaired RUNPATH is missing $REQUIRED_COMPONENT: $ACTUAL_RUNPATH" >&2
67
+ exit 1
68
+ fi
69
+ done
70
+
71
+ NEEDED="$(patchelf --print-needed "$NATIVE_EXTENSION")"
72
+ if ! grep -q '^libgomp-' <<<"$NEEDED"; then
73
+ echo "native library does not link the bundled libgomp: $NEEDED" >&2
74
+ exit 1
75
+ fi
76
+
77
+ python -m wheel pack --dest-dir "$DEST_DIR" "$UNPACKED_ROOT"
@@ -0,0 +1,85 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "[0-9]+.[0-9]+.[0-9]+"
7
+
8
+ permissions:
9
+ contents: read
10
+
11
+ jobs:
12
+ check-version:
13
+ name: Check tag matches package version
14
+ runs-on: ubuntu-latest
15
+ steps:
16
+ - name: Checkout repository
17
+ uses: actions/checkout@v7
18
+ with:
19
+ persist-credentials: false
20
+ - name: Compare tag with pyproject.toml
21
+ env:
22
+ TAG: ${{ github.ref_name }}
23
+ run: |
24
+ python3 - <<'EOF'
25
+ import os
26
+ import sys
27
+ import tomllib
28
+
29
+ tag = os.environ["TAG"]
30
+ with open("pyproject.toml", "rb") as f:
31
+ version = tomllib.load(f)["project"]["version"]
32
+ if tag != version:
33
+ sys.exit(f"Tag {tag} does not match pyproject.toml version {version}")
34
+ EOF
35
+
36
+ build:
37
+ needs: check-version
38
+ uses: ./.github/workflows/wheels.yml
39
+
40
+ test:
41
+ needs: check-version
42
+ uses: ./.github/workflows/test.yml
43
+
44
+ publish-pypi:
45
+ name: Publish to PyPI
46
+ needs: [build, test]
47
+ runs-on: ubuntu-latest
48
+ environment:
49
+ name: pypi
50
+ url: https://pypi.org/project/tommos/${{ github.ref_name }}/
51
+ permissions:
52
+ id-token: write
53
+ steps:
54
+ - name: Download distributions
55
+ uses: actions/download-artifact@v8
56
+ with:
57
+ pattern: tommos-*
58
+ merge-multiple: true
59
+ path: dist
60
+ - name: Publish
61
+ uses: pypa/gh-action-pypi-publish@release/v1
62
+
63
+ github-release:
64
+ name: Create GitHub release
65
+ needs: publish-pypi
66
+ runs-on: ubuntu-latest
67
+ permissions:
68
+ contents: write
69
+ steps:
70
+ - name: Download distributions
71
+ uses: actions/download-artifact@v8
72
+ with:
73
+ pattern: tommos-*
74
+ merge-multiple: true
75
+ path: dist
76
+ - name: Create release
77
+ env:
78
+ GH_TOKEN: ${{ github.token }}
79
+ TAG: ${{ github.ref_name }}
80
+ run: >-
81
+ gh release create "$TAG" dist/*
82
+ --repo "$GITHUB_REPOSITORY"
83
+ --title "$TAG"
84
+ --generate-notes
85
+ --verify-tag
@@ -0,0 +1,40 @@
1
+ name: Test package
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ push:
6
+ branches:
7
+ - main
8
+ pull_request:
9
+ workflow_call:
10
+
11
+ env:
12
+ PYTEST_ADDOPTS: "--color=yes"
13
+
14
+ jobs:
15
+ test:
16
+ runs-on: ${{ matrix.os }}
17
+ strategy:
18
+ matrix:
19
+ os: [ubuntu-latest, macos-latest]
20
+ steps:
21
+ - name: Checkout repository
22
+ uses: actions/checkout@v7
23
+ - name: Setup Pixi
24
+ uses: prefix-dev/setup-pixi@v0.10.1
25
+ - name: Run tests
26
+ run: pixi run -e test test
27
+ - name: Run example
28
+ run: pixi run -e sample sample
29
+ # for later: standardised task names
30
+ # - name: unit tests
31
+ # run: pixi run test-unittest
32
+ # - name: doc tests
33
+ # run: pixi run test-docstrings
34
+ # - name: Test examples
35
+ # run: pixi run test-notebooks
36
+ - name: Keep pixi.lock artifact for debugging
37
+ uses: actions/upload-artifact@v7
38
+ with:
39
+ path: pixi.lock
40
+ if: ${{ matrix.os == 'ubuntu-latest' && !cancelled() }}
@@ -0,0 +1,108 @@
1
+ name: Build distributions
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ push:
6
+ branches:
7
+ - main
8
+ pull_request:
9
+ workflow_call:
10
+
11
+ permissions:
12
+ contents: read
13
+
14
+ jobs:
15
+ build-linux-wheels:
16
+ name: manylinux_2_28 x86-64
17
+ runs-on: ubuntu-latest
18
+ steps:
19
+ - name: Checkout repository
20
+ uses: actions/checkout@v7
21
+ with:
22
+ persist-credentials: false
23
+ - name: Setup Python
24
+ uses: actions/setup-python@v7
25
+ - name: Install cibuildwheel
26
+ run: python -m pip install cibuildwheel==4.1.1
27
+ - name: Build and test repaired wheels
28
+ run: python -m cibuildwheel --platform linux --output-dir wheelhouse
29
+ env:
30
+ CIBW_ARCHS_LINUX: x86_64
31
+ CIBW_BUILD: "cp3{11,12,13,14}-manylinux_x86_64"
32
+ CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28
33
+ CIBW_REPAIR_WHEEL_COMMAND_LINUX: >-
34
+ python -m pip install wheel==0.47.0 &&
35
+ bash {project}/.github/scripts/repair_linux_wheel.sh
36
+ {wheel} {dest_dir}
37
+ CIBW_TEST_REQUIRES: pytest
38
+ CIBW_TEST_SOURCES: tests
39
+ CIBW_TEST_COMMAND_LINUX: >-
40
+ unset MKLROOT LD_LIBRARY_PATH PYTHONPATH &&
41
+ JAX_ENABLE_X64=True python -m pytest -q tests
42
+ - name: Check for a single wheel without bundled oneMKL
43
+ shell: bash
44
+ run: |
45
+ set -euo pipefail
46
+ shopt -s nullglob
47
+ wheels=(wheelhouse/*.whl)
48
+ if [[ "${#wheels[@]}" -ne 1 ]]; then
49
+ echo "Expected exactly one wheel, found ${#wheels[@]}" >&2
50
+ exit 1
51
+ fi
52
+ if zipinfo -1 "${wheels[0]}" | grep -E '(^|/)libmkl[^/]*\.so'; then
53
+ echo "The tommos wheel must not bundle oneMKL libraries" >&2
54
+ exit 1
55
+ fi
56
+ - name: Retain repaired wheels
57
+ if: ${{ !cancelled() }}
58
+ uses: actions/upload-artifact@v7
59
+ with:
60
+ name: tommos-manylinux_2_28-x86_64-wheels
61
+ path: wheelhouse/*.whl
62
+ if-no-files-found: error
63
+ retention-days: 30
64
+
65
+ build-sdist-and-pure-wheel:
66
+ name: sdist and pure Python wheel
67
+ runs-on: macos-latest
68
+ steps:
69
+ - name: Checkout repository
70
+ uses: actions/checkout@v7
71
+ with:
72
+ persist-credentials: false
73
+ - name: Setup Python
74
+ uses: actions/setup-python@v7
75
+ with:
76
+ python-version: '3.14' # no h5py wheel for 3.15 yet
77
+ - name: Build sdist and wheel
78
+ run: |
79
+ python -m pip install build
80
+ python -m build
81
+ - name: Test wheel outside checkout
82
+ shell: bash
83
+ run: |
84
+ set -euo pipefail
85
+ wheels=(dist/*-py3-none-any.whl)
86
+ if [[ ${#wheels[@]} -ne 1 || ! -f "${wheels[0]}" ]]; then
87
+ echo "Expected exactly one dist/*-py3-none-any.whl artifact" >&2
88
+ exit 1
89
+ fi
90
+ portable_root="$(mktemp -d "${TMPDIR:-/tmp}/tommos-portable-install.XXXXXX")"
91
+ portable_env="${portable_root}/venv"
92
+ python -m venv "${portable_env}"
93
+ source "${portable_env}/bin/activate"
94
+ python -m pip install "${wheels[0]}"
95
+ isolated_cwd="$(mktemp -d "${TMPDIR:-/tmp}/tommos-portable-cwd.XXXXXX")"
96
+ cd "${isolated_cwd}"
97
+ unset PYTHONPATH MKLROOT LD_LIBRARY_PATH
98
+ python -m pip install pytest
99
+ cp -R "$GITHUB_WORKSPACE/tests" .
100
+ JAX_ENABLE_X64=True python -m pytest -q tests
101
+ - name: Retain sdist and wheel
102
+ if: ${{ !cancelled() }}
103
+ uses: actions/upload-artifact@v7
104
+ with:
105
+ name: tommos-sdist-and-pure-wheel
106
+ path: dist/*
107
+ if-no-files-found: error
108
+ retention-days: 30
@@ -0,0 +1,44 @@
1
+ # C++ build artifacts
2
+ build/
3
+ dist/
4
+ *.egg-info/
5
+ deps/
6
+ bin/
7
+
8
+ # Python artifacts
9
+ __pycache__/
10
+ *.py[cod]
11
+ *$py.class
12
+
13
+ # Temporary/Output files
14
+ *.out
15
+ *.vtu
16
+ *.npz
17
+ *.csv
18
+ *.png
19
+ *.pdf
20
+ *.log
21
+ *.tmp
22
+ *.trace.json.gz
23
+ benchmarking/*_bench.txt
24
+ benchmarking/BENCHMARK_REPORT.md
25
+ examples/evaluate_materials/base_structures/
26
+
27
+ # IDEs
28
+ .vscode/
29
+ .idea/
30
+ trace_dir/
31
+ .pixi/
32
+ pixi.lock
33
+
34
+ # LaTeX artifacts
35
+ *.aux
36
+ *.bbl
37
+ *.blg
38
+
39
+ # CMake and build artifacts
40
+ CMakeCache.txt
41
+ CMakeFiles/
42
+ Makefile
43
+ cmake_install.cmake
44
+ *.so
@@ -0,0 +1,22 @@
1
+ repos:
2
+ - repo: https://github.com/pre-commit/pre-commit-hooks
3
+ rev: v6.0.0
4
+ hooks:
5
+ - id: check-merge-conflict # checks for files that contain merge conflict strings
6
+ - id: check-toml # checks toml files for parseable syntax
7
+ - id: debug-statements # checks for debugger imports and py37+ `breakpoint()` calls in python source
8
+ - id: check-added-large-files
9
+ args: ['--maxkb=1000', '--enforce-all']
10
+ - id: check-yaml
11
+ - id: check-json
12
+
13
+ - repo: https://github.com/astral-sh/ruff-pre-commit
14
+ rev: v0.17.6
15
+ hooks:
16
+ - id: ruff-check
17
+ types_or: [python, pyi, jupyter]
18
+ args: [--fix, --exit-non-zero-on-fix]
19
+ files: "^(src|tests)/"
20
+ - id: ruff-format
21
+ types_or: [python, pyi, jupyter]
22
+ files: "^(src|tests)/"
@@ -0,0 +1,64 @@
1
+ {
2
+ "creators": [
3
+ {
4
+ "name": "Schrefl, Thomas",
5
+ "orcid": "0000-0002-0871-0520",
6
+ "affiliation": "University for Continuing Education Krems"
7
+ },
8
+ {
9
+ "name": "Fischbacher, Johann",
10
+ "orcid": "0000-0002-0815-5379",
11
+ "affiliation": "University for Continuing Education Krems"
12
+ },
13
+ {
14
+ "name": "Kovacs, Alexander",
15
+ "orcid": "0000-0002-8413-1950",
16
+ "affiliation": "University for Continuing Education Krems"
17
+ },
18
+ {
19
+ "name": "Pile, Santa",
20
+ "orcid": "0000-0001-7854-847X",
21
+ "affiliation": "University for Continuing Education Krems"
22
+ },
23
+ {
24
+ "name": "Lang, Martin",
25
+ "orcid": "0000-0001-7104-7867",
26
+ "affiliation": "Max Planck Institute for the Structure and Dynamics of Matter"
27
+ },
28
+ {
29
+ "name": "Adams, Michael",
30
+ "orcid": "0000-0001-9269-8087",
31
+ "affiliation": "Max Planck Institute for the Structure and Dynamics of Matter"
32
+ },
33
+ {
34
+ "name": "Petrocchi, Andrea",
35
+ "orcid": "0009-0005-1867-6732",
36
+ "affiliation": "Max Planck Institute for the Structure and Dynamics of Matter"
37
+ },
38
+ {
39
+ "name": "Holt, Samuel",
40
+ "orcid": "0000-0003-3323-8958",
41
+ "affiliation": "Max Planck Institute for the Structure and Dynamics of Matter"
42
+ },
43
+ {
44
+ "name": "Fangohr, Hans",
45
+ "orcid": "0000-0001-5494-7193",
46
+ "affiliation": "Max Planck Institute for the Structure and Dynamics of Matter, University of Southampton"
47
+ }
48
+ ],
49
+ "title": "tommos",
50
+ "description": "High-performance finite-element micromagnetic simulations on CPUs and GPUs using JAX and C++.",
51
+ "license": "MIT",
52
+ "upload_type": "software",
53
+ "language": "eng",
54
+ "grants": [
55
+ {
56
+ "id": "10.13039/501100000780::101135546"
57
+ }
58
+ ],
59
+ "communities": [
60
+ {
61
+ "identifier": "mammos"
62
+ }
63
+ ]
64
+ }
tommos-0.1.0/AGENTS.md ADDED
@@ -0,0 +1,70 @@
1
+ # Agent Rules
2
+
3
+ ## Rule 0: Global Pre-flight Checklist
4
+ At the start of every message, you MUST explicitly output a markdown block titled **`[Rule Compliance Checklist]`**. In this checklist, you must list every rule relevant to your upcoming response and, if applicable, cite the exact tool call ID used to satisfy it before proceeding with your reasoning or actions.
5
+
6
+ ## Rule 1: NO TOOL EXECUTION WITHOUT APPROVAL
7
+ **CRITICAL:** Do NOT use the `replace_file_content`, `multi_replace_file_content`, or `write_to_file` tools under ANY circumstances until the user explicitly writes the word **[Approved]**. Always describe in detail what you plan to do. Once you propose a plan, you MUST immediately stop calling tools and end your turn.
8
+
9
+ ## Rule 1.1: Mandatory Compliance Check-in
10
+ Before invoking any file-editing tool, you must explicitly output the exact phrase: *"I am verifying that the user has explicitly approved this specific code change."* If you cannot find the explicit approval in the immediate chat history, you must abort the tool execution.
11
+
12
+ ## Rule 2: Relevant Code Changes and Improvements
13
+ You are prohibited from using file-editing tools on any file that the user did not explicitly mention in their prompt. If you identify an optional improvement in another file, you MUST output the exact header **`# [UNREQUESTED IMPROVEMENT]`** and you are prohibited from generating a plan until the user responds with `[Approved]`.
14
+
15
+ ## Rule 3: Interaction Sequence for Fixes
16
+ If a `run_command` tool call returns an exit code other than 0, you MUST immediately halt execution and output a markdown block titled **`[ERROR DIAGNOSIS]`** containing your analysis. You are strictly prohibited from invoking further tools (like `run_command` or file editors) to attempt a fix until you receive the word `[Approved]`.
17
+
18
+ ## Rule 4: Mechanical Syntax Check Before Execution
19
+ Before invoking the `run_command` tool to execute a Python script (e.g., `python3 loop.py`), you MUST explicitly output the phrase: **'I verify that a previous `run_command` execution of `python3 -m py_compile [filename]` returned exit code 0.'** If you cannot reference a successful compile step in the chat context, you are prohibited from executing the script.
20
+
21
+ ## Rule 5: No Commits Without Quoted Proof
22
+ Before invoking the `run_command` tool with `git commit`, you must actively fetch and output the exact terminal or log output proving the code succeeded.
23
+ * **For local tests (pytest/python):** You must quote the `run_command` stdout showing passing tests.
24
+ * **For Slurm jobs:** You must use the `grep_search` or `view_file` tool to read the generated `.log` file and quote the success indicator.
25
+
26
+ You must explicitly output the exact phrase: *"I verify success via the following log output: [insert exact log quote]"*. If you cannot quote the success output from a tool call in your immediate context, you must abort the commit.
27
+
28
+ ## Rule 6: No Assumptions Without Confirmation
29
+ When using the `replace_file_content` or `multi_replace_file_content` tool, if your replacement chunk deletes more than 5 consecutive lines of existing code, or removes existing comments/docstrings, you MUST explicitly output: **'Warning: This plan deletes existing code.'** You are prohibited from executing the edit unless the user's prompt specifically instructed you to delete it.
30
+
31
+ ## Rule 7: Mechanical Side Effect Search
32
+ Before generating a plan to modify any Python function or class, you MUST invoke the `grep_search` tool to search for all occurrences of that function/class name across the entire `src/` directory. You must explicitly list all files that import or use the target before proposing your changes.
33
+
34
+ ## Rule 8: Stick to the Approved Plan
35
+ If you encounter an error (e.g. from `run_command`) that prevents you from completing an already approved plan, you MUST output the exact phrase: **'Plan execution blocked by error.'** You are strictly prohibited from generating alternative file edits until you have presented a new plan and received a new `[Approved]` keyword.
36
+
37
+ ## Rule 9: Mechanical Evidence Verification (Anti-Hallucination)
38
+ When citing log outputs or file contents to the user, you MUST enclose the exact text in a markdown block prefixed with **`[EXTRACTED EVIDENCE]`**. You are strictly prohibited from generating an `[EXTRACTED EVIDENCE]` block unless the text is a verbatim substring of output returned by a `run_command`, `grep_search`, or `view_file` tool call in the current or immediate prior turn.
39
+
40
+ ## Rule 10: Citation and Verifiability
41
+ Before stating any factual claim regarding third-party libraries, physics, or system behaviors, you MUST explicitly output `[Source: URL/File]` immediately following the claim. You are strictly prohibited from generating this citation unless you have actively executed the `search_web`, `read_url_content`, or `view_file` tool to read that exact source during the current session.
42
+
43
+ ## Rule 11: Mechanical Link Verification
44
+ You are prohibited from generating markdown hyperlinks `[text](http...)` to external sites unless you have explicitly invoked the `read_url_content` tool (or `run_command` with `curl -I`) on that exact URL in the current or previous turn. Before generating any external hyperlink, you MUST explicitly output a block titled `[LINK VERIFICATION]` containing the exact HTTP 200 OK output from your tool call. If you cannot quote the successful status code, you must drop the link.
45
+
46
+ ## Rule 12: Resolve Contradictions
47
+ Before proposing a diagnosis for an error, you MUST output a markdown table titled **'Hypothesis Check'** with two columns: [Current Hypothesis] and [Previous Hypothesis]. If they differ, you MUST output the exact phrase: **'I was wrong previously.'** before proposing the new fix.
48
+
49
+ ## Rule 13: The "Dead End" Admission Rule (Anti-Pivot)
50
+ If you attempt to mechanically verify a claim, fact, or hypothesis and the verification fails (e.g., `grep_search` finds no results, a URL returns 404, or a log file lacks the expected output), you MUST immediately halt execution and output a markdown block titled **`[VERIFICATION FAILURE]`** detailing exactly what failed.
51
+
52
+ You are strictly **prohibited** from proposing an alternative hypothesis, generating a new claim, or pivoting to a new solution in the same response. You must explicitly state: *"I cannot verify my claim and must stop."* and immediately end your turn to await user guidance.
53
+
54
+
55
+
56
+ ## LaTeX Paper Writing Rules
57
+ - **The Preservation Rule**: When using `replace_file_content` on a `.tex` file, your `ReplacementContent` MUST be equal to or greater in length (character count) than your `TargetContent`. If you attempt to delete more text than you add, you MUST output: **'Warning: This edit reduces the document length'** and you are prohibited from executing the edit without explicit `[Approved]` permission.
58
+ - **The Precision Rule**: Immediately before drafting any new LaTeX text containing math blocks, you MUST output a list titled **'Variable Definitions'**. For every single symbol used in the draft, you must list its definition. If a symbol in your draft is missing from this list, you are prohibited from writing the file.
59
+ - **The Fact-Checking Rule**: Before invoking `write_to_file` on a `.tex` file, if the text contains a factual claim about physics or history, you MUST output a citation to a specific file or URL you have read using `view_file` or `read_url_content` in the current session. If no such tool was called, you are prohibited from writing the text.
60
+ - **The Post-Writing Fact-Check Rule**: Immediately after invoking `write_to_file` or a replacement tool on a `.tex` file, you MUST generate a markdown table titled **'Fact-Check Matrix'** with 3 columns: [Claim], [Source Citation], and [Verification Status]. You cannot proceed to any other task or end the session until this table is generated to verify the newly added text against primary sources.
61
+ - **The Formal Tone Rule**: Avoid colloquialisms, conversational language, and dramatic or "fancy" phrasing. Always write in a strictly formal, objective, and academic tone appropriate for a scientific publication.
62
+ - **The Consistency Rule**: Before calling `write_to_file` or a replacement tool on a `.tex` file to add new mathematical formulas, you MUST explicitly output a markdown table titled **'Consistency Check'** that maps your new variables to the output of a prior `grep_search` or `view_file` tool call. You are prohibited from writing the file until you prove you have computationally searched for existing definitions.
63
+ - **Plotting**:
64
+ - **Legibility**: When writing or modifying Python plotting code (e.g. `matplotlib`), you MUST explicitly include `plt.rcParams.update({'font.size': 14})` (or larger).
65
+ - **Distinguishability**: Differentiate data curves using multiple visual cues simultaneously (e.g., combine distinct colors with varying line styles or marker symbols).
66
+ - **Titles**: You are prohibited from generating plot titles using `plt.title()`; all descriptions must go in captions.
67
+
68
+ ## Coding Style & Types
69
+ - **Documentation**: All functions must use **Google-style docstrings** without type hints in the docstrings. Each parameter must be documented separately.
70
+ - **Type Safety**: Use explicit **Python type hints** for all parameters and return types. Use `jnp.ndarray` (or `Array` alias) for JAX arrays and `np.ndarray` for CPU/IO data.
tommos-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 MAgnetic Multiscale MOdelling Suite (MaMMoS)
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.