Révision 7d97341d

b/modules/dos_input.py
497 497
    return pts_per_angle
498 498

  
499 499

  
500
def get_max_structures():
501
    err_msg = num_error % ('max_structures', 'positive integer')
502
    max_structures = try_command(dos_inp.getint, [(ValueError, err_msg)],
503
                                 'Screening', 'max_structures', fallback=np.inf)
504
    if max_structures <= 0:
505
        logger.error(err_msg)
506
        raise ValueError(err_msg)
507
    return max_structures
508

  
509

  
500 510
def get_coll_thrsld():
501 511
    err_msg = num_error % ('collision_threshold',
502 512
                           'positive decimal number')
......
685 695
        return_vars['disso_atoms'] = get_disso_atoms()
686 696
        return_vars['ads_algo'] = get_ads_algo()
687 697
        return_vars['sample_points_per_angle'] = get_pts_per_angle()
698
        return_vars['max_structures'] = get_max_structures()
688 699
        return_vars['collision_threshold'] = get_coll_thrsld()
689 700
        return_vars['min_coll_height'] = get_min_coll_height()
690 701
        cart_axes = [[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0],
b/modules/screening.py
468 468
    @param inp_vars: Calculation parameters from input file.
469 469
    """
470 470
    import os
471
    from random import choice
471 472
    from modules.formats import read_coords, adapt_format
472 473
    from modules.calculation import run_calc
473 474

  
......
492 493
                                 inp_vars['min_coll_height'],
493 494
                                 inp_vars['collision_threshold'],
494 495
                                 inp_vars['disso_atoms'])
496
    if len(surf_ads_list) > inp_vars['max_structures']:
497
        reduced_surf_ads_list = []
498
        while len(reduced_surf_ads_list) < inp_vars['max_structures']:
499
            new_conf = choice(surf_ads_list)
500
            if new_conf not in reduced_surf_ads_list:
501
                reduced_surf_ads_list.append(new_conf)
502
        surf_ads_list = reduced_surf_ads_list
495 503
    logger.info(f'Generated {len(surf_ads_list)} adsorbate-surface atomic '
496 504
                f'configurations, to carry out a calculation of.')
497 505
    run_calc('screening', inp_vars, surf_ads_list)

Formats disponibles : Unified diff