Skip to content

Commit 60a215b

Browse files
committed
Add a test for parameter setting of a scalar vector
1 parent da33e49 commit 60a215b

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

tests/test_init_scalar.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import fidimag
2+
from fidimag.common import init_scalar
3+
import numpy as np
4+
import unittest
5+
6+
def m_init(pos, t):
7+
x, y, z = pos
8+
return np.sin(t)
9+
10+
def test_init_scalar_function():
11+
import fidimag
12+
import numpy as np
13+
# Create simulation
14+
nx = ny = nz = 2
15+
mesh = fidimag.common.CuboidMesh(nx=nx, ny=ny, nz=nz,
16+
dx=1, dy=1, dz=1)
17+
18+
test_vec = np.zeros(nx * ny * nz)
19+
test_vec[:] = init_scalar(m_init, mesh, 0)
20+
assert test_vec[0] == 0.0
21+
test_vec[:] = init_scalar(m_init, mesh, np.pi/2.0)
22+
assert test_vec[0] == 1.0

0 commit comments

Comments
 (0)