-
Notifications
You must be signed in to change notification settings - Fork 0
/
loads.py
202 lines (131 loc) · 4.24 KB
/
loads.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
import numpy as np
from plate import Plate
class Load:
"""Base class for loads on a rectangular plate.
Parameters
----------
p0 : float, optional
Load magnitude. Defaults to 1.
plate : Plate
Plate on which the load is being applied.
"""
def __init__(self, **kwargs):
# Store parameters
self.p0 = kwargs.get("p0", 1.0)
self.plate = kwargs.get("plate", Plate())
def p(self, x, y):
return 0.0
def p_from_series(self, x, y, m_terms=10, n_terms=10):
p = 0.0
for mi in self.m[:min(m_terms, len(self.m))]:
for ni in self.n[:min(n_terms,len(self.n))]:
p += self.P_mn(mi, ni)*np.sin(mi*np.pi*x/self.plate.a)*np.sin(ni*np.pi*y/self.plate.b)
return p
class UniformLoad(Load):
"""Class for a uniform load.
Parameters
----------
p0 : float, optional
Load magnitude. Defaults to 1.
plate : Plate
Plate on which the load is being applied.
"""
def __init__(self, **kwargs):
super().__init__(**kwargs)
# Initialize Fourier coeff calcs
self.m = np.array(range(1, 999, 2))
self.n = np.array(range(1, 999, 2))
def p(self, x, y):
return self.p0
def Pmn(self, m, n):
return 16.0*self.p0/(np.pi**2*m*n)
def Pm(self, m):
return 4.0*self.p0/(np.pi*m)
def F_total(self):
return self.p0*self.plate.a*self.plate.b
class SinusoidalLoad(Load):
"""Class for a sinusoidal load.
Parameters
----------
p0 : float, optional
Load magnitude. Defaults to 1.
plate : Plate
Plate on which the load is being applied.
"""
def __init__(self, **kwargs):
super().__init__(**kwargs)
# Initialize Fourier coefs calcs
self.m = np.array([1], dtype=int)
self.n = np.array([1], dtype=int)
def p(self, x, y):
return self.p0*np.sin(np.pi*x/self.plate.a)*np.sin(np.pi*y/self.plate.b)
def Pmn(self, m, n):
if m == 1 and n == 1:
return self.p0
else:
return 0.0
def F_total(self):
return 4.0*self.p0*self.plate.a*self.plate.b
class HydrostaticLoad(Load):
"""Class for a hydrostatic load.
Parameters
----------
p0 : float, optional
Load magnitude. Defaults to 1.
plate : Plate
Plate on which the load is being applied.
"""
def __init__(self, **kwargs):
super().__init__(**kwargs)
# Initialize Fourier coefficient calcs
self.m = np.array(range(1, 500))
self.n = np.array(range(1, 999, 2))
def p(self, x, y):
return self.p0*x/self.plate.a
def Pmn(self, m, n):
return 8.0*self.p0/(np.pi**2*m*n)*(-1)**(m+1)
def Pm(self, m):
return 2.0*self.p0/(np.pi*m)*(-1)**(m+1)
def F_total(self):
return 0.5*self.p0*self.plate.a*self.plate.b
class PatchLoad(Load):
"""Class for a patch load.
Parameters
----------
p0 : float, optional
Load magnitude. Defaults to 1.
c : float
Width of patch in x-direction.
d : float
Width of patch in y-direction.
x : float
Center of patch in x-direction.
y : float
Center of patch in y-direction.
plate : Plate
Plate on which the load is being applied.
"""
def __init__(self, **kwargs):
super().__init__(**kwargs)
# Store patch information
self.c = kwargs.get("c")
self.d = kwargs.get("d")
self.x0 = kwargs.get("x")
self.y0 = kwargs.get("y")
# Initialize Fourier coef calcs
self.m = np.array(range(1,50))
self.n = np.array(range(1,50))
def p(self, x, y):
if x < self.x0 + self.c and x > self.x0 - self.c and y < self.y0 + self.d and y > self.y0 - self.d:
return self.p0
else:
return 0.0
def Pmn(self, m, n):
x = 4.0*self.p0/(np.pi**2*m*n*self.c*self.d)
x *= np.sin(m*np.pi*self.x0/self.plate.a)
x *= np.sin(n*np.pi*self.y0/self.plate.b)
x *= np.sin(m*np.pi*self.c/self.plate.a)
x *= np.sin(n*np.pi*self.d/self.plate.b)
return x
def F_total(self):
return 4.0*self.c*self.d*self.p0