Skip to content

Commit 8f65cf4

Browse files
authored
Merge pull request #16 from dassh-dev/develop
Merge develop into master
2 parents 8823e4b + 8447d33 commit 8f65cf4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+5532
-1646
lines changed

.github/workflows/ci.yml

+41-17
Original file line numberDiff line numberDiff line change
@@ -14,28 +14,61 @@ on:
1414
workflow_dispatch:
1515

1616
jobs:
17-
main:
18-
runs-on: ubuntu-latest
1917

18+
test_python_older:
19+
runs-on: ubuntu-20.04
2020
strategy:
2121
matrix:
22-
python-version: [3.8, 3.7, 3.6]
23-
22+
python-version: ["3.6"]
23+
2424
name: "Python ${{ matrix.python-version }}"
2525
steps:
2626
- uses: actions/checkout@v2
27-
2827
- name: Set up Python ${{ matrix.python-version }}
2928
uses: actions/setup-python@v2
3029
with:
3130
python-version: ${{ matrix.python-version }}
32-
31+
3332
- name: Package setup
3433
shell: bash
3534
run: |
3635
pip install -r requirements.txt
3736
pip install .
38-
37+
38+
- name: Package tests
39+
shell: bash
40+
run: pytest --cov=./dassh ./tests/ --cov-report xml:coverage_${{ matrix.python-version }}.xml
41+
42+
- name: Upload coverage to Codecov
43+
uses: codecov/codecov-action@v2
44+
with:
45+
fail_ci_if_error: true
46+
flags: unittests
47+
name: codecov-umbrella
48+
verbose: true
49+
files: coverage_${{ matrix.python-version }}.xml
50+
token: ${{ secrets.CODECOV_TOKEN }}
51+
52+
test_python_newer:
53+
runs-on: ubuntu-latest
54+
strategy:
55+
matrix:
56+
python-version: ["3.7", "3.8"]
57+
58+
name: "Python ${{ matrix.python-version }}"
59+
steps:
60+
- uses: actions/checkout@v2
61+
- name: Set up Python ${{ matrix.python-version }}
62+
uses: actions/setup-python@v2
63+
with:
64+
python-version: ${{ matrix.python-version }}
65+
66+
- name: Package setup
67+
shell: bash
68+
run: |
69+
pip install -r requirements.txt
70+
pip install .
71+
3972
- name: Package tests
4073
shell: bash
4174
run: pytest --cov=./dassh ./tests/ --cov-report xml:coverage_${{ matrix.python-version }}.xml
@@ -48,13 +81,4 @@ jobs:
4881
name: codecov-umbrella
4982
verbose: true
5083
files: coverage_${{ matrix.python-version }}.xml
51-
# dry_run: true
52-
53-
#finish:
54-
# needs: main
55-
# runs-on: ubuntu-latest
56-
# steps:
57-
# - name: CodeCov
58-
# shell: bash
59-
# run: codecov
60-
84+
token: ${{ secrets.CODECOV_TOKEN }}

dassh/__init__.py

100755100644
+3-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# permissions and limitations under the License.
1515
########################################################################
1616
"""
17-
date: 2022-03-21
17+
date: 2023-02-28
1818
author: Milos Atz, Micheal Smith
1919
"""
2020
########################################################################
@@ -39,10 +39,11 @@
3939
from dassh.plot import *
4040
from dassh import mesh_functions
4141
from dassh.orificing import *
42+
from dassh import hotspot
4243
import dassh.py4c as py4c
4344

4445

4546
np.set_printoptions(threshold=sys.maxsize, linewidth=500)
4647

4748

48-
__version__ = '0.10.3'
49+
__version__ = '0.12.0'

dassh/__main__.py

+66-3
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,18 @@
1414
# permissions and limitations under the License.
1515
########################################################################
1616
"""
17-
date: 2022-01-20
17+
date: 2022-12-19
1818
author: matz
19-
Main DASSH calculation procedure
19+
Main DASSH calculation procedures
2020
"""
2121
########################################################################
2222
import os
2323
import sys
24-
import dassh
24+
import numpy as np
2525
import argparse
2626
import cProfile
2727
import logging
28+
import dassh
2829
_log_info = 20 # logging levels must be int
2930

3031

@@ -216,6 +217,7 @@ def _run_dassh(dassh_inp, args, timestep, wdir, link=None):
216217
# Perform the sweep
217218
dassh_logger.log(_log_info, 'Performing temperature sweep...')
218219
reactor.temperature_sweep(verbose=args['verbose'])
220+
reactor.postprocess()
219221

220222
# Post-processing: write output, save reactor if desired
221223
dassh_logger.log(_log_info, 'Temperature sweep complete')
@@ -278,5 +280,66 @@ def plot():
278280
dassh_logger.log(_log_info, 'DASSH_PLOT execution complete')
279281

280282

283+
def integrate_pin_power(args=None):
284+
"""Set up DASSH Reactor object, integrate pin power, and write to CSV"""
285+
# Get input file from command line arguments
286+
parser = argparse.ArgumentParser(description='Process DASSH cmd')
287+
parser.add_argument('inputfile',
288+
metavar='inputfile',
289+
help='The input file to run with DASSH')
290+
parser.add_argument('--save_reactor',
291+
action='store_true',
292+
help='Save DASSH Reactor object after sweep')
293+
args = parser.parse_args(args)
294+
295+
# Initiate logger
296+
print(dassh._ascii._ascii_title)
297+
in_path = os.path.split(args.inputfile)[0]
298+
dassh_logger = dassh.logged_class.init_root_logger(in_path, 'dassh_power')
299+
300+
# Pre-processing
301+
# Read input file and set up DASSH input object
302+
dassh_logger.log(_log_info, f'Reading input: {args.inputfile}')
303+
dassh_input = dassh.DASSHPower_Input(args.inputfile)
304+
305+
# Initialize the Reactor object
306+
reactor = dassh.Reactor(dassh_input, write_output=False)
307+
308+
# Generate pin power distributions
309+
dassh_logger.log(_log_info, 'Generating pin power distributions...')
310+
asm_ids = []
311+
n_pins = []
312+
integrated_pin_powers = []
313+
for a in reactor.assemblies:
314+
if a.has_rodded:
315+
asm_ids.append(a.id)
316+
n_pins.append(a.rodded.n_pin)
317+
integrated_pin_powers.append(
318+
dassh.power._integrate_pin_power(a.power))
319+
320+
# Save reactor if desired
321+
dassh_logger.log(_log_info, 'Saving data')
322+
if args.save_reactor:
323+
if sys.version_info < (3, 7):
324+
handlers = dassh_logger.handlers[:]
325+
for handler in handlers:
326+
handler.close()
327+
dassh_logger.removeHandler(handler)
328+
reactor.save()
329+
if sys.version_info < (3, 7):
330+
dassh_logger = dassh.logged_class.init_root_logger(
331+
os.path.split(dassh_logger._root_logfile_path)[0],
332+
'dassh', 'a+')
333+
334+
# Write distributions to CSV
335+
arr_to_write = np.zeros((max(n_pins) + 1, len(asm_ids)))
336+
arr_to_write[0] = asm_ids
337+
for col in range(arr_to_write.shape[1]):
338+
arr_to_write[1:(n_pins[col] + 1), col] = integrated_pin_powers[col]
339+
outpath = os.path.join(dassh_input.path, 'total_pin_power.csv')
340+
np.savetxt(outpath, arr_to_write, delimiter=',')
341+
dassh_logger.log(_log_info, 'DASSH_POWER execution complete')
342+
343+
281344
if __name__ == '__main__':
282345
main()

0 commit comments

Comments
 (0)