-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from deepmodeling/devel
style: enforce LF line ending (#661)
- Loading branch information
Showing
11 changed files
with
1,085 additions
and
1,083 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
name: test Python import | ||
|
||
on: | ||
- push | ||
- pull_request | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.9' | ||
architecture: 'x64' | ||
- run: python -m pip install uv | ||
- run: python -m uv pip install --system . | ||
- run: python -c 'import dpdata' | ||
name: test Python import | ||
|
||
on: | ||
- push | ||
- pull_request | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.9' | ||
architecture: 'x64' | ||
- run: python -m pip install uv | ||
- run: python -m uv pip install --system . | ||
- run: python -c 'import dpdata' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
Authors | ||
======= | ||
|
||
Authors | ||
======= | ||
|
||
.. git-shortlog-authors:: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,64 @@ | ||
from __future__ import annotations | ||
|
||
import numpy as np | ||
|
||
|
||
def read_orca_sp_output(fn: str) -> tuple[np.ndarray, np.ndarray, float, np.ndarray]: | ||
"""Read from ORCA output. | ||
Note that both the energy and the gradient should be printed. | ||
Parameters | ||
---------- | ||
fn : str | ||
file name | ||
Returns | ||
------- | ||
np.ndarray | ||
atomic symbols | ||
np.ndarray | ||
atomic coordinates | ||
float | ||
total potential energy | ||
np.ndarray | ||
atomic forces | ||
""" | ||
coord = None | ||
symbols = None | ||
forces = None | ||
energy = None | ||
with open(fn) as f: | ||
flag = 0 | ||
for line in f: | ||
if flag in (1, 3, 4): | ||
flag += 1 | ||
elif flag == 2: | ||
s = line.split() | ||
if not len(s): | ||
flag = 0 | ||
else: | ||
symbols.append(s[0].capitalize()) | ||
coord.append([float(s[1]), float(s[2]), float(s[3])]) | ||
elif flag == 5: | ||
s = line.split() | ||
if not len(s): | ||
flag = 0 | ||
else: | ||
forces.append([float(s[3]), float(s[4]), float(s[5])]) | ||
elif line.startswith("CARTESIAN COORDINATES (ANGSTROEM)"): | ||
# coord | ||
flag = 1 | ||
coord = [] | ||
symbols = [] | ||
elif line.startswith("CARTESIAN GRADIENT"): | ||
flag = 3 | ||
forces = [] | ||
elif line.startswith("FINAL SINGLE POINT ENERGY"): | ||
energy = float(line.split()[-1]) | ||
symbols = np.array(symbols) | ||
forces = -np.array(forces) | ||
coord = np.array(coord) | ||
assert coord.shape == forces.shape | ||
|
||
return symbols, coord, energy, forces | ||
from __future__ import annotations | ||
|
||
import numpy as np | ||
|
||
|
||
def read_orca_sp_output(fn: str) -> tuple[np.ndarray, np.ndarray, float, np.ndarray]: | ||
"""Read from ORCA output. | ||
Note that both the energy and the gradient should be printed. | ||
Parameters | ||
---------- | ||
fn : str | ||
file name | ||
Returns | ||
------- | ||
np.ndarray | ||
atomic symbols | ||
np.ndarray | ||
atomic coordinates | ||
float | ||
total potential energy | ||
np.ndarray | ||
atomic forces | ||
""" | ||
coord = None | ||
symbols = None | ||
forces = None | ||
energy = None | ||
with open(fn) as f: | ||
flag = 0 | ||
for line in f: | ||
if flag in (1, 3, 4): | ||
flag += 1 | ||
elif flag == 2: | ||
s = line.split() | ||
if not len(s): | ||
flag = 0 | ||
else: | ||
symbols.append(s[0].capitalize()) | ||
coord.append([float(s[1]), float(s[2]), float(s[3])]) | ||
elif flag == 5: | ||
s = line.split() | ||
if not len(s): | ||
flag = 0 | ||
else: | ||
forces.append([float(s[3]), float(s[4]), float(s[5])]) | ||
elif line.startswith("CARTESIAN COORDINATES (ANGSTROEM)"): | ||
# coord | ||
flag = 1 | ||
coord = [] | ||
symbols = [] | ||
elif line.startswith("CARTESIAN GRADIENT"): | ||
flag = 3 | ||
forces = [] | ||
elif line.startswith("FINAL SINGLE POINT ENERGY"): | ||
energy = float(line.split()[-1]) | ||
symbols = np.array(symbols) | ||
forces = -np.array(forces) | ||
coord = np.array(coord) | ||
assert coord.shape == forces.shape | ||
|
||
return symbols, coord, energy, forces |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,53 @@ | ||
from __future__ import annotations | ||
|
||
import numpy as np | ||
|
||
from dpdata.format import Format | ||
from dpdata.orca.output import read_orca_sp_output | ||
from dpdata.unit import EnergyConversion, ForceConversion | ||
|
||
energy_convert = EnergyConversion("hartree", "eV").value() | ||
force_convert = ForceConversion("hartree/bohr", "eV/angstrom").value() | ||
|
||
|
||
@Format.register("orca/spout") | ||
class ORCASPOutFormat(Format): | ||
"""ORCA single point energy output. | ||
Note that both the energy and the gradient should be | ||
printed into the output file. | ||
""" | ||
|
||
def from_labeled_system(self, file_name: str, **kwargs) -> dict: | ||
"""Read from ORCA single point energy output. | ||
Parameters | ||
---------- | ||
file_name : str | ||
file name | ||
**kwargs | ||
keyword arguments | ||
Returns | ||
------- | ||
dict | ||
system data | ||
""" | ||
symbols, coord, energy, forces = read_orca_sp_output(file_name) | ||
|
||
atom_names, atom_types, atom_numbs = np.unique( | ||
symbols, return_inverse=True, return_counts=True | ||
) | ||
natoms = coord.shape[0] | ||
|
||
return { | ||
"atom_types": atom_types, | ||
"atom_names": list(atom_names), | ||
"atom_numbs": list(atom_numbs), | ||
"coords": coord.reshape((1, natoms, 3)), | ||
"energies": np.array([energy * energy_convert]), | ||
"forces": (forces * force_convert).reshape((1, natoms, 3)), | ||
"cells": np.zeros((1, 3, 3)), | ||
"orig": np.zeros(3), | ||
"nopbc": True, | ||
} | ||
from __future__ import annotations | ||
|
||
import numpy as np | ||
|
||
from dpdata.format import Format | ||
from dpdata.orca.output import read_orca_sp_output | ||
from dpdata.unit import EnergyConversion, ForceConversion | ||
|
||
energy_convert = EnergyConversion("hartree", "eV").value() | ||
force_convert = ForceConversion("hartree/bohr", "eV/angstrom").value() | ||
|
||
|
||
@Format.register("orca/spout") | ||
class ORCASPOutFormat(Format): | ||
"""ORCA single point energy output. | ||
Note that both the energy and the gradient should be | ||
printed into the output file. | ||
""" | ||
|
||
def from_labeled_system(self, file_name: str, **kwargs) -> dict: | ||
"""Read from ORCA single point energy output. | ||
Parameters | ||
---------- | ||
file_name : str | ||
file name | ||
**kwargs | ||
keyword arguments | ||
Returns | ||
------- | ||
dict | ||
system data | ||
""" | ||
symbols, coord, energy, forces = read_orca_sp_output(file_name) | ||
|
||
atom_names, atom_types, atom_numbs = np.unique( | ||
symbols, return_inverse=True, return_counts=True | ||
) | ||
natoms = coord.shape[0] | ||
|
||
return { | ||
"atom_types": atom_types, | ||
"atom_names": list(atom_names), | ||
"atom_numbs": list(atom_numbs), | ||
"coords": coord.reshape((1, natoms, 3)), | ||
"energies": np.array([energy * energy_convert]), | ||
"forces": (forces * force_convert).reshape((1, natoms, 3)), | ||
"cells": np.zeros((1, 3, 3)), | ||
"orig": np.zeros(3), | ||
"nopbc": True, | ||
} |
Oops, something went wrong.