Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .fz/calculators/Localhost_Scale-shift.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"uri": "sh://",
"n": 1,
"models": {
"Scale-shift": "bash .fz/calculators/Scale-shift.sh"
}
}
61 changes: 61 additions & 0 deletions .fz/calculators/Scale-shift.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/bin/bash

# Scale-shift calculator script
# Compatible with fz framework

# Check for SCALE installation
if [ -z "$SCALE_HOME" ]; then
export SCALE_HOME="/SCALE/scale6.2"
fi
export CMDS=${SCALE_HOME}/bin

# if directory as input, cd into it
if [ -d "$1" ]; then
cd "$1"
# Find the first input file (not .out or .msg)
input=$(ls | grep -v '\.out$' | grep -v '\.msg$' | grep -v '\.sh$' | head -n 1)
if [ -z "$input" ]; then
echo "No input file found in directory. Exiting."
exit 1
fi
shift
# if $1 is a file, use it
elif [ -f "$1" ]; then
input="$1"
shift
else
echo "Usage: $0 <input_file or input_directory>"
exit 2
fi

PID_FILE=$PWD/PID
echo $$ >> $PID_FILE

output="$(basename $input).out"
msgs="$(basename $input).msg"

${CMDS}/scalerte $input $output > $msgs 2>&1 &

PID_SCALE=$!
echo $PID_SCALE >> $PID_FILE
wait $PID_SCALE

# test for "congratulations" message in output for csas5-shift/csas6-shift
if [[ (`grep -E "=csas[56]-shift" $input 2>/dev/null | wc -l` == "1" ) ]]
then
echo "Testing congratulations..."
if [ `grep "Congratulations" *.out 2>/dev/null | wc -l` == "0" ]
then
echo "Error: no congratulations !"
if [ -f $PID_FILE ]; then
rm -f $PID_FILE
fi
exit 1
else
echo "OK: Congratulations returned."
fi
fi

if [ -f $PID_FILE ]; then
rm -f $PID_FILE
fi
17 changes: 17 additions & 0 deletions .fz/models/Scale-shift.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"id": "Scale-shift",
"varprefix": "&",
"formulaprefix": "@",
"delim": "()",
"commentline": "'",
"output": {
"mean_keff": "grep 'best estimate system k-eff' *.out | head -1 | awk '{for(i=1;i<=NF;i++) if($i==\"k-eff\") print $(i+1)}' 2>/dev/null || echo 1.0",
"sigma_keff": "grep 'best estimate system k-eff' *.out | head -1 | awk '{for(i=1;i<=NF;i++) if($i==\"-\") print $(i+1)}' 2>/dev/null || echo 0.001",
"mean_E_lethargy": "grep 'Energy of average lethargy of Fission' *.out | head -1 | awk '{print $7}' 2>/dev/null || echo 100",
"sigma_E_lethargy": "grep 'Energy of average lethargy of Fission' *.out | head -1 | awk '{print $10}' 2>/dev/null || echo 10",
"mean_nubar": "grep 'system nu bar' *.out | head -1 | awk '{print $4}' 2>/dev/null || echo 1.0",
"sigma_nubar": "grep 'system nu bar' *.out | head -1 | awk '{print $7}' 2>/dev/null || echo 0.001",
"mean_free_path": "grep 'system mean free path' *.out | head -1 | awk '{print $5}' 2>/dev/null || echo 1.0",
"sigma_free_path": "grep 'system mean free path' *.out | head -1 | awk '{print $8}' 2>/dev/null || echo 0.001"
}
}
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@

All notable changes to the fz-scale plugin will be documented in this file.

## [Unreleased]

### Added
- Support for CSAS-Shift sequence (csas5-shift, csas6-shift)
- Scale-shift.json model definition for Shift Monte Carlo solver
- Scale-shift.sh calculator script for executing CSAS-Shift calculations
- Localhost_Scale-shift.json calculator configuration
- Godiva example input file using csas6-shift
- Documentation and usage examples for CSAS-Shift in README.md
- Enhanced test suite to validate Scale-shift model and calculator

## [1.0.0] - 2025-01-13

### Added
Expand Down
63 changes: 60 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

A [Funz](https://github.com/Funz/fz) plugin for running SCALE (Standardized Computer Analyses for Licensing Evaluation) calculations.

This plugin provides support for three SCALE calculation types:
This plugin provides support for four SCALE calculation types:
- **Scale-keno**: KENO criticality calculations (=csas5, =csas6)
- **Scale-shift**: CSAS-Shift criticality calculations with Shift Monte Carlo solver (=csas5-shift, =csas6-shift)
- **Scale-tsunami**: TSUNAMI sensitivity/uncertainty analysis (=tsunami-3d)
- **Scale-xsdrnpm**: XSDRNPM transport calculations (=xsdrnpm, =csas1x)

Expand All @@ -22,6 +23,13 @@ This plugin provides support for three SCALE calculation types:
- `mean_nubar`, `sigma_nubar`: Average neutrons per fission
- `mean_free_path`, `sigma_free_path`: System mean free path

#### Scale-shift
Same output variables as Scale-keno:
- `mean_keff`, `sigma_keff`: Effective multiplication factor and uncertainty
- `mean_E_lethargy`, `sigma_E_lethargy`: Energy of average lethargy of fission
- `mean_nubar`, `sigma_nubar`: Average neutrons per fission
- `mean_free_path`, `sigma_free_path`: System mean free path

#### Scale-tsunami
All Scale-keno outputs plus sensitivity coefficients for various isotopes:
- H-1, O-16, Al-27, Ti-48, Fe-56, C
Expand Down Expand Up @@ -55,6 +63,20 @@ results = fz.fzr(
results_dir="godiva_results"
)

print(results[['r', 'mean_keff', 'sigma_keff']])

# Example: CSAS-Shift calculation with varying sphere radius
# Uses the Shift Monte Carlo solver for improved performance
results = fz.fzr(
input_path="examples/Scale-shift/godiva.inp",
input_variables={
"r": [8.5, 8.6, 8.7, 8.741, 8.8, 8.9, 9.0]
},
model="Scale-shift",
calculators="Localhost_Scale-shift",
results_dir="godiva_shift_results"
)

print(results[['r', 'mean_keff', 'sigma_keff']])
```

Expand All @@ -63,18 +85,23 @@ print(results[['r', 'mean_keff', 'sigma_keff']])
```
your_project/
├── examples/
│ └── Scale-keno/
│ └── godiva.inp # Example KENO input file
│ ├── Scale-keno/
│ │ └── godiva.inp # Example KENO input file
│ └── Scale-shift/
│ └── godiva.inp # Example CSAS-Shift input file
├── .fz/
│ ├── models/
│ │ ├── Scale-keno.json
│ │ ├── Scale-shift.json
│ │ ├── Scale-tsunami.json
│ │ └── Scale-xsdrnpm.json
│ └── calculators/
│ ├── Scale-keno.sh
│ ├── Scale-shift.sh
│ ├── Scale-tsunami.sh
│ ├── Scale-xsdrnpm.sh
│ ├── Localhost_Scale-keno.json
│ ├── Localhost_Scale-shift.json
│ ├── Localhost_Scale-tsunami.json
│ └── Localhost_Scale-xsdrnpm.json
└── results/ # Generated by fz
Expand Down Expand Up @@ -108,6 +135,36 @@ In this example:
- The comment character `'` is used for the header line
- The calculation type is `=csas6` (KENO-VI)

### CSAS-Shift Input File Example

For CSAS-Shift calculations, simply use `=csas5-shift` or `=csas6-shift` instead of `=csas5` or `=csas6`:

```
'Input generated by GeeWiz SCALE 6.0.2
=csas6-shift
godiva
ce_v7_endf
read composition
uranium 1 den=18.742 1 293
92234 1.0202
92235 93.7112
92238 5.2686 end
end composition
read geometry
global unit 1
sphere 10 &(r)
media 1 1 10
boundary 10
end geometry
end data
end
```

The key difference:
- `=csas6-shift` uses the Shift Monte Carlo solver instead of KENO
- Improved performance and scalability, especially for parallel computations
- Compatible with all KENO V.a and KENO-VI geometries

## Expected Output

When running a parametric study, fz returns a pandas DataFrame:
Expand Down
18 changes: 18 additions & 0 deletions examples/Scale-shift/godiva.inp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
'Input generated by GeeWiz SCALE 6.0.2 Compiled on February 18, 2009
=csas6-shift
godiva
ce_v7_endf
read composition
uranium 1 den=18.742 1 293
92234 1.0202
92235 93.7112
92238 5.2686 end
end composition
read geometry
global unit 1
sphere 10 &(r)
media 1 1 10
boundary 10
end geometry
end data
end
10 changes: 7 additions & 3 deletions tests/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ def test_model_files():
models = [
".fz/models/Scale-keno.json",
".fz/models/Scale-tsunami.json",
".fz/models/Scale-xsdrnpm.json"
".fz/models/Scale-xsdrnpm.json",
".fz/models/Scale-shift.json"
]

required_fields = ["id", "varprefix", "delim", "commentline", "output"]
Expand Down Expand Up @@ -57,7 +58,8 @@ def test_calculator_files():
calculators = [
".fz/calculators/Localhost_Scale-keno.json",
".fz/calculators/Localhost_Scale-tsunami.json",
".fz/calculators/Localhost_Scale-xsdrnpm.json"
".fz/calculators/Localhost_Scale-xsdrnpm.json",
".fz/calculators/Localhost_Scale-shift.json"
]

for calc_file in calculators:
Expand Down Expand Up @@ -86,7 +88,8 @@ def test_calculator_scripts():
scripts = [
".fz/calculators/Scale-keno.sh",
".fz/calculators/Scale-tsunami.sh",
".fz/calculators/Scale-xsdrnpm.sh"
".fz/calculators/Scale-xsdrnpm.sh",
".fz/calculators/Scale-shift.sh"
]

for script_file in scripts:
Expand All @@ -109,6 +112,7 @@ def test_example_files():

examples = [
"examples/Scale-keno/godiva.inp",
"examples/Scale-shift/godiva.inp",
"examples/example_usage.py"
]

Expand Down
Loading