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 cost function from the HDF5 file cost, used_volume = load_cost(args.cost) # Find the optimal charges results = {} results['x'] = cost.solve(args.qtot, args.ridge) results['charges'] = results['x'][:cost.natom] # Related properties results['cost'] = cost.value(results['x']) if results['cost'] < 0: results['rmsd'] = 0.0 else: results['rmsd'] = (results['cost'] / used_volume)**0.5 # Worst case stuff results['cost_worst'] = cost.worst(0.0) if results['cost_worst'] < 0: results['rmsd_worst'] = 0.0 else: results['rmsd_worst'] = (results['cost_worst'] / used_volume)**0.5 # Write some things on screen if log.do_medium: log('Important parameters:') log.hline() log('RMSD charges: %10.5e' % np.sqrt( (results['charges']**2).mean())) log('RMSD ESP: %10.5e' % results['rmsd']) log('Worst RMSD ESP: %10.5e' % results['rmsd_worst']) log.hline() # Perform a symmetry analysis if requested if args.symmetry is not None: mol_pot = IOData.from_file(args.symmetry[0]) mol_sym = IOData.from_file(args.symmetry[1]) if not hasattr(mol_sym, 'symmetry'): raise ValueError('No symmetry information found in %s.' % args.symmetry[1]) aim_results = {'charges': results['charges']} sym_results = symmetry_analysis(mol_pot.coordinates, mol_pot.cell, mol_sym.symmetry, aim_results) results['symmetry'] = sym_results # Store the results in an HDF5 file write_script_output(fn_h5, grp_name, results, 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 cost function from the HDF5 file cost, used_volume = load_cost(args.cost) # Find the optimal charges results = {} results['x'] = cost.solve(args.qtot, args.ridge) results['charges'] = results['x'][:cost.natom] # Related properties results['cost'] = cost.value(results['x']) if results['cost'] < 0: results['rmsd'] = 0.0 else: results['rmsd'] = (results['cost']/used_volume)**0.5 # Worst case stuff results['cost_worst'] = cost.worst(0.0) if results['cost_worst'] < 0: results['rmsd_worst'] = 0.0 else: results['rmsd_worst'] = (results['cost_worst']/used_volume)**0.5 # Write some things on screen if log.do_medium: log('Important parameters:') log.hline() log('RMSD charges: %10.5e' % np.sqrt((results['charges']**2).mean())) log('RMSD ESP: %10.5e' % results['rmsd']) log('Worst RMSD ESP: %10.5e' % results['rmsd_worst']) log.hline() # Perform a symmetry analysis if requested if args.symmetry is not None: sys = System.from_file(args.symmetry[0]) sys_sym = System.from_file(args.symmetry[1]) sym = sys_sym.extra.get('symmetry') if sym is None: raise ValueError('No symmetry information found in %s.' % args.symmetry[1]) sys_results = {'charges': results['charges']} sym_results = symmetry_analysis(sys, sym, sys_results) results['symmetry'] = sym_results sys.extra['symmetry'] = sym # Store the results in an HDF5 file write_script_output(fn_h5, grp_name, results, 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 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)