Skip to content

Commit 5152589

Browse files
committed
more matrix tests
1 parent c3df600 commit 5152589

File tree

4 files changed

+83
-5
lines changed

4 files changed

+83
-5
lines changed

pyNastran/bdf/test/test_utils.py

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,46 @@
88
parse_patran_syntax, parse_patran_syntax_dict, parse_patran_syntax_dict_map,
99
write_patran_syntax_dict, split_eids_along_nids,
1010
parse_femap_syntax,
11-
get_femap_property_comments_dict, get_femap_material_comments_dict)
11+
split_comment_to_femap_comment,
12+
get_femap_property_comments_dict,
13+
get_femap_material_comments_dict)
1214
PKG_PATH = Path(pyNastran.__path__[0])
1315
MODEL_PATH = PKG_PATH / '..' / 'models'
1416

1517

1618
class TestBdfUtils(unittest.TestCase):
19+
def test_split_comment_to_femap_comment(self):
20+
in1 = '$ Femap Region 12345 : Wing NSM'
21+
is_passed, error_msg, (word, idi, name) = split_comment_to_femap_comment(in1)
22+
assert is_passed, is_passed
23+
assert error_msg == '', error_msg
24+
assert word == 'Region', word
25+
assert idi == 12345, idi
26+
assert name == 'Wing NSM', name
27+
28+
in2 = '$ Femap Property 100 : Wing Skin 20 Plies\n$\n$ Femap Layup 101 : 20 Ply\n'
29+
is_passed, error_msg, (word, idi, name) = split_comment_to_femap_comment(in2)
30+
assert not is_passed, is_passed
31+
# assert error_msg == '', error_msg
32+
# assert word == 'Property', word
33+
# assert idi == 100, idi
34+
# assert name == 'Wing Skin 20 Plies', name
35+
36+
in3 = '$$ Femap Material 202 : Steel:42\n'
37+
is_passed, error_msg, (word, idi, name) = split_comment_to_femap_comment(in2)
38+
assert not is_passed, is_passed
39+
# assert error_msg == '', error_msg
40+
# assert word == 'Material', word
41+
# assert idi == 202, idi
42+
# assert name == 'Steel:42', name
43+
44+
in4 = (
45+
'$ Femap Property 8000007 : Aileron, Steel Pin dia=.375\n'
46+
'$ Femap PropShape 8000007 : 5,0,0.1875,0.,0.,0.,0.,0.\n'
47+
'$ Femap PropMethod 8000007 : 5,0,1,0.\n'
48+
'$ Femap PropOrient 8000007 : 5,0,0.,1.,2.,3.,4.,-1.,0.,0.')
49+
split_comment_to_femap_comment(in4)
50+
1751
def test_get_femap_comments_dict(self):
1852
"""tests:
1953
- ``get_femap_property_comments_dict``

pyNastran/bdf/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
def split_comment_to_femap_comment(comment: str) -> tuple[bool, str, tuple[str, int, str]]:
2727
"""
28-
[$ Femap Region 12345 : Wing NSM']
28+
['$ Femap Region 12345 : Wing NSM']
2929
['$ Femap Property 100 : Wing Skin 20 Plies\n$\n$ Femap Layup 101 : 20 Ply\n']
3030
['$$ Femap Material 202 : Steel:42\n']
3131
['$ Femap Property 8000007 : Aileron, Steel Pin dia=.375', '$ Femap PropShape 8000007 : 5,0,0.1875,0.,0.,0.,0.,0.', '$ Femap PropMethod 8000007 : 5,0,1,0.', '$ Femap PropOrient 8000007 : 5,0,0.,1.,2.,3.,4.,-1.,0.,0.']

pyNastran/femutils/matrix3d.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def dot_33_n33(A: np.ndarray, B: np.ndarray,
7575
#print(D[i, :, :])
7676
#print('------------------------')
7777
assert np.all(np.allclose(C, D))
78-
return D
78+
return C
7979

8080

8181
def dot_n33_33(A: np.ndarray, B: np.ndarray,

pyNastran/femutils/test/test_utils.py

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@
1212

1313
import pyNastran
1414
from pyNastran.femutils.io import loadtxt_nice, savetxt_nice
15-
from pyNastran.femutils.matrix3d import dot_n33_n33, transpose3d, triple_n33_n33, triple_n33_33
15+
from pyNastran.femutils.matrix3d import (
16+
dot_33_n33, dot_n33_33, dot_n33_n33,
17+
transpose3d,
18+
triple_n33_n33, triple_n33_33)
1619
from pyNastran.femutils.utils import (
1720
augmented_identity, perpendicular_vector,
1821
perpendicular_vector2d, vstack_lists,
@@ -24,9 +27,50 @@
2427
PKG_PATH = pyNastran.__path__[0]
2528

2629

27-
#class TestNan(unittest.TestCase):
2830
class TestMatrix3d(unittest.TestCase):
2931
"""tests functions in femutils.matrix3d"""
32+
def test_dot_33_n33(self):
33+
"""tests dot_33_n33"""
34+
A = np.array([
35+
[[1., 0., 0.],
36+
[0., 1., 0.],
37+
[0., 0., 1.], ],
38+
39+
[[1., 0., 0.],
40+
[0., 1., 0.],
41+
[0., 0., 1.], ],
42+
43+
[[1., 0., 0.],
44+
[0., 1., 0.],
45+
[0., 0., 1.], ],
46+
])
47+
theta = np.radians([12.])
48+
B = cylindrical_rotation_matrix(theta, dtype='float64')
49+
assert B.shape == (1, 3, 3), B.shape
50+
C = dot_33_n33(B[0, :, :], A)
51+
D = dot_33_n33(B[0, :, :], A, debug=True)
52+
53+
def test_dot_n33_33(self):
54+
"""tests dot_n33_33"""
55+
A = np.array([
56+
[[1., 0., 0.],
57+
[0., 1., 0.],
58+
[0., 0., 1.], ],
59+
60+
[[1., 0., 0.],
61+
[0., 1., 0.],
62+
[0., 0., 1.], ],
63+
64+
[[1., 0., 0.],
65+
[0., 1., 0.],
66+
[0., 0., 1.], ],
67+
])
68+
theta = np.radians([12.])
69+
B = cylindrical_rotation_matrix(theta, dtype='float64')
70+
assert B.shape == (1, 3, 3), B.shape
71+
C = dot_n33_33(A, B[0, :, :])
72+
D = dot_n33_33(A, B[0, :, :], debug=True)
73+
3074
def test_dot_n33_n33(self):
3175
"""tests dot_n33_n33"""
3276
A = np.array([

0 commit comments

Comments
 (0)