Example #1
0
def nmz_power_assem(l4_n_power_assem, l_n_power_nmz):
    '''
    Normalize the power distribution of assemblies.
    :param l4_n_power_assem: 4-D list -- power distribution of assemblies, 1st dimention is step, 2nd / 3rd / 4th dimension are x_count, y_count and z_count, respectively.
    :param l_n_power_nmz: 1-D list -- normalized power of each step.
    :return: l4_n_power_assem_nmz: 4-D list -- normalized power distribution of assemblies.
    '''
    if len(l4_n_power_assem) != len(l_n_power_nmz):
        print 'ERROR! number of tally file %s not equal number of innerproduct file %s!' % (
            len(l4_n_power_assem), len(l_n_power_nmz))
        exit()
    else:
        l4_n_power_assem_nmz = []

        n_step = len(l4_n_power_assem)
        x_count = len(l4_n_power_assem[0])
        y_count = len(l4_n_power_assem[0][0])
        z_count = len(l4_n_power_assem[0][0][0])
        l3_n_power_assem = get_matrix_3D(x_count, y_count, z_count)
        fis_rate_assem_sum = _calc_sum(l4_n_power_assem)

        for step in range(n_step):
            for x in range(x_count):
                for y in range(y_count):
                    for z in range(z_count):
                        l3_n_power_assem[x][y][z] = l4_n_power_assem[step][x][
                            y][z] / fis_rate_assem_sum[step] * l_n_power_nmz[
                                step]

            l4_n_power_assem_nmz.append(l3_n_power_assem)
            l3_n_power_assem = get_matrix_3D(x_count, y_count, z_count)

    return l4_n_power_assem_nmz
Example #2
0
def get_power_assem(fission_rate):
    '''
    This function helps to get total fission rate of every assembly.
    ! NOTICE ! This function requires the fission rate list to be a 4-dimension list
    ! NOTICE ! in which the 2nd and the 3rd dimension size must be the same.
    ! NOTICE ! fission_rate[timesteps][xmesh][ymesh][zmesh]
    '''
    
    total_timestep = len(fission_rate)
    x_count = len(fission_rate[0])
    y_count = len(fission_rate[0][0])
    z_count = len(fission_rate[0][0][0])
    fis_rate_assem =  [0 for i in range(total_timestep)]
    fis_rate_assem_step = get_matrix_3D(2,2,z_count)
    
    for timestep in range(total_timestep):
        for x in range(x_count):
            for y in range(y_count):
                for z in range(z_count):
                    if x<x_count/2 and y<y_count/2:
                        fis_rate_assem_step[0][0][z] += fission_rate[timestep][x][y][z]
                    elif x>=x_count/2 and y<y_count/2:
                        fis_rate_assem_step[1][0][z] += fission_rate[timestep][x][y][z]
                    elif x<x_count/2 and y>=y_count/2:
                        fis_rate_assem_step[0][1][z] += fission_rate[timestep][x][y][z]
                    elif x>=x_count/2 and y>=y_count/2:
                        fis_rate_assem_step[1][1][z] += fission_rate[timestep][x][y][z]
        
        fis_rate_assem[timestep] = fis_rate_assem_step
        fis_rate_assem_step = get_matrix_3D(2,2,z_count)
        
    return fis_rate_assem
Example #3
0
def nmz_power_mesh(fis_rate_ave, fis_rate_total_nmz):
    '''
    This function helps to normalize the fission rate of meshes.
    '''
    if len(fis_rate_ave) != len(fis_rate_total_nmz):
        print 'ERROR! number of tally file %s not equal number of innerproduct file %s!' % (
            len(fis_rate_ave), len(fis_rate_total_nmz))
        exit()
    else:
        fis_rate_ave_nmz = []

        timestep = len(fis_rate_total_nmz)

        x_count = len(fis_rate_ave[0])
        y_count = len(fis_rate_ave[0][0])
        z_count = len(fis_rate_ave[0][0][0])
        fis_rate_ave_step = get_matrix_3D(x_count, y_count, z_count)
        fis_rate_ave_sum = _calc_sum(fis_rate_ave)

        for step in range(timestep):
            for x in range(x_count):
                for y in range(y_count):
                    for z in range(z_count):
                        fis_rate_ave_step[x][y][z] = fis_rate_ave[step][x][y][
                            z] / fis_rate_ave_sum[step] * fis_rate_total_nmz[
                                step]

            fis_rate_ave_nmz.append(fis_rate_ave_step)
            fis_rate_ave_step = get_matrix_3D(x_count, y_count, z_count)

    return fis_rate_ave_nmz
Example #4
0
def get_power_mesh(s_tally_name, x_count, y_count, z_count):
    '''
    This function helps to extract fission rate AVE value from the inp.tally file.
    This function will return a list of floats.
    '''
    with open(s_tally_name, 'r') as f_tally:
        l3_n_power_mesh = get_matrix_3D(x_count, y_count, z_count)
        # War: 'Tot\s+([.\d]+[Ee][+-]\d+)' is only valid for multigroup case
        l_s_power_mesh = re.findall('Tot\s+([.\d]+[Ee][+-]\d+)',f_tally.read())
            
    for x in range(x_count):
        for y in range(y_count):
            for z in range(z_count):
                l3_n_power_mesh[x][y][z] = float(l_s_power_mesh[x + y * x_count + z * x_count * y_count])
    
    return l3_n_power_mesh