This repository has been archived on 2022-02-23. You can view files and clone it, but cannot push or open issues or pull requests.
pathfinder/tests/model/test_staticdipole.py
Deepak 4011a5c698
All checks were successful
gitea-physics/pathfinder/pipeline/head This commit looks good
Adds better test for static dipole as well as calculating dot measurements
2021-08-29 15:38:41 -05:00

24 lines
987 B
Python

import numpy
import pathfinder.model as model
def test_static_dipole():
d1 = model.StaticDipole((1, 2, 3), (4, 5, 6))
d2 = model.StaticDipole((4, 5, 6), (1, 2, 3))
dipoles = model.StaticDipoleArrangement([d1, d2])
dot_position1 = (-1, -1, -1)
expected_v1 = -0.3338923121348659
numpy.testing.assert_allclose(dipoles.get_dot_measurement(dot_position1).v, expected_v1, err_msg="Voltage at dot isn't as expected.")
numpy.testing.assert_allclose(dipoles.get_dot_measurement(dot_position1).r, dot_position1, err_msg="Dot isn't where expected.")
# test multiple dots
dot_position2 = (-1, -1, -5)
expected_v2 = -0.1254445237566694
both_measurements = dipoles.get_dot_measurements([dot_position1, dot_position2])
measured_voltages = numpy.sort([m.v for m in both_measurements])
expected_measured_voltages = numpy.sort([expected_v1, expected_v2])
numpy.testing.assert_allclose(measured_voltages, expected_measured_voltages, err_msg="Didn't get the measured voltages expected")