Skip to content

Commit 0707cb8

Browse files
committed
Raise SrFitError when bond valences are all zero.
Bond valences evaluate to zero for structure models that have bare atom symbols instead of cation anion specifications. BVSRestraint would produce a constant, structure-independent penalty; this would be hard to track down for non-expert users. This closes #15.
1 parent 7c831f9 commit 0707cb8

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

diffpy/srfit/structure/bvsrestraint.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,11 @@ def _validate(self):
8989
p = self.penalty()
9090
if p is None or p is nan:
9191
raise SrFitError("Cannot evaluate penalty")
92-
92+
v = self._calc.value
93+
if len(v) > 1 and not v.any():
94+
emsg = ("Bond valence sums are all zero. Check atom symbols in "
95+
"the structure or define custom bond-valence parameters.")
96+
raise SrFitError(emsg)
9397
return
9498

9599
# End of class BVSRestraint

0 commit comments

Comments
 (0)