def main(): args = parse_args() fn_h5, grp_name = parse_h5(args.output, 'output') # check if the group is already present (and not empty) in the output file if check_output(fn_h5, grp_name, args.overwrite): return # Load the system sys = System.from_file(args.wfn) # Define a list of optional arguments for the WPartClass: WPartClass = wpart_schemes[args.scheme] kwargs = dict((key, val) for key, val in vars(args).iteritems() if key in WPartClass.options) # Load the proatomdb if args.atoms is not None: proatomdb = ProAtomDB.from_file(args.atoms) proatomdb.normalize() kwargs['proatomdb'] = proatomdb else: proatomdb = None # Run the partitioning agspec = AtomicGridSpec(args.grid) molgrid = BeckeMolGrid(sys, agspec, mode='only') sys.update_grid(molgrid) # for the grid to be written to the output wpart = wpart_schemes[args.scheme](sys, molgrid, **kwargs) names = wpart.do_all() write_part_output(fn_h5, grp_name, wpart, names, args)
def main(): args = parse_args() fn_h5, grp_name = parse_h5(args.output, 'output') # check if the group is already present (and not empty) in the output file if check_output(fn_h5, grp_name, args.overwrite): return # Load the system sys = System.from_file(args.cube) ugrid = sys.grid if not isinstance(ugrid, UniformGrid): raise TypeError( 'The specified file does not contain data on a rectangular grid.') ugrid.pbc[:] = parse_pbc(args.pbc) moldens = sys.extra['cube_data'] # Reduce the grid if required if args.stride > 1 or args.chop > 0: moldens, ugrid = reduce_data(moldens, ugrid, args.stride, args.chop) # Load the proatomdb and make pro-atoms more compact if that is requested proatomdb = ProAtomDB.from_file(args.atoms) if args.compact is not None: proatomdb.compact(args.compact) proatomdb.normalize() # Select the partitioning scheme CPartClass = cpart_schemes[args.scheme] # List of element numbers for which weight corrections are needed: wcor_numbers = list(iter_elements(args.wcor)) # Run the partitioning kwargs = dict((key, val) for key, val in vars(args).iteritems() if key in CPartClass.options) cpart = cpart_schemes[args.scheme](sys, ugrid, True, moldens, proatomdb, wcor_numbers, args.wcor_rcut_max, args.wcor_rcond, **kwargs) names = cpart.do_all() # Do a symmetry analysis if requested. if args.symmetry is not None: sys_sym = System.from_file(args.symmetry) sym = sys_sym.extra.get('symmetry') if sym is None: raise ValueError('No symmetry information found in %s.' % args.symmetry) sys_results = dict((name, cpart[name]) for name in names) sym_results = symmetry_analysis(sys, sym, sys_results) cpart.cache.dump('symmetry', sym_results) names.append('symmetry') sys.extra['symmetry'] = sym write_part_output(fn_h5, grp_name, cpart, names, args)
def main(): args = parse_args() fn_h5, grp_name = parse_h5(args.output, 'output') # check if the group is already present (and not empty) in the output file if check_output(fn_h5, grp_name, args.overwrite): return # Load the system sys = System.from_file(args.cube) ugrid = sys.grid if not isinstance(ugrid, UniformGrid): raise TypeError('The specified file does not contain data on a rectangular grid.') ugrid.pbc[:] = parse_pbc(args.pbc) moldens = sys.extra['cube_data'] # Reduce the grid if required if args.stride > 1 or args.chop > 0: moldens, ugrid = reduce_data(moldens, ugrid, args.stride, args.chop) # Load the proatomdb and make pro-atoms more compact if that is requested proatomdb = ProAtomDB.from_file(args.atoms) if args.compact is not None: proatomdb.compact(args.compact) proatomdb.normalize() # Select the partitioning scheme CPartClass = cpart_schemes[args.scheme] # List of element numbers for which weight corrections are needed: wcor_numbers = list(iter_elements(args.wcor)) # Run the partitioning kwargs = dict((key, val) for key, val in vars(args).iteritems() if key in CPartClass.options) cpart = cpart_schemes[args.scheme]( sys, ugrid, True, moldens, proatomdb, wcor_numbers, args.wcor_rcut_max, args.wcor_rcond, **kwargs) names = cpart.do_all() # Do a symmetry analysis if requested. if args.symmetry is not None: sys_sym = System.from_file(args.symmetry) sym = sys_sym.extra.get('symmetry') if sym is None: raise ValueError('No symmetry information found in %s.' % args.symmetry) sys_results = dict((name, cpart[name]) for name in names) sym_results = symmetry_analysis(sys, sym, sys_results) cpart.cache.dump('symmetry', sym_results) names.append('symmetry') sys.extra['symmetry'] = sym write_part_output(fn_h5, grp_name, cpart, names, args)
def main(): args = parse_args() fn_h5, grp_name = parse_h5(args.output, 'output') # check if the group is already present (and not empty) in the output file if check_output(fn_h5, grp_name, args.overwrite): return # Load the system mol = IOData.from_file(args.wfn) # Define a list of optional arguments for the WPartClass: WPartClass = wpart_schemes[args.scheme] kwargs = dict((key, val) for key, val in vars(args).iteritems() if key in WPartClass.options) # Load the proatomdb if args.atoms is not None: proatomdb = ProAtomDB.from_file(args.atoms) proatomdb.normalize() kwargs['proatomdb'] = proatomdb else: proatomdb = None # Run the partitioning agspec = AtomicGridSpec(args.grid) grid = BeckeMolGrid(mol.coordinates, mol.numbers, mol.pseudo_numbers, agspec, mode='only') dm_full = mol.get_dm_full() moldens = mol.obasis.compute_grid_density_dm(dm_full, grid.points, epsilon=args.epsilon) dm_spin = mol.get_dm_spin() if dm_spin is not None: kwargs['spindens'] = mol.obasis.compute_grid_density_dm( dm_spin, grid.points, epsilon=args.epsilon) wpart = wpart_schemes[args.scheme](mol.coordinates, mol.numbers, mol.pseudo_numbers, grid, moldens, **kwargs) keys = wpart.do_all() if args.slow: # ugly hack for the slow analysis involving the AIM overlap operators. wpart_slow_analysis(wpart, mol) keys = list(wpart.cache.iterkeys(tags='o')) write_part_output(fn_h5, grp_name, wpart, keys, args)
def main(): args = parse_args() fn_h5, grp_name = parse_h5(args.output, 'output') # check if the group is already present (and not empty) in the output file if check_output(fn_h5, grp_name, args.overwrite): return # Load the system mol = IOData.from_file(args.wfn) # Define a list of optional arguments for the WPartClass: WPartClass = wpart_schemes[args.scheme] kwargs = dict((key, val) for key, val in vars(args).iteritems() if key in WPartClass.options) # Load the proatomdb if args.atoms is not None: proatomdb = ProAtomDB.from_file(args.atoms) proatomdb.normalize() kwargs['proatomdb'] = proatomdb else: proatomdb = None # Run the partitioning agspec = AtomicGridSpec(args.grid) grid = BeckeMolGrid(mol.coordinates, mol.numbers, mol.pseudo_numbers, agspec, mode='only') dm_full = mol.get_dm_full() moldens = mol.obasis.compute_grid_density_dm(dm_full, grid.points, epsilon=args.epsilon) dm_spin = mol.get_dm_spin() if dm_spin is not None: kwargs['spindens'] = mol.obasis.compute_grid_density_dm(dm_spin, grid.points, epsilon=args.epsilon) wpart = wpart_schemes[args.scheme](mol.coordinates, mol.numbers, mol.pseudo_numbers,grid, moldens, **kwargs) keys = wpart.do_all() if args.slow: # ugly hack for the slow analysis involving the AIM overlap operators. wpart_slow_analysis(wpart, mol) keys = list(wpart.cache.iterkeys(tags='o')) write_part_output(fn_h5, grp_name, wpart, keys, args)
def main(): args = parse_args() fn_h5, grp_name = parse_h5(args.output, 'output') # check if the group is already present (and not empty) in the output file if check_output(fn_h5, grp_name, args.overwrite): return # Load the IOData mol = IOData.from_file(args.cube) ugrid = mol.grid if not isinstance(ugrid, UniformGrid): raise TypeError('The density cube file does not contain data on a rectangular grid.') ugrid.pbc[:] = parse_pbc(args.pbc) moldens = mol.cube_data # Reduce the grid if required if args.stride > 1 or args.chop > 0: moldens, ugrid = reduce_data(moldens, ugrid, args.stride, args.chop) # Load the spin density (optional) if args.spindens is not None: molspin = IOData.from_file(args.spindens) if not isinstance(molspin.grid, UniformGrid): raise TypeError('The spin cube file does not contain data on a rectangular grid.') spindens = molspin.cube_data if args.stride > 1 or args.chop > 0: spindens = reduce_data(spindens, molspin.grid, args.stride, args.chop)[0] if spindens.shape != moldens.shape: raise TypeError('The shape of the spin cube does not match the shape of the density cube.') else: spindens = None # Load the proatomdb and make pro-atoms more compact if that is requested proatomdb = ProAtomDB.from_file(args.atoms) if args.compact is not None: proatomdb.compact(args.compact) proatomdb.normalize() # Select the partitioning scheme CPartClass = cpart_schemes[args.scheme] # List of element numbers for which weight corrections are needed: if args.wcor == '0': wcor_numbers = [] else: wcor_numbers = list(iter_elements(args.wcor)) # Run the partitioning kwargs = dict((key, val) for key, val in vars(args).iteritems() if key in CPartClass.options) cpart = cpart_schemes[args.scheme]( mol.coordinates, mol.numbers, mol.pseudo_numbers, ugrid, moldens, proatomdb, spindens=spindens, local=True, wcor_numbers=wcor_numbers, wcor_rcut_max=args.wcor_rcut_max, wcor_rcond=args.wcor_rcond, **kwargs) keys = cpart.do_all() # Do a symmetry analysis if requested. if args.symmetry is not None: mol_sym = IOData.from_file(args.symmetry) if not hasattr(mol_sym, 'symmetry'): raise ValueError('No symmetry information found in %s.' % args.symmetry) aim_results = dict((key, cpart[key]) for key in keys) sym_results = symmetry_analysis(mol.coordinates, ugrid.get_cell(), mol_sym.symmetry, aim_results) cpart.cache.dump('symmetry', sym_results) keys.append('symmetry') write_part_output(fn_h5, grp_name, cpart, keys, args)