Skip to content

Fix modified inductance element La to match its documented definition - #337

Open
shaurya20335 wants to merge 1 commit into
ECSHackWeek:mainfrom
shaurya20335:fix-modified-inductance
Open

shaurya20335 wants to merge 1 commit into
ECSHackWeek:mainfrom
shaurya20335:fix-modified-inductance

Conversation

@shaurya20335

Copy link
Copy Markdown

Fixes #312

The modified inductance element La is documented as

Z = L * (j * omega)^alpha

but the code computes (L * 1j * omega) ** alpha, so L also gets raised to the power alpha. The two only agree when alpha = 1. For alpha < 1 the fitted L comes out wrong and its units don't make sense.

Changes:

  • elements.py: Z = L * (1j * omega) ** alpha
  • units of L changed from H sec to H sec^(a - 1), since L * omega^alpha has to be in Ohm. This follows the same style as the TLMQ element (F sec^(gamma - 1)).
  • test_each_element: the old reference values for La matched the buggy formula, so I recomputed them from L * omega^alpha * exp(j * alpha * pi / 2) with L = 0.1 and alpha = 0.2
  • new test_La_linear_in_L: doubling L should double Z for any alpha. It fails on the old code and passes with the fix.

flake8 is clean and the full test suite passes locally (36 passed).

One thing to note for users: anyone who fitted circuits with La before this will get a different (now correct) L value if they refit. The alpha values and the fit quality are not affected, since the old form is just a reparameterisation of L.

La computed (L * j * omega)^alpha, which also raises L to the power alpha.
The docs (and EC-Lab's definition) give Z = L * (j * omega)^alpha. Fix the
formula, update the La reference values in test_each_element, add a test
that Z is linear in L, and correct the units of L to H sec^(a - 1).

Fixes ECSHackWeek#312
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Modified inductance circuit element implemented incorrectly

1 participant