Skip to content

Commit

Permalink
JSON update (#122)
Browse files Browse the repository at this point in the history
* JSON update

* fix requirements

* expected files

* Expected files

* tests rework

* improved tests
  • Loading branch information
grzanka authored May 8, 2023
1 parent e1cb5f4 commit 2a1ff47
Show file tree
Hide file tree
Showing 13 changed files with 824 additions and 461 deletions.
36 changes: 33 additions & 3 deletions .github/workflows/test-run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,41 @@ on:
workflow_dispatch:

jobs:
build-and-test:

smoke-test-on-linux:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.11'

- name: Install dependencies
run: |
python3 -m pip install --upgrade pip
pip3 install -r requirements.txt
pip3 install -r test_requirements.txt
- name: Run main tests
run: python -m pytest tests/


build-and-test:
runs-on: ${{ matrix.platform }}
needs: smoke-test-on-linux
strategy:
matrix:
python-version: ['3.9', '3.10', '3.11']
matrix:
python-version: ['3.11']
platform: ['windows-latest', 'macos-latest']
include:
- python-version: '3.9'
platform: 'ubuntu-latest'
- python-version: '3.10'
platform: 'ubuntu-latest'

steps:
- name: Checkout
uses: actions/checkout@v3
Expand Down
7 changes: 3 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,6 @@ cython_debug/
.ionide

# End of https://www.toptal.com/developers/gitignore/api/python,visualstudiocode,pycharm
beam.dat
detect.dat
geo.dat
mat.dat

**/*.dat
!input_examples/expected_shieldhit_output/*.dat
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Yet Another Particle Transport IDE - converter

The Converter of the project file (JSON file generated by frontend part) into a set of input files for SHIELD-HIT12A (beam.dat, mat.dat, geo.dat and detect.dat).
The Converter of the project file (JSON file generated by frontend part) into a set of input files for particle transport simulators:
- SHIELD-HIT12A (beam.dat, mat.dat, geo.dat and detect.dat).
- TOPAS

## Requirements
- Python 3.9+
Expand Down
2 changes: 2 additions & 0 deletions input_examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
An input file generated with yaptide UI (https://yaptide.github.io/web_dev/).
Open first example, then save it as JSON file under `sh_parser_test.json` name.
1 change: 1 addition & 0 deletions input_examples/expected_shieldhit_output/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Output files generated using the UI ("Input files" / "Generate from editor").
14 changes: 14 additions & 0 deletions input_examples/expected_shieldhit_output/beam.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

RNDSEED 89736501 ! Random seed
JPART0 2 ! Incident particle type
TMAX0 150.0 1.5 ! Incident energy and energy spread; both in (MeV/nucl)
TCUT0 0 1000 ! energy cutoffs [MeV]
NSTAT 10000 0 ! NSTAT, Step of saving
STRAGG 2 ! Straggling: 0-Off 1-Gauss, 2-Vavilov
MSCAT 2 ! Mult. scatt 0-Off 1-Gauss, 2-Moliere
NUCRE 1 ! Nucl.Reac. switcher: 1-ON, 0-OFF
BEAMPOS 0 0 0 ! Position of the beam
BEAMDIR 0.0 0.0 ! Direction of the beam
BEAMSIGMA 0 0 ! Beam extension
! no BEAMSAD value
DELTAE 0.03 ! relative mean energy loss per transportation step
75 changes: 75 additions & 0 deletions input_examples/expected_shieldhit_output/detect.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
Geometry Cyl
Name CylZ_Mesh
R 0 5 1
Z 0 20 400

Geometry Mesh
Name YZ_Mesh
X -0.25 0.25 1
Y -2 2 80
Z 0 20 400

Geometry Cyl
Name EntrySlab
R 0 5 1
Z 0 0.1 1

Geometry Cyl
Name PeakSlab
R 0 5 1
Z 15.3 15.4 1

Filter
Name Protons
Z == 1
A == 1
Filter
Name Primaries
Z == 1
A == 1
GEN == 0
Filter
Name Secondary_protons
Z == 1
A == 1
GEN >= 1
Output
Filename z_profile.bdo
Geo CylZ_Mesh
Quantity Dose
Quantity Fluence Protons
Quantity Fluence Primaries
Quantity Fluence Secondary_protons

Output
Filename yz_profile.bdo
Geo YZ_Mesh
Quantity Dose
Quantity Fluence Protons
Quantity Fluence Secondary_protons

Output
Filename entrance.bdo
Geo EntrySlab
Quantity Dose
Quantity AvgEnergy Primaries
Quantity AvgEnergy Protons
Quantity AvgEnergy Secondary_protons
Quantity dLET Protons
Quantity tLET Protons
Quantity Fluence Protons
Diff1 0 160 640
Diff1Type E

Output
Filename peak.bdo
Geo PeakSlab
Quantity Dose
Quantity AvgEnergy Primaries
Quantity AvgEnergy Protons
Quantity AvgEnergy Secondary_protons
Quantity dLET Protons
Quantity tLET Protons
Quantity Fluence Protons
Diff1 0 160 640
Diff1Type E
15 changes: 15 additions & 0 deletions input_examples/expected_shieldhit_output/geo.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

0 0 Proton pencil beam in water
RCC 1 0.0 0.0 0.0 0.0 0.0 20.0
5.0
RCC 2 0.0 0.0 -0.5 0.0 0.0 22.0
5.5
RCC 3 0.0 0.0 -1.5 0.0 0.0 24.0
6.0
END
001 +1
002 +2 -1
003 -2 +3 -1
END
1 2 3
1 1000 0
3 changes: 3 additions & 0 deletions input_examples/expected_shieldhit_output/mat.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
MEDIUM 1
ICRU 276
END
Loading

0 comments on commit 2a1ff47

Please sign in to comment.