Loading pygriffin/pygriffin.py +52 −1 Original line number Diff line number Diff line from collections import Iterable from numbers import Integral from numbers import Integral, Real import os from pathlib import Path import subprocess Loading @@ -25,6 +25,7 @@ class PyGriffin: self.input = input self.mesh = mesh self.n_procs = n_procs self._keff = None def run(self, input=None, mesh=None, Loading Loading @@ -184,6 +185,46 @@ class PyGriffin: self.run(input=self.mesh, other_args=['--mesh-only', mesh_name]) return Path(mesh_name).resolve().absolute() def postrun(self, griffin_csv_file): """ Extract Griffin k-effective to output file Parameters ---------- griffin_csv_file : str or pathlib.Path object CSV file generated by Griffin which stores eigenvalue information Returns ------- int Errorcode of the Griffin postrun (0 is success, 1 is csv_file not found, 2 is incorrect csv data format 3 is eigenvalue not found) """ if not Path(griffin_csv_file).is_file(): # CSV file not found return 1 with open(griffin_csv_file, 'r') as f: lines = f.readlines() if len(lines) < 3: # Insufficient row entries in csv file return 2 keff_field = "eigenvalue" header = lines[0].split('\n')[0] output_fields = header.split(',') if keff_field not in output_fields: # Output eigenvalue filed not found in csv file return 3 keff_index = output_fields.index(keff_field) result_row = lines[-1].split('\n')[0] self.keff = float(result_row.split(',')[keff_index]) return 0 def __call__(self, cwd=None): return self.run(cwd) Loading Loading @@ -291,3 +332,13 @@ class PyGriffin: pyg.n_procs = 1 return pyg @property def keff(self): return self._keff @keff.setter def keff(self, keff): cv.check_type('Griffin k-effective', keff, Real) cv.check_greater_than('Griffin k-effective', keff, 0) self._keff = keff Loading
pygriffin/pygriffin.py +52 −1 Original line number Diff line number Diff line from collections import Iterable from numbers import Integral from numbers import Integral, Real import os from pathlib import Path import subprocess Loading @@ -25,6 +25,7 @@ class PyGriffin: self.input = input self.mesh = mesh self.n_procs = n_procs self._keff = None def run(self, input=None, mesh=None, Loading Loading @@ -184,6 +185,46 @@ class PyGriffin: self.run(input=self.mesh, other_args=['--mesh-only', mesh_name]) return Path(mesh_name).resolve().absolute() def postrun(self, griffin_csv_file): """ Extract Griffin k-effective to output file Parameters ---------- griffin_csv_file : str or pathlib.Path object CSV file generated by Griffin which stores eigenvalue information Returns ------- int Errorcode of the Griffin postrun (0 is success, 1 is csv_file not found, 2 is incorrect csv data format 3 is eigenvalue not found) """ if not Path(griffin_csv_file).is_file(): # CSV file not found return 1 with open(griffin_csv_file, 'r') as f: lines = f.readlines() if len(lines) < 3: # Insufficient row entries in csv file return 2 keff_field = "eigenvalue" header = lines[0].split('\n')[0] output_fields = header.split(',') if keff_field not in output_fields: # Output eigenvalue filed not found in csv file return 3 keff_index = output_fields.index(keff_field) result_row = lines[-1].split('\n')[0] self.keff = float(result_row.split(',')[keff_index]) return 0 def __call__(self, cwd=None): return self.run(cwd) Loading Loading @@ -291,3 +332,13 @@ class PyGriffin: pyg.n_procs = 1 return pyg @property def keff(self): return self._keff @keff.setter def keff(self, keff): cv.check_type('Griffin k-effective', keff, Real) cv.check_greater_than('Griffin k-effective', keff, 0) self._keff = keff