def test_more_than_two_assemblies(): """" This tests to see if data extracted from the input file with more than two assemblies can be used to create a StepCharacteristicSolver object without error. """ current_directory = os.path.dirname(os.path.realpath(__file__)) file_path = os.path.join(current_directory, 'testing_files/assembly_info_3plus_test.csv') sig_t, sig_sin, sig_sout, sig_f, nu, chi, groups, cells, cell_size, assembly_map, material, assembly_size, \ assembly_cells = read_csv.read_csv(file_path) slab = StepCharacteristicSolver(sig_t, sig_sin, sig_sout, sig_f, nu, chi, groups, cells, cell_size, material) slab.solve()
def test_step_characteristic_solve(): current_directory = os.path.dirname(os.path.realpath(__file__)) file_path = os.path.join(current_directory, 'testing_files/assembly_info_test.csv') sig_t, sig_sin, sig_sout, sig_f, nu, chi, groups, cells, cell_size, assembly_map, material, assembly_size, \ assembly_cells = read_csv.read_csv(file_path) slab = StepCharacteristicSolver(sig_t, sig_sin, sig_sout, sig_f, nu, chi, groups, cells, cell_size, material) slab.solve() rows = [] # initialize a temporary storage variable elements = [] # initialize a temporary storage variable file_path = os.path.join(current_directory, 'testing_files/validation_flux.csv') # Read in flux validation data. with open(file_path, 'r') as file: reader = csv.reader(file, delimiter=',') for row in reader: rows.append(row[:1]) for col in row: elements.append(col) number_rows = len(rows) number_elements = len(elements) # Reshape matrix to correct format. flux_ref = numpy.reshape(elements, [number_rows, number_elements / number_rows]).astype(numpy.float) file_path = os.path.join(current_directory, 'testing_files/validation_k.csv') # Read in eigenvalue validation data. with open(file_path, 'r') as file: reader = csv.reader(file, delimiter=',') for row in reader: k_ref = row k_ref = float(k_ref[0]) # convert to float flux_difference = abs(flux_ref - slab.flux_new) # calculate difference in flux k_difference = abs(k_ref - slab.k_new) # calculate difference in eigenvalue # If the fluxes are within 1e-5 and the eigenvalues are within 1e-4, we'll say it works. assert numpy.max(flux_difference) < 1e-5 assert k_difference < 1e-4
def __init__(self, assembly_data_file): # Determine current directory path for input file and read in data, then use that data to create a # StepCharacteristicSolver instance, where the heterogeneous solution is found. file_path = assembly_data_file self.sig_t, self.sig_sin, self.sig_sout, self.sig_f, self.nu, self.chi, self.groups, self.cells, self.cell_size\ , self.assembly_map, self.material, self.assembly_size, self.assembly_cells = read_csv.read_csv(file_path) self.slab = StepCharacteristicSolver(self.sig_t, self.sig_sin, self.sig_sout, self.sig_f, self.nu, self.chi, self.groups, self.cells, self.cell_size, self.material) self.slab.solve() # Initialize variables self.average_edge_flux = np.zeros((2, 1)) self.discontinuity_factor_left = np.zeros((2, 1)) self.discontinuity_factor_right = np.zeros((2, 1)) self.sig_t_h = np.zeros((2, 1)) self.sig_sin_h = np.zeros((2, 1)) self.sig_sout_h = np.zeros((2, 1)) self.sig_f_h = np.zeros((2, 1)) self.eddington_factor_h = np.zeros((2, 1)) self.sig_r_h = np.zeros((2, 1)) # Calculate the homogeneous data. self.perform_homogenization()
def __init__(self, single_assembly_input_files): # Determine local directory to find input file. self.single_assembly_input_files = single_assembly_input_files file_path = single_assembly_input_files[0] self.sig_t, self.sig_sin, self.sig_sout, self.sig_f, self.nu, self.chi, self.groups, self.cells, self.cell_size \ , self.assembly_map, self.material, self.assembly_size, self.assembly_cells = read_csv.read_csv(file_path) # 'a' stands for assembly. The variables below will hold the homogenized nuclear data for each unique assembly. self.eddington_factor_a = np.zeros( (self.groups, len(single_assembly_input_files) - 1)) self.sig_r_a = np.zeros( (self.groups, len(single_assembly_input_files) - 1)) self.sig_t_a = np.zeros( (self.groups, len(single_assembly_input_files) - 1)) self.sig_sin_a = np.zeros( (self.groups, len(single_assembly_input_files) - 1)) self.sig_sout_a = np.zeros( (self.groups, len(single_assembly_input_files) - 1)) self.sig_f_a = np.zeros( (self.groups, len(single_assembly_input_files) - 1)) self.f_a = np.zeros( (self.groups, 2 * (len(single_assembly_input_files) - 1))) # 'g' stand for global. The variables below will hold the homogenized nuclear data for each node. self.eddington_factor_g = np.zeros( (self.groups, len(self.assembly_map))) self.sig_r_g = np.zeros((self.groups, len(self.assembly_map))) self.sig_t_g = np.zeros((self.groups, len(self.assembly_map))) self.sig_sin_g = np.zeros((self.groups, len(self.assembly_map))) self.sig_sout_g = np.zeros((self.groups, len(self.assembly_map))) self.sig_f_g = np.zeros((self.groups, len(self.assembly_map))) self.f_g = np.zeros((self.groups, 2 * len(self.assembly_map))) # Run methods to perform global homogenization. self.build_assembly_data() self.build_global_data()
import NoQuD.step_characteristic_solve.StepCharacteristicSolver as SC import NoQuD.read_input_data.read_csv_input_file as R import NoQuD.HomogeneousSolve.NodalSolve as HS import numpy as np import matplotlib.pyplot as plt sig_t, sig_sin, sig_sout, sig_f, nu, chi, groups, cells, cell_size, assembly_map, material, assembly_size, \ assembly_cells = R.read_csv('assembly_info_test.csv') slab = SC.StepCharacteristicSolver(sig_t, sig_sin, sig_sout, sig_f, nu, chi, groups, cells, cell_size, material) slab.solve() test = HS.NodalSolve([ 'assembly_info_test.csv', 'assembly_info_single_test.csv', 'assembly_info_single_test_b.csv' ]) test.solve() x = np.arange(0.0, 40., 40. / 256.0) plt.plot(x, test.flux[0, 0, :], linestyle='--') plt.plot(x, slab.flux_new[0][:]) plt.plot(x, test.flux[0, 1, :], linestyle='--') plt.plot(x, slab.flux_new[1][:]) plt.xlabel('Position [cm]') plt.ylabel('Flux [s^-1 cm^-2]') plt.title('Neutron Flux') plt.figlegend( ['QD: fast', 'Transport: fast', 'QD: thermal', 'Transport: thermal'], loc='center') plt.ticklabel_format(style='sci', axis='y', scilimits=(0, 0)) plt.xlim(0, 40) plt.savefig('flux.eps', format='eps', dpi=1200)