-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathLEEPO.py
553 lines (377 loc) · 19.8 KB
/
LEEPO.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
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
#!/usr/bin/python
# -*- coding: utf-8 -*-
'''
@author:Naveen Kumar Vasudevan,
400107764,
Doctoral Student,
The Xi Research Group,
Department of Chemical Engineering,
McMaster University,
Hamilton,
Canada.
https://naveenovan.wixsite.com/kuroonai
This program was made based on the following research work:
Xu, Xiaoming, Mansoor A. Khan, and Diane J. Burgess. "Predicting hydrophilic
drug encapsulation inside unilamellar liposomes."
International journal of pharmaceutics 423.2 (2012): 410-418.
DOI : https://doi.org/10.1016/j.ijpharm.2011.12.019
# Python code to calculate Encapuslation efficiecny of Liposomes
(L)iposome
(E)ncapsulation
(E)fficiency
(P)redictor &
(O)ptimizer
# Program Usage : python LEEPO-sphere.py mu sigma, sizerange ...
# Example command : python LEEPO.py 190.0 38.0 1000 0.23 5.2 0.45 140 5 60.04
Enter the system parameters in the order of:
1. Mean (μ - nm {float})
2. Standard deviation (σ - nm {float})
3. Size range (eg: for 1-1000 nm enter "1000")
4. Anticipated defect (% {float})
5. Bilayer thickness (d - nm)
6. Molecular area of lipid (a - nm^2)
7. Lipid molar concentration (c - mMol/L)
8. Total volume (V - ml)
9. Expected Encapsulation efficiency (%) [optional] - provide only if defect value optimization is required.
'''
import sys
import os
import matplotlib.pyplot as plt; plt.rcdefaults()
import math
from scipy import constants as cons
import time
#descrip='Enter the system parameters in the order of:\n\n1. Mean (mu - nm {float})\n2. Standard deviation (sigma - nm {float})\n3. Size range (eg: for 1-1000 nm enter "1000")\n4. Anticipated defect (% {float})\n5. membrane thickness (d - nm)\n6. Molecular area of lipid (a - nm^2)\n7. Lipid molar concentration (c - mMol/L)\n8. Total volume (V - ml)\n9. Expected Encapsulation efficiency (%) [optional]'
#parser = argparse.ArgumentParser(description=descrip, formatter_class=argparse.RawTextHelpFormatter)
#args = parser.parse_args()
timer=time.time()
if len(sys.argv) < 9 or len(sys.argv) > 10:
print('\n\nSyntax error encountered:\n\nUsage:\n\nEnter the system parameters in the order of:\n\n1. Mean (μ - nm)\n2. Standard deviation (σ - nm)\n3. Size range (eg: for 1-1000 nm enter "1000")\n4. Anticipated defect (%)\n5. Bilayer thickness (d - nm)\n6. Molecular area of lipid (a - nm^2)\n7. Lipid molar concentration (c - mMol/L)\n8. Total volume (V - ml)\n9. Expected Encapsulation efficiency (%) [optional]\n\n')
raise Exception("Syntax: *.py mu sd ...")
cwd = os.getcwd()
if os.name=='nt':folder='%s\\LEEPO-plots'%cwd
elif os.name=='posix':folder='%s/LEEPO-plots'%cwd
if os.path.isdir(folder):
os.chdir(folder)
else:
os.mkdir('LEEPO-plots')
os.chdir(folder)
mu, sigma, sizerange, defect, d, molarea, c, V = float(sys.argv[1]),float(sys.argv[2]),int(sys.argv[3]),float(sys.argv[4]),float(sys.argv[5]),float(sys.argv[6]),float(sys.argv[7]),float(sys.argv[8])
if len(sys.argv) == 10:expEE = float(sys.argv[9])
print("\nInput values are as follows:\n")
print("Mean (μ) - %.4f nm\n"%mu)
print("\tStandard deviation (σ) - %.4f nm\n" %sigma)
print("\t\tSize range - %d nm\n" %sizerange)
print("\t\t\tDefect - %.4f %%\n" %defect)
print("\t\t\t\tLipid bilayer thickness (d) - %.4f nm\n" %d)
print("\t\t\t\t\tLipid molecular area (a) - %.4f nm^2\n" %molarea)
print("\t\t\t\t\t\tLiposome molar concentration (c)- %.4f mMol/L\n" %c)
print("\t\t\t\t\t\t\tTotal volume (V) - %.4f ml\n" %V)
if len(sys.argv) == 10:print("\t\t\t\t\t\t\t\tExpected/Experimental EE- %.4f %%\n" %expEE)
EE=0
EE_back=0
iteration=0
max_defect="yes"
def plotEE(ev, ee):
labels = 'Encapsulated', 'Free'
sizes = [sum(ev), V-sum(ev)]
colors = ['Green', 'Red']
explode = (0.0, 0.1) # explode 1st slice
# Plot
plt.pie(sizes, explode=explode, labels=labels, colors=colors,
autopct='%1.2f%%', shadow=True, startangle=100)
plt.axis('equal')
#plt.show()
if abs(ee-expEE) >= abs(float(0.01)):
plt.title("LEEPO-Predicted EE")
plt.savefig("LEEPO-predicted.pdf", bbox_inches='tight')
plt.close()
elif abs(ee-expEE) <= abs(float(0.01)):
plt.title("LEEPO-Optimized EE")
plt.savefig("LEEPO-Optimised.pdf", bbox_inches='tight')
plt.close()
return()
def plotEE_old(ev, ee):
labels = 'Encapsulated', 'Free'
sizes = [sum(ev), V-sum(ev)]
colors = ['Green', 'Red']
explode = (0.0, 0.1) # explode 1st slice
# Plot
plt.pie(sizes, explode=explode, labels=labels, colors=colors,
autopct='%1.2f%%', shadow=True, startangle=100)
plt.axis('equal')
#plt.show()
plt.title("Old Model's - Predicted EE")
plt.savefig("old model-predicted.pdf", bbox_inches='tight')
plt.close()
return()
def complotter(p1,p2,lst,lst1,colour,colour1,ylab,title,name):
print(("\n\tPlotting %s")%title)
plt.figure()
plt.plot(p1,linestyle=lst, color=colour,lw=1.0, label='Predicted')
plt.plot(p2,linestyle=lst1, color=colour1,lw=1.0, label='Optimized')
plt.title(title)
plt.xlabel('Vesticle size (nm)')
plt.ylabel(ylab)
plt.legend(loc='best')
plt.savefig(name, bbox_inches='tight')
plt.close('all')
def compareplot(mu, sigma, sizerange, defect,defect1, d, molarea, c, V):
sigbymu=sigma/mu
x=list(range(1,sizerange+1)) #particle side/dia in (nm)
p=[0]*sizerange #probability of given size
dx=[0]*sizerange
v_in=[0]*sizerange #internal volume micro - L
area_out=[0]*sizerange # outer surface area nm2
area_in=[0]*sizerange # inner surface area nm2
lnum_out=[0]*sizerange #lipid molecule number out
lnum_in=[0]*sizerange #lipid molecule number in
k=[0]*sizerange #lipid number per incident
vesiclenumber=[0]*sizerange
entrapvolume=[0]*sizerange
dx1=[0]*sizerange
v_in1=[0]*sizerange #internal volume micro - L
area_out1=[0]*sizerange # outer surface area nm2
area_in1=[0]*sizerange # inner surface area nm2
lnum_out1=[0]*sizerange #lipid molecule number out
lnum_in1=[0]*sizerange #lipid molecule number in
k1=[0]*sizerange #lipid number per incident
vesiclenumber1=[0]*sizerange
entrapvolume1=[0]*sizerange
print("\nplotting the predicted and optimised outputs for comparison\n")
for i in range(0,sizerange):
#probability with no unit
p[i]=(1/math.sqrt(2 * math.pi * (sigbymu)**2 * x[i]**2) ) * math.exp((math.log(x[i])-math.log(mu))**2/(-2 * (sigbymu)**2))
#defect in terms of the probability
for i in range(0,sizerange):
dx[i] = defect*(p[i]/max(p))
dx1[i] = defect1*(p[i]/max(p))
for i in range(0,sizerange):
#internal volume in (micro L)
v_in[i]=( (4/3) * math.pi * (float(x[i])/2 - d)**3 * (1-dx[i]) + (4/3) * math.pi * (float(x[i])/2 - d/2)**3 * dx[i] ) * 10**-18
v_in1[i]=( (4/3) * math.pi * (float(x[i])/2 - d)**3 * (1-dx1[i]) + (4/3) * math.pi * (float(x[i])/2 - d/2)**3 * dx1[i] ) * 10**-18
#outer surface area
area_out[i]= 4 * math.pi * (float(x[i])/2)**2
area_out1[i]= 4 * math.pi * (float(x[i])/2)**2
#inner surface area
if x[i] < d:
area_in[i]=0
area_in1[i]=0
else:
area_in[i]= 4 * math.pi * (float(x[i])/2 - d)**2 * (1-dx[i]) + 4 * math.pi * (float(x[i])/2 - d/2)**2 * dx[i]
area_in1[i]= 4 * math.pi * (float(x[i])/2 - d)**2 * (1-dx1[i]) + 4 * math.pi * (float(x[i])/2 - d/2)**2 * dx1[i]
lnum_out[i]=area_out[i]/molarea
lnum_in[i]=area_in[i]/molarea
lnum_out1[i]=area_out1[i]/molarea
lnum_in1[i]=area_in1[i]/molarea
k[i]=p[i]*(lnum_out[i]+lnum_in[i])
k1[i]=p[i]*(lnum_out1[i]+lnum_in1[i])
m=c*V*cons.N_A/10**6/sum(k)
m1=c*V*cons.N_A/10**6/sum(k1)
for i in range(0,sizerange):
vesiclenumber[i]=m*p[i]
entrapvolume[i]=vesiclenumber[i]*v_in[i]/1000
vesiclenumber1[i]=m1*p[i]
entrapvolume1[i]=vesiclenumber1[i]*v_in1[i]/1000
complotter(dx,dx1,'-','-','r','g','Defect %','Defect Percentage','LEEPO-defect.pdf')
complotter(v_in,v_in1,'-','-','r','g',r'Internal volume ($\mu$l)','Internal volume','LEEPO-V_internal.pdf')
complotter(area_out,area_out1,'-','-','r','g','a_out (nm^2)','Outer Surface area','LEEPO-area_outer.pdf')
complotter(area_in,area_in1,'-','-','r','g','a_in (nm^2)','Inner Surface area','LEEPO-area_inner.pdf')
complotter(lnum_out,lnum_out1,'-','-','r','g','# units','Outer Lipid units','LEEPO-lin.pdf')
complotter(lnum_in,lnum_in1,'-','-','r','g','# units','Inner Lipid units','LEEPO-lout.pdf')
complotter(k,k1,'-','-','r','g','# units','Lipid units','LEEPO-lipid units.pdf')
complotter(vesiclenumber,vesiclenumber1,'-','-','r','g','# units','Vesicle number','LEEPO-Vesiclenumber.pdf')
complotter(entrapvolume,entrapvolume1,'-','-','r','g','Entraped volume (ml)','Entraped volume','LEEPO-entrapvol.pdf')
print(("\nPlots completed and can be accessed at '%s'\n")%folder)
def max_defect (mu, sigma, sizerange, defect, d, molarea, c, V, EE):
sigbymu=sigma/mu
x=list(range(1,sizerange+1)) #particle side/dia in (nm)
p=[0]*sizerange #probability of given size
dx=[0]*sizerange
v_in=[0]*sizerange #internal volume micro - L
area_out=[0]*sizerange # outer surface area nm2
area_in=[0]*sizerange # inner surface area nm2
lnum_out=[0]*sizerange #lipid molecule number out
lnum_in=[0]*sizerange
k=[0]*sizerange
vesiclenumber=[0]*sizerange
entrapvolume=[0]*sizerange
EE_new=EE
defect_old=defect
iteration=0
print('\nOptimal range determination step begins !!\n')
while abs(EE_new-74.05) >= abs(float(0.01)):
if EE_new < 74.05: defect=defect+(abs(EE_new-74.05)/10)
elif EE_new > 74.05: defect=defect-(abs(EE_new-74.05)/10)
#else: exit()
for i in range(0,sizerange):
#probability with no unit
p[i]=(1/math.sqrt(2 * math.pi * (sigbymu)**2 * x[i]**2) ) * math.exp((math.log(x[i])-math.log(mu))**2/(-2 * (sigbymu)**2))
#defect in terms of the probability
for i in range(0,sizerange):
dx[i] = defect*(p[i]/max(p))
for i in range(0,sizerange):
#internal volume in (micro L)
v_in[i]=( (4/3) * math.pi * (float(x[i])/2 - d)**3 * (1-dx[i]) + (4/3) * math.pi * (float(x[i])/2 - d/2)**3 * dx[i] ) * 10**-18
#outer surface area
area_out[i]= 4 * math.pi * (float(x[i])/2)**2
#inner surface area
if x[i] < d:area_in[i]=0
else:
area_in[i]= 4 * math.pi * (float(x[i])/2 - d)**2 * (1-dx[i]) + 4 * math.pi * (float(x[i])/2 - d/2)**2 * dx[i]
lnum_out[i]=area_out[i]/molarea
lnum_in[i]=area_in[i]/molarea
k[i]=p[i]*(lnum_out[i]+lnum_in[i])
m=c*V*cons.N_A/10**6/sum(k)
for i in range(0,sizerange):
vesiclenumber[i]=m*p[i]
entrapvolume[i]=vesiclenumber[i]*v_in[i]/1000
EE_new=sum(entrapvolume)/V * 100
print(("Iteration No: %d ##############################")%iteration)
print(("\n\t\tThe encapsulation efficiency for the system at interation %d is %.4f %% , The defect is %.4f %%, Δ efficiency = %.4f %%\n")%(iteration,EE_new,abs(defect),abs(EE_new-expEE)))
print(("\t\tThe entrapment volume is %.4f μl/μmol\n")%(sum(entrapvolume)/(c*V)*1000))
iteration=iteration+1
#if abs(EE_new-expEE) != abs(0.0001):exit
print(("\nThe optimal Encapsulation efficiency range we can expect before liposome degradation is %.4f - %.4f %%")%(EE,EE_new))
print(("\n\nThe Optimal defect/void %% is between %.4f - %.4f %%\n")%(abs(defect_old),defect))
def encap_opt (mu, sigma, sizerange, defect, d, molarea, c, V, EE):
sigbymu=sigma/mu
x=list(range(1,sizerange+1)) #particle side/dia in (nm)
p=[0]*sizerange #probability of given size
dx=[0]*sizerange
v_in=[0]*sizerange #internal volume micro - L
area_out=[0]*sizerange # outer surface area nm2
area_in=[0]*sizerange # inner surface area nm2
lnum_out=[0]*sizerange #lipid molecule number out
lnum_in=[0]*sizerange
k=[0]*sizerange
vesiclenumber=[0]*sizerange
entrapvolume=[0]*sizerange
EE_new=EE
iteration=0
print('Optimization step begins !!\n')
while abs(EE_new-expEE) >= abs(float(0.00001)):
if EE_new < expEE: defect=defect+(abs(EE_new-expEE)/10)
elif EE_new > expEE: defect=defect-(abs(EE_new-expEE)/10)
#else: exit()
for i in range(0,sizerange):
#probability with no unit
p[i]=(1/math.sqrt(2 * math.pi * (sigbymu)**2 * x[i]**2) ) * math.exp((math.log(x[i])-math.log(mu))**2/(-2 * (sigbymu)**2))
#defect in terms of the probability
for i in range(0,sizerange):
dx[i] = defect*(p[i]/max(p))
for i in range(0,sizerange):
#internal volume in (micro L)
v_in[i]=( (4/3) * math.pi * (float(x[i])/2 - d)**3 * (1-dx[i]) + (4/3) * math.pi * (float(x[i])/2 - d/2)**3 * dx[i] ) * 10**-18
#outer surface area
area_out[i]= 4 * math.pi * (float(x[i])/2)**2
#inner surface area
if x[i] < d:area_in[i]=0
else:
area_in[i]= 4 * math.pi * (float(x[i])/2 - d)**2 * (1-dx[i]) + 4 * math.pi * (float(x[i])/2 - d/2)**2 * dx[i]
lnum_out[i]=area_out[i]/molarea
lnum_in[i]=area_in[i]/molarea
k[i]=p[i]*(lnum_out[i]+lnum_in[i])
m=c*V*cons.N_A/10**6/sum(k)
for i in range(0,sizerange):
vesiclenumber[i]=m*p[i]
entrapvolume[i]=vesiclenumber[i]*v_in[i]/1000
EE_new=sum(entrapvolume)/V * 100
print(("Iteration No: %d ##############################")%iteration)
print(("\n\t\tThe encapsulation efficiency for the system at interation %d is %.4f %% , The defect is %.4f %%, Δ efficiency = %.4f %%\n")%(iteration,EE_new,defect,abs(EE_new-expEE)))
print(("\t\tThe entrapment volume is %.4f μl/μmol\n")%(sum(entrapvolume)/(c*V)*1000))
iteration=iteration+1
#if abs(EE_new-expEE) != abs(0.0001):exit
print('Optimization ends!!\n\n')
print(('The optimized values are :\n\nExpected EE \t\t- %.4f %%\n\nEE predicted by model \t- %.4f %%\n\nEE Optimized by model \t- %.4f %%\n\nDefect Percentage \t- %.4f %%\n\nTotal Vesicles \t\t- %.4E\n\nTotal internal volume \t- %.4f ml\n\nEntrapment volume \t- %.4f μl/μmol\n\nNumber of optimization steps - %d steps\n\n')%(expEE,EE,EE_new,abs(defect),m,sum(entrapvolume),sum(entrapvolume)/(c*V)*1000,iteration-1))
max_defect (mu, sigma, sizerange, defect, d, molarea, c, V, EE_new)
print(('\n\nThe total execution time is %s seconds\n\n')%(time.time()-timer))
plotEE(entrapvolume, EE_new)
compareplot(mu, sigma, sizerange, float(sys.argv[4]),defect, d, molarea, c, V)
def encap_old (mu, sigma, sizerange, defect, d, molarea, c, V):
sigbymu=sigma/mu
x=list(range(1,sizerange+1)) #particle side/dia in (nm)
p=[0]*sizerange #probability of given size
dx=[0]*sizerange
v_in=[0]*sizerange #internal volume micro - L
area_out=[0]*sizerange # outer surface area nm2
area_in=[0]*sizerange # inner surface area nm2
lnum_out=[0]*sizerange #lipid molecule number out
lnum_in=[0]*sizerange #lipid molecule number in
k=[0]*sizerange #lipid number per incident
vesiclenumber=[0]*sizerange
entrapvolume=[0]*sizerange
for i in range(0,sizerange):
#probability with no unit
p[i]=(1/math.sqrt(2 * math.pi * (sigbymu)**2 * x[i]**2) ) * math.exp((math.log(x[i])-math.log(mu))**2/(-2 * (sigbymu)**2))
#defect in terms of the probability
for i in range(0,sizerange):
dx[i] = defect*(p[i]/max(p))
for i in range(0,sizerange):
#internal volume in (micro L)
v_in[i]=( (4/3) * math.pi * (float(x[i])/2 - d)**3 * (1-dx[i]) + (4/3) * math.pi * (float(x[i])/2 - d/2)**3 * dx[i] ) * 10**-18
#outer surface area
area_out[i]= 4 * math.pi * (float(x[i])/2)**2
#inner surface area
if x[i] < d:area_in[i]=0
else:
area_in[i]= 4 * math.pi * (float(x[i])/2 - d)**2 * (1-dx[i]) + 4 * math.pi * (float(x[i])/2 - d/2)**2 * dx[i]
lnum_out[i]=area_out[i]/molarea
lnum_in[i]=area_in[i]/molarea
k[i]=p[i]*(lnum_out[i]+lnum_in[i])
m=c*V*cons.N_A/10**6/sum(k)
for i in range(0,sizerange):
vesiclenumber[i]=m*p[i]
entrapvolume[i]=vesiclenumber[i]*v_in[i]/1000
EE=sum(entrapvolume)/V * 100
print("\nW.R.T Existing model with no parameter for defect:\n\n")
print(("\n\t\tThe encapsulation efficiency for the system is %.4f %%\n\n")%(EE))
print(("\n\t\tThe entrapment volume is %.4f μl/μmol\n")%(sum(entrapvolume)/(c*V)*1000))
print(('\n\t\tTotal Vesicles \t\t- %.4E\n\n\t\tTotal internal volume \t- %.4f ml\n\n\t\tEntrapment volume \t- %.4f μl/μmol\n\n')%(m,sum(entrapvolume),sum(entrapvolume)/(c*V)*1000))
plotEE_old(entrapvolume, EE)
def encap (mu, sigma, sizerange, defect, d, molarea, c, V):
sigbymu=sigma/mu
x=list(range(1,sizerange+1)) #particle side/dia in (nm)
p=[0]*sizerange #probability of given size
dx=[0]*sizerange
v_in=[0]*sizerange #internal volume micro - L
area_out=[0]*sizerange # outer surface area nm2
area_in=[0]*sizerange # inner surface area nm2
lnum_out=[0]*sizerange #lipid molecule number out
lnum_in=[0]*sizerange #lipid molecule number in
k=[0]*sizerange #lipid number per incident
vesiclenumber=[0]*sizerange
entrapvolume=[0]*sizerange
for i in range(0,sizerange):
#probability with no unit
p[i]=(1/math.sqrt(2 * math.pi * (sigbymu)**2 * x[i]**2) ) * math.exp((math.log(x[i])-math.log(mu))**2/(-2 * (sigbymu)**2))
#defect in terms of the probability
for i in range(0,sizerange):
dx[i] = defect*(p[i]/max(p))
for i in range(0,sizerange):
#internal volume in (micro L)
v_in[i]=( (4/3) * math.pi * (float(x[i])/2 - d)**3 * (1-dx[i]) + (4/3) * math.pi * (float(x[i])/2 - d/2)**3 * dx[i] ) * 10**-18
#outer surface area
area_out[i]= 4 * math.pi * (float(x[i])/2)**2
#inner surface area
if x[i] < d:area_in[i]=0
else:
area_in[i]= 4 * math.pi * (float(x[i])/2 - d)**2 * (1-dx[i]) + 4 * math.pi * (float(x[i])/2 - d/2)**2 * dx[i]
lnum_out[i]=area_out[i]/molarea
lnum_in[i]=area_in[i]/molarea
k[i]=p[i]*(lnum_out[i]+lnum_in[i])
m=c*V*cons.N_A/10**6/sum(k)
for i in range(0,sizerange):
vesiclenumber[i]=m*p[i]
entrapvolume[i]=vesiclenumber[i]*v_in[i]/1000
EE=sum(entrapvolume)/V * 100
print(("\n\t\tThe encapsulation efficiency for the system is %.4f %%\n\n")%(EE))
print(("\n\t\tThe entrapment volume is %.4f μl/μmol\n")%(sum(entrapvolume)/(c*V)*1000))
print(('\n\t\tDefect Percentage \t- %.4f%%\n\n\t\tTotal Vesicles \t\t- %.4E\n\n\t\tTotal internal volume \t- %.4f ml\n\n\t\tEntrapment volume \t- %.4f μl/μmol\n\n')%(defect,m,sum(entrapvolume),sum(entrapvolume)/(c*V)*1000))
encap_old (mu, sigma, sizerange, 0, d, molarea, c, V)
if 'expEE' in globals() and abs(EE-expEE) >= abs(float(0.01)):
encap_opt (mu, sigma, sizerange, defect, d, molarea, c, V, EE)
else:return
plotEE(entrapvolume, EE)
encap (mu, sigma, sizerange, defect, d, molarea, c, V)
exit()