PyFlex  1.0
Riser cross section analysis
pyflex.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 
15 import slenders
16 
17 
18 def analytical_input(inputfile, delimiter, commentchar):
19  # All needed input
20  obligatory_keyword = ["LayerType"]
21  optional_keyword = ["TypicalCurvature", "LayerRadii", "TypicalTension",
22  "LayAngle", "CompNumber", "YoungsModulus","Thickness",
23  "Width","Poisson","InitialGap","FrictionFactor",
24  "InternalPressureLayer","ExternalPressureLayer"]
25  # initialize all optionals to None
26 
27  layer_radii = None
28  layer_type = None
29  thickness = None
30  gap_ini = None
31  youngs_modulus = None
32  poisson = None
33  fric_fac = None
34  lay_angle = None
35  comp_number = None
36  width = None
37  intpresslayer = None
38  extpresslayer = None
39  typical_curvature = None
40  typical_tension = None
41 
42  # reading all the input obviously
43  inputfile_object = open(inputfile, 'r')
44  tmp_input_content = inputfile_object.readlines()
45  input_content=[]
46  for line in tmp_input_content:
47  tmp=line.split(commentchar,1)[0]
48  if len(tmp)>0:
49  input_content.append(line.split(commentchar,1)[0])
50  comment = 0
51  for line in input_content:
52  if line[0] == commentchar:
53  comment += 1
54  elif line[0:1] == "\n":
55  comment += 1
56 
57  elif line.find("LayerRadii") > -1:
58  index = line.find(delimiter)
59  tmp = line[index + 1: len(line) - 1]
60  tmp = tmp.split(",")
61  count = 0
62  layer_radii = []
63  for i in tmp:
64  count += 1
65  layer_radii.append(float(i))
66 
67  elif line.find("LayerType") > -1:
68  index = line.find(delimiter)
69  tmp = line[index + 1: len(line) - 1]
70  tmp = tmp.split(",")
71  count = 0
72  layer_type = []
73  for i in tmp:
74  count += 1
75  layer_type.append(str(i))
76 
77  elif line.find("Thickness") > -1:
78  index = line.find(delimiter)
79  tmp = line[index + 1: len(line) - 1]
80  tmp = tmp.split(",")
81  count = 0
82  thickness = []
83  for i in tmp:
84  count += 1
85  thickness.append(float(i))
86 
87  elif line.find("InitialGap") > -1:
88  index = line.find(delimiter)
89  tmp = line[index + 1: len(line) - 1]
90  tmp = tmp.split(",")
91  count = 0
92  gap_ini = []
93  for i in tmp:
94  count += 1
95  gap_ini.append(float(i))
96 
97  elif line.find("YoungsModulus") > -1:
98  index = line.find(delimiter)
99  tmp = line[index + 1: len(line) - 1]
100  tmp = tmp.split(",")
101  count = 0
102  youngs_modulus = []
103  for i in tmp:
104  count += 1
105  youngs_modulus.append(float(i))
106 
107  elif line.find("Poisson") > -1:
108  index = line.find(delimiter)
109  tmp = line[index + 1: len(line) - 1]
110  tmp = tmp.split(",")
111  count = 0
112  poisson = []
113  for i in tmp:
114  count += 1
115  poisson.append(float(i))
116 
117  elif line.find("FrictionFactor") > -1:
118  index = line.find(delimiter)
119  tmp = line[index + 1: len(line) - 1]
120  tmp = tmp.split(",")
121  count = 0
122  fric_fac = []
123  for i in tmp:
124  count += 1
125  fric_fac.append(float(i))
126 
127  elif line.find("LayAngle") > -1:
128  index = line.find(delimiter)
129  tmp = line[index + 1:len(line) - 1]
130  tmp = tmp.split(",")
131  count = 0
132  lay_angle = []
133  for i in tmp:
134  count += 1
135  lay_angle.append(float(i))
136 
137  elif line.find("CompNumber") > -1:
138  index = line.find(delimiter)
139  tmp = line[index + 1:len(line) - 1]
140  tmp = tmp.split(",")
141  count = 0
142  comp_number = []
143  for i in tmp:
144  count += 1
145  comp_number.append(float(i))
146 
147  elif line.find("Width") > -1:
148  index = line.find(delimiter)
149  tmp = line[index + 1:len(line) - 1]
150  tmp = tmp.split(",")
151  count = 0
152  width = []
153  for i in tmp:
154  count += 1
155  width.append(float(i))
156 
157  elif line.find("InternalPressureLayer") > -1:
158  index = line.find(delimiter)
159  intpresslayer = int(line[index + 1:len(line) - 1])
160 
161  elif line.find("ExternalPressureLayer") > -1:
162  index = line.find(delimiter)
163  extpresslayer = int(line[index + 1:len(line) - 1])
164 
165  elif line.find("TypicalTension") > -1:
166  index = line.find(delimiter)
167  typical_tension = float(line[index + 1:len(line) - 1])
168 
169  elif line.find("TypicalCurvature") > -1:
170  index = line.find(delimiter)
171  typical_curvature = float(line[index + 1:len(line) - 1])
172 
173  else:
174  tmp = line.split(delimiter)
175  print('Keyword "%s" not recognized' % (tmp[0]))
176  inputfile_object.close()
177  slender = slenders.Slender(layer_radii, layer_type,
178  thickness, gap_ini, youngs_modulus, poisson, fric_fac,
179  lay_angle, comp_number, width,
180  intpresslayer, extpresslayer,
181  typical_tension, typical_curvature)
182 
183  return slender
184 
185 
186 def parser(arguments, delimiter, commentchar):
187  if arguments[1] == "-a":
188  # analytical approach
189  print("Analytical results anticipated")
190  slender = analytical_input(arguments[2], delimiter, commentchar)
191  return slender
192  elif arguments[1] == "n":
193  print("Results from local analyses anticipated")
194  else:
195  print("Not a valid option (yet)")
196  # results from numerical analysis provided
197 
def parser(arguments, delimiter, commentchar)
Definition: pyflex.py:186
def analytical_input(inputfile, delimiter, commentchar)
Definition: pyflex.py:18