Skip to content

Funz/fz-Casmo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fz-casmo

A Funz plugin for CASMO5, Studsvik's advanced lattice physics code for Light Water Reactors.

This plugin enables parametric studies with CASMO5 using the fz framework.

Features

Input Syntax

  • Variable syntax: ${variable_name}
  • Formula syntax: @{formula}
  • Comment character: *

Supported Output Variables

The CASMO model extracts these output variables from output files:

For Depletion Calculations (*_dep.out files)

When using depletion input files with DEP card, the following arrays are extracted from the summary table (one value per burnup step):

  • burnup: Burnup evolution [MWd/kgU]
  • k_inf: Infinite multiplication factor evolution
  • m2: Migration area evolution [cm²]
  • u235_wt_pct: U-235 weight percent evolution
  • fissile_pu_wt_pct: Fissile Pu weight percent evolution
  • total_pu_wt_pct: Total Pu weight percent evolution
  • pin_power_peak: Pin power peaking factor evolution

Depletion metadata (scalar values):

  • dep_target: Target burnup from DEP card [MWd/kgU]
  • num_burnup_steps: Number of depletion steps performed
  • hist_void: Historical (depletion-averaged) void fraction [%]
  • hist_tfu: Historical fuel temperature [K]
  • hist_tmo: Historical moderator temperature [K]
  • hist_bor: Historical boron concentration [ppm]

For Single State Point Calculations (*.out files)

For calculations without depletion, scalar values are extracted:

  • k_inf: Infinite multiplication factor (single value)
  • m2: Migration area (single value)
  • power_peak: Power peaking factor
  • pin_power: 2D pin power distribution array
  • pin_exposure: 2D pin exposure distribution array
  • decay_constants: Delayed neutron decay constants
  • beta_eff: Effective delayed neutron fraction
  • neutron_generation_time: Mean neutron generation time

Installation

This plugin requires the Funz/fz framework and a licensed copy of CASMO5.

pip install git+https://github.com/Funz/fz.git

Set the CASMO5 installation path:

export CASMO_PATH="/path/to/casmo5"

Usage

With fz Python API

Single State Point Calculation

import fz

# Example: Run calculation with varying enrichment
results = fz.fzr(
    input_path="examples/CASMO/input.inp",
    input_variables={
        "enrichment": [3.0, 3.5, 4.0, 4.5],
        "fuel_temp": 900,
        "moderator_temp": 580
    },
    model="CASMO",
    calculators="localhost_CASMO",
    results_dir="my_results"
)

print(results[['enrichment', 'k_inf', 'm2']])

Depletion Calculation

import fz
import pandas as pd

# Example: Run depletion calculation with varying enrichment
results = fz.fzr(
    input_path="examples/CASMO/input_dep.inp",  # Input file with DEP card
    input_variables={
        "enrichment": [3.0, 3.5, 4.0],
        "fuel_temp": 900,
        "moderator_temp": 580
    },
    model="CASMO",
    calculators="localhost_CASMO",
    results_dir="depletion_results"
)

# Results contain arrays for each enrichment
for idx, row in results.iterrows():
    print(f"\nEnrichment: {row['enrichment']}%")
    print(f"Burnup points: {row['burnup']}")
    print(f"K-infinity evolution: {row['k_inf']}")
    print(f"U-235 depletion: {row['u235_wt_pct']}")
    print(f"Pu buildup: {row['total_pu_wt_pct']}")

Directory Structure

your_project/
├── examples/
│   └── CASMO/
│       └── input.inp           # Example input file
├── .fz/
│   ├── models/
│   │   └── CASMO.json          # Model configuration
│   └── calculators/
│       ├── CASMO.sh            # Calculator script
│       └── localhost_CASMO.json
├── tests/
│   └── test_plugin.py          # Test suite
└── results/                    # Generated by fz

Example Input File

* Example input file for CASMO plugin
* Variables are defined using ${variable_name} syntax

* Material definitions
FUE 1 10.42/${enrichment}     * UO2 fuel with variable enrichment
MOD 3 ${moderator_temp}/1.0   * Water moderator

* State point definition
TFU=${fuel_temp}              * Fuel temperature (K)
TMO=${moderator_temp}         * Moderator temperature (K)

In this example:

  • ${enrichment}, ${fuel_temp}, and ${moderator_temp} are variable parameters that will be substituted by fz
  • Lines starting with * are comments

Model Configuration

The model JSON file defines variable syntax and output parsing:

{
    "id": "CASMO",
    "varprefix": "$",
    "formulaprefix": "@",
    "delim": "{}",
    "commentline": "*",
    "output": {
        "burnup": "grep -A 1000 'BURNUP' output.txt | grep -E '^[[:space:]]*[0-9]' | awk '{print $1}'",
        "k_inf": "grep -A 1000 'BURNUP' output.txt | grep -E '^[[:space:]]*[0-9]' | awk '{print $2}'",
        "m2": "grep -A 1000 'BURNUP' output.txt | grep -E '^[[:space:]]*[0-9]' | awk '{print $3}'"
    }
}

Fields:

  • id: Unique identifier for the model
  • varprefix: Character prefix for variables (e.g., $ for ${x})
  • formulaprefix: Character prefix for formulas
  • delim: Delimiter characters around variable names
  • commentline: Character(s) that start a comment line
  • output: Mapping of output variable names to shell commands that extract their values

Calculator Configuration

The calculator JSON files define how to execute your code:

{
    "uri": "sh://",
    "models": {
        "CASMO": "bash .fz/calculators/CASMO.sh"
    }
}
  • uri: Execution method (sh:// for local shell, ssh:// for remote)
  • models: Mapping of model names to execution commands

Remote Execution

To run calculations on a remote server:

results = fz.fzr(
    input_path="examples/CASMO/input.inp",
    input_variables={"enrichment": [3.0, 4.0, 5.0]},
    model="CASMO",
    calculators="ssh://[email protected]/bash /path/to/calculators/CASMO.sh",
    results_dir="remote_results"
)

Troubleshooting

CASMO5 not found

Ensure CASMO_PATH environment variable is set:

export CASMO_PATH="/path/to/casmo5"

Calculator script not found

Ensure the calculator script is executable:

chmod +x .fz/calculators/CASMO.sh

Output variable not found

Check the output section in your model JSON file. The shell commands must correctly parse your output files.

Running Tests

python tests/test_plugin.py

License

BSD 3-Clause License. See LICENSE file.

Related Links

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •