diff --git a/openmc/cmfd.py b/openmc/cmfd.py index 54c43f333..85550c495 100644 --- a/openmc/cmfd.py +++ b/openmc/cmfd.py @@ -246,7 +246,7 @@ class CMFDMesh: Real) check_greater_than('CMFD mesh {}-grid length'.format(dims[i]), len(grid[i]), 1) - self._grid = np.array(grid) + self._grid = [np.array(g) for g in grid] self._display_mesh_warning('rectilinear', 'CMFD mesh grid') def _display_mesh_warning(self, mesh_type, variable_label): @@ -1382,9 +1382,7 @@ class CMFDRun: """ # Write each element in vector to file - with open(base_filename+'.dat', 'w') as fh: - for val in vector: - fh.write('{:0.8f}\n'.format(val)) + np.savetxt(f'{base_filename}.dat', vector, fmt='%.8f') # Save as numpy format np.save(base_filename, vector) diff --git a/tests/regression_tests/cmfd_feed/test.py b/tests/regression_tests/cmfd_feed/test.py index fa22b0fe3..d513dee2a 100644 --- a/tests/regression_tests/cmfd_feed/test.py +++ b/tests/regression_tests/cmfd_feed/test.py @@ -111,7 +111,7 @@ def test_cmfd_write_matrices(): # Load flux vector from numpy output file flux_np = np.load('fluxvec.npy') # Load flux from data file - flux_dat = np.loadtxt("fluxvec.dat", delimiter='\n') + flux_dat = np.loadtxt("fluxvec.dat") # Compare flux from numpy file, .dat file, and from simulation assert(np.all(np.isclose(flux_np, cmfd_run._phi)))