Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Account for new I/O formats #4

Merged
merged 1 commit into from
Mar 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ install_requires =
numpy
h5py
ase
hsd
fortnet-python

[options.packages.find]
Expand Down
25 changes: 22 additions & 3 deletions src/fnetase/calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,28 @@ def _check_bpnn_configuration(fname, tforces):
"'. No network group/information present."
raise FortnetAseError(msg)

if not bpnn.attrs.get('targettype').decode('UTF-8').strip() == 'global':
# read number of system-wide targets
nglobaltargets = bpnn.attrs.get('nglobaltargets')
if len(nglobaltargets) == 1:
nglobaltargets = nglobaltargets[0]
else:
msg = "Error while reading netstat file '" + self._fname + \
"'. Unrecognized number of global targets obtained."
raise FortnetAseError(msg)

# read number of atomic targets
natomictargets = bpnn.attrs.get('natomictargets')
if len(natomictargets) == 1:
natomictargets = natomictargets[0]
else:
msg = "Error while reading netstat file '" + self._fname + \
"'. Unrecognized number of atomic targets obtained."
raise FortnetAseError(msg)

if nglobaltargets != 1 or natomictargets != 0:
msg = "Error while reading netstat file '" + fname + \
"'. Only networks trained on global properties supported."
"'. Only networks trained on a single global property" + \
" are supported."
raise FortnetAseError(msg)

atomicnumbers = np.sort(np.array(bpnn['atomicnumbers'], dtype=int))
Expand Down Expand Up @@ -307,7 +326,7 @@ def read_energy():
fnetout = Fnetout(FNETOUT)
# assume a single system-wide energy prediction
# further assume that the target unit was a.u.
energy = fnetout.predictions[0, 0] * HARTREE_EV
energy = fnetout.globalpredictions[0, 0] * HARTREE_EV

return energy

Expand Down