def callScaFES(T_blood=T_blood):

        global count
        global params
        count += 1

        print()
        print('##### ScaFES iteration: {} #####'.format(count))

        case = params['NAME_CONFIGFILE_TEMPLATE'].split('.')[0]
        case = case.split('_')[0]
        params['NAME_CONFIGFILE'] = case + '-pymc-' + TESTED_VARIABLES + '.ini'
        params['NAME_RESULTFILE'] = ''
        config = configparser.ConfigParser()
        config.optionxform = str
        config.read(params['NAME_CONFIGFILE_TEMPLATE'])
        # T_blood.
        config['Brain']['T_BLOOD'] = str(T_blood)
        config['Tumor']['T_BLOOD'] = str(T_blood)

        with open(params['NAME_CONFIGFILE'], 'w') as configfile:
            config.write(configfile)

        # Call simulation.
        parse_config_file(params)
        check_variables(params)
        calc_variables(params)
        check_stability(params)
        if params['USE_MRI_FILE'] == False:
            create_region_file(params)
        create_init_file(params)
        set_environment_variables(params)
        call_simulation(params, params['RUN_SCRIPT'])
        if params['NAME_RESULTFILE'] != '':
            # Compute temperatures of normal, tumor, vessel tisue.
            temp = temperature_array_from_result(params['NAME_RESULTFILE'])
            tumor = region_array_from_file(params['NAME_REGION_FILE'])
            vessels = surface_vessels_array_from_file(
                params['NAME_VESSELS_FILE'])

            T_tumor, _, _, _ = calc_tumor_near_surface_temperatures(
                temp, tumor)
            if params['USE_VESSELS_SEGMENTATION'] == True:
                temp = temp[-1, :, :]
                T_vessel, _, _, _ = calc_vessels_temperatures(temp, vessels)
                T_normal, _, _, _ = calc_non_vessels_temperatures(
                    temp, vessels)
            else:
                T_vessel = -1.0
                T_normal = -1.0
        else:
            print('* ERROR: No result file written.')
            print('Aborting.')
            exit()

        return [T_normal, T_tumor, T_vessel]
Exemplo n.º 2
0
def main():
    params = {'NAME_CONFIGFILE': ''}
    params['NAME_RESULTFILE'] = ''
    # Check if path to configfile is provided and if file exists.
    if len(sys.argv) > 1:
        if os.path.isfile(sys.argv[1]) == True:
            params['NAME_CONFIGFILE'] = sys.argv[1]
            run_script = 'RUN_WEAK_SCALINGTEST_HELPER.sh'
        else:
            print('* ERROR:', sys.argv[1], 'does not exist.')
        if len(sys.argv) > 2:
            if os.path.isfile(sys.argv[2]) == True:
                run_script = sys.argv[2]
            else:
                print('* ERROR: Optional run script', sys.argv[2],
                      'does not exist.')
                print('Aborting.')
                exit()
    else:
        print('* ERROR: No command line argument for configfile provided.')

    if params['NAME_CONFIGFILE'] == '':
        print('Usage: python3', sys.argv[0],
              '<PATH/TO/CONFIGFILE> [<PATH/TO/RUN/SCRIPT]')
        print('Aborting.')
        exit()

    print('Start weak scaling test.')

    parse_config_file(params)
    parse_config_file_scaling(params)
    check_variables(params)
    check_variables_scaling(params)

    print('Type of test: {0}.'.format(params['TEST']))

    for factor in params['SCALING']:
        calc_variables(params)
        calc_variables_scaling(factor, params)
        check_stability(params)
        if params['CREATE_INITFILE'] == True:
            create_init_file(params)
        set_environment_variables(params)
        set_environment_variables_scaling(params)
        start_simulation(params, run_script)
        if params['NAME_RESULTFILE'] != '' and params['SPACE_DIM'] == 3:
            plot_surface(params['NAME_RESULTFILE'])

    print()
    print('Test finished.')
Exemplo n.º 3
0
    def callScaFES(omega_brain=omega_brain,
                   omega_tumor=omega_tumor,
                   omega_vessel=omega_vessel,
                   T_blood=T_blood,
                   q_brain=q_brain,
                   q_tumor=q_tumor,
                   lambda_bt=lambda_bt,
                   rho_c_brain=rho_c_brain,
                   rho_c_tumor=rho_c_tumor,
                   h=h):

        global count
        global params
        count += 1

        print()
        print('##### ScaFES iteration: {} #####'.format(count))

        case = params['NAME_CONFIGFILE_TEMPLATE'].split('.')[0]
        case = case.split('_')[0]
        params['NAME_CONFIGFILE'] = case + '-pymc-' + TESTED_VARIABLES + '.ini'
        params['NAME_RESULTFILE'] = ''
        config = configparser.ConfigParser()
        config.optionxform = str
        config.read(params['NAME_CONFIGFILE_TEMPLATE'])
        # Omega.
        config['Brain']['OMEGA'] = str(omega_brain)
        config['Tumor']['OMEGA'] = str(omega_tumor)
        config['MRI']['USE_VESSELS_SEGMENTATION'] = 'True'
        config['MRI']['VARIABLES_VESSELS'] = 'omega'
        config['MRI']['VALUES_VESSELS'] = str(omega_vessel)
        config['MRI']['VALUES_NON_VESSELS'] = str(omega_brain)
        # T_blood.
        config['Brain']['T_BLOOD'] = str(T_blood)
        config['Tumor']['T_BLOOD'] = str(T_blood)
        # Q.
        config['Brain']['Q'] = str(q_brain)
        config['Tumor']['Q'] = str(q_tumor)
        # lambda.
        config['Brain']['LAMBDA'] = str(lambda_bt)
        config['Tumor']['LAMBDA'] = str(lambda_bt)
        # rho * c.
        config['Brain']['C'] = str(rho_c_brain)
        config['Brain']['RHO'] = str(1000.0)
        config['Tumor']['C'] = str(rho_c_tumor)
        config['Tumor']['RHO'] = str(1000.0)
        # h.
        config['Parameters']['H'] = str(h)

        with open(params['NAME_CONFIGFILE'], 'w') as configfile:
            config.write(configfile)

        # Call simulation.
        parse_config_file(params)
        check_variables(params)
        calc_variables(params)
        check_stability(params)
        if params['USE_MRI_FILE'] == False:
            create_region_file(params)
        create_init_file(params)
        set_environment_variables(params)
        call_simulation(params, params['RUN_SCRIPT'])
        if params['NAME_RESULTFILE'] != '':
            # Compute temperatures of normal, tumor, vessel tisue.
            temp = temperature_array_from_result(params['NAME_RESULTFILE'])
            tumor = region_array_from_file(params['NAME_REGION_FILE'])
            vessels = surface_vessels_array_from_file(
                params['NAME_VESSELS_FILE'])

            T_tumor, _, _, _ = calc_tumor_near_surface_temperatures(
                temp, tumor)
            if params['USE_VESSELS_SEGMENTATION'] == True:
                temp = temp[-1, :, :]
                T_vessel, _, _, _ = calc_vessels_temperatures(temp, vessels)
                T_normal, _, _, _ = calc_non_vessels_temperatures(
                    temp, vessels)
            else:
                T_vessel = -1.0
                T_normal = -1.0
        else:
            print('* ERROR: No result file written.')
            print('Aborting.')
            exit()

        global dat_file_name
        with open(dat_file_name, 'a') as backupfile:
            backupfile.write(str(omega_brain) + '\t' \
                             + str(omega_tumor) + '\t' \
                             + str(omega_vessel) + '\t' \
                             + str(T_blood) + '\t' \
                             + str(q_brain) + '\t' \
                             + str(q_tumor) + '\t' \
                             + str(lambda_bt) + '\t' \
                             + str(rho_c_brain) + '\t' \
                             + str(rho_c_tumor) + '\t' \
                             + str(h) + '\t' \
                             + str(T_normal) + '\t' \
                             + str(T_tumor) + '\t' \
                             + str(T_vessel) + '\n')

        if (count % 25 == 0):
            searchpath = './' + params['NAME_EXECUTABLE'] + '-' + case + '-*.*'
            log_files = glob.glob(searchpath)
            for f in log_files:
                os.remove(f)

        return [T_normal, T_tumor, T_vessel]