PyFlex  1.0
Riser cross section analysis
slenders.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 import numpy as np
15 
16 
17 class Slender:
18  """ A class defining a slender cross section"""
19 
20  def __init__(self, layer_radii=None, layer_type=None,
21  thickness=None, gap_ini=None, youngs_modulus=None, poisson=None, fric_fac=None,
22  lay_angle=None, comp_number=0, width=None,
23  intpresslayer=None, extpresslayer=None, typical_tension=None, typical_curvature=None):
24  """
25 
26  :param layer_radii: Radius of a layer
27  :param layer_type: Type of a layer wires or sheath
28  :param thickness: Thickness of a layer
29  :param gap_ini: Initial gap on the inside of a layer
30  :param youngs_modulus: Young's modulus for the material of a layer
31  :param poisson: Poissons ratio for the material of layer
32  :param fric_fac: Friction factor on the inside of a layer
33  :param lay_angle: Lay angle of a wire layer, dummy for sheath layer
34  :param comp_number: number of tendons in a wire layer, dummy for sheath layer
35  :param width: Width of the tendons in a layer, dummy for sheath layer
36  :param typical_tension: Typical tension, used for preliminary analysis
37  :param typical_curvature: Typical curvature, used for preliminary analysis
38  :param intpresslayer: The layer on which internal pressure is applied
39  :param extpresslayer: The layer on which external pressure is applied
40  :return: Object of type slender
41  """
42 
43  if layer_radii:
44  tmp = []
45  for i in layer_radii:
46  tmp.append(float(i))
47  self.layer_radii = tmp
48  else:
49  self.layer_radii = [0.0]
50 
51  if layer_type:
52  tmp = []
53  if len(layer_type) == len(layer_type):
54  for i in layer_type:
55  tmp.append(i)
56  self.layer_type = tmp
57  else:
58  print("Cannot interpret the layer type. It is either sheath or wire and has to"
59  "given for each layer.")
60  else:
61  tmp = []
62  for i in range(len(self.layer_radii)):
63  tmp.append("wires")
64  self.layer_type = tmp
65 
66  if thickness:
67  tmp = []
68  if len(thickness) == len(self.layer_radii):
69  for i in thickness:
70  tmp.append(float(i))
71  self.thickness = tmp
72  elif len(thickness) == 1:
73  for i in range(len(self.layer_radii)):
74  tmp.append(float(thickness[0]))
75  self.thickness = tmp
76  else:
77  print("Cannot interpret the thickness. either it has to be defined "
78  "with the length equal to the number of layers, or it has "
79  "to be of length 1.")
80  else:
81  tmp = []
82  for i in range(len(self.layer_radii)):
83  tmp.append(0.0)
84  self.thickness = tmp
85 
86  if gap_ini:
87  tmp = []
88  if len(gap_ini) == len(self.layer_radii):
89  for i in gap_ini:
90  tmp.append(float(i))
91  self.gap_ini = tmp
92  elif len(gap_ini) == 1:
93  for i in range(len(self.layer_radii)):
94  tmp.append(float(gap_ini[0]))
95  self.gap_ini = tmp
96  else:
97  print("Cannot interpret the thickness. either it has to be defined "
98  "with the length equal to the number of layers, or it has "
99  "to be of length 1.")
100  else:
101  tmp = []
102  for i in range(len(self.layer_radii)):
103  tmp.append(0.0)
104  self.gap_ini = tmp
105 
106  if not youngs_modulus:
107  self.youngs_modulus = []
109  for i in range(len(self.layer_radii)):
110  self.youngs_modulus.append(0.0)
111  self.youngs_modulusDefault.append(207 * 10 ** 9)
112  elif len(youngs_modulus) == 1:
113  self.youngs_modulus = []
114  for i in range(len(self.layer_radii)):
115  self.youngs_modulus.append(float(youngs_modulus[0]))
116  elif len(youngs_modulus) == len(self.layer_radii):
117  self.youngs_modulus = youngs_modulus
118  else:
119  print("Wrong format on Youngs modulus given.")
120 
121  if poisson:
122  tmp = []
123  if len(poisson) == len(self.layer_radii):
124  for i in poisson:
125  tmp.append(float(i))
126  self.poisson = tmp
127  elif len(poisson) == 1:
128  for i in range(len(self.layer_radii)):
129  tmp.append(float(poisson[0]))
130  self.poisson = tmp
131  else:
132  print("Cannot interpret the thickness. either it has to be defined "
133  "with the length equal to the number of layers, or it has "
134  "to be of length 1.")
135  else:
136  tmp = []
137  for i in range(len(self.layer_radii)):
138  tmp.append(0.0)
139  self.poisson = tmp
140 
141  if not fric_fac:
142  self.fricfac = []
143  self.fricfacDefault = []
144  for i in range(len(self.layer_radii)):
145  self.fricfacDefault.append(0.15)
146  self.fricfac.append(0.0)
147  elif isinstance(fric_fac, float):
148  self.fricfac = []
149  for i in range(len(self.layer_radii)):
150  self.fricfac.append(fric_fac)
151  elif len(fric_fac) == 1:
152  self.fricfac = []
153  for i in range(len(self.layer_radii)):
154  self.fricfac.append(fric_fac)
155  elif len(fric_fac) == len(self.layer_radii):
156  self.fricfac = fric_fac
157  else:
158  print("If specified the friction factor should either"
159  " be defined as one number to be used for each interface,"
160  "or for the inner interface of each given layer")
161 
162  # specific for wire layers
163  if width:
164  tmp = []
165  if len(width) == len(self.layer_radii):
166  for i in width:
167  tmp.append(float(i))
168  self.width = tmp
169  elif len(width) == 1:
170  for i in range(len(self.layer_radii)):
171  tmp.append(float(width[0]))
172  self.width = tmp
173  else:
174  print("Cannot interpret the width. either it has to be defined "
175  "with the length equal to the number of layers, or it has "
176  "to be of length 1.")
177  else:
178  tmp = []
179  for i in range(len(self.layer_radii)):
180  tmp.append(0.0)
181  self.width = tmp
182 
183  if lay_angle:
184  tmp = []
185  if len(lay_angle) == len(self.layer_radii):
186  for i in lay_angle:
187  tmp.append(float(i) * np.pi / 180.0)
188  self.lay_angle = tmp
189  elif len(lay_angle) == 1:
190  for i in range(len(self.layer_radii)):
191  tmp.append(float(lay_angle[0]) * np.pi / 180.0 * float((1 - 2 * (i % 2))))
192  self.lay_angle = tmp
193  else:
194  print("Cannot interpret the layangle. either it has to be defined "
195  "with the length equal to the number of layers, or it has "
196  "to be of length 1.")
197  else:
198  tmp = []
199  for i in range(len(self.layer_radii)):
200  tmp.append(0.0)
201  self.lay_angle = tmp
202 
203  if comp_number:
204  if len(comp_number) == len(self.layer_radii):
205  self.comp_number = comp_number
206  else:
207  print("Length of comp_number taken to be %d which is different from the number of "
208  "layers found to be %d." % len(comp_number), len(self.layer_radii))
209  else:
210  self.comp_number = []
211  for i in range(len(self.layer_radii)):
212  self.comp_number.append(0.0)
213 
214  if intpresslayer:
215  self.intpresslayer=intpresslayer
216  else:
217  self.intpresslayer=1
218  if extpresslayer:
219  self.extpresslayer=extpresslayer
220  else:
221  self.extpresslayer=len(self.layer_radii)
222 
223  #Scenario parameters
224 
225  if typical_tension:
226  self.typical_tension = float(typical_tension)
227  else:
228  self.typical_tension = 0.0
229 
230  if typical_curvature:
231  self.typical_curvature = float(typical_curvature)
232  else:
233  self.typical_curvature = 0.0
234 
236 
237  def calc_tendon_area(self):
238  """A method for calculating the tendon area if tendon, or layer area if sheath
239 
240  :rtype : list
241  :return:The area of the tendons defined
242  """
243  area = []
244  for i in range(len(self.thickness)):
245  if self.layer_type[i] == 'wires':
246  area.append(self.thickness[i] *
247  self.width[i])
248  elif self.layer_type[i] == 'sheath':
249  area.append(2.0*np.pi*self.layer_radii[i]*
250  self.thickness[i])
251  else:
252  print('Layer type for layer ',i+1,' read as "',self.layer_type[i],'", must be wires or sheath.' )
253  return area
254 
255  def num_layers(self):
256  """Method for finding the number of layers of the model"""
257  num = 0
258  if self.lay_angle:
259  num = max(len(self.lay_angle), num)
260  if self.comp_number:
261  num = max(len(self.comp_number), num)
262  if self.fricfac:
263  num = max(len(self.fricfac), num)
264  if self.layer_radii:
265  num = max(len(self.layer_radii), num)
266  if self.thickness:
267  num = max(len(self.thickness), num)
268  if self.width:
269  num = max(len(self.width), num)
270  if self.tendon_area:
271  num = max(len(self.tendon_area), num)
272  if self.youngs_modulus:
273  num = max(len(self.youngs_modulus), num)
274  return num
def calc_tendon_area(self)
Definition: slenders.py:237
def __init__(self, layer_radii=None, layer_type=None, thickness=None, gap_ini=None, youngs_modulus=None, poisson=None, fric_fac=None, lay_angle=None, comp_number=0, width=None, intpresslayer=None, extpresslayer=None, typical_tension=None, typical_curvature=None)
Definition: slenders.py:23
def num_layers(self)
Definition: slenders.py:255