From f4fd747b73ca259fb6d9594fb331bf3445f55977 Mon Sep 17 00:00:00 2001 From: "Saullo G. P. Castro" Date: Mon, 11 Mar 2024 22:42:06 +0100 Subject: [PATCH] TST: test clean-up and completion --- composites/kassapoglou.py | 7 ------- tests/test_kassapoglou.py | 10 +++++++++- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/composites/kassapoglou.py b/composites/kassapoglou.py index 62be7c6..38ec4ce 100644 --- a/composites/kassapoglou.py +++ b/composites/kassapoglou.py @@ -216,10 +216,3 @@ def calc_Nxx_crit_combined_shear_full(Nxy, a, b, D11, D12, D16, D22, D26, D66): Nxx_crit2 = a*(36*a11 + 9*a22 + sqrt(term))/(18*pi**2*b) return min(abs(Nxx_crit1), abs(Nxx_crit2)) - -if __name__ == '__main__': - # NOTE a difficult convergence case... - args = '0.8 14089642.804130534 2011013.713237885 5.359101079856173e-12 5453279.395887981 2582673.2451443337'.split(' ') - args = map(float, args) - test = calc_Nxy_crit(*args) - diff --git a/tests/test_kassapoglou.py b/tests/test_kassapoglou.py index 574f2be..c700106 100644 --- a/tests/test_kassapoglou.py +++ b/tests/test_kassapoglou.py @@ -66,6 +66,9 @@ def test_calc_Nxx_crit(): #plt.plot(AR_values, np.asarray(res)) #plt.show() + assert np.allclose(calc_Nxx_crit(b*AR, b, 1, 1, D11, D12, D22, D66), + calc_Nxx_crit(b*AR, b, 1, None, D11, D12, D22, D66)) + try: calc_Nxx_crit(b*AR, b, None, None, D11, D12, D22, D66) except NotImplementedError: @@ -81,10 +84,15 @@ def test_calc_Nxy_crit(): a_values = np.linspace(0.1, 0.5) res = [] for a in a_values: - res.append(calc_Nxy_crit(a, lam.D[0, 0], lam.D[0, 1], lam.D[0, 2], lam.D[1, 1], lam.D[2, 2])) + res.append(calc_Nxy_crit(a, lam.D11, lam.D12, lam.D16, lam.D22, lam.D66)) res_expected = [79688.55992406543, 68114.0022704454, 58889.57598574364, 51419.57333450177, 45285.73547400736, 40187.4044061502, 35903.96554281875, 32270.57385354717, 29162.053403091162, 26481.969879263816, 24155.06026735022, 22121.89066686104, 20335.02310316517, 18756.22315240477, 17354.39749457425, 16104.051205932257, 14984.120320908534, 13977.078850002274, 13068.248915899261, 12245.262872171586, 11497.640308736318, 10816.452732075362, 10194.055750316005, 9623.87366720392, 9100.225083361767, 8618.180819678446, 8173.447493599944, 7762.271588205649, 7381.359992966362, 7027.813861439158, 6699.073294971503, 6392.870873657024, 6107.192453563187, 5840.243960125795, 5590.423152014058, 5356.295523016742, 5136.573663123334, 4930.099522731353, 4735.829122489075, 4552.8193308193, 4380.216395633825, 4217.245969223063, 4063.204408198967, 3917.45116557157, 3779.4021210406136, 3648.5237195644836, 3524.327808168894, 3406.3670775281935, 3294.2310286958063, 3187.5423969626177] assert np.allclose(res, res_expected) + try: + calc_Nxy_crit(a, -lam.D11, lam.D12, lam.D16, lam.D22, lam.D66) + except RuntimeError: + pass + #import matplotlib.pyplot as plt #plt.plot(a_values*1000, np.asarray(res)/1000) #plt.xlabel('Plate dimension a [mm]')