Exemplo n.º 1
0
def main():
    args = parse_args()
    print("args", args)

    if args.implementation == TORCHANI:
        from torchani_calculator import torchani_calculator
        calculator = torchani_calculator(args.network_type, args.numb_networks)
    elif args.implementation == AES_ANI:
        from ani_ase import ani_ase_calculator
        calculator = ani_ase_calculator(args.network_type)
    elif args.implementation == KHAN:
        from khan_calculator import khan_calculator
        calculator = khan_calculator(args.network_type, args.khan_network,
                                     args.numb_networks)

    strs = list(StructureReader(args.mae_file))
    cvgd = optimize_structures(strs,
                               calculator.committee,
                               maxit=500,
                               thresh=0.01)

    rd = rawdataset_from_st(strs)
    energy_data = calculator.committee.compute_data(rd)
    for st, data in zip(strs, energy_data):
        st.property["r_j_ANI_ENERGY"] = data.energy
        st.property["r_j_ANI_RHO"] = data.rho

    base, ext = os.path.splitext(args.mae_file)
    outfile = base + "_optimized" + ext
    print("final structure written to file: %s" % outfile)
    with StructureWriter(outfile) as writer:
        writer.extend(strs)
def main():
    args = parse_args()
    print("args", args)

    if args.implementation == TORCHANI:
        from torchani_calculator import torchani_calculator
        calculator = torchani_calculator(args.network_type)
    elif args.implementation == AES_ANI:
        from ani_ase import ani_ase_calculator
        calculator = ani_ase_calculator(args.network_type)
    elif args.implementation == KHAN:
        from khan_calculator import khan_calculator
        calculator = khan_calculator(args.network_type, args.khan_network,
                                     args.numb_networks)

    assert args.cif_file.endswith('.cif')

    atoms = ase_io.read(args.cif_file)
    print("Space group of crystal: %s" % spacegroup.get_spacegroup(atoms))
    print("initial unit cell")
    print(atoms.cell)

    atom_index_group1 = []

    for i in range(1, atoms.get_number_of_atoms()):
        if atom_belong_to_mol1(i, atoms):
            atom_index_group1.append(i)

    MC_steps = int(args.MC)
    all_frames = 'all_frames.xyz'
    for i in range(0, int(MC_steps)):
        atoms.set_calculator(calculator)
        old_frame = atoms.copy()
        old_frame.set_calculator(calculator)
        new_frame, message = Monte_Carlo(old_frame, atom_index_group1,
                                         calculator)
        print("MC step %d" % i)
        if message == 'Accepted':
            outfile = "Accepted_%d.cif" % i
            ase_io.write(all_frames, atoms, append=True)
            ase_io.write(outfile, atoms)
        atoms = new_frame.copy()
def main():

    args = parse_args()
    print("args", args)

    if args.implementation == TORCHANI:
        from torchani_calculator import torchani_calculator
        calculator = torchani_calculator(args.network_type)
    elif args.implementation == AES_ANI:
        from ani_ase import ani_ase_calculator
        calculator = ani_ase_calculator(args.network_type)
    elif args.implementation == KHAN:
        from khan_calculator import khan_calculator
        calculator = khan_calculator(args.network_type, args.khan_network,
                                     args.numb_networks)

    assert args.cif_file.endswith('.cif')

    print('debug? ', args.debug)
    atoms = ase_io.read(args.cif_file)
    numb_molecules = len(molecule_lists(atoms))
    print('number of molecules: ', numb_molecules)
    MC_stpes = args.MC
    space_group = Spacegroup(args.space_group)
    # step size in MC
    f1, f2, f3, f4, f5, f6, f7, f8 = args.MC_f1_f2_f3_f4_f5_f6_f7_f8
    perturbation_type = args.perturbation_type
    molecule1_in_cell = []
    for i in range(1, atoms.get_number_of_atoms()):
        if atom_belong_to_mol1(i, atoms):
            molecule1_in_cell.append(i)
    print("initial unit cell")
    print(atoms.cell)
    print("To do Monte Carlo for %d step." % MC_stpes)
    print("Molecule index in ASU are: ", molecule1_in_cell)

    translation_stats = []
    rotation_stats = []
    cell_length_a_stats = []
    cell_length_b_stats = []
    cell_length_c_stats = []
    cell_angle_alpha_stats = []
    cell_angle_beta_stats = []
    cell_angle_gamma_stats = []
    counter = 0
    atoms_input = atoms.copy()
    while (counter <= MC_stpes):
        if isinstance(perturbation_type, list):
            # random_number = random.choice([1,2,3,4,5,6,7,8])
            random_choices = get_random_choices(
                [f1, f2, f3, f4, f5, f6, f7, f8])
            random_number = random.choice(random_choices)
        else:
            random_number = perturbation_dict[perturbation_type]
        if random_number == 1:
            # translation
            atoms_input.set_calculator(calculator)
            ret_atoms, message = Monte_Carlo(atoms_input, calculator,
                                             space_group, f1, 'translate',
                                             counter, molecule1_in_cell,
                                             MC_stpes, args.debug)
            translation_stats.append(message)
            counter += 1
            atoms_input = ret_atoms.copy()
        elif random_number == 2:
            # rotation
            atoms_input.set_calculator(calculator)
            ret_atoms, message = Monte_Carlo(atoms_input, calculator,
                                             space_group, f2, 'rotation',
                                             counter, molecule1_in_cell,
                                             MC_stpes, args.debug)
            rotation_stats.append(message)
            counter += 1
            atoms_input = ret_atoms.copy()
        elif random_number == 3:
            # cell_length a
            atoms_input.set_calculator(calculator)
            ret_atoms, message = Monte_Carlo(atoms_input, calculator,
                                             space_group, f3, 'cell_length_a',
                                             counter, molecule1_in_cell,
                                             MC_stpes, args.debug)
            cell_length_a_stats.append(message)
            counter += 1
            atoms_input = ret_atoms.copy()
        elif random_number == 4:
            # cell_length b
            atoms_input.set_calculator(calculator)
            ret_atoms, message = Monte_Carlo(atoms_input, calculator,
                                             space_group, f4, 'cell_length_b',
                                             counter, molecule1_in_cell,
                                             MC_stpes, args.debug)
            cell_length_b_stats.append(message)
            counter += 1
            atoms_input = ret_atoms.copy()
        elif random_number == 5:
            # cell_length c
            atoms_input.set_calculator(calculator)
            ret_atoms, message = Monte_Carlo(atoms_input, calculator,
                                             space_group, f5, 'cell_length_c',
                                             counter, molecule1_in_cell,
                                             MC_stpes, args.debug)
            cell_length_c_stats.append(message)
            counter += 1
            atoms_input = ret_atoms.copy()
        elif random_number == 6:
            # cell_angle alpha
            atoms_input.set_calculator(calculator)
            ret_atoms, message = Monte_Carlo(atoms_input, calculator,
                                             space_group, f6,
                                             'cell_angle_alpha', counter,
                                             molecule1_in_cell, MC_stpes,
                                             args.debug)
            cell_angle_alpha_stats.append(message)
            counter += 1
            atoms_input = ret_atoms.copy()
        elif random_number == 7:
            # cell_angle beta
            atoms_input.set_calculator(calculator)
            ret_atoms, message = Monte_Carlo(atoms_input, calculator,
                                             space_group, f7,
                                             'cell_angle_beta', counter,
                                             molecule1_in_cell, MC_stpes,
                                             args.debug)
            cell_angle_beta_stats.append(message)
            counter += 1
            atoms_input = ret_atoms.copy()
        elif random_number == 8:
            # cell_angle gamma
            atoms_input.set_calculator(calculator)
            ret_atoms, message = Monte_Carlo(atoms_input, calculator,
                                             space_group, f8,
                                             'cell_angle_gamma', counter,
                                             molecule1_in_cell, MC_stpes,
                                             args.debug)
            cell_angle_gamma_stats.append(message)
            counter += 1
            atoms_input = ret_atoms.copy()
        #if counter % 1000 == 0:
        #    with open("MC_trace_%d.json"%counter, "w") as fh:
        #        json.dump(MC_trace, fh, indent=4)

    #with open("MC_trace.json", "w") as fh:
    #    json.dump(MC_trace, fh, indent=4)
    #print("MC trace are recorded in: MC_trace.json")

    if len(translation_stats):
        print("Acceptance ratio of translation move is %f" %
              (countX("Accepted", translation_stats) / len(translation_stats)))
    if len(rotation_stats):
        print("Acceptance ratio of rotation move is %f" %
              (countX("Accepted", rotation_stats) / len(rotation_stats)))
    if len(cell_length_a_stats):
        print("Acceptance ratio of cell length a move is %f" %
              (countX("Accepted", cell_length_a_stats) /
               len(cell_length_a_stats)))
    if len(cell_length_b_stats):
        print("Acceptance ratio of cell length b move is %f" %
              (countX("Accepted", cell_length_b_stats) /
               len(cell_length_b_stats)))
    if len(cell_length_c_stats):
        print("Acceptance ratio of cell length c move is %f" %
              (countX("Accepted", cell_length_c_stats) /
               len(cell_length_c_stats)))
    if len(cell_angle_alpha_stats):
        print("Acceptance ratio of cell angle alpha move is %f" %
              (countX("Accepted", cell_angle_alpha_stats) /
               len(cell_angle_alpha_stats)))
    if len(cell_angle_beta_stats):
        print("Acceptance ratio of cell angle beta move is %f" %
              (countX("Accepted", cell_angle_beta_stats) /
               len(cell_angle_beta_stats)))
    if len(cell_angle_gamma_stats):
        print("Acceptance ratio of cell angle gamma move is %f" %
              (countX("Accepted", cell_angle_gamma_stats) /
               len(cell_angle_gamma_stats)))
def main():

    args = parse_args()
    print("args", args)

    if args.implementation == TORCHANI:
        from torchani_calculator import torchani_calculator
        calculator = torchani_calculator(args.network_type)
    elif args.implementation == AES_ANI:
        from ani_ase import ani_ase_calculator
        calculator = ani_ase_calculator(args.network_type)
    elif args.implementation == KHAN:
        from khan_calculator import khan_calculator
        calculator = khan_calculator(args.network_type, args.khan_network,
                                     args.numb_networks)

    assert args.cif_file.endswith('.cif')

    print('debug? ', args.debug)
    atoms = ase_io.read(args.cif_file)
    numb_molecules = len(molecule_lists(atoms))
    print('number of molecules: ', numb_molecules)
    MC_stpes = args.MC
    space_group = Spacegroup(args.space_group)
    # step size in MC
    f1, f2, f3, f4, f5, f6, f7, f8 = args.MC_f1_f2_f3_f4_f5_f6_f7_f8
    perturbation_type = args.perturbation_type
    molecule1_in_cell = []
    for i in range(1, atoms.get_number_of_atoms()):
        if atom_belong_to_mol1(i, atoms):
            molecule1_in_cell.append(i)
    print("initial unit cell")
    print(atoms.cell)
    print("To do Monte Carlo for %d step." % MC_stpes)
    print("Molecule index in ASU are: ", molecule1_in_cell)

    counter = 0
    atoms.set_calculator(calculator)
    while (counter <= MC_stpes):
        if isinstance(perturbation_type, list):
            # random_number = random.choice([1,2,3,4,5,6,7,8])
            random_choices = get_random_choices(
                [f1, f2, f3, f4, f5, f6, f7, f8])
            random_number = random.choice(random_choices)
        else:
            random_number = perturbation_dict[perturbation_type]
        if random_number == 1:
            # translation
            Monte_Carlo(atoms, calculator, space_group, f1, 'translate',
                        counter, numb_molecules, molecule1_in_cell, MC_stpes,
                        args.debug)
            counter += 1
        elif random_number == 2:
            # rotation
            Monte_Carlo(atoms, calculator, space_group, f2, 'rotation',
                        counter, numb_molecules, molecule1_in_cell, MC_stpes,
                        args.debug)
            counter += 1
        elif random_number == 3:
            # cell_length a
            Monte_Carlo(atoms, calculator, space_group, f3, 'cell_length_a',
                        counter, numb_molecules, molecule1_in_cell, MC_stpes,
                        args.debug)
            counter += 1
        elif random_number == 4:
            # cell_length b
            Monte_Carlo(atoms, calculator, space_group, f4, 'cell_length_b',
                        counter, numb_molecules, molecule1_in_cell, MC_stpes,
                        args.debug)
            counter += 1
        elif random_number == 5:
            # cell_length c
            Monte_Carlo(atoms, calculator, space_group, f5, 'cell_length_c',
                        counter, numb_molecules, molecule1_in_cell, MC_stpes,
                        args.debug)
            counter += 1
        elif random_number == 6:
            # cell_angle alpha
            Monte_Carlo(atoms, calculator, space_group, f6, 'cell_angle_alpha',
                        counter, numb_molecules, molecule1_in_cell, MC_stpes,
                        args.debug)
            counter += 1
        elif random_number == 7:
            # cell_angle beta
            Monte_Carlo(atoms, calculator, space_group, f7, 'cell_angle_beta',
                        counter, numb_molecules, molecule1_in_cell, MC_stpes,
                        args.debug)
            counter += 1
        elif random_number == 8:
            # cell_angle gamma
            Monte_Carlo(atoms, calculator, space_group, f8, 'cell_angle_gamma',
                        counter, numb_molecules, molecule1_in_cell, MC_stpes,
                        args.debug)
            counter += 1
Exemplo n.º 5
0
def main():

    args = parse_args()
    print("args", args)

    if args.implementation == TORCHANI:
        from torchani_calculator import torchani_calculator
        calculator = torchani_calculator(args.network_type)
    elif args.implementation == AES_ANI:
        from ani_ase import ani_ase_calculator
        calculator = ani_ase_calculator(args.network_type)
    elif args.implementation == KHAN:
        from khan_calculator import khan_calculator
        calculator = khan_calculator(args.network_type, args.khan_network,
                                     args.numb_networks)

    assert args.cif_file.endswith('.cif')

    print('debug? ', args.debug)
    atoms = ase_io.read(args.cif_file)
    numb_molecules = len(molecule_lists(atoms))
    print('number of molecules: ', numb_molecules)
    total_number_of_molecules = numb_molecules
    MC_stpes = args.MC
    space_group = Spacegroup(args.space_group)
    # step size in MC
    f1, f2, f3, f4 = args.MC_f1_f2_f3_f4
    perturbation_type = args.perturbation_type
    molecule1_in_cell = []
    for i in range(1, atoms.get_number_of_atoms()):
        if atom_belong_to_mol1(i, atoms):
            molecule1_in_cell.append(i)
    # print("Space group of crystal: %s" % spacegroup.get_spacegroup(atoms))
    print("initial unit cell")
    print(atoms.cell)
    print("To do Monte Carlo for %d step." % MC_stpes)
    print("Molecule index in ASU are: ", molecule1_in_cell)

    translation_stats = []
    rotation_stats = []
    cell_length_stats = []
    cell_angle_stats = []
    counter = 0
    atoms_input = atoms.copy()
    # space_group = spacegroup.get_spacegroup(atoms)
    while (counter <= MC_stpes):
        if isinstance(perturbation_type, list):
            random_number = random.choice([1, 2, 3, 4])
        else:
            random_number = perturbation_dict[perturbation_type]
        if random_number == 1:
            # translation
            atoms_input.set_calculator(calculator)
            ret_atoms, message = Monte_Carlo(atoms_input, calculator,
                                             space_group, f1, 'translate',
                                             counter, molecule1_in_cell,
                                             MC_stpes, args.debug)
            translation_stats.append(message)
            counter += 1
            atoms_input = ret_atoms.copy()
        elif random_number == 2:
            # rotation
            atoms_input.set_calculator(calculator)
            ret_atoms, message = Monte_Carlo(atoms_input, calculator,
                                             space_group, f2, 'rotation',
                                             counter, molecule1_in_cell,
                                             MC_stpes, args.debug)
            rotation_stats.append(message)
            counter += 1
            atoms_input = ret_atoms.copy()
        elif random_number == 3:
            # cell_length
            atoms_input.set_calculator(calculator)
            ret_atoms, message = Monte_Carlo(atoms_input, calculator,
                                             space_group, f3, 'cell_length',
                                             counter, molecule1_in_cell,
                                             MC_stpes, args.debug)
            cell_length_stats.append(message)
            counter += 1
            atoms_input = ret_atoms.copy()
        else:
            # cell_angle
            atoms_input.set_calculator(calculator)
            ret_atoms, message = Monte_Carlo(atoms_input, calculator,
                                             space_group, f4, 'cell_angle',
                                             counter, molecule1_in_cell,
                                             MC_stpes, args.debug)
            cell_angle_stats.append(message)
            counter += 1
            atoms_input = ret_atoms.copy()

    with open("MC_trace.json", "w") as fh:
        json.dump(MC_trace, fh, indent=4)
    print("MC trace are recorded in: MC_trace.json")

    print("Acceptance ratio of translation move is %f" %
          (countX("Accepted", translation_stats) / len(translation_stats)))
    print("Acceptance ratio of rotation move is %f" %
          (countX("Accepted", rotation_stats) / len(rotation_stats)))
    print("Acceptance ratio of cell length move is %f" %
          (countX("Accepted", cell_length_stats) / len(cell_length_stats)))
    print("Acceptance ratio of cell angle move is %f" %
          (countX("Accepted", cell_angle_stats) / len(cell_angle_stats)))
def main():
    args = parse_args()
    print("args", args)

    if args.implementation == TORCHANI:
        from torchani_calculator import torchani_calculator
        calculator = torchani_calculator(args.network_type, args.numb_networks)
    elif args.implementation == AES_ANI:
        from ani_ase import ani_ase_calculator
        calculator = ani_ase_calculator(args.network_type)
    elif args.implementation == KHAN:
        from khan_calculator import khan_calculator
        calculator = khan_calculator(args.network_type, args.khan_network,
                                     args.numb_networks)

    #assert args.cif_file.endswith('.cif') or args.cif_file.endswith('.xyz')
    if args.cif_file.endswith('.mae'):
        st = next(StructureReader(args.cif_file))

        if args.truncate_box:
            # reduced size box
            a = 12.0
            deletions = []
            for mol in st.molecule:
                rcom = center_of_mass(st, mol.getAtomIndices())
                inbox = [abs(x) < a / 2 for x in rcom]
                if False in [abs(x) < a / 2 for x in rcom]:
                    deletions.extend(mol.getAtomIndices())
            st.deleteAtoms(deletions)

        rd = rawdataset_from_st([st])
        ase_molecs = khan_molec_to_ase_atoms(rd.all_Xs)
        atoms = ase_molecs[0]

        if args.truncate_box:
            # hard coded box
            #a = 22.6868
            vecs = [[a, 0.0, 0.0], [0.0, a, 0.0], [0.0, 0.0, a]]
            atoms.set_cell(vecs)
            atoms.set_pbc([True, True, True])
            print("after set cell", atoms.get_pbc())

    if args.cif_file.endswith('.cif'):
        atoms = ase_io.read(args.cif_file)

    if args.box_length is not None:
        atoms.set_cell([
            [args.box_length, 0.0, 0.0],
            [0.0, args.box_length, 0.0],
            [0.0, 0.0, args.box_length],
        ])
        atoms.set_pbc([True, True, True])

    if args.supercell is not None:
        atoms = build_supercell(atoms, [args.supercell] * 3)

    periodic = False not in atoms.get_pbc()

    print("cell")
    print(atoms.get_cell())

    if periodic:
        #atoms.wrap()
        space_group = spacegroup.get_spacegroup(atoms)
        print("Space group of crystal: %s" % space_group)
        print("initial unit cell")
        print(atoms.cell)

        # this shows how to get unique atoms and there equivalents
        #scaled_positions = atoms.get_scaled_positions()
        #unique_positions = space_group.unique_sites(scaled_positions)
        #all_positions, symmetry_map = space_group.equivalent_sites(unique_positions)
        #symmetry_groups = defaultdict(list)
        #for igroup, position in zip(symmetry_map, all_positions):
        #    symmetry_groups[igroup].append(position)

        #print("unique positions")
        #for xyz in unique_positions:
        #    print(xyz)

        #for igroup in sorted(symmetry_groups.keys()):
        #    print("positions in symmetry group %d" % igroup)
        #    for xyz in symmetry_groups[igroup]:
        #        print(xyz)

    torsions = ()
    if args.torsion is not None:
        torsions = [(
            float(args.torsion[0]),
            int(args.torsion[1]),
            int(args.torsion[2]),
            int(args.torsion[3]),
        )]

    if args.optimize:
        # cannot optimize cell until we implement a stress tensor
        energy = optimize_molecule(
            atoms,
            calculator,
            torsions=torsions,
            thresh=0.05,
            optimize_cell=args.relax_cell,
        )
    else:
        start_time = time.time()
        energy = single_point_energy(atoms, calculator)
        print("--- %s seconds ---" % (time.time() - start_time))
    if args.dynamics:
        traj = molecular_dynamics(atoms,
                                  calculator,
                                  total_time=args.total_time,
                                  time_step=args.time_step)
        if args.cif_file.endswith('.mae'):
            st = next(StructureReader(args.cif_file))
            with StructureWriter("md_path.mae") as writer:
                for m in traj:
                    st0 = st.copy()
                    st0.setXYZ(m.get_positions())
                    writer.append(st0)
        else:
            with open("md_path.xyz", "w") as fout:
                xyz_lst = []
                for atoms in traj:
                    xyz_lst.append("%d\n" % len(atoms))
                    species = atoms.get_chemical_symbols()
                    carts = atoms.get_positions()
                    for ch, xyz in zip(species, carts):
                        xyz_lst.append("%s %.8f %.8f %.8f" %
                                       (ch, xyz[0], xyz[1], xyz[2]))

                fout.write("\n".join(xyz_lst))

    print("energy of cell (au):", energy)

    if periodic:
        space_group = spacegroup.get_spacegroup(atoms)
        print("Final Space group of crystal: %s" % space_group)
        print("energy of cell/volume (au):", energy / atoms.get_volume())
        print("final unit cell")
        print(atoms.cell)

    print("Uncertainty %.4f (kcal/mol)" %
          (calculator.uncertainty(atoms) * 627.509))

    if periodic:
        outfile = os.path.splitext(args.cif_file)[0] + "_optimized.cif"
    else:
        outfile = os.path.splitext(args.cif_file)[0] + "_optimized.xyz"
    ase_io.write(outfile, atoms)
    print("final structure written to file: %s" % outfile)
Exemplo n.º 7
0
def main():
    args = parse_args()
    print("args", args)

    if args.implementation == TORCHANI:
        from torchani_calculator import torchani_calculator
        calculator = torchani_calculator(args.network_type, args.numb_networks)
    elif args.implementation == AES_ANI:
        from ani_ase import ani_ase_calculator
        calculator = ani_ase_calculator(args.network_type, args.numb_networks)
    elif args.implementation == KHAN:
        from khan_calculator import khan_calculator
        calculator = khan_calculator(args.network_type, None,
                                     args.numb_networks)

    data = read_json_data(args.datadir,
                          remove_atomic_energy=False,
                          energy_cutoff=1.0e10)

    all_abs_errors = []
    all_conf_errors = []
    for k in data:
        json_data = data[k]
        X = [np.array(carts) for carts in json_data["X"]]
        #y = [float(ener) for ener in json_data["energy"]]
        y = [float(ener) for ener in json_data["Y"]]

        n_geoms = len(y)

        molecules = khan_molec_to_ase_atoms(X)
        energies = []
        refs = []
        print("data for input", k)
        for i, m in enumerate(molecules):

            #if not all(method == CCSD for method in json_data["min_method"]):
            #    print(json_data["min_method"])
            #    raise ValueError("what the hell")

            if args.optimize:
                indices = list(map(int, json_data["scan_coord"][i]))
                value = float(json_data["scan_value"][i]) * np.pi / 180.0
                torsion = [value, indices]
                energy = optimize_molecule(m, calculator, [torsion])
            else:
                energy = single_point_energy(m, calculator)

            energies.append(energy)
            refs.append(y[i])

            print("ani energy: %.8f ref energy: %.8f" % (energy, y[i]))

        np_energies = np.array(energies)
        np_refs = np.array(refs)

        dE = np_energies - np_refs
        ndata = len(dE)
        abs_error = np.sqrt(np.dot(dE, dE) / ndata)
        all_abs_errors.extend(dE)

        min_ref = 0  #np.argmin(np_refs)
        np_energies = np_energies - np_energies[min_ref]
        np_refs = np_refs - np_refs[min_ref]
        dE = np_energies - np_refs
        dE = dE[1:]
        conf_error = np.sqrt(np.dot(dE, dE) / (ndata - 1))
        mad = np.mean(abs(dE))
        #  skip the one reference
        all_conf_errors.extend(dE)

        print(
            "datset %s: absolute error %.4f relative rmse %.4f relative mad %.4f"
            % (k, abs_error * KCAL, conf_error * KCAL, mad * KCAL))

    dE = np.array(all_abs_errors)
    ndata = len(dE)
    abs_error = np.sqrt(np.dot(dE, dE) / ndata)

    dE = np.array(all_conf_errors)
    ndata = len(dE)
    conf_error = np.sqrt(np.dot(dE, dE) / ndata)
    mad = np.mean(abs(dE))

    print(
        "Total errors: absolute error: %f rmse relative error %.4f mad relative error %.4f"
        % (abs_error * KCAL, conf_error * KCAL, mad * KCAL))