Loading pygriffin/pygriffin.py +39 −6 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ class PyGriffin: self.mesh = mesh self.n_procs = n_procs self._keff = None self._subassembly_power_volume = None def run(self, input=None, mesh=None, Loading Loading @@ -194,7 +195,7 @@ 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): def postrun(self, griffin_csv_file, griffin_subassembly_output_file): """ Extract Griffin k-effective to output file Loading @@ -202,36 +203,64 @@ class PyGriffin: ---------- griffin_csv_file : str or pathlib.Path object CSV file generated by Griffin which stores eigenvalue information griffin_subassembly_output_file : str or pathlib.Path object CSV file generated by Griffin which stores subassembly power and volume data Returns ------- int Errorcode of the Griffin postrun (0 is success, 1 is csv_file not found, 2 is incorrect csv data format 1 is eigenvalue csv_file not found, 2 is incorrect eigenvalue csv data format 3 is eigenvalue not found) 4 is subassembly csv_file not found, 5 is incorrect subassembly csv data format 6 is power/volume data not found) """ if not Path(griffin_csv_file).is_file(): # CSV file not found # Eigenvalue 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 # Insufficient row entries in eigenvalue 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 # Output eigenvalue field 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]) if not Path(griffin_subassembly_output_file).is_file(): # Subassembly power volume CSV file not found return 4 with open(griffin_subassembly_output_file, 'r') as f: lines = f.readlines() if len(lines) < 2: # Insufficient row entries in power volume csv file return 5 header = lines[0].split('\n')[0] output_fields = header.split(',') if len(output_fields) != 4: # Incorrect number of output fields in power volume csv file return 5 if 'power' not in output_fields or 'volume' not in output_fields: # Output power and volume fields not found in csv file return 6 self._subassembly_power_volume = {} for result_row in lines[1:]: assembly_id, plane_id, power, volume = result_row.split(',') self._subassembly_power_volume[(int(assembly_id), int(plane_id))] = (float(power), float(volume)) return 0 def __call__(self, cwd=None): Loading Loading @@ -351,3 +380,7 @@ class PyGriffin: cv.check_type('Griffin k-effective', keff, Real) cv.check_greater_than('Griffin k-effective', keff, 0) self._keff = keff @property def subassembly_power_volume(self): return self._subassembly_power_volume tests/postrun_insuffrow.csv→tests/postrun_eigen_insuffrow.csv +0 −0 File moved. View file tests/postrun_success.csv→tests/postrun_eigen_success.csv +0 −0 File moved. View file tests/postrun_nopower.csv 0 → 100644 +5 −0 Original line number Diff line number Diff line Level-0-assembly_id,Level-1-plane_id,not_power,volume 0,0,0,1.0 0,1,0,2.0 1,0,0,1.0 1,1,2.5,2.0 tests/postrun_novolume.csv 0 → 100644 +5 −0 Original line number Diff line number Diff line Level-0-assembly_id,Level-1-plane_id,power,not_volume 0,0,0,1.0 0,1,0,2.0 1,0,0,1.0 1,1,2.5,2.0 Loading
pygriffin/pygriffin.py +39 −6 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ class PyGriffin: self.mesh = mesh self.n_procs = n_procs self._keff = None self._subassembly_power_volume = None def run(self, input=None, mesh=None, Loading Loading @@ -194,7 +195,7 @@ 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): def postrun(self, griffin_csv_file, griffin_subassembly_output_file): """ Extract Griffin k-effective to output file Loading @@ -202,36 +203,64 @@ class PyGriffin: ---------- griffin_csv_file : str or pathlib.Path object CSV file generated by Griffin which stores eigenvalue information griffin_subassembly_output_file : str or pathlib.Path object CSV file generated by Griffin which stores subassembly power and volume data Returns ------- int Errorcode of the Griffin postrun (0 is success, 1 is csv_file not found, 2 is incorrect csv data format 1 is eigenvalue csv_file not found, 2 is incorrect eigenvalue csv data format 3 is eigenvalue not found) 4 is subassembly csv_file not found, 5 is incorrect subassembly csv data format 6 is power/volume data not found) """ if not Path(griffin_csv_file).is_file(): # CSV file not found # Eigenvalue 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 # Insufficient row entries in eigenvalue 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 # Output eigenvalue field 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]) if not Path(griffin_subassembly_output_file).is_file(): # Subassembly power volume CSV file not found return 4 with open(griffin_subassembly_output_file, 'r') as f: lines = f.readlines() if len(lines) < 2: # Insufficient row entries in power volume csv file return 5 header = lines[0].split('\n')[0] output_fields = header.split(',') if len(output_fields) != 4: # Incorrect number of output fields in power volume csv file return 5 if 'power' not in output_fields or 'volume' not in output_fields: # Output power and volume fields not found in csv file return 6 self._subassembly_power_volume = {} for result_row in lines[1:]: assembly_id, plane_id, power, volume = result_row.split(',') self._subassembly_power_volume[(int(assembly_id), int(plane_id))] = (float(power), float(volume)) return 0 def __call__(self, cwd=None): Loading Loading @@ -351,3 +380,7 @@ class PyGriffin: cv.check_type('Griffin k-effective', keff, Real) cv.check_greater_than('Griffin k-effective', keff, 0) self._keff = keff @property def subassembly_power_volume(self): return self._subassembly_power_volume
tests/postrun_nopower.csv 0 → 100644 +5 −0 Original line number Diff line number Diff line Level-0-assembly_id,Level-1-plane_id,not_power,volume 0,0,0,1.0 0,1,0,2.0 1,0,0,1.0 1,1,2.5,2.0
tests/postrun_novolume.csv 0 → 100644 +5 −0 Original line number Diff line number Diff line Level-0-assembly_id,Level-1-plane_id,power,not_volume 0,0,0,1.0 0,1,0,2.0 1,0,0,1.0 1,1,2.5,2.0