diff --git a/.fz/calculators/Localhost_Scale-shift.json b/.fz/calculators/Localhost_Scale-shift.json new file mode 100644 index 0000000..592db74 --- /dev/null +++ b/.fz/calculators/Localhost_Scale-shift.json @@ -0,0 +1,7 @@ +{ + "uri": "sh://", + "n": 1, + "models": { + "Scale-shift": "bash .fz/calculators/Scale-shift.sh" + } +} diff --git a/.fz/calculators/Scale-shift.sh b/.fz/calculators/Scale-shift.sh new file mode 100755 index 0000000..2394369 --- /dev/null +++ b/.fz/calculators/Scale-shift.sh @@ -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 " + 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 diff --git a/.fz/models/Scale-shift.json b/.fz/models/Scale-shift.json new file mode 100644 index 0000000..fcdf30b --- /dev/null +++ b/.fz/models/Scale-shift.json @@ -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" + } +} diff --git a/CHANGELOG.md b/CHANGELOG.md index c8277df..c007c85 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/README.md b/README.md index 72b7331..542dd9e 100644 --- a/README.md +++ b/README.md @@ -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) @@ -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 @@ -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']]) ``` @@ -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 @@ -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: diff --git a/examples/Scale-shift/godiva.inp b/examples/Scale-shift/godiva.inp new file mode 100644 index 0000000..7d4232d --- /dev/null +++ b/examples/Scale-shift/godiva.inp @@ -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 diff --git a/tests/test_plugin.py b/tests/test_plugin.py index d18f9f8..6c18d52 100755 --- a/tests/test_plugin.py +++ b/tests/test_plugin.py @@ -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"] @@ -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: @@ -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: @@ -109,6 +112,7 @@ def test_example_files(): examples = [ "examples/Scale-keno/godiva.inp", + "examples/Scale-shift/godiva.inp", "examples/example_usage.py" ]