|
1 | | -from __future__ import annotations |
2 | | - |
3 | | -import numpy as np |
4 | | - |
5 | | -from dpdata.format import Format |
6 | | -from dpdata.orca.output import read_orca_sp_output |
7 | | -from dpdata.unit import EnergyConversion, ForceConversion |
8 | | - |
9 | | -energy_convert = EnergyConversion("hartree", "eV").value() |
10 | | -force_convert = ForceConversion("hartree/bohr", "eV/angstrom").value() |
11 | | - |
12 | | - |
13 | | -@Format.register("orca/spout") |
14 | | -class ORCASPOutFormat(Format): |
15 | | - """ORCA single point energy output. |
16 | | -
|
17 | | - Note that both the energy and the gradient should be |
18 | | - printed into the output file. |
19 | | - """ |
20 | | - |
21 | | - def from_labeled_system(self, file_name: str, **kwargs) -> dict: |
22 | | - """Read from ORCA single point energy output. |
23 | | -
|
24 | | - Parameters |
25 | | - ---------- |
26 | | - file_name : str |
27 | | - file name |
28 | | - **kwargs |
29 | | - keyword arguments |
30 | | -
|
31 | | - Returns |
32 | | - ------- |
33 | | - dict |
34 | | - system data |
35 | | - """ |
36 | | - symbols, coord, energy, forces = read_orca_sp_output(file_name) |
37 | | - |
38 | | - atom_names, atom_types, atom_numbs = np.unique( |
39 | | - symbols, return_inverse=True, return_counts=True |
40 | | - ) |
41 | | - natoms = coord.shape[0] |
42 | | - |
43 | | - return { |
44 | | - "atom_types": atom_types, |
45 | | - "atom_names": list(atom_names), |
46 | | - "atom_numbs": list(atom_numbs), |
47 | | - "coords": coord.reshape((1, natoms, 3)), |
48 | | - "energies": np.array([energy * energy_convert]), |
49 | | - "forces": (forces * force_convert).reshape((1, natoms, 3)), |
50 | | - "cells": np.zeros((1, 3, 3)), |
51 | | - "orig": np.zeros(3), |
52 | | - "nopbc": True, |
53 | | - } |
| 1 | +from __future__ import annotations |
| 2 | + |
| 3 | +import numpy as np |
| 4 | + |
| 5 | +from dpdata.format import Format |
| 6 | +from dpdata.orca.output import read_orca_sp_output |
| 7 | +from dpdata.unit import EnergyConversion, ForceConversion |
| 8 | + |
| 9 | +energy_convert = EnergyConversion("hartree", "eV").value() |
| 10 | +force_convert = ForceConversion("hartree/bohr", "eV/angstrom").value() |
| 11 | + |
| 12 | + |
| 13 | +@Format.register("orca/spout") |
| 14 | +class ORCASPOutFormat(Format): |
| 15 | + """ORCA single point energy output. |
| 16 | +
|
| 17 | + Note that both the energy and the gradient should be |
| 18 | + printed into the output file. |
| 19 | + """ |
| 20 | + |
| 21 | + def from_labeled_system(self, file_name: str, **kwargs) -> dict: |
| 22 | + """Read from ORCA single point energy output. |
| 23 | +
|
| 24 | + Parameters |
| 25 | + ---------- |
| 26 | + file_name : str |
| 27 | + file name |
| 28 | + **kwargs |
| 29 | + keyword arguments |
| 30 | +
|
| 31 | + Returns |
| 32 | + ------- |
| 33 | + dict |
| 34 | + system data |
| 35 | + """ |
| 36 | + symbols, coord, energy, forces = read_orca_sp_output(file_name) |
| 37 | + |
| 38 | + atom_names, atom_types, atom_numbs = np.unique( |
| 39 | + symbols, return_inverse=True, return_counts=True |
| 40 | + ) |
| 41 | + natoms = coord.shape[0] |
| 42 | + |
| 43 | + return { |
| 44 | + "atom_types": atom_types, |
| 45 | + "atom_names": list(atom_names), |
| 46 | + "atom_numbs": list(atom_numbs), |
| 47 | + "coords": coord.reshape((1, natoms, 3)), |
| 48 | + "energies": np.array([energy * energy_convert]), |
| 49 | + "forces": (forces * force_convert).reshape((1, natoms, 3)), |
| 50 | + "cells": np.zeros((1, 3, 3)), |
| 51 | + "orig": np.zeros(3), |
| 52 | + "nopbc": True, |
| 53 | + } |
0 commit comments