Skip to content

Commit

Permalink
expand test
Browse files Browse the repository at this point in the history
  • Loading branch information
kbonney committed Dec 10, 2024
1 parent 0c8605c commit d8449e3
Showing 1 changed file with 42 additions and 4 deletions.
46 changes: 42 additions & 4 deletions opensg/tests/test_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
from os.path import abspath, dirname, join
import numpy as np
import opensg
import filecmp


example_data_path = ""
testdir = dirname(abspath(str(__file__)))
Expand All @@ -17,8 +19,30 @@ def setUp(self):

self.blade_mesh = opensg.BladeMesh(mesh_data)
return super().setUp()

def test_segment_creation(self):
mesh_filename = "section.msh"
expected_mesh_filename = join(datadir, 'test_section.msh')

_ = self.blade_mesh.generate_segment_mesh(segment_index=1, filename=mesh_filename)

assert filecmp.cmp(mesh_filename, expected_mesh_filename)

def test_ABD_matrix(self):
section_mesh = self.blade_mesh.generate_segment_mesh(segment_index=1, filename="section.msh")
abd = section_mesh.compute_ABD()

abd_concat = np.concat(abd)
# np.savetxt(join(datadir, 'abd_test.txt'), abd_concat) # use to reset ground truth

expected_abd = np.loadtxt(join(datadir, 'abd_test.txt'))
assert np.isclose(abd_concat, expected_abd).all()

def test_timo_stiffness(self):
pass


def test_example(self):
def test_EB_stiffness(self):
# load expected values
# expected_ABD = np.loadtxt("")
# expected_stiffness = np.loadtxt("")
Expand All @@ -27,8 +51,22 @@ def test_example(self):
ABD = section_mesh.compute_ABD()
# assert np.isclsoe(ABD, expected_ABD).all()

stiffness_matrix = section_mesh.compute_stiffness_EB(ABD)
assert stiffness_matrix.shape == (4,4)
# assert np.isclsoe(stiffness_matrix, expected_stiffness).all()
computed_stiffness_matrix = section_mesh.compute_stiffness_EB(ABD)
# np.savetxt(join(datadir, 'stiffness_test.txt'), computed_stiffness_matrix) # use to reset ground truth

assert computed_stiffness_matrix.shape == (4,4)

expected_stiffness_matrix = np.loadtxt(join(datadir, 'stiffness_test.txt'))
assert np.isclose(computed_stiffness_matrix, expected_stiffness_matrix).all()



"""
[[ 5.6138e+09  7.8930e+07 -9.1787e+07 -6.2902e+08]
[ 7.8930e+07  2.2724e+10 -6.0954e+08  2.0795e+08]
[-9.1787e+07 -6.0954e+08  1.0064e+10  9.9959e+08]
[-6.2902e+08  2.0795e+08  9.9959e+08  1.2617e+10]]
"""

if __name__ == "__main__":
unittest.main()

0 comments on commit d8449e3

Please sign in to comment.