-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbending_energies_functions.py
377 lines (275 loc) · 12.9 KB
/
bending_energies_functions.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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
# -*- coding: utf-8 -*-
"""
These functions can be used to calculate the surface areas and bending energies
of oblate spheroids, elliptic hyperboloids and combinations of oblate spheroids
and elliptic hyperboloids, as described in the publication 'A Biophysical
Model for Plant Cell Plate Development' by Jawaid et al. Further explanations
about how to use this codeare given in the functions.'
Authored by Muhammad Zaki Jawaid
Contact via email ([email protected]) for questions
Uploaded to GitHub 8/23/2020
"""
import numpy as np
from scipy import integrate
def surface_area_hyperboloid_generic(a,b,c,h):
"""
Input:
a (float): major axis radius at the center of the
hyperboloid
b (float): minor axis radius at the center of the
hyperboloid
c (float): measure of elongation of the hyperboloid along the
polar axis
h (float): height of the hyperboloid
Output:
Surface area of a elliptical one sheeted hyperboloid with
given a,b,c,h (float)
"""
#simplifyng variables
e = (b**2)*(c**2)
f = (a**2)*(c**2)
g = (a**2)*(b**2)
#u parameterizes the surface along the z-axis
#v goes from 0 to 2pi
integrand = lambda v,u : np.sqrt(e*(u**2+1)*(np.cos(v)**2)+f*(u**2+1)*
(np.sin(v)**2)+g*u*u)
i = lambda v : 0.0
j = lambda v : np.pi/2
return (8*integrate.dblquad(integrand,0,h/(2*c),i,j)[0])
def get_pd(a1,c1,a2,c2):
"""
This function is used to calculate pd.
pd is described as the penetration distance, or the shared distance of the
hyperboloid and the oblate spheroid, and is used to calculate the height
of the connected hyperboloid.
Input:
a1 (float) : major axis radius of the oblate spheroid that the
hyperboloid is connected to.
c1 (float) : minor axis radius of the oblate spheroid that the
hyperboloid is connected to.
a2 (float) : major axis radius of the hyperboloid at the center of the
hyperboloid.
c2 (float) : minor axis radius of the hyperboloid at the center of the
hyperboloid.
Output:
pd (float) : penetration distance, or the shared distance of the
hyperboloid and the oblate spheroid, and is used to
calculate the height of the connected hyperboloid.
"""
d = get_d(a1,c1,a2,c2)
pd = a1-d*(a2**2/(a2**2+c2**2))
return pd
def get_h(a1,c1,a2,c2):
"""
This function is used to calculate the height of a hyperboloid the is
connected to an oblate spheroid.
Input:
a1 (float) : major axis radius of the oblate spheroid that the
hyperboloid is connected to.
c1 (float) : minor axis radius of the oblate spheroid that the
hyperboloid is connected to.
a2 (float) : major axis radius of the hyperboloid at the center of the
hyperboloid.
c2 (float) : minor axis radius of the hyperboloid at the center of the
hyperboloid.
Output:
h (float) : height of a hyperboloid connected to an oblate spheroid.
"""
d = get_d(a1,c1,a2,c2)
h = 2*d*(1-a2**2/(a2**2+c2**2))
return h
def surface_area_hyperboloid(a1,c1,a2,c2):
"""
This functions returns the surface area of a one-sheeted elliptical
hyperboloid that is connected to an oblate spheroid such that curvature
continuity is maintained. Because of this constraint, Eqs. S2-S4 from the
supplemental information can be invoked.
Input:
a1 (float) : major axis radius of the oblate spheroid that the
hyperboloid is connected to.
c1 (float) : minor axis radius of the oblate spheroid that the
hyperboloid is connected to.
a2 (float) : major axis radius of the hyperboloid at the center of the
hyperboloid.
c2 (float) : minor axis radius of the hyperboloid at the center of the
hyperboloid.
Output:
Surface area of a one-sheeted elliptical hyperboloid
that is connected to an oblate spheroid (float).
"""
# the height, h, and the minor axis radius, b, of the hyperboloid is
# constrained by the oblate spheroid it is connected to because of
# continuity considerations, as explained in Eqs. S2 - S4.
# the get_h function calculates this h, and the expression for b is given below.
h = get_h(a1,c1,a2,c2)
b = a2*c1/a1
#simplifying variables
a = a2
c = c2
e = (b**2)*(c**2)
f = (a**2)*(c**2)
g = (a**2)*(b**2)
# u,v, parameterize the surface
#u is along z axis
#v goes from 0 to 2pi
integrand = lambda v,u : np.sqrt(e*(u**2+1)*(np.cos(v)**2)+f*(u**2+1)*
(np.sin(v)**2)+g*u*u)
i = lambda v : 0.0
j = lambda v : np.pi/2
return (8*integrate.dblquad(integrand,0,h/(2*c),i,j)[0])
def get_d(a1,c1,a2,c2):
"""
This function is used to calculate d.
d is described in Eq. S1 as the distance from the the center point of the
hyperboloid on the polar axis from the center of the connected oblate
spheroid, and is used to calculate the penetration depth
as well as the height of the connected hyperboloid.
Input:
a1 (float) : major axis radius of the oblate spheroid that the
hyperboloid is connected to.
c1 (float) : minor axis radius of the oblate spheroid that the
hyperboloid is connected to.
a2 (float) : major axis radius of the hyperboloid at the center of the
hyperboloid.
c2 (float) : minor axis radius of the hyperboloid at the center of the
hyperboloid.
Output:
d (float) : distance from the the center point of the
hyperboloid on the polar axis from the center of the
connected oblate spheroid.
"""
d = (np.sqrt(a1**2-a2**2))*(np.sqrt(a2**2+c2**2))/a2
return d
def surface_area_os(a,c):
"""
This function returns the surface area of an oblate spheroid,
given that a >= c.
Input:
a (float) : major axis of the oblate spheroid
c (float) : minor axis of the oblate spheroid
Output:
S (float) : surface area of the oblate spheroid
"""
if a == c:
return 4*np.pi*a*c
else:
ecc = np.sqrt(1.0-((c**2)/(a**2)))
S = 2*np.pi*(a**2)+(np.log((1+ecc)/(1-ecc)))*np.pi*(c**2)/(ecc)
return S
def surface_area_correction_os(a1,c1,a2,c2):
"""
This function calculates the area of within the intersection created
when an oblate spheroid and a hyperboloid are connected with the
constraint of curvature continuity.
Input:
a1 (float) : major axis radius of the oblate spheroid that the
hyperboloid is connected to.
c1 (float) : minor axis radius of the oblate spheroid that the
hyperboloid is connected to.
a2 (float) : major axis radius of the hyperboloid at the center of the
hyperboloid.
c2 (float) : minor axis radius of the hyperboloid at the center of the
hyperboloid.
Output:
area within intersection (float)
"""
#center offset distance as calculated in get_d
d = get_d(a1,c1,a2,c2)
#simplifying variables
cons = 1-(((d*(a2**2))/(a2**2+c2**2))**2)/(a1**2)
integrand = lambda u,v : (a1/np.sqrt(2))*np.sqrt(a1**2+c1**2+(a1**2-c1**2)*
np.cos(2*v))*np.sin(v)
i = lambda u : 0
j = lambda v : np.arcsin(np.sqrt((cons-np.cos(v)**2)/(np.sin(v)**2)))
v_i = np.arccos(np.sqrt(cons))
return (4*integrate.dblquad(integrand,v_i,np.pi/2,i,j)[0])
def bending_energy_os(a,c,c0,K):
"""
This functions calculates the mean curvature energy of an oblate spheriod
with major axis radius 'a', and minor axis radius 'c', given that a >= c.
Input:
a (float) : major axis of the oblate spheroid
c (float) : minor axis of the oblate spheroid
c0 (float): spontaneous curvature as described in Eq. 2
K (float) : bending rigidity, as described in Eq. 2
Output:
mean curvature energy of oblate spheroid (float)
"""
E = lambda x: ((K/2)*((np.sqrt(2)*c*(3*a**2+c**2+(a**2-c**2)*np.cos(2*x))/
(a*(a**2+c**2+(a**2-c**2)*np.cos(2*x))**1.5) -2*c0)**2)*
np.sqrt(2)*np.pi*a*(np.sqrt(a**2+c**2+(a**2-c**2)*np.cos(2*x)))
*np.sin(x))
return integrate.quad(E,0,np.pi)[0]
def bending_energy_hyperboloid(a1,c1,a2,c2,c0,K):
"""
This function calculates the mean curvature energy of an elliptical hyperboloid
that is connected to an oblate spheroid with curvature continuity.
Because of this constraint, Eqs. S2-S4 from the
supplemental information can be invoked.
Input:
a1 (float) : major axis radius of the oblate spheroid that the
hyperboloid is connected to.
c1 (float) : minor axis radius of the oblate spheroid that the
hyperboloid is connected to.
a2 (float) : major axis radius of the hyperboloid at the center of the
hyperboloid.
c2 (float) : minor axis radius of the hyperboloid at the center of the
hyperboloid.
c0 (float): spontaneous curvature as described in Eq. 2
K (float) : bending rigidity, as described in Eq. 2
Output:
bending energy of the hyperboloid (float)
"""
#calculating the height and the minor axis radius
h = get_h(a1,c1,a2,c2)
b = a2*c1/a1
#simplifying variables
a = a2
c = c2
e = (b**2)*(c**2)
f = (a**2)*(c**2)
g = (a**2)*(b**2)
integrand = lambda v,u : (((((a*b*c)*((b*b*u*u-a*a)*(np.sin(v)**2)+
(a*a*u*u-b*b)*(np.cos(v)**2)+
(u*u+1)*(c*c))/((e*(u**2+1)*
(np.cos(v)**2)+f*(u**2+1)*(np.sin(v)**2)+g*u*u)**1.5))-2*c0)**2)*
(np.sqrt(e*(u**2+1)*(np.cos(v)**2)+
f*(u**2+1)*(np.sin(v)**2)+g*u*u)))
i = lambda v : 0.0
j = lambda v : np.pi/2
return (0.5*K*(8*integrate.dblquad(integrand,0,h/(2*c),i,j)[0]))
def bending_energy_os_correction(a1,c1,a2,c2,c0,K):
"""
This function calculates the contribution to the mean curvature energy by
the surface area within the intersection that is created
when an oblate spheroid and a hyperboloid are connected with the
constraint of curvature continuity.
Input:
a1 (float) : major axis radius of the oblate spheroid that the
hyperboloid is connected to.
c1 (float) : minor axis radius of the oblate spheroid that the
hyperboloid is connected to.
a2 (float) : major axis radius of the hyperboloid at the center of the
hyperboloid.
c2 (float) : minor axis radius of the hyperboloid at the center of the
hyperboloid.
c0 (float): spontaneous curvature as described in Eq. 2
K (float) : bending rigidity, as described in Eq. 2
Output:
mean curvature energy cortribution due to
the area within intersection (float)
"""
#calculating offset distance
d=get_d(a1,c1,a2,c2)
#x is the theta angle (in the xy plane)
#we do the phi integral as a function of theta, then we do the theta integral
integrand = lambda x,u: (((K/2)*((np.sqrt(2)*c1*
(3*a1**2+c1**2+(a1**2-c1**2)*np.cos(2*x))/
(a1*(a1**2+c1**2+(a1**2-c1**2)*np.cos(2*x))**1.5) -2*c0)**2)*
np.sqrt(2)*np.pi*a1*(np.sqrt(a1**2+c1**2+(a1**2-c1**2)*np.cos(2*x)))*
np.sin(x))/(2*np.pi))
cons=1-(((d*(a2**2))/(a2**2+c2**2))**2)/(a1**2)
i = lambda u : 0
j = lambda x : np.arcsin(np.sqrt((cons-np.cos(x)**2)/(np.sin(x)**2)))
v_i = np.arccos(np.sqrt(cons))
return (4*integrate.dblquad(integrand,v_i,np.pi/2,i,j)[0])