Skip to content

Commit

Permalink
fixed indexerror in approx
Browse files Browse the repository at this point in the history
  • Loading branch information
ronaldtanner committed Jan 16, 2025
1 parent 156349a commit 0cfd658
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/femagtools/mcv.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,16 +241,20 @@ def approx(db2, curve, ctype):
bi2.append(bk12)

if ctype in (DEMCRV, MAG_AC_CRV):
dhdbn = 0
k = len(bi2)-1
if curve['bi'][k] - curve['bi'][k-1] > 0:
dhdbn = ((curve['hi'][k] - curve['h'][k-1],KK)
/(curve['bi'][k] - curve['bi'][k-1]))
a.append(MUE0*dhdbn)
b.append(MUE0*curve['hi'][k] - dhdbn*curve['bi'][k])
else:
a.append(1.0)
b.append(MUE0*curve['hi'][-1]-curve['bi'][-1])
try:
dhdbn = 0
k = len(bi2)-1
if curve['bi'][k] - curve['bi'][k-1] > 0:
dhdbn = ((curve['hi'][k] - curve['h'][k-1],KK)
/(curve['bi'][k] - curve['bi'][k-1]))
a.append(MUE0*dhdbn)
b.append(MUE0*curve['hi'][k] - dhdbn*curve['bi'][k])
else:
a.append(1.0)
b.append(MUE0*curve['hi'][-1]-curve['bi'][-1])
except IndexError:
logger.warning("curve %s", curve)
pass
return dict(nuer=nuer, a=a, b=b, bi2=bi2)


Expand Down

0 comments on commit 0cfd658

Please sign in to comment.