Skip to content

Commit

Permalink
Merge pull request #4 from vanderhe/targetMixture
Browse files Browse the repository at this point in the history
Account for new I/O formats
  • Loading branch information
vanderhe committed Mar 15, 2022
2 parents c53110b + 07c97b4 commit daa931f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
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

0 comments on commit daa931f

Please sign in to comment.