PyFlex  1.0
Riser cross section analysis
test_coefficients.py
Go to the documentation of this file.
1 """Copyright (C) 2016 Joakim A. Taby
2 
3  This program is free software: you can redistribute it and/or modify
4  it under the terms of the GNU General Public License as published by
5  the Free Software Foundation, either version 3 of the License.
6 
7  This program is distributed in the hope that it will be useful,
8  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  GNU General Public License for more details.
11 
12  You should have received a copy of the GNU General Public License
13  along with this program. If not, see <http://www.gnu.org/licenses/>."""
14 from unittest import TestCase
15 
16 import coefficients
17 import slenders
18 import numpy as np
19 
20 
21 # noinspection PyUnresolvedReferences,PyUnresolvedReferences,PyUnresolvedReferences,PyUnresolvedReferences,PyUnresolvedReferences,PyUnresolvedReferences,PyUnresolvedReferences,PyUnresolvedReferences,PyUnresolvedReferences,PyUnresolvedReferences,PyUnresolvedReferences,PyUnresolvedReferences,PyUnresolvedReferences
22 class TestCoefficients(TestCase):
23  """ testing the coefficients module
24  """
25 
27  # test from Master thesis of Frederika Nugteren.
28  alpha = np.array([-86.1*np.pi/180, 87.6*np.pi/180, 30.0*np.pi/180, -30.0*np.pi/180])
29  R = np.array([ 108.1e-3, 113e-3, 118.2e-3, 124.6e-3])
30  A = np.array([ 218.7e-6, 45.3e-6, 60e-6, 60e-6])
31  n = np.array([ 2, 2, 50, 53])
32  p_ext = 0.0
33  p_int = 0.0
34  t = np.array([4.0e-3,4.0e-3,5.0e-3,5.0e-3])
35  sigma=np.array([[ 3.45189159e+08, 3.30322233e+08, 3.16835196e+08, 3.12779821e+08],
36  [ 3.37408352e+08, 3.22703186e+08, 3.58052949e+08, 3.54092508e+08],
37  [ -7.78080666e+06, -7.61904752e+06, 4.12177525e+07, 4.13126878e+07],
38  [ 3.74934599e+08, 3.58683549e+08, 3.72876786e+08, 3.68474047e+08],
39  [ 5.38704293e+08, 5.15502879e+08, 4.94454927e+08, 4.88126084e+08]])
40 
41  contactforce1 = coefficients.analytical_contact_pressures(sigma,alpha,n,A,R,t,p_int,p_ext)
42  equality_test=np.allclose(contactforce1,
43  [[ 4.70708766e+07, 1.57487585e+07, 6.38244872e+06, 3.02105496e+06],
44  [ 4.70708766e+07, 1.64120719e+07, 7.21908279e+06, 3.42008293e+06],
45  [ 3.69746936e-04, 6.63313434e+05, 8.36634074e+05, 3.99027981e+05],
46  [ 5.17575871e+07, 1.77110161e+07, 7.51513247e+06, 3.55899030e+06],
47  [ 7.34590952e+07, 2.45776079e+07, 9.96048816e+06, 4.71467668e+06]])
48 
49 
50  self.assertTrue(equality_test)
51  contactforce2 = coefficients.analytical_contact_pressures(sigma[2,:],alpha,n,A,R,t,p_int,p_ext)
52  equality_test=np.allclose(contactforce2,
53  [[3.69746936e-04, 6.63313434e+05, 8.36634074e+05, 3.99027981e+05]])
54  self.assertTrue(equality_test)
55 
56 
58  errorfraction = 1.0e-6
59  s = slenders.Slender([["5.15", "25"], ["10"]], youngs_modulus=[207e9],
60  lay_angle=[35, 45], layer_radii=[1, 2], comp_number=[1, 1])
61  # checking for no given lay_angle
62  contactforce = np.array([9, 19])
63  critcurv = coefficients.critical_curvature(s, contactforce,
64  frictionfactors=np.array([0.1]))
65  self.assertAlmostEqual(critcurv.max(), 0.0, delta=errorfraction)
66  # checking with some numbers
67  slenders.Slender([["5.15", "25"], ["10"]], youngs_modulus=[207e9],
68  lay_angle=[45], layer_radii=[1, 2], comp_number=[1, 1])
69  critcurv = coefficients.critical_curvature(s, contactforce,
70  frictionfactors=np.array([0.1]))
71  equality_test = np.allclose(critcurv, np.array([9.55146349e-14 - 1.21781917e-13]))
72  self.assertTrue(equality_test)
73  # Comparing with first project of Inoceano
74  tens = np.array([5000])
75  s = slenders.Slender([[5.15e-3, 2.0e-3], [5.15e-3, 2.0e-3]],
76  lay_angle=[20],
77  comp_number=[51, 46], youngs_modulus=[210.0e9],
78  fric_fac=0.15, layer_radii=[46.925e-3, 41.775e-3])
79  contactforce = np.array([8399.06251, 15250.90005])
80  critcurv = coefficients.critical_curvature(s, contactforce)
81  equality_test = np.allclose(critcurv, [ 1.08610516e-05, 7.00385091e-06])
82  self.assertTrue(equality_test)
83 
85  s = slenders.Slender([[5.15, 25], [5.15e-3]])
86  bendcoeff = coefficients.local_bending_sympy(s)
87  self.assertEqual(len(bendcoeff[0]), 4)
88  # More tests should be written if this is used in its current form
89 
90  def test_local_bending(self):
91  s = slenders.Slender([[5.15e-3 / 2], [5.15e-3 / 2]], lay_angle=[20],
92  comp_number=[51, 46], youngs_modulus=[210.0e9])
93  bendcoeff = coefficients.local_bending(s.layergeometry, s.lay_angle,
94  np.arange(0, 2 * np.pi, 2 * np.pi / 16).reshape(-1, 1),
95  np.arange(0, 2 * np.pi, 2 * np.pi / 16),
96  s.youngs_modulus, bend_model="tan")
97  self.assertEqual(np.max(np.max(bendcoeff[0])), 540750000.0)
98  bendcoeff = coefficients.local_bending(s.layergeometry, s.lay_angle,
99  np.arange(0, 2 * np.pi, 2 * np.pi / 16).reshape(-1, 1),
100  np.arange(0, 2 * np.pi, 2 * np.pi / 16),
101  s.youngs_modulus)
102  self.assertAlmostEqual(np.max(np.max(bendcoeff[0])), 567579730.86247504, delta=0.0001)
103 
105  t_eff = np.array([0.0, 220.6e3, 220.6e3, 131.1e3, 0])
106  p_int =np.array([46.2e6, 46.2e6, 0.0, 50.8e6, 72.1e6])
107  p_ext = np.array([ 0.0, 0.0, 0.0 , 0.0, 0.0])
108 
109  alpha = np.array([-86.1*np.pi/180, 87.6*np.pi/180, 30.0*np.pi/180, -30.0*np.pi/180])
110  R = np.array([ 108.1e-3, 113e-3, 118.2e-3, 124.6e-3])
111  thick = np.array([ 0.0, 0.0, 0.0, 0.0])
112  A = np.array([ 218.7e-6, 45.3e-6, 60e-6, 60e-6])
113  E = np.array([ 200.0e9, 200.0e9, 200.0e9, 200.0e9])
114  n = np.array([ 2, 2, 50, 53])
115 
116  stresshist = coefficients.tension_stress_history(t_eff, p_int, p_ext, alpha, R, thick, A, E, n)
117  equality_test = np.allclose(stresshist,
118  np.array([[ 3.45189159e+08, 3.30322233e+08, 3.16835196e+08, 3.12779821e+08],
119  [ 3.37408352e+08, 3.22703186e+08, 3.58052949e+08, 3.54092508e+08],
120  [ -7.78080666e+06, -7.61904752e+06, 4.12177525e+07, 4.13126878e+07],
121  [ 3.74934599e+08, 3.58683549e+08, 3.72876786e+08, 3.68474047e+08],
122  [ 5.38704293e+08, 5.15502879e+08, 4.94454927e+08, 4.88126084e+08]]))
123  self.assertTrue(equality_test)
124 
126  curvhist = (-0.5 + np.random.random([15, 2])) * 0.05
127  # testing rectangular tendons
128  s = slenders.Slender([[5.15e-3 / 2.0, 10e-3], [5.15e-3 / 2.0, 10e-3]], lay_angle=[20],
129  comp_number=[51, 46], youngs_modulus=[210.0e9])
130  stresshist = coefficients.bending_stress_history(s, curvhist, ntheta=8,
131  nphi=16, bend_model="tan")
132  self.assertEqual(stresshist[0].shape, (15, 8, 4))
133  # Data from first project of Inoceano
134  s = slenders.Slender([[5.15e-3 / 2.0], [5.15e-3 / 2.0]], lay_angle=[20],
135  comp_number=[51, 46], youngs_modulus=[210.0e9])
136  stresshist = coefficients.bending_stress_history(s, curvhist, ntheta=8,
137  nphi=8, bend_model="tan")
138  self.assertEqual(stresshist[0].shape, (15, 8, 8))
139 
140  curvhist = np.array([[1, 0], [0, 1]])
141  stresshist = coefficients.bending_stress_history(s, curvhist, ntheta=8, nphi=8,
142  bend_model="tan")
143  self.assertEqual(stresshist[0][0, 0, 0], stresshist[1][1, 2, 0])
def local_bending(thickness, width, alpha, theta, phi, e, r, type, bend_model="Savik")
def analytical_contact_pressures(sigma, alpha, n, A, R, t, p_int, p_ext)
Definition: coefficients.py:17
def bending_stress_history(slenderobject, curvhist, ntheta=16, nphi=16, bend_model="Savik")
def tension_stress_history(t_eff, p_int, p_ext, alpha, R, thick, A, E, n)
def critical_curvature(slenderobject, contact_pressure, frictionfactors=np.array([5, 5, 5]))
Definition: coefficients.py:72