Skip to content
This repository has been archived by the owner on Oct 1, 2020. It is now read-only.

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
drewejohnson committed Apr 12, 2017
2 parents e8d926b + 71634d6 commit f04a8ec
Show file tree
Hide file tree
Showing 28 changed files with 1,277 additions and 606 deletions.
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,9 @@ ENV/

# Backup garbage
*.ini
*.bak

# SCALE stuff
applet_resources/
*.ps
*.msg
*.tempdir.path

# Scheduler
*.pbs
Expand Down
31 changes: 0 additions & 31 deletions CritOpS.py

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2017 Drew Johnson
Copyright (c) 2017 Andrew Johnson

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
75 changes: 69 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,17 @@ A. Johnson

**Objective**: Iteratively update a parameter in a template NEWT file in
order to obtain a critical system.

[1]: M. D. DeHart, and S. Bowman, "Reactor Physics Methods and Analysis Capabilities in SCALE," Nuclear Technology, Technical Paper
vol. 174, no.2, pp. 196-213, 2011.

ASCII Art generated from [http://patorjk.com/software/taag](http://patorjk.com/software/taag/#p=display&f=Slant&t=CritOpS-NEWT)
## Setup
```
git clone https://github.com/drewejohnson/CritOpS.git
cd CritOpS
python setup.py install
```
The code currently requires `python3` due to some formatting calls, and `pandas` for some better data output.

## Input Syntax
```
python3 CritOpS.py [-h] [-v] [-o OUTPUT] inp_file param_file
python3 CritOpS.py inp_file param_file [-v] [-o OUTPUT]
positional arguments:
inp_file template SCALE input file
Expand All @@ -33,4 +35,65 @@ optional arguments:
-o OUTPUT, --output OUTPUT
write status to output file
```
The parameter file controls iteration procedure and `SCALE` execution.
Parameters that can be updated with the parameter file include
1. `k_target`: Desired value of k-eff to be obtained from the `SCALE` runs
1. `eps_k`: Acceptable accuracy between `k_target` and each value of k-eff
1. `iter_lim`: Maximum number of times to run `SCALE`
1. `exe_str`: Absolute path to your `SCALE` executable.
1. `var_char`: Whatever character you want to use as a designator for the variables

Currently, `CritOpS` only supports one iteration variable, which is declared in the parameter file with
```
iter_var <var> <start> <min> <max>
```

The input file should be a valid `NEWT` input file, with some minor modifications.
There should exist certain values defined as variables preceeded by the `var_char`,
```
cuboid 20 5 0 0 -$del_z
```

Given some input and parameter files, the code will create and execute successive input files,
parse the outputs for the update k-eff, and then update the iteration variables.

## Caveats/Future Work
This code was designed to optimize the thickness of a reflector, and assumes that each parameter
has a positive effect on criticality.
Increasing the value of an iteration variable is assumed to increase the criticality.
Technically this code could work on any `SCALE` input file, and so long as the output file contains the k-eff string, the iteration procedure should work.
This was not the intent, nor has this been tested.

Future work will include
1. The ability to specify positive/negative feedbacks
1. The ability to specify and iterate upon multiple variables
1. The ability to define some variables as functions of iteration variables

## License
MIT License

Copyright (c) 2017 Andrew Johnson

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

## References
[1]: M. D. DeHart, and S. Bowman, "Reactor Physics Methods and Analysis Capabilities in SCALE," Nuclear Technology, Technical Paper
vol. 174, no.2, pp. 196-213, 2011. http://dx.doi.org/10.13182/NT174-196

ASCII Art generated from [http://patorjk.com/software/taag](http://patorjk.com/software/taag/#p=display&f=Slant&t=CritOpS-NEWT)
5 changes: 5 additions & 0 deletions critops/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from critops.constants import *
from critops.iterator import *
from critops.outputs import *
from critops.readinputs import *
from critops.utils import *
72 changes: 72 additions & 0 deletions critops/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
"""
______ _ __ ____ _____ _ _________ ________
/ ____/____(_) /_/ __ \____ / ___/ / | / / ____/ | / /_ __/
/ / / ___/ / __/ / / / __ \\__ \_____/ |/ / __/ | | /| / / / /
/ /___/ / / / /_/ /_/ / /_/ /__/ /____/ /| / /___ | |/ |/ / / /
\____/_/ /_/\__/\____/ .___/____/ /_/ |_/_____/ |__/|__/ /_/
/_/
CritOpS
A Critical Optimization Search tool for NEWT[1]
Andrew Johnson
Objective: Iteratively update a parameter in a template NEWT file in
order to obtain a critical system.
[1]: M. D. DeHart, and S. Bowman, "Reactor Physics Methods and Analysis
Capabilities in SCALE," Nuclear Technology, Technical Paper
vol. 174, no.2, pp. 196-213, 2011.
"""

import argparse
import os
import sys

from critops import utils
from critops.constants import header, default_params
from critops.iterator import itermain
from critops.outputs import output_landing
from critops.readinputs import readmain

# Input parameters
parser = argparse.ArgumentParser(description=header, formatter_class=argparse.RawDescriptionHelpFormatter,
usage='critops inp_file param_file [-v] [-o OUTPUT]')
parser.add_argument('inp_file', type=str, help='template SCALE input file')
parser.add_argument('param_file', type=str, help='file containing parameters for operation')
parser.add_argument('-v', '--verbose', help='reveal more of the mystery behind the operation', action='store_true')
parser.add_argument('-o', '--output', help="write status to output file", type=str)

if __name__ == '__main__':

if int(sys.version_info[0]) < 3:
raise SystemError('Need python 3 >')

kwargs = {}
for key in default_params:
kwargs[key] = default_params[key]

args = vars(parser.parse_args())
kwargs['verbose'] = args.pop('verbose')
kwargs['output'] = args.pop('output')

if kwargs['output'] is None:
print(header)
else:
with open(kwargs['output'], 'w') as outobj:
outobj.write(header)

# Update files to be absolute references
for file in ('inp_file', 'param_file'):
args[file] = os.path.join(os.getcwd(), args[file])
if not os.path.exists(args[file]):
utils.error('File {} does not exist'.format(args[file]), 'CritOps __main__', args)

# Read the input files
template, iter_vars = readmain(args['inp_file'], args['param_file'], kwargs)

# Start the iteration
iter_vecs, k_vec, conv_type = itermain(template, args['inp_file'], iter_vars, kwargs)

# Output
output_landing(iter_vecs, k_vec, conv_type, **kwargs)
43 changes: 43 additions & 0 deletions critops/constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
"""
NRE6401 - Molten Salt Reactor
CritOpS
constants
Objective: Header file for some useful constants
"""
lineBreakShort = '-' * 10 + '\n'
lineBreakLong = "*" * 70 + '\n'

default_params = {
'eps_k': 1E-4, 'k_target': 1.0, 'iter_lim': 50,
'inf': 1E30, 'tiny': 1E-16, 'var_char': '$', 'exe_str': 'C:\\SCALE-6.2.1\\bin\\scalerte.exe'
}

pName = "CritOpS-NEWT v2.0.0dev5"
asciiHeader = r"""
______ _ __ ____ _____ _ _________ ________
/ ____/____(_) /_/ __ \____ / ___/ / | / / ____/ | / /_ __/
/ / / ___/ / __/ / / / __ \\__ \_____/ |/ / __/ | | /| / / / /
/ /___/ / / / /_/ /_/ / /_/ /__/ /____/ /| / /___ | |/ |/ / / /
\____/_/ /_/\__/\____/ .___/____/ /_/ |_/_____/ |__/|__/ /_/
/_/
""" # http://patorjk.com/software/taag/#p=display&f=Slant&t=CritOpS-NEWT

header = lineBreakLong + asciiHeader + pName.center(len(lineBreakLong)) + """
A Critical Optimization Search tool for NEWT[1]
A. Johnson
Objective: Iteratively update a parameter in a template NEWT file in
order to obtain a critical system.
[1]: M. D. DeHart, and S. Bowman, "Reactor Physics Methods and Analysis
\tCapabilities in SCALE," Nuclear Technology, Technical Paper
\tvol. 174, no.2, pp. 196-213, 2011.
""" + lineBreakLong

supVarChars = ('$',)
Loading

0 comments on commit f04a8ec

Please sign in to comment.