Skip to content

Commit

Permalink
Add trivial test.
Browse files Browse the repository at this point in the history
  • Loading branch information
1uc committed Oct 10, 2024
1 parent 7a1a322 commit 5ea2f83
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
21 changes: 21 additions & 0 deletions test/usecases/nonlinear/nonlin.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
NEURON {
SUFFIX nonlin
}

STATE { x }

FUNCTION solve() {
: Iterative solvers need a starting guess.
x = 1.0
SOLVE eq

solve = x
}

NONLINEAR eq {
~ x*x = 4.0
}

FUNCTION residual(x) {
residual = x - 2.0
}
15 changes: 15 additions & 0 deletions test/usecases/nonlinear/test_nonlin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from neuron import h, gui


def test_nonlin():
s = h.Section()
s.insert("nonlin")
inst = s(0.5).nonlin

x = inst.solve()
error = inst.residual(x)
assert abs(error) < 1e-9, f"{x = }, {error = }"


if __name__ == "__main__":
test_nonlin()

0 comments on commit 5ea2f83

Please sign in to comment.