gitronics 0.5.17__tar.gz → 0.5.19__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 (73) hide show
  1. {gitronics-0.5.17 → gitronics-0.5.19}/.github/workflows/docs.yml +3 -2
  2. {gitronics-0.5.17 → gitronics-0.5.19}/Cargo.lock +3 -3
  3. {gitronics-0.5.17 → gitronics-0.5.19}/Cargo.toml +2 -2
  4. {gitronics-0.5.17 → gitronics-0.5.19}/PKG-INFO +1 -1
  5. gitronics-0.5.19/docs/best_practices.md +85 -0
  6. gitronics-0.5.19/docs/examples.md +60 -0
  7. gitronics-0.5.19/docs/getting_started/assessments.md +33 -0
  8. gitronics-0.5.19/docs/getting_started/building_a_model.md +73 -0
  9. gitronics-0.5.19/docs/getting_started/card_id_numbers.md +16 -0
  10. gitronics-0.5.19/docs/getting_started/concepts.md +15 -0
  11. gitronics-0.5.19/docs/getting_started/configuration_file.md +93 -0
  12. gitronics-0.5.19/docs/getting_started/file_types.md +157 -0
  13. gitronics-0.5.19/docs/getting_started/migrating.md +36 -0
  14. gitronics-0.5.19/docs/getting_started/new_project.md +32 -0
  15. gitronics-0.5.19/docs/getting_started/project_structure.md +41 -0
  16. gitronics-0.5.19/docs/getting_started.md +28 -0
  17. gitronics-0.5.19/docs/hooks/version_from_git.py +53 -0
  18. {gitronics-0.5.17 → gitronics-0.5.19}/docs/index.md +6 -2
  19. {gitronics-0.5.17 → gitronics-0.5.19}/docs/installation.md +7 -12
  20. {gitronics-0.5.17 → gitronics-0.5.19}/docs/usage/build.md +6 -1
  21. {gitronics-0.5.17 → gitronics-0.5.19}/example_project/reference_model/envelope_structure.mcnp +14 -15
  22. {gitronics-0.5.17 → gitronics-0.5.19}/mkdocs.yml +17 -6
  23. gitronics-0.5.17/docs/best-practices.md +0 -99
  24. gitronics-0.5.17/docs/changelog.md +0 -25
  25. gitronics-0.5.17/docs/examples.md +0 -110
  26. gitronics-0.5.17/docs/getting-started.md +0 -105
  27. gitronics-0.5.17/docs/usage/configuration.md +0 -162
  28. {gitronics-0.5.17 → gitronics-0.5.19}/.github/workflows/ci.yml +0 -0
  29. {gitronics-0.5.17 → gitronics-0.5.19}/.github/workflows/release.yml +0 -0
  30. {gitronics-0.5.17 → gitronics-0.5.19}/.gitignore +0 -0
  31. {gitronics-0.5.17 → gitronics-0.5.19}/.vscode/settings.json +0 -0
  32. {gitronics-0.5.17 → gitronics-0.5.19}/LICENSE +0 -0
  33. {gitronics-0.5.17 → gitronics-0.5.19}/README.md +0 -0
  34. {gitronics-0.5.17 → gitronics-0.5.19}/docs/assets/logo.png +0 -0
  35. {gitronics-0.5.17 → gitronics-0.5.19}/docs/requirements.txt +0 -0
  36. {gitronics-0.5.17 → gitronics-0.5.19}/docs/usage/migrate.md +0 -0
  37. {gitronics-0.5.17 → gitronics-0.5.19}/example_project/assessment_specific/filler_model_3.mcnp +0 -0
  38. {gitronics-0.5.17 → gitronics-0.5.19}/example_project/assessment_specific/filler_model_3.metadata +0 -0
  39. {gitronics-0.5.17 → gitronics-0.5.19}/example_project/assessment_specific/small_override.yaml +0 -0
  40. {gitronics-0.5.17 → gitronics-0.5.19}/example_project/configurations/valid_configuration.yaml +0 -0
  41. {gitronics-0.5.17 → gitronics-0.5.19}/example_project/output/.gitignore +0 -0
  42. {gitronics-0.5.17 → gitronics-0.5.19}/example_project/reference_model/data_cards/fine_mesh.tally +0 -0
  43. {gitronics-0.5.17 → gitronics-0.5.19}/example_project/reference_model/data_cards/materials.mat +0 -0
  44. {gitronics-0.5.17 → gitronics-0.5.19}/example_project/reference_model/data_cards/my_transform.transform +0 -0
  45. {gitronics-0.5.17 → gitronics-0.5.19}/example_project/reference_model/data_cards/volumetric_source.source +0 -0
  46. {gitronics-0.5.17 → gitronics-0.5.19}/example_project/reference_model/envelope_structure.metadata +0 -0
  47. {gitronics-0.5.17 → gitronics-0.5.19}/example_project/reference_model/filler_models/filler_model_1.mcnp +0 -0
  48. {gitronics-0.5.17 → gitronics-0.5.19}/example_project/reference_model/filler_models/filler_model_1.metadata +0 -0
  49. {gitronics-0.5.17 → gitronics-0.5.19}/example_project/reference_model/filler_models/filler_model_2.mcnp +0 -0
  50. {gitronics-0.5.17 → gitronics-0.5.19}/example_project/reference_model/filler_models/filler_model_2.metadata +0 -0
  51. {gitronics-0.5.17 → gitronics-0.5.19}/pyproject.toml +0 -0
  52. {gitronics-0.5.17 → gitronics-0.5.19}/python/gitronics/__init__.py +0 -0
  53. {gitronics-0.5.17 → gitronics-0.5.19}/python/gitronics/__main__.py +0 -0
  54. {gitronics-0.5.17 → gitronics-0.5.19}/python/gitronics/gitronics.pyi +0 -0
  55. {gitronics-0.5.17 → gitronics-0.5.19}/python/tests/test_build_model.py +0 -0
  56. {gitronics-0.5.17 → gitronics-0.5.19}/python/tests/test_cli_works.py +0 -0
  57. {gitronics-0.5.17 → gitronics-0.5.19}/resources/simple_model.mcnp +0 -0
  58. {gitronics-0.5.17 → gitronics-0.5.19}/src/build_model.rs +0 -0
  59. {gitronics-0.5.17 → gitronics-0.5.19}/src/build_report.rs +0 -0
  60. {gitronics-0.5.17 → gitronics-0.5.19}/src/cli.rs +0 -0
  61. {gitronics-0.5.17 → gitronics-0.5.19}/src/lib.rs +0 -0
  62. {gitronics-0.5.17 → gitronics-0.5.19}/src/main.rs +0 -0
  63. {gitronics-0.5.17 → gitronics-0.5.19}/src/migrate_model.rs +0 -0
  64. {gitronics-0.5.17 → gitronics-0.5.19}/src/model_config.rs +0 -0
  65. {gitronics-0.5.17 → gitronics-0.5.19}/src/project_manager/load_metadata.rs +0 -0
  66. {gitronics-0.5.17 → gitronics-0.5.19}/src/project_manager/load_model_config.rs +0 -0
  67. {gitronics-0.5.17 → gitronics-0.5.19}/src/project_manager/load_project_files.rs +0 -0
  68. {gitronics-0.5.17 → gitronics-0.5.19}/src/project_manager.rs +0 -0
  69. {gitronics-0.5.17 → gitronics-0.5.19}/src/python.rs +0 -0
  70. {gitronics-0.5.17 → gitronics-0.5.19}/src/report.css +0 -0
  71. {gitronics-0.5.17 → gitronics-0.5.19}/src/types.rs +0 -0
  72. {gitronics-0.5.17 → gitronics-0.5.19}/src/utils.rs +0 -0
  73. {gitronics-0.5.17 → gitronics-0.5.19}/tests/test_example_project.rs +0 -0
@@ -40,7 +40,8 @@ jobs:
40
40
  run: |
41
41
  git config user.name "github-actions[bot]"
42
42
  git config user.email "github-actions[bot]@users.noreply.github.com"
43
- # Deploy this version and update the "latest" alias
43
+ # Deploy this version and update the "latest" alias
44
44
  pip install mike
45
45
  mike deploy --push --update-aliases "${{ steps.version.outputs.version }}" latest
46
- mike set-default --push latest
46
+ # Set the site root to the numeric release version
47
+ mike set-default --push "${{ steps.version.outputs.version }}"
@@ -390,7 +390,7 @@ dependencies = [
390
390
 
391
391
  [[package]]
392
392
  name = "gitronics"
393
- version = "0.5.17"
393
+ version = "0.5.19"
394
394
  dependencies = [
395
395
  "chrono",
396
396
  "clap",
@@ -635,9 +635,9 @@ dependencies = [
635
635
 
636
636
  [[package]]
637
637
  name = "migjorn"
638
- version = "0.1.7"
638
+ version = "0.1.8"
639
639
  source = "registry+https://github.com/rust-lang/crates.io-index"
640
- checksum = "c31cf1891e03ac7a0e23dd2310b1714ba454d5bfd1936851aa2ce31b7492f748"
640
+ checksum = "d3f2fe960921f8c049fc7ac5536e96cba576e902cf040c258e8092eabb9eeaaf"
641
641
  dependencies = [
642
642
  "clap",
643
643
  "memchr",
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "gitronics"
3
- version = "0.5.17"
3
+ version = "0.5.19"
4
4
  edition = "2024"
5
5
  description = "Build MCNP neutronics models from modular components"
6
6
  license = "EUPL-1.2"
@@ -16,7 +16,7 @@ crate-type = ["cdylib", "rlib"]
16
16
 
17
17
  [dependencies]
18
18
  pyo3 = { version = "0.23", features = ["extension-module", "abi3-py39"] }
19
- migjorn = { version = "0.1.7" }
19
+ migjorn = { version = "0.1.8" }
20
20
  walkdir = "2.5.0"
21
21
  serde = { version = "1.0.228", features = ["derive"] }
22
22
  serde-saphyr = "0.0.26"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gitronics
3
- Version: 0.5.17
3
+ Version: 0.5.19
4
4
  Classifier: Programming Language :: Rust
5
5
  Classifier: Programming Language :: Python :: Implementation :: CPython
6
6
  Classifier: Programming Language :: Python :: Implementation :: PyPy
@@ -0,0 +1,85 @@
1
+ # Best Practices
2
+
3
+ This document lists some recommended practices for managing your Gitronics project.
4
+ Following these practices will help you avoid common pitfalls and make your project easier to maintain.
5
+
6
+ ## Modularization
7
+
8
+ Every file (or system) in a Gitronics project should be independent of the others.
9
+ This means that a filler model should not reference cells or surfaces from other filler models or the envelope structure directly.
10
+
11
+ - Filler models should not share surfaces.
12
+ - Filler models should not share surfaces with the envelope structure.
13
+ - Avoid the use of `#` cells. If used, they should be defined in the same file, not a reference to a cell defined in other file.
14
+
15
+ ## Envelope cell definition
16
+
17
+ It is recommended to place the envelope name place holder at the end of the cell definition.
18
+
19
+ ??? note "Example"
20
+ ```
21
+ 21055 0 1 -2 8 -7 -6 -5
22
+ imp:n=1.0 imp:p=1.0
23
+ $ @env:toroidal_field_coil_18
24
+ ```
25
+
26
+ !!! Warning "Space for the `FILL` card"
27
+ The `FILL` card will be inserted by Gitronics right after the last cell parameter of the cell definition (after the `imp:p=1.0` in the example above). If there is not space to the right of the last parameter, the newly added `FILL` card may break the maximum line length of MCNP. To avoid this, it is recommended to leave some space after the last parameter of the cell definition before the envelope name placeholder as in the example above.
28
+
29
+ ## Title cards
30
+
31
+ All the Gitronic files (geometry and data card files) should have a title card at the top of the file.
32
+ The title card is a single line that will be ignored by Gitronics when assembling the model, but it is useful to provide a brief description for the user when viewing the independent file.
33
+
34
+ ## Do not commit large files
35
+
36
+ The Gitronics methodology is designed to manage the source files of a model, not the assembled MCNP input files.
37
+ Via the information in the header of the `assembled.mcnp` file, it is possible to reproduce the exact same model from the source files. Therefore, it is not necessary to commit the assembled MCNP input files to the repository.
38
+
39
+ Commiting large files to the repository will make it slower to clone and checkout branches, and it will also make it harder to track changes.
40
+
41
+ !!! tip "Use `.gitignore`"
42
+ Make use of the `.gitignore` file to avoid committing unnecessary files. You can place a `.gitignore` file with the content `*` in a folder to ignore all files in that folder (like the `output/` folder).
43
+ You can ignore specific files by name or extension.
44
+ For example, to ignore all `.mcnp` files of a folder, you can add the line `*.mcnp` to the `.gitignore` file.
45
+
46
+ !!! Warning "Do not commit binary files"
47
+ It is considered a bad practice to commit binary files to the repository (Excel files, runtpe, etc).
48
+ Binary files cannot be diffed, and they will make the repository size grow unnecessarily.
49
+ Even if the files are text-based, do not commit large files like the `output` file of an MCNP run.
50
+
51
+ ## Use descriptive, lowercase stem names
52
+
53
+ Stem names appear in configuration files and in assembled-model metadata. Choose names that describe the *physics content*, not the version or date:
54
+
55
+ | Avoid | Prefer |
56
+ |---|---|
57
+ | `model_2024_v3_final` | `blanket_tungsten_fw` |
58
+ | `mat_13` | `reduced_activation_ferritic_steel` |
59
+ | `tally1` | `tritium_breeding_ratio` |
60
+
61
+ ## Nested universes
62
+
63
+ Each filler model file should contain only one universe.
64
+ The `$ @env:<envelope_name>` placeholder will only work on envelope structure files.
65
+
66
+ If a nested universe is absolutely needed, place the level 2 universe in the same file as the level 1 universe.
67
+ Make sure that the level 1 universe have the `FILL` cards correctly defined for the level 2 universe, which is placed right after the definition of the level 1.
68
+
69
+ ## Track origin of the model in the metadata
70
+
71
+ Add a field like `reference` or similar to the `.metadata` files of each filler model to track the origin of the model.
72
+ This is useful for future reference and for understanding the provenance of the model.
73
+
74
+ ## Tag releases
75
+
76
+ Every time you build a model for a formal assessment or publication, create a git tag. Gitronics records the commit hash in the assembled file's metadata, but a tag makes it trivially easy to check out the exact source state later.
77
+
78
+ ```bash
79
+ git tag -a v1.2.0 -m "Design freeze for FDR submission"
80
+ git push origin v1.2.0
81
+ ```
82
+
83
+ ## Include metadata files in version control
84
+
85
+ The `.metadata` files alongside each filler model are part of the source. Commit them alongside the `.mcnp` files.
@@ -0,0 +1,60 @@
1
+ # Examples
2
+
3
+ ## `example_project` — minimal working project
4
+
5
+ The repository ships with a small example project in [`example_project/`](https://github.com/Fusion4Energy/gitronics/tree/main/example_project). It demonstrates the essential project layout and a valid configuration file.
6
+
7
+ ### Structure
8
+
9
+ ```
10
+ example_project/
11
+ ├── configurations/
12
+ │ └── valid_configuration.yaml
13
+ ├── output/
14
+ │ └── .gitignore
15
+ └── reference_model/
16
+ ├── envelope_structure.mcnp
17
+ ├── envelope_structure.metadata
18
+ └── filler_models/
19
+ ├── filler_model_1.mcnp
20
+ ├── filler_model_1.metadata
21
+ └── filler_model_2.mcnp
22
+ ```
23
+
24
+ ### Configuration
25
+
26
+ ```yaml title="example_project/configurations/valid_configuration.yaml"
27
+ project_roots: [..]
28
+
29
+ envelope_structure: envelope_structure
30
+
31
+ source: volumetric_source
32
+ materials: [materials]
33
+ transformations: [my_transform]
34
+ tallies: [fine_mesh]
35
+
36
+ envelopes:
37
+ my_envelope_name_1: filler_model_1
38
+ envelope_name_2: filler_model_2
39
+ ```
40
+
41
+ ### Building it
42
+
43
+ ```bash
44
+ cd example_project
45
+ gitronics build configurations/valid_configuration.yaml --output-path output/
46
+ ```
47
+
48
+
49
+ ---
50
+
51
+ ## Using the Python API
52
+
53
+ Gitronics can also be driven from Python, which is useful when integrating with automated workflows or parametric studies:
54
+
55
+ ```python
56
+ import gitronics
57
+
58
+ # Build a model — equivalent to running the CLI
59
+ gitronics.run(["gitronics", "build", "configurations/baseline.yaml", "-o", "output/"])
60
+ ```
@@ -0,0 +1,33 @@
1
+ # Assessments
2
+
3
+ Gitronics can also be used to manage the specific changes required to the model for a specific assessment.
4
+ The recommended practice is to create a new Git branch for the assessment.
5
+ Then, create a new directory that will contain all the assessment-specific files (e.g. new filler models, tallies, configuration files, etc.).
6
+ This directory could also contain post-processing scripts, organization files and others.
7
+
8
+ Remember that the `project_roots` field in the configuration file can contain multiple directories, so the assessment-specific directory can be added to the list of roots to be searched for files.
9
+
10
+ ```
11
+ gitronics_project/
12
+ ├── configurations/
13
+ │ └── baseline.yaml ← The reference configuration file
14
+ |
15
+ ├── reference_model/ ← Directory containing the reference files
16
+ │ └── ...
17
+ |
18
+ └── assessment_specific/
19
+ ├── configurations/
20
+ │ └── modified.yaml ← This configuration overrides baseline.yaml applying changes
21
+
22
+ ├── changes/ ← Directory containing new files
23
+ │ ├── specific_tally.tally ← New tally only for this assessment
24
+ │ └── new_diagnostic.yaml ← New filler only for this assessment
25
+ |
26
+ ├── output/
27
+ │ └── assembled.mcnp ← Assembled model for this assessment
28
+
29
+ └── postprocessing/ ← Scripts to process the results of this assessment
30
+ └── ...
31
+ ```
32
+
33
+ After the assessment is complete, the branch can be stored as a file via `git bundle`, and the assessment-specific files can be deleted from the main branch to keep it clean.
@@ -0,0 +1,73 @@
1
+ # Build Model
2
+
3
+ Once a configuration file is ready, the model can be built with the `gitronics build` command.
4
+ After the [installation of Gitronics](../installation.md) is complete, the command can be run from the terminal.
5
+ For example:
6
+
7
+ ```bash
8
+ gitronics build configurations/baseline.yaml -o output/
9
+ ```
10
+
11
+ This will assemble the model defined in `baseline.yaml` and write an `assembled.mcnp` file to the `output/` directory.
12
+
13
+ !!! tip "HTML report"
14
+ The `gitronics build` command can also generate an HTML report of the assembled model. This report includes a summary of the configuration, a list of all files used, and the filler models assignation of the envelope structure.
15
+
16
+ If there is any problem during the assembly (configuration wrongly defined, missing files, duplicated card IDs, etc.), Gitronics will raise an error and the build will fail. The error message will indicate the cause of the failure and the file where it occurred.
17
+
18
+ See also: [Build command details](../usage/build.md).
19
+
20
+ ## What happens during a build
21
+
22
+ When running the `gitronics build` command, the following steps are performed:
23
+
24
+ 1. The configuration file (and any parent configs it inherits from) is loaded and merged.
25
+ 2. All the files referenced in the configuration file are read and parsed. This includes the envelope structure, filler models, and data card files.
26
+ 3. All fillers and data card files are reordered by their card type and ID numbers. Every `assembled.mcnp` file will have the same deterministic order of cards. Only the first ID number of the first card in each file is used to determine the order of the files.
27
+ 4. The envelope structure is adapted to include the `FILL` cards for the envelope cells that have a filler model assigned. The `FILL` cards will reference the correct universe ID of the filler model by parsing the filler model in search of the first `U` card. The transformation associated to each `FILL` card is also applied as defined in the metadata of the filler model.
28
+ 5. The envelope structure, filler models, and data card files are concatenated into a single MCNP input file.
29
+ 6. Validations checks are performed on the assembled model to ensure that it is a valid MCNP input file. This includes checking for duplicate card IDs, missing cards, and other potential issues. Failure to pass the checks will crash the build with an error message.
30
+ 7. The assembled model is written to the output file: `assembled.mcnp`.
31
+ 8. An HTML report is written to the output directory with name: `build_report.html`.
32
+
33
+ ## Logging
34
+
35
+ While the build is running, Gitronics will print `INFO` and `WARNING` messages to the terminal indicating the progress of the assembly.
36
+
37
+ !!! tip "`WARNING` messages"
38
+ Watch out for `WARNING` messages, they indicate potential mistakes that will not stop the build, for example, the existence of envelope cells in the envelope structure that are not referenced in the configuration file.
39
+ If the intention was to leave them empty, it is better to explicitly declare them as `null` in the configuration file to make sure they are not forgotten via `envelope_name: null`.
40
+
41
+ ??? note "Example of `build` logging"
42
+ ```
43
+ [2026-06-23 14:38:02 INFO gitronics] Starting model build process for: configurations/valid_configuration.yaml
44
+ [2026-06-23 14:38:02 INFO gitronics] Loading: reference_model/envelope_structure.mcnp
45
+ [2026-06-23 14:38:02 INFO gitronics] Loading: reference_model/filler_models/filler_model_1.mcnp
46
+ [2026-06-23 14:38:02 INFO gitronics] Loading: reference_model/filler_models/filler_model_2.mcnp
47
+ [2026-06-23 14:38:02 INFO gitronics] Loading: reference_model/data_cards/my_transform.transform
48
+ [2026-06-23 14:38:02 INFO gitronics] Loading: reference_model/data_cards/materials.mat
49
+ [2026-06-23 14:38:02 INFO gitronics] Loading: reference_model/data_cards/fine_mesh.tally
50
+ [2026-06-23 14:38:02 INFO gitronics] Loading: reference_model/data_cards/volumetric_source.source
51
+ [2026-06-23 14:38:02 INFO gitronics] Adapting envelope structure with FILL cards
52
+ [2026-06-23 14:38:02 INFO gitronics] Composing model
53
+ [2026-06-23 14:38:02 INFO gitronics] Performing validation checks on the assembled model
54
+ [2026-06-23 14:38:02 INFO gitronics] Build completed successfully in: output/assembled.mcnp
55
+ ```
56
+
57
+ ## Header
58
+
59
+ The `assembled.mcnp` file will contain a header comment at the top of the file like:
60
+
61
+ ```
62
+ C ============================================================
63
+ C Built by gitronics v0.1.0
64
+ C Configuration : configurations/baseline.yaml
65
+ C Git commit : v0.5.18-3-g04d555a
66
+ C Date / time : 2026-06-23 12:34:51
67
+ C ============================================================
68
+ ```
69
+
70
+ The first information line shows the Gitronics version used to build the model.
71
+ The second line shows the configuration file used to build the model, relative to the current working directory.
72
+ The third line shows the Git commit hash of the repository at the time of the build.
73
+ The fourth line shows the date and time when the build was performed.
@@ -0,0 +1,16 @@
1
+ # Card ID numbers
2
+
3
+ Whenever a file of any type is loaded by Gitronics during a `build` command, Gitronics will copy and paste the cards into a single model.
4
+ If two different files share the same card ID number, for example, two different filler models share a surface, Gitronics will include that surface twice in the assembled model, which will cause a validation error crashing the build process.
5
+ Gitronics will warn about which card IDs are duplicated with an error message.
6
+
7
+ [Migjorn](https://github.com/Fusion4Energy/migjorn), the parser used internally by Gitronics, is capable of renumbering on the fly any card ID.
8
+ However, as a design choice, Gitronics does not perform any automatic renumbering of card IDs.
9
+ This is to avoid unexpected changes in the assembled model that could be difficult to track and debug.
10
+
11
+ Therefore, it is the responsibility of the user to ensure that all card IDs are unique across all files in the project.
12
+ The recommended practice is to keep a consistent numbering scheme for all the individual files in the project, so that they can be assembled without conflicts.
13
+ Tools like [Migjorn](https://github.com/Fusion4Energy/migjorn) or [F4Enix](https://github.com/Fusion4Energy/F4Enix) make the renumbering of MCNP files effortless.
14
+
15
+ !!! tip "A single card ID per system"
16
+ A good practice is to assign the same card ID number to the different cards related to the same system. That is, make the universe ID of a filler model the same as the first cell ID, which is also the first surface ID, the first material ID (if the system needs non-standard materials). Same with tallies and transformations that are specific to that system.
@@ -0,0 +1,15 @@
1
+ # Concepts
2
+
3
+ The following is a list of concepts or keywords that are used throughout the documentation.
4
+
5
+ - **Gitronics**. The name of the tool and methodology.
6
+ - **Gitronics project**. A reactor/s or other nuclear project that is managed with the Gitronics methodology.
7
+ - **Git**. A distributed version control system that is used to track changes in the files of a **Gitronics project**.
8
+ - **Reference model directory**. A directory containing files that can be used to assemble an MCNP model.
9
+ - **Assembled model**. The output of the `gitronics build` command, a single MCNP input file generated from a **configuration** file and the contents of the **reference model directory**.
10
+ - **Configuration file**. A YAML file that declares which filler models and data cards are used to assemble a model.
11
+ - **Envelope structure**. An MCNP input file that defines the *level 0* geometry cells, that is, cells that do not belong to a filler universe. It is the only mandatory file in a Gitronics project.
12
+ - **Envelope cell**. A MCNP cell that can be filled with a filler model. They are defined in the envelope structure file as cells with an inline comment of the form `$ @env:<envelope_name>`, where `<envelope_name>` is the name for the envelope cell.
13
+ - **Filler model**. An MCNP input file that defines a *filler universe*, which is a set of geometry cells that can be inserted into an envelope cell. A filler model must have a metadata file with the same name and the `.metadata` extension.
14
+ - **Data card file**. A file that contains MCNP data cards, such as materials, sources, tallies, transformations or others. These files can have the following extensions: `.mat`, `.source`, `.tally`, or `.transform`.
15
+ - **Metadata file**. A YAML file that contains metadata related to a geometry or data card file. A metadata file must have the same name as the file it describes, but with the `.metadata` extension. These files are optional except for filler models and they can hold any arbitrary information.
@@ -0,0 +1,93 @@
1
+ # Configuration file
2
+
3
+ This is a YAML file that declares which filler models and data cards are used to assemble a model.
4
+ The configuration file does not need to be in the `reference_model` directory, it can be anywhere in the project.
5
+ For example:
6
+
7
+ ```
8
+ gitronics_project/
9
+ ├── configurations/
10
+ │ ├── baseline.yaml ← A configuration file
11
+ │ └── alternative.yaml ← Another configuration file
12
+ |
13
+ ├── reference_model/ ← Directory containing the geometry and data card files
14
+ │ └── ...
15
+ |
16
+ ├── assessment_specific/ ← Directory containing more geometry and data card files
17
+ │ └── ...
18
+ |
19
+ └── outputs/
20
+ └── assembled.mcnp ← An assembled MCNP input file generated with `gitronics build`
21
+ ```
22
+
23
+ ## Contents
24
+
25
+ A configuration file can only contain the following fields:
26
+
27
+ - **`project_roots`**: A list of directory paths to search for referenced files.
28
+ - **`overrides`**: A path to a parent configuration file to inherit from.
29
+ - **`envelope_structure`**: The file stem of the envelope structure MCNP file.
30
+ - **`source`**: The file stem of the source data card file.
31
+ - **`materials`**: A list of file stems of the materials data card files.
32
+ - **`transformations`**: A list of file stems of the transformations data card files.
33
+ - **`tallies`**: A list of file stems of the tallies data card files.
34
+ - **`envelopes`**: A dictionary that maps envelope cell names to filler model file stems. A value of empty or `null` indicates that the envelope cell should be left empty.
35
+
36
+ The only mandatory fields in a configuration file are `project_roots` and `envelope_structure`.
37
+ If a configuration employs `overrides`, the `envelope_structure` field could be defined in the parent, only the `project_roots` field would still be mandatory.
38
+
39
+ ??? info "Configuration file example"
40
+ ```yaml
41
+ project_roots: [..]
42
+ overrides: null
43
+ envelope_structure: envelope_structure
44
+ source: volumetric_source
45
+ materials: [materials_v2, extra_nuclides]
46
+ transformations: [sector_transforms]
47
+ tallies: [fine_mesh_tally, heating_tally]
48
+ envelopes:
49
+ blanket_sector_01: blanket_v3
50
+ divertor_outer: divertor_cassette
51
+ shielding_block: null
52
+ ```
53
+
54
+ !!! warning "Paths"
55
+ All paths in the configuration file are relative to the configuration file itself. If the configuration file is moved to a different directory, all paths must be updated accordingly.
56
+
57
+ ### `project_roots`
58
+
59
+ This field is a list of directory paths (relative to the configuration file) that Gitronics searches recursively for referenced files.
60
+ Paths are resolved at load time.
61
+ This will usually point to the main `reference_model` directory, but it can also include other directories that contain additional geometry or data card files like an `assessment_specific` directory.
62
+
63
+ ### `overrides`
64
+
65
+ This field is a relative path to a *parent* configuration file. If set, the parent is loaded first and the current file is merged on top of it. See [Overriding other configuration](#overriding-other-configuration) for more details.
66
+
67
+ ### `envelope_structure`
68
+
69
+ This field is the file stem (file name without the extension) of the envelope structure MCNP file.
70
+ The file must be discoverable in one of the directories specified in `project_roots`.
71
+
72
+ ### `source`, `materials`, `transformations`, `tallies`
73
+
74
+ These fields are the file stems of the data card files to include in the assembled model.
75
+ The files must be discoverable in one of the directories specified in `project_roots`.
76
+ Only one source file can be specified, but any number of materials, transformations and tallies files can be included.
77
+
78
+ ### `envelopes`
79
+
80
+ This field is a dictionary that maps envelope cell names to filler model file stems.
81
+ If an envelope cell name appears in the dictionary but is not found in the envelope structure, Gitronics will raise an error.
82
+
83
+ ## Overriding other configuration
84
+
85
+ If a configuration file specifies the `overrides` field, it will inherit from the parent configuration file. The parent is loaded first and the current file is merged on top of it. Fields present in the current file take precedence; the parent provides defaults.
86
+
87
+ The overriding rules are as follows:
88
+ - The field `project_roots` is not inherited, it must be specified in the current configuration file.
89
+ - The fields `envelope_structure`, `source`, `materials`, `transformations`, and `tallies` are inherited, but they can be overridden in the current configuration file. If the current file defines the field, the parent value is ignored.
90
+ - The field `envelopes` is inherited and merged entry-by-entry. The current file can add new envelopes or change specific ones without repeating the full list. If an envelope name is present in both the parent and the current configuration, the current value takes precedence.
91
+
92
+ !!! tip "Nested inheritance"
93
+ Inheritance chains are allowed but are not considered a good practice. It is simpler and less error-prone to inherit from a single parent configuration file.
@@ -0,0 +1,157 @@
1
+ # File types
2
+
3
+ The files inside a Gitronics project can be classified into three types:
4
+
5
+ - Geometry files
6
+ - Data card files
7
+ - Metadata files
8
+
9
+ ## Geometry files
10
+
11
+ Files with the `.mcnp` extension are considered geometry files.
12
+ These files can be either an [envelope structure](#envelope-structure) file or a [filler model](#filler-models) file.
13
+ The only parts of the files that Gitronics will consider in a geometry file are the first two sections of an MCNP input file: the *cell cards* and the *surface cards*.
14
+
15
+ Even though an assembled MCNP file may need cards like materials and transformations, these cards will be read from the data card files instead of the geometry files.
16
+ This is a design choice to avoid duplication of information and to keep the geometry files focused on the geometry definition.
17
+
18
+ ??? note "Geometry file example"
19
+ ```
20
+ C Filler model 121 │ ← Title
21
+ 1001 14 -7.89 1001 -1002 1004 -1003 │ ← Cells section
22
+ IMP:N=1 IMP:P=1 U=121 │
23
+ 1002 0 1001 -1002 │
24
+ IMP:N=1 IMP:P=1 U=121 │
25
+
26
+ C Surfaces model 121
27
+ 1001 PZ -1.4030000e+02 │ ← Surface section
28
+ 1002 PZ 4.6300000e+01 │
29
+ 1003 CZ 160.700000 │
30
+ 1004 CZ 144.900000 │
31
+
32
+ C Data cards (not considered)
33
+ m14 1001.31c 2.379E-02 $ H-1 │ ← Data cards section
34
+ 5010.31c 2.350E-04 $ B10 │ This will not be
35
+ 5011.31c 9.469E-04 $ B11 │ considered by
36
+ 8016.31c 4.276E-02 $ O │ gitronics
37
+ 11023.31c 2.068E-04 $ Na │
38
+ c 12000.31c 3.768E-05 $ Mg │
39
+ 12024.31c 2.976E-05 $ Mg-24 │
40
+ 12025.31c 3.768E-06 $ Mg-25 │
41
+ 12026.31c 4.149E-06 $ Mg-26 │
42
+ 13027.31c 6.034E-04 $ Al │
43
+ c 14000.31c 1.239E-02 $ Si │
44
+ 14028.31c 1.143E-02 $ Si-28 │
45
+ 14029.31c 5.786E-04 $ Si-29 │
46
+ c │
47
+ mode n │
48
+ sdef sur 398 nrm=-1 │
49
+ dir=d1 wgt=132732289.6 │
50
+ sb1 -21 2 │
51
+ lost 1000 │
52
+ prdmp j 1e7 │
53
+ nps 1e9 │
54
+ ```
55
+
56
+ !!! warning "Title card"
57
+ The title card of a geometry file is mandatory. Omitting it may cause an invalid parsing. Only the title card of the envelope structure file will be preserved in the assembled output file. The title cards of filler files will be ignored.
58
+
59
+ !!! tip "Data cards in geometry files"
60
+ A geometry file may contain data cards, making it a complete and valid MCNP input file by itself. While Gitronics will ignore these data cards, they can be useful for testing the geometry without the need to create a configuration file. It can be especially useful to have a stochastic volume calculation source in the geometry to check for lost particles and calculate the volumes of the cells in a filler model.
61
+
62
+ ### Envelope structure
63
+
64
+ This is a special MCNP input file, it is the only mandatory file in a Gitronics project.
65
+ This file defines the *Level 0* or *block/envelope structure* of the model, that is, all the geometry cells that do not belong to a filler universe.
66
+ A Gitronics project can contain any number of envelope structure files, but one (and only one) must be used to build a model.
67
+
68
+ In this file, envelope cells can be defined if necessary. To do so, simply add an inline comment in the cell definition of the form `$ @env:<envelope_name>`, where `<envelope_name>` is the name for the envelope cell. For example:
69
+
70
+ ```
71
+ 21055 0 1 -2 8 -7 -6 -5
72
+ imp:n=1.0 imp:p=1.0
73
+ $ @env:toroidal_field_coil_18
74
+ ```
75
+
76
+ !!! tip "Multiple envelopes with the same name"
77
+ It is possible to assign the same name to multiple envelope cells. This way, the configuration file would only need to reference the envelope name once, and all cells with that name will be filled with the same filler model. This is useful when a logical envelope cell needs to be decomposed into multiple cells to avoid lost particles or any other reason, but they all represent the same physical component.
78
+
79
+ ### Filler models
80
+
81
+ This kind of geometry files define a *filler universe*, that is, a set of cells and surfaces that can be used to fill envelope cells.
82
+ The cells of the files should already include the `U=<universe_id>` card, where `<universe_id>` is the universe ID number that will be used to fill the envelope cell.
83
+
84
+ ## Data card files
85
+
86
+ These kind of files contain MCNP data cards and they must have one of the following extensions: `.mat`, `.source`, `.tally`, or `.transform`.
87
+ The choice of the file extension is only for organizational purposes, Gitronics does not enforce any restriction on the content of these files. For example, a file with the `.mat` extension can contain tally cards, and it will still be read by Gitronics.
88
+
89
+ A data card file is not a valid MCNP input file on its own.
90
+ It consists on a title card followed by a list of MCNP data cards.
91
+ The title card is mandatory, and it will be ignored by Gitronics when assembling the model.
92
+ The data cards will be read until encountering a blank line or the end of the file.
93
+ Any content after that will be ignored.
94
+
95
+ ??? note "Data card file example"
96
+ ```
97
+ Tallies for radmaps │ ← Title (ignored)
98
+ C These talllies will produce radmaps │ ← Useful header comment
99
+ C throughout the reactor geometry │ (included)
100
+ FMESH24:N geom=xyz | ← Data cards section
101
+ origin -2200 -2200 -1800 |
102
+ imesh 2200 iints 176 |
103
+ jmesh 2200 jints 176 |
104
+ kmesh 3200 kints 200 |
105
+ emesh 0.1 20 |
106
+ FM24 1.5e17 |
107
+ FC24 Neutron flux |
108
+ C |
109
+ FMESH34:N geom=xyz |
110
+ origin -2200 -2200 -1800 |
111
+ imesh 2200 iints 176 |
112
+ jmesh 2200 jints 176 |
113
+ kmesh 3200 kints 200 |
114
+ FM34 2.60131e9 992 1 -4 |
115
+ FC34 Neutron dose in silica Gy/h |
116
+ C |
117
+
118
+ This block will not be read: | ← Not included
119
+ ...
120
+ ```
121
+
122
+ !!! note "Arbitrary data card files"
123
+ There are dozens of different types of data cards in MCNP and all of them can be included in any data card file. However, the recommended practice is to group the run parameters like `NPS`, `MODE`, `WWINP`, `PRNTDMP` and the like into the `.source` source file.
124
+
125
+ !!! warning "Number of data card files"
126
+ Any number of data card files can be used to assemble a model with only one limitation. Only one `.source` file can be specified in the configuration.
127
+
128
+ ## Metadata files
129
+
130
+ This kind of files are [YAML](https://yaml.org/) files that contain metadata related to other *geometry* or *data card* file.
131
+ The metadata file must have the same name as the file it describes, but with the `.metadata` extension.
132
+ For example, the file `toroidal_field_coil.mcnp` can have a metadata file called `toroidal_field_coil.metadata`.
133
+
134
+ These metadata files can contain any information, Gitronics will not enforce any restriction on the content of these files.
135
+
136
+ These files are optional for any file except for filler models.
137
+ Filler models must have a metadata file with at least the `transformation` field, which is a dictionary that maps any envelope name that the filler model can be applied to, to a transformation string.
138
+ The transformation string can be a transformation card like `(123)` or a transformation definition like `(10.1 0 0)`.
139
+ If the transformation definition is preceded by a `*`, it will be interpreted as a transformation in degrees instead of radians like in `*(0.001 0.001 0.001 70 20 90 160 70 90 90 90 0)`.
140
+ The string can also be left empty or with the `null` value to indicate that no transformation should be applied to the filler model when it is inserted into that envelope cell.
141
+
142
+ ??? note "Metadata file example"
143
+ ```yaml
144
+ description: "Toroidal field coil model..." │ ← Arbitrary field (ignored)
145
+ reference: "HA73HF" │ ← Arbitrary field (ignored)
146
+ transformations: │ ← Only mandatory field for fillers
147
+ my_envelope_name_1: "(10)" │ ← When applied to this envelope, the FILL will use TR card 10
148
+ my_envelope_name_2: │ ← No transformation for this envelope
149
+ my_envelope_name_3: null │ ← No transformation for this envelope
150
+ my_envelope_name_4: "(1.23 0.2 0.5)" │ ← Transformation of (1.23 0.2 0.5)
151
+ env_5: "*(0 0 0 130 40 90 140 130 90 90 90 0)" │ ← Transformation in degrees
152
+ ```
153
+
154
+ It is a design choice to put the responsibility of selecting the correct transformation for each envelope cell into the metadata of the filler model.
155
+ An envelope should be agnostic of the filler models that may be applied to it, which could be developed independently by different teams.
156
+ When preparing a new filler model, the developer has to specify in the metadata how that filler model should be used when applied to each potential envelope cell.
157
+ If a filler model has to be applied to a new envelope cell, this system will require the explicit consideration of the developer/integrator to add the new envelope name to the metadata of the filler model, which is a good practice to avoid mistakes.
@@ -0,0 +1,36 @@
1
+ # Migrate an Existing Model
2
+
3
+ If you already have a monolithic MCNP input file, use the `migrate` command to convert it into a Gitronics project structure automatically.
4
+
5
+ ```bash
6
+ gitronics migrate path/to/my_model.mcnp --output-path ./my_project
7
+ ```
8
+
9
+ This produces:
10
+
11
+ ```
12
+ my_project/
13
+ ├── configurations/
14
+ │ └── baseline.yaml ← ready-to-use baseline configuration
15
+ ├── output/
16
+ │ └── .gitignore
17
+ └── reference_model/
18
+ ├── envelope_structure.mcnp
19
+ ├── envelope_structure.metadata
20
+ └── filler_models/
21
+ ├── universe_101.mcnp
22
+ ├── universe_101.metadata
23
+ └── ...
24
+ ```
25
+
26
+ !!! tip
27
+ The `migrate` command does its best to identify universe boundaries automatically.
28
+ Review the generated `envelope_structure.mcnp` and filler models to confirm they look correct before committing.
29
+
30
+ After migration, verify the round-trip by running a build:
31
+
32
+ ```bash
33
+ gitronics build my_project/configurations/baseline.yaml --output-path my_project/output
34
+ ```
35
+
36
+ See also: [Migrate command details](../usage/migrate.md).