-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add E3 features (node/edge) to hamiltonian/density blocks (#129)
* stack changes * fix test ham to feature
- Loading branch information
1 parent
40a408c
commit 48d89f8
Showing
10 changed files
with
347 additions
and
23 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
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
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
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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import numpy as np | ||
from dptb.utils.tools import j_must_have | ||
from ase.io import read | ||
import ase | ||
from typing import Union | ||
import matplotlib.pyplot as plt | ||
import torch | ||
from typing import Optional | ||
import matplotlib | ||
import logging | ||
from dptb.data import AtomicData, AtomicDataDict | ||
from dptb.data.interfaces.ham_to_feature import feature_to_block | ||
|
||
log = logging.getLogger(__name__) | ||
|
||
def write_ham( | ||
data: Union[AtomicData, ase.Atoms, str], | ||
model: torch.nn.Module, | ||
AtomicData_options: dict={}, | ||
device: Union[str, torch.device]=None | ||
): | ||
|
||
model.eval() | ||
if isinstance(device, str): | ||
device = torch.device(device) | ||
# get the AtomicData structure and the ase structure | ||
if isinstance(data, str): | ||
structase = read(data) | ||
data = AtomicData.from_ase(structase, **AtomicData_options) | ||
elif isinstance(data, ase.Atoms): | ||
structase = data | ||
data = AtomicData.from_ase(structase, **AtomicData_options) | ||
elif isinstance(data, AtomicData): | ||
structase = data.to("cpu").to_ase() | ||
data = data | ||
|
||
data = AtomicData.to_AtomicDataDict(data.to(device)) | ||
data = model.idp(data) | ||
|
||
# set the kpoint of the AtomicData | ||
data = model(data) | ||
block = feature_to_block(data=data, idp=model.idp) | ||
|
||
return block | ||
|
||
|
||
|
||
|
Binary file not shown.
Oops, something went wrong.