Skip to content

Commit

Permalink
Add unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
james-packer committed Oct 29, 2024
1 parent 1b82300 commit 3967914
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions tests/test_graphs.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,49 @@ def test_get_heatflow_graph(mc):
assert almost_equal(y1[3], 11.68)


def test_get_fea_graph(mc):
reset_to_default_file(mc)

mc.set_variable("TorqueCalculation", True)
mc.set_variable("ElectromagneticForcesCalc_Load", True)

mc.do_magnetic_calculation()

x, y = mc.get_fea_graph("Bt Gap (on load)", 1)
assert len(x) == len(y) == 181
assert almost_equal(x[16], 4)
assert almost_equal(y[16], 0.344792719, 2)


def test_get_fea_graph_transient(mc):
reset_to_default_file(mc)

mc.set_variable("TorqueCalculation", True)
mc.set_variable("ElectromagneticForcesCalc_Load", True)

mc.do_magnetic_calculation()

x, y = mc.get_fea_graph("Br Gap (stator) (on load transient)", 1, 0)
assert len(x) == len(y) == 4
assert almost_equal(x[1], 120)
assert almost_equal(y[1], 0.626116165, 2)


def test_get_magnetic_3d_graph(mc):
reset_to_default_file(mc)

mc.set_variable("TorqueCalculation", True)
mc.set_variable("ElectromagneticForcesCalc_Load", True)

mc.do_magnetic_calculation()

graph_result = mc.get_magnetic_3d_graph("Ft_Stator_OL", 1)
assert len(graph_result.x) == 481
assert len(graph_result.y) == 4
# Note that graph viewer shows in kN, result is in N
assert almost_equal(graph_result.data[1][1], -0.560483068, 3)


# #Not fully ready submitted an issue
# def test_get_fea_graph_point():
# reset_to_default_file(mc)
Expand Down

0 comments on commit 3967914

Please sign in to comment.