Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
490 commits
Select commit Hold shift + click to select a range
f61c98e
errors
AdriaLlealS Nov 25, 2025
10536cf
errors
AdriaLlealS Nov 25, 2025
8d9d254
Fixing errors
AdriaLlealS Nov 25, 2025
8e51477
errors
AdriaLlealS Nov 25, 2025
4e7ed67
errors
AdriaLlealS Nov 25, 2025
d7e62c6
errors
AdriaLlealS Nov 25, 2025
2da1d90
errors
AdriaLlealS Nov 25, 2025
6ebca9b
errors
AdriaLlealS Nov 25, 2025
65dc53d
errors
AdriaLlealS Nov 25, 2025
c8e1209
trying
AdriaLlealS Nov 25, 2025
f92c5fa
trying
AdriaLlealS Nov 25, 2025
bd9ff22
kinda solved
AdriaLlealS Nov 25, 2025
97edaf3
trying again
AdriaLlealS Nov 25, 2025
c269c38
trying
AdriaLlealS Nov 25, 2025
5116c0f
testing newbc
AdriaLlealS Nov 25, 2025
c55d1f4
baking test
AdriaLlealS Nov 25, 2025
a8ffa84
dfw_bins
AdriaLlealS Nov 25, 2025
91f9afa
custom tols SS
AdriaLlealS Nov 25, 2025
3c5d37f
mistake
AdriaLlealS Nov 25, 2025
5e8f975
div bins
AdriaLlealS Nov 26, 2025
dce67c4
tolerances
AdriaLlealS Nov 26, 2025
f4cc3c2
tols
AdriaLlealS Nov 26, 2025
a5200ae
tols
AdriaLlealS Nov 26, 2025
f3b8f79
tols and cap stepsize
AdriaLlealS Nov 26, 2025
491d25c
model
AdriaLlealS Nov 26, 2025
8512839
xdmfexport
AdriaLlealS Nov 26, 2025
3cd7a96
xdmfexport back
AdriaLlealS Nov 26, 2025
5edca69
tols
AdriaLlealS Nov 26, 2025
f03ba41
tryig to make hisp able to run in old and new BCs
AdriaLlealS Nov 26, 2025
ac14bd6
init
AdriaLlealS Nov 26, 2025
e76314f
Updated model to handle new and old bc
AdriaLlealS Nov 27, 2025
d5f1b0a
error calling gaussian_ufl
AdriaLlealS Nov 27, 2025
4e2c314
modified model to currently parse pulses data
AdriaLlealS Nov 27, 2025
a76ab99
smaller initial timesteps
AdriaLlealS Nov 27, 2025
bbb56cc
Fixing initial timestep
AdriaLlealS Nov 27, 2025
75a9731
tolerances and initial timesteps
AdriaLlealS Nov 27, 2025
c36a44f
finer mesh for W bins
AdriaLlealS Nov 27, 2025
d279ebc
trying to make solver converge for W
AdriaLlealS Nov 27, 2025
07f29c4
W not converging
AdriaLlealS Nov 27, 2025
f1d0c28
even finer mesh for W
AdriaLlealS Nov 27, 2025
7b3dcec
initial timestep
AdriaLlealS Nov 27, 2025
79bda5c
ridiculuously small stepsize to avoid solver issue
AdriaLlealS Nov 27, 2025
9554a0b
solver not converging for W bins
AdriaLlealS Nov 27, 2025
f7a24b6
trying to make the solver converge for W bins
AdriaLlealS Nov 27, 2025
6fbca78
Finding tols for the NewBC
AdriaLlealS Nov 27, 2025
312729f
modified tols and initial stepsize for NewBC
AdriaLlealS Nov 27, 2025
31bba75
Added option to accept copper thickness as None
AdriaLlealS Nov 27, 2025
92fb8c8
tols timesteps
AdriaLlealS Nov 27, 2025
cf7ee9a
super fine W mesh near the surface
AdriaLlealS Nov 27, 2025
62ee4b4
trying to make W bins run with old BC
AdriaLlealS Nov 27, 2025
cb07cf4
ridiculously small initial stepsize
AdriaLlealS Nov 27, 2025
c2102f4
W bins not converging with oldBCs
AdriaLlealS Nov 27, 2025
df97246
Debugging W oldBC
AdriaLlealS Nov 28, 2025
d66ff9d
rtol
AdriaLlealS Nov 28, 2025
fa24414
atol W oldBC
AdriaLlealS Nov 28, 2025
1b032c7
tolerances
AdriaLlealS Nov 28, 2025
ee77be7
higher timestep cap
AdriaLlealS Nov 28, 2025
d60aaae
Tolerances and surface reocmb BC
AdriaLlealS Nov 28, 2025
2f02b63
normalizing gaussian function from 0 to L
AdriaLlealS Nov 28, 2025
160ccdd
tolerances
AdriaLlealS Nov 28, 2025
1c96d38
initial timestep
AdriaLlealS Nov 28, 2025
457ccde
tols
AdriaLlealS Nov 28, 2025
68048b2
rtol in model.py
AdriaLlealS Nov 28, 2025
9aadf07
rtol div bins
AdriaLlealS Dec 1, 2025
a44dc07
more aggressive cutback factor
AdriaLlealS Dec 1, 2025
c312fa6
0 conc. BC
AdriaLlealS Dec 1, 2025
99ecce6
trying to solve div bins
AdriaLlealS Dec 2, 2025
383c677
trying to run div bins
AdriaLlealS Dec 2, 2025
5b39755
div bins
AdriaLlealS Dec 2, 2025
a8907c6
div W bins
AdriaLlealS Dec 2, 2025
c43a6fa
W div bins
AdriaLlealS Dec 2, 2025
e0caeae
rtol W bins
AdriaLlealS Dec 2, 2025
95f2501
5s max stepsize FP
AdriaLlealS Dec 2, 2025
9e897b9
W div bins
AdriaLlealS Dec 2, 2025
745df39
last W div bin
AdriaLlealS Dec 3, 2025
01cba18
capping stepsize
AdriaLlealS Dec 3, 2025
61a0843
exports
AdriaLlealS Dec 3, 2025
9477f13
print festim version
AdriaLlealS Dec 3, 2025
c4a7363
festim version
AdriaLlealS Dec 3, 2025
3f4edb9
trap element check
AdriaLlealS Dec 3, 2025
6de1b73
checking
AdriaLlealS Dec 3, 2025
8f44d61
trap elements type
AdriaLlealS Dec 3, 2025
f890d96
my_model inspection
AdriaLlealS Dec 3, 2025
4dce6eb
elemnts for traps checking
AdriaLlealS Dec 3, 2025
e8ff1ae
checking trap elements
AdriaLlealS Dec 3, 2025
3b88f1b
going back to dg traps to check
AdriaLlealS Dec 3, 2025
b9072a5
xdmf export not working for dg traps
AdriaLlealS Dec 3, 2025
02a19c9
testing
AdriaLlealS Dec 3, 2025
3bfe6e7
testing
AdriaLlealS Dec 3, 2025
a401f0d
testing
AdriaLlealS Dec 3, 2025
f6e2929
testing
AdriaLlealS Dec 3, 2025
e838ae3
testing
AdriaLlealS Dec 3, 2025
91afc1b
test
AdriaLlealS Dec 3, 2025
0e382c6
back to normal
AdriaLlealS Dec 3, 2025
1ac43df
almost working for all
AdriaLlealS Dec 3, 2025
fa336e5
adding vertices function
AdriaLlealS Dec 3, 2025
bd0e8f8
tolerances and mesh
AdriaLlealS Dec 4, 2025
b76060e
mesh
AdriaLlealS Dec 4, 2025
04d5978
Previous setup ran all wall bins and 50% div bins
AdriaLlealS Dec 4, 2025
8f64d78
finer mesh
AdriaLlealS Dec 4, 2025
e3a45ab
slower timestep coarser meshes NewBC
AdriaLlealS Dec 4, 2025
cb664e9
stepsize
AdriaLlealS Dec 4, 2025
be2b302
new meshing
AdriaLlealS Dec 4, 2025
c7a26e2
running all bins
AdriaLlealS Dec 4, 2025
69f0e46
run all bins
AdriaLlealS Dec 4, 2025
7b8d1bb
trying to run all div bins
AdriaLlealS Dec 5, 2025
bd878e1
New hisp model and simulations input from a csv table
AdriaLlealS Dec 10, 2025
350ad00
bin class defined in hisp
AdriaLlealS Dec 10, 2025
43ba8fe
fixing bug in bin indexing
AdriaLlealS Dec 10, 2025
2b9ec47
coarser meshes for implantation flux
AdriaLlealS Dec 10, 2025
eee9eb6
Moving bin, reactor classes to PFC-Tritium-Transport.
AdriaLlealS Dec 15, 2025
222205d
moving scenario and pulses definition to PFC-Tritium-Transport
AdriaLlealS Dec 15, 2025
14c847b
testing material file implementation
AdriaLlealS Dec 18, 2025
8b7eed7
testing new meshing function
AdriaLlealS Dec 19, 2025
a3ebb9e
indexing error in get_heat
AdriaLlealS Dec 19, 2025
014cb3b
new festim models
AdriaLlealS Dec 19, 2025
cb9173c
fixing hisp bin
AdriaLlealS Dec 19, 2025
eba38b0
fixing hisp.bin
AdriaLlealS Dec 19, 2025
535bcec
fixing hisp new_model
AdriaLlealS Dec 19, 2025
5329486
fixing new models to hanlde materials table
AdriaLlealS Dec 19, 2025
4d78d90
dolfinx time issues
AdriaLlealS Dec 19, 2025
5f53be3
updating models to handle new material objetcs
AdriaLlealS Jan 8, 2026
8112ff8
temperature function errors
AdriaLlealS Jan 8, 2026
d6bfb11
fixing exports
AdriaLlealS Jan 8, 2026
425d7fe
target number of iterations
AdriaLlealS Jan 8, 2026
e6116a1
fixing trap parameters
AdriaLlealS Jan 8, 2026
05eec43
debugging trap parameters
AdriaLlealS Jan 8, 2026
630f1bf
fixing trap density
AdriaLlealS Jan 8, 2026
cbb3cd5
support all BCs types
AdriaLlealS Jan 8, 2026
4e03e65
printing BCs summary
AdriaLlealS Jan 8, 2026
8ca03a0
fixing sources implementation
AdriaLlealS Jan 8, 2026
783242e
fixing source definitions
AdriaLlealS Jan 8, 2026
5a0f5de
cleaning the repo
AdriaLlealS Jan 8, 2026
6b1a2f8
imports in helpers
AdriaLlealS Jan 8, 2026
5d62a0b
returning to previous imports
AdriaLlealS Jan 8, 2026
0d08bdc
migrating functions to new_mb_model
AdriaLlealS Jan 9, 2026
3d686d3
changing import locations
AdriaLlealS Jan 9, 2026
38b7ea8
deleting old imports
AdriaLlealS Jan 9, 2026
d982bce
deleting old functions still imported
AdriaLlealS Jan 9, 2026
1635049
deleting old model files
AdriaLlealS Jan 9, 2026
e00f956
getting the repo ready
AdriaLlealS Jan 9, 2026
d7f23f3
deleting unused files
AdriaLlealS Jan 12, 2026
243b18d
Merge pull request #3 from AdriaLlealS/testing2
AdriaLlealS Jan 12, 2026
05b5f03
readme
AdriaLlealS Jan 12, 2026
60ba6ec
Update README.md
AdriaLlealS Jan 12, 2026
15d2f41
modifying imports directory
AdriaLlealS Jan 12, 2026
349c55f
adding surface recombination to the analytical BC
AdriaLlealS Jan 12, 2026
56f17c0
updating cross recombination term
AdriaLlealS Jan 13, 2026
0dd513c
going back to previous mb_model
AdriaLlealS Jan 13, 2026
ffa5ad3
Merge branch 'main' into testing2
AdriaLlealS Jan 13, 2026
4cca949
Merge pull request #4 from AdriaLlealS/testing2
AdriaLlealS Jan 13, 2026
7647437
Set model element for traps to 'CG'
AdriaLlealS Jan 19, 2026
8fe7459
Refactor vertex generation to use graded_vertices
AdriaLlealS Jan 20, 2026
4dbee2b
Refactor milestone creation for adaptive timestepping
AdriaLlealS Jan 20, 2026
e722526
Update graded_vertices radius from 1.01 to 1.1
AdriaLlealS Jan 20, 2026
6d39c34
Finer mesh
AdriaLlealS Jan 23, 2026
11d22d3
Implantation ranges and reflection coefficients
AdriaLlealS Jan 28, 2026
97e91aa
Adding dynamic calculations for implantation
AdriaLlealS Jan 28, 2026
9712261
Merge branch 'testing2' of https://github.com/AdriaLlealS/hisp into t…
AdriaLlealS Jan 28, 2026
a1bceda
Implantation parameters debugging
AdriaLlealS Jan 28, 2026
84098ad
Migrating PlasmaDataHandling to PFC-TT and adding scaling factors to …
AdriaLlealS Jan 29, 2026
20797ec
adding profiles export for sanity check and analysis
AdriaLlealS Feb 2, 2026
3fd45d8
Profile1DExport
AdriaLlealS Feb 2, 2026
3435b04
Setting profile exports to false for the moment
AdriaLlealS Feb 2, 2026
a260e76
Merge pull request #5 from AdriaLlealS/testing2
AdriaLlealS Feb 2, 2026
99a7415
added temperature model for SS
AdriaLlealS Feb 4, 2026
bbf96d4
Merge pull request #6 from AdriaLlealS/testing2
AdriaLlealS Feb 4, 2026
47da17b
Added meshing capabilities to PFC-TT
AdriaLlealS Feb 5, 2026
8944ff7
improving meshing from PFC
AdriaLlealS Feb 5, 2026
0220465
solving import error
AdriaLlealS Feb 5, 2026
2aec739
Merge pull request #7 from AdriaLlealS/testing2
AdriaLlealS Feb 5, 2026
1659ffb
Updating initial stepsize to 0.01s
AdriaLlealS Feb 10, 2026
88d8d26
Solving profiles exporting bug
AdriaLlealS Feb 18, 2026
f191438
fixing profile export times
AdriaLlealS Feb 18, 2026
8e47dc7
fixing profile export times
AdriaLlealS Feb 18, 2026
03262f6
Merge pull request #8 from AdriaLlealS/testing2
AdriaLlealS Feb 19, 2026
3d212dc
Fixing buf in profile export times
AdriaLlealS Feb 19, 2026
19b0b95
Merge pull request #9 from AdriaLlealS/testing2
AdriaLlealS Feb 19, 2026
4ef1646
Changing minimum spacing between exported profiles to 10s
AdriaLlealS Feb 19, 2026
a5241d4
Merge pull request #10 from AdriaLlealS/testing2
AdriaLlealS Feb 19, 2026
50be22e
Small bug choosing temperature model for W bins with cu_thickness=0
AdriaLlealS Mar 4, 2026
5dcf8e9
Small bug choosing temperature model for W bins with cu_thickness=0
AdriaLlealS Mar 4, 2026
919345e
switching back to CG elements for traps
AdriaLlealS Mar 10, 2026
dae0fc5
showing trap elemnt type
AdriaLlealS Mar 13, 2026
d5f8226
going back to DG elements for traps
AdriaLlealS Mar 13, 2026
317f96d
taking smaller stepsizes for boron
AdriaLlealS Mar 13, 2026
81c5617
trying CG for W
AdriaLlealS Mar 16, 2026
ecfd074
back to DG trap elements
AdriaLlealS Mar 16, 2026
36f3637
testing with CG elements
AdriaLlealS Mar 17, 2026
96ad1ca
switching yet again to DG
AdriaLlealS Mar 17, 2026
4ecd7b8
fixing max_stepsize bug
AdriaLlealS Mar 17, 2026
ae17b3f
fixing max stepsize during baking
AdriaLlealS Mar 17, 2026
bfcdb9a
implementing locally time to export to run previous version of fesitm
AdriaLlealS Mar 18, 2026
0b69f4d
commenting out profile exports for festim20a
AdriaLlealS Mar 18, 2026
c9a0b9c
festim20a
AdriaLlealS Mar 18, 2026
c0aa9aa
postpro
AdriaLlealS Mar 18, 2026
03873dd
Activating profile exports and letting FESTIM handle it natively
AdriaLlealS Mar 24, 2026
090376a
checkpointing for future restarts
AdriaLlealS Mar 24, 2026
ac2f4cd
exports to input_folder/results
AdriaLlealS Mar 24, 2026
6b866ed
naming of checkpoint files
AdriaLlealS Mar 24, 2026
d98e7d0
Merge branch 'main' into testing2
AdriaLlealS Mar 26, 2026
955f389
Merge pull request #12 from AdriaLlealS/testing2
AdriaLlealS Mar 26, 2026
15b6a3e
allowing user to provide custom temperature models from PFC-T-T
AdriaLlealS Mar 26, 2026
a82fd34
removing references to old export
AdriaLlealS Mar 26, 2026
cc65ee7
Merge pull request #13 from AdriaLlealS/testing2
AdriaLlealS Mar 27, 2026
f11d989
Improved input_table / bin syntax
AdriaLlealS Apr 1, 2026
e5b47d9
Merge pull request #14 from AdriaLlealS/testing2
AdriaLlealS Apr 1, 2026
eca6912
0 flux BC test
AdriaLlealS Apr 7, 2026
01c993d
removing the old_backup from the main
AdriaLlealS Apr 7, 2026
2ec0ae0
removing old files from the main branch
AdriaLlealS Apr 7, 2026
a599b38
Merge pull request #15 from AdriaLlealS/main
AdriaLlealS Apr 7, 2026
07a0399
baking temperature from scenario
AdriaLlealS Apr 9, 2026
7b4165a
baking temp from PFC-TT
AdriaLlealS Apr 9, 2026
146c101
Surface recombination at rearside
AdriaLlealS Apr 9, 2026
ed3885e
Material parameters debug
AdriaLlealS Apr 9, 2026
d984d7d
Merge pull request #16 from AdriaLlealS/main
AdriaLlealS Apr 28, 2026
3bf3997
saturating traps with D
AdriaLlealS Apr 28, 2026
613446a
sync
AdriaLlealS Apr 28, 2026
5b28009
Saturating traps with D
AdriaLlealS Apr 28, 2026
e8907d1
initial concentration
AdriaLlealS Apr 28, 2026
4c5b37d
gdc+bake pulse created
AdriaLlealS Apr 28, 2026
b47ad83
commenting out the D pre-loading
AdriaLlealS Apr 28, 2026
401b975
testing damaged tungsten
AdriaLlealS Apr 29, 2026
1be8f3b
add surface term to analytical BC
AdriaLlealS May 7, 2026
b2752cc
removing damage in the surface
AdriaLlealS May 7, 2026
ed5cf15
correcting the formula
AdriaLlealS May 7, 2026
36705fd
back to previous formula
AdriaLlealS May 7, 2026
db3fb58
kr0
AdriaLlealS May 7, 2026
2a35810
kr0
AdriaLlealS May 7, 2026
51bd2aa
silly mistake
AdriaLlealS May 7, 2026
24f09bd
mistake
AdriaLlealS May 7, 2026
7869b21
clean
AdriaLlealS May 12, 2026
af3eec6
Surface concentration update and GDC+bake handling
AdriaLlealS May 12, 2026
1aa0843
cleaning new_mb_model
AdriaLlealS May 12, 2026
4b229aa
Merge pull request #18 from AdriaLlealS/testing2
AdriaLlealS May 12, 2026
0efe699
fixing bug when implantation_params are none
AdriaLlealS May 12, 2026
719bc63
tests and updating classes import from PFC-TT
AdriaLlealS May 12, 2026
f856480
readme
AdriaLlealS May 12, 2026
ffa805f
readme
AdriaLlealS May 12, 2026
4ed76a0
readme
AdriaLlealS May 12, 2026
d28cfdd
examples
AdriaLlealS May 13, 2026
edbd220
updated readme
AdriaLlealS May 13, 2026
1fb47bf
updated plot
AdriaLlealS May 13, 2026
f896942
updated figure
AdriaLlealS May 13, 2026
5a51949
updated readme files
AdriaLlealS May 13, 2026
c461d68
readme
AdriaLlealS May 13, 2026
37608bd
readme
AdriaLlealS May 13, 2026
e05c4bf
updated readme
AdriaLlealS May 13, 2026
208b206
yet another readme update
AdriaLlealS May 13, 2026
d2bf5d3
examples readme
AdriaLlealS May 13, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
85 changes: 60 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,46 +1,81 @@
[![CI](https://github.com/kaelyndunnell/hisp/actions/workflows/ci.yml/badge.svg)](https://github.com/kaelyndunnell/hisp/actions/workflows/ci.yml)
[![docs](https://readthedocs.org/projects/hisp/badge/?version=latest)](https://hisp.readthedocs.io/en/latest/)

# HISP

Hydrogen Inventory Simulations for PFCs (HISP) is a series of code that uses FESTIM to simulate deuterium and tritium inventories in a fusion tokamak first wall and divertor PFCs.
Hydrogen Inventory Simulations for PFCs (HISP) is a series of code that uses FESTIM to simulate deuterium and tritium inventories in a fusion tokamak first wall and divertor PFCs.

## How to Run:
**This fork** reworks HISP to serve as the FESTIM orchestrator for [PFC-Tritium-Transport](https://github.com/iterorganization/PFC-Tritium-Transport) (PFC-TT): it receives bin objects, material properties, scenarios, and plasma data from PFC-TT and builds the corresponding FESTIM simulations. PFC-TT owns all physics definitions, inputs, and user control.

Clone the repository:
That said, once the core PFC-TT classes are importable (by having a local clone and its conda environment), HISP can also be used independently of PFC-TT's workflow. The [`example/`](example/) folder demonstrates this: bins and scenarios are defined directly in Python and passed to HISP to build and solve a simulation.

```
git clone https://github.com/kaelyndunnell/hisp
cd hisp
For more advanced use cases — including flexible input handling, detailed physics control, or large parameter studies — users are encouraged to work directly with https://github.com/iterorganization/PFC-Tritium-Transport, which provides a more complete and streamlined way to set up and run simulations.

## What HISP Does

For each bin it constructs a FESTIM simulation: it translates the bin geometry (thickness, optional Cu layer, surface area) into the model domain, assigns material parameters and trap definitions, builds time-dependent boundary conditions and implantation source expressions, and selects appropriate boundary-condition types (Robin/Neumann) before assembling and solving the transport equations with adaptive time-stepping. The per-bin outputs (retained inventory, surface fluxes, concentration profiles, and time traces) are exported to JSON for post-processing or aggregation across bins.

## Dependencies

HISP depends on:
- [FESTIM](https://github.com/festim-dev/festim) — finite element solver for hydrogen transport
- [PFC-Tritium-Transport](https://github.com/iterorganization/PFC-Tritium-Transport) — provides bin definitions, material classes, scenario handling, and plasma data

Both are installed as part of the PFC-TT conda environment (see below).

## How to Install

Follow the full installation instructions in the [PFC-Tritium-Transport README](https://github.com/iterorganization/PFC-Tritium-Transport). In summary:

### 1. Clone PFC-Tritium-Transport
```bash
git clone --branch main https://github.com/iterorganization/PFC-Tritium-Transport.git
```

Run this command to create a new environment with the right dependencies (eg. dolfinx):
### 2. Create the conda environment
This step installs all core simulation dependencies including **FESTIM** (required by both PFC-Tritium-Transport and HISP), FEniCS-DOLFINx, PETSc, and all other required packages:
```bash
conda config --set channel_priority flexible
conda env create -f PFC-TT.yml
conda activate PFC-TT
```
conda env create -f environment.yml

### 3. Register the PFC-TT path
HISP needs to know where PFC-Tritium-Transport is located on your system at runtime. Register the path once in your conda environment (replace with your actual clone location):
```bash
conda env config vars set PFC_TT_PATH="/path/to/your/PFC-Tritium-Transport"
conda deactivate && conda activate PFC-TT
```

Then, activate the environment:
You can verify it was set correctly with:
```bash
conda env config vars list
```
conda activate hisp-env

### 4. Install HISP
HISP is installed without dependencies since FESTIM and all other requirements are already provided by the PFC-TT conda environment:
```bash
pip install --no-deps git+https://github.com/AdriaLlealS/hisp.git@main
pip install h_transport_materials
```

## Examples

Install the `hisp` package with:
The `example/` folder contains a working example based on the HISP paper ([Dunnell et al., 2026](https://arxiv.org/abs/2604.04751)), demonstrating a full simulation of deuterium and tritium retention in iter's first wall and divertor plasma-facing components.

```
python -m pip install -e .
```
This example includes the results for a single bin under a specific scenario, along with a simple plotting script to visualise the outputs and the corresponding generated plot.

This will also install the pip dependencies like `h-transport-materials` and `FESTIM`.
See [`example/README.md`](example/README.md) for a full description of the example and instructions on how to run it.

> **_NOTE:_** Using `-e` with pip will install the package in editable mode, meaning the source code can be modified without having to reinstall the package.
## Running Tests

## Run the tests
With the conda environment active and `PFC_TT_PATH` set:
```bash
cd /path/to/hisp
python -m pytest tests/ -v
```

After cloning the repo and installing hisp, run:
## Development History

```
python -m pytest test
```
The first prototype (2024) was a single framework that combined simulation setup and solver execution, using MHIMS as the hydrogen isotope transport solver.

In early 2025, MHIMS was replaced by FESTIM for improved computational efficiency, and the codebase was split into two repositories — PFC-TT and HISP. During this stage, HISP still retained a significant role in handling physics definitions and simulation inputs alongside solver-related functionalities.

> **_NOTE:_** Make sure to install the test dependencies with `python -m pip install -e .[test]`
A subsequent major refactor further clarified the separation of responsibilities: all physics definitions and input handling were moved into PFC-TT, where they were also extended and further developed. At the same time, HISP evolved towards a role focused on solver execution and orchestration, with improved flexibility and integration with FESTIM. These developments led to the present versions of both codes.
13 changes: 0 additions & 13 deletions environment.yml

This file was deleted.

66 changes: 66 additions & 0 deletions example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Example: ITER PFCs tritium retention simulation

This folder recreates the bin definitions and operational scenarios shown in the
paper below. It demonstrates how to:

1. Define the plasma-facing component segments (bins) of a reactor with their
geometry, materials, and trap parameters.
2. Run HISP on a single bin to solve the hydrogen isotope transport equations
(diffusion + trapping) via FESTIM and obtain time-resolved retention results.

Reference:
> Dunnell, K., Lleal, A., Hodille, E. A., Dufour, J., Delaporte-Mathurin, R., & Wauters, T. (2026).
> *Hydrogen Inventory Simulations for PFCs (HISP)*.
> arXiv:2604.04751. https://arxiv.org/abs/2604.04751

## Files

| File | Purpose |
|------|---------|
| `make_iter_bins.py` | Creates 94 Bin objects (62 poloidal segments × wetted modes) based on the configuration described in the HISP paper |
| `scenarioA.py` | Defines a plasma operation scenario consisting of: 10 FP,DT pulses + STM (4-day wait) + bake |
| `scenarioB.py` | Defines a plasma operation scenario consisting of: 10 FP,DT pulses + 2-day GDC + bake |
| `scenarioC.py` | Defines a plasma operation scenario consisting of: 5 FP,DT pulses + 1 DD pulse + 5 FP,DT pulses + 1 DD pulse + 2-day GDC + bake |
| `run_single_bin.py` | Main script — runs one bin with a chosen scenario |
| `plot_T_inventory.py` | Plots tritium inventory from results JSON |
| `data/` | Binned plasma flux data (ion/atom fluxes, energies, heat loads per bin) |

## How to run

Activate the PFC-TT conda environment (which should already have `PFC_TT_PATH` set — see the main HISP README for setup).

```bash
conda activate PFC-TT
cd hisp/example
python run_single_bin.py --bin-index 0 --scenario scenarioA
```

Options:
- `--bin-index N` — which bin to simulate (0–93)
- `--scenario {do_nothing, capability_test, just_glow}`

Results are saved as JSON in `results_binN_<material>_<mode>/`.

## Post-processing

`plot_T_inventory.py` reads the results JSON and plots the total tritium
inventory over time, decomposed into its mobile and trapped contributions
(one curve per trap). This gives a clear view of how retention evolves
through the pulse sequence and the baking.

Below is the result for bin 0 — the high-wetted sub-bin of ITER's First Wall
Panel 1 — run with Scenario A:

![T inventory for bin 0](results_bin0_W_high_wetted/T_inventory.png)

## Adapting this example for your own simulation

The files in this folder can be used as templates for custom simulations. For any simulation you set up yourself, you need to provide two things: **bin definitions** (geometry, materials, trap parameters) and **binned plasma data files** (fluxes, heat loads, particle energies per bin).

**To define your own bins and materials**, edit `make_iter_bins.py`. The file has two parts:

- **Materials** — defined at the top as `Material` objects. Each material requires a name, atomic density (`Mat_density`), diffusion parameters (`D0`, `E_D`), recombination parameters (`K_R`, `E_R`), and a list of `Trap` objects with their density (atomic fraction), trapping and detrapping rate prefactors (`k_0`, `p_0`) and activation energies (`E_k`, `E_p`). Add or modify materials here to match your reactor's PFC materials.

- **Bin table** (`_BIN_DATA`) — each row defines one bin with its poloidal coordinates (`z_start`, `r_start`, `z_end`, `r_end`), material name, thickness, copper backing thickness, wetted mode, surface areas, and boundary condition types. Modify the rows to match your reactor geometry, or add new rows for additional bins. Each bin must reference a material defined in the materials block above.

**To provide your own plasma data**, you need to supply binned flux data files for each pulse type in your scenario — containing ion and atom fluxes, particle energies, and heat loads for each bin. The `data/` folder contains the files used in this example and serves as a reference for the expected format. These files are assigned to each pulse type inside the scenario file — look for the data file path assignments at the top of `scenarioA.py` as a template. Every bin defined in `make_iter_bins.py` must have a corresponding entry in the binned flux data files.
Loading
Loading