-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathmagic.py
More file actions
59 lines (41 loc) · 1.39 KB
/
magic.py
File metadata and controls
59 lines (41 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# -*- coding: utf-8 -*-
"""
Magic GVR tool
S Lilley
Sept 2020
"""
import argparse
import neut_utilities as ut
import meshtal_analysis as ma
import numpy as np
def generate_header(output_data):
return output_data
def generate_mesh_header(mesh, output_data):
return output_data
def normalise_mesh(mesh):
""" normalise so highest point is a half """
result = mesh.data["value"]
result = result.astype(np.float)
norm_const = 0.5 / max(result)
norm_data = result * norm_const
return norm_data
def do_magic(infile, ofile='wwinp'):
""" generates a weight window file based on magic GVR method """
ut.setup_logging()
# read meshtal file
meshes = ma.read_mesh_tally_file(args.input)
# set up output
output_data = []
output_data = generate_header(output_data)
# generate ww meshes for each meshtal
for mesh in meshes:
output_data = generate_mesh_header(mesh, output_data)
# normed = normalise_mesh(mesh)
# write output
ut.write_lines(ofile, output_data)
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Perform magic GVR")
parser.add_argument("input", help="path to the mcnp meshtal file")
parser.add_argument("output", help="path to the output ww file")
args = parser.parse_args()
do_magic(args.input, args.output)