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
| from ctypes import *
|
| TS_SUCCESS=0
| TS_FAIL=1
|
| TS_ID_FILAMENT=1
|
| TS_COORD_CARTESIAN=0
| TS_COORD_SPHERICAL=1
| TS_COORD_CYLINDRICAL=2
|
|
| class ts_coord(Structure):
| _fields_=[
| ("e1", c_double),
| ("e2", c_double),
| ("e3", c_double),
| ("coord_type", c_uint)
| ]
| class ts_vertex(Structure):
| pass
| class ts_bond(Structure):
| pass
| class ts_triangle(Structure):
| pass
| class ts_cell(Structure):
| pass
| class ts_poly(Structure):
| pass
| class ts_cluster(Structure):
| pass
| ts_vertex._fields_=[
| ('idx',c_uint),
| ('x',c_double),
| ('y',c_double),
| ('z',c_double),
| ('neigh_no',c_uint),
| ('neigh', POINTER(POINTER(ts_vertex))),
| ('bond_length', POINTER(c_double)),
| ('bond_length_dual',POINTER(c_double)),
| ('curvature', c_double),
| ('energy', c_double),
| ('energy_h',c_double),
| ('tristar_no', c_uint),
| ('tristar', POINTER(POINTER(ts_triangle))),
| ('bond_no',c_uint),
| ('bond',POINTER(POINTER(ts_bond))),
| ('cell',POINTER(ts_cell)),
| ('xk',c_double),
| ('c',c_double),
| ('id', c_uint),
| ('projArea',c_double),
| ('relR', c_double),
| ('solAngle', c_double),
| ('grafted_poly', POINTER(ts_poly)),
| ('cluster',POINTER(ts_cluster)),
| ]
| class ts_vertex_list(Structure):
| _fields_=[('n',c_uint), ('vtx',POINTER(POINTER(ts_vertex)))]
|
| ts_bond._fields_=[('idx',c_uint),
| ('vtx1', POINTER(ts_vertex)),
| ('vtx2', POINTER(ts_vertex)),
| ('bond_length',c_double),
| ('bond_length_dual',c_double),
| ('tainted', c_char),
| ('energy',c_double),
| ('x',c_double),
| ('y',c_double),
| ('z',c_double),
| ]
| class ts_bond_list(Structure):
| _fields_=[('n', c_uint),('bond',POINTER(POINTER(ts_bond)))]
|
| ts_triangle._fields_=[
| ('idx',c_uint),
| ('vertex', POINTER(ts_vertex)*3),
| ('neigh_no',c_uint),
| ('neigh', POINTER(POINTER(ts_triangle))),
| ('xnorm', c_double),
| ('ynorm', c_double),
| ('znorm', c_double),
| ('area', c_double),
| ('volume', c_double),
| ('energy', c_double),
| ]
|
| class ts_triangle_list(Structure):
| _fields_=[('n',c_uint),('a0',c_double),('tria', POINTER(POINTER(ts_triangle))),]
|
|
| ts_cell._fields_=[
| ('idx', c_uint),
| ('vertex', POINTER(POINTER(ts_vertex))),
| ('nvertex', c_uint),
| ]
|
| class ts_cell_list(Structure):
| _fields_=[
| ('ncmax', c_uint*3),
| ('cellno', c_uint),
| ('cell',POINTER(POINTER(ts_cell))),
| ('dcell', c_double),
| ('shift', c_double),
| ('max_occupancy', c_double),
| ('dmin_interspecies', c_double)
| ]
|
| class ts_spharm(Structure):
| _fields_=[
| ('l',c_uint),
| ('ulm', POINTER(POINTER(c_double))),
| # ('ulmComplex', POINTER(POINTER(gsl_complex))), #poisci!!!!
| ('ulmComplex', POINTER(POINTER(c_double))), #temporary solution
| ('sumUlm2', POINTER(POINTER(c_double))),
| ('N', c_uint),
| ('co',POINTER(POINTER(c_double))),
| ('Ylmi', POINTER(POINTER(c_double))),
| ]
|
| ts_poly._fields_=[
| ('vlist', POINTER(ts_vertex_list)),
| ('blist', POINTER(ts_bond_list)),
| ('grafted_vtx',POINTER(ts_vertex)),
| ('k', c_double),
| ]
|
| class ts_poly_list(Structure):
| _fields_=[('n',c_uint),('poly',POINTER(POINTER(ts_poly)))]
|
| class ts_tape(Structure):
| _fields_=[
| ('nshell',c_long),
| ('ncxmax',c_long),
| ('ncymax',c_long),
| ('nczmax',c_long),
| ('npoly',c_long),
| ('nmono',c_long),
| ('internal_poly',c_long),
| ('nfil',c_long),
| ('nfono', c_long),
| ('R_nucleus',c_long),
| ('R_nucleusX',c_double),
| ('R_nucleusY',c_double),
| ('R_nucleusZ',c_double),
| ('pswitch',c_long),
| ('constvolswitch',c_long),
| ('constareaswitch',c_long),
| ('stretchswitch',c_long),
| ('xkA0',c_double),
| ('constvolprecision',c_double),
| ('multiprocessing',c_char_p),
| ('brezveze0',c_long),
| ('brezveze1',c_long),
| ('brezveze2',c_long),
| ('xk0',c_double),
| ('dmax',c_double),
| ('dmin_interspecies',c_double),
| ('stepsize',c_double),
| ('kspring',c_double),
| ('xi',c_double),
| ('pressure',c_double),
| ('iterations',c_long),
| ('inititer',c_long),
| ('mcsweeps',c_long),
| ('quiet',c_long),
| ('shc',c_long),
| ('number_of_vertice_with_c0',c_long),
| ('c0', c_double),
| ('w', c_double),
| ('F', c_double),
| ]
|
|
| class ts_vesicle(Structure):
| _fields_=[
| ('vlist', POINTER(ts_vertex_list)),
| ('blist', POINTER(ts_bond_list)),
| ('tlist', POINTER(ts_triangle_list)),
| ('clist', POINTER(ts_cell_list)),
| ('nshell', c_uint),
| ('bending_rigidity',c_double),
| ('dmax',c_double),
| ('stepsize',c_double),
| ('cm', c_double*3),
| ('volume', c_double),
| ('sphHarmonics',POINTER(ts_spharm)),
| ('poly_list', POINTER(ts_poly_list)),
| ('filament_list', POINTER(ts_poly_list)),
| ('spring_constant', c_double),
| ('pressure', c_double),
| ('pswitch', c_int),
| ('tape', POINTER(ts_tape)),
| ('R_nucleus', c_double),
| ('R_nucleusX', c_double),
| ('R_nucleusY', c_double),
| ('R_nucleusZ', c_double),
| ('nucleus_center', c_double *3 ),
| ('area', c_double),
| ]
|
| ts_cluster._fields_=[('nvtx',c_uint),('idx',c_uint),('vtx', POINTER(POINTER(ts_vertex)))]
|
| class ts_cluster_list(Structure):
| _fields_=[('n',c_uint),('cluster',POINTER(POINTER(ts_cluster)))]
|
|
|
|
| ts=CDLL('libtrisurf.so')
|
|
|
| #function call wrappers
| def create_vesicle_from_tape(tape):
| """Using pointer for tape, it creates a vesicle, returning pointer to it."""
| ts.create_vesicle_from_tape.argtype=POINTER(ts_tape)
| ts.create_vesicle_from_tape.restype=POINTER(ts_vesicle)
| return ts.create_vesicle_from_tape(tape)
|
| def parsetape(filename='tape'):
| """Loads tape with filename (if not given it defaults to 'tape'). It returns a pointer to structure for tape"""
| ts.parsetape.restype=POINTER(ts_tape)
| ts.parsetape.argtype=[c_char_p]
| return ts.parsetape(filename.encode('ascii'))
|
| def parseDump(filename):
| """Loads a vtu file with 'filename' and creates a vesicle returning pointer to it"""
| ts.parseDump.argtype=[c_char_p]
| ts.parseDump.restype=POINTER(ts_vesicle)
| vesicle=ts.parseDump(filename.encode('ascii'))
| return vesicle
|
| def single_timestep(vesicle):
| """Makes a single timestep in simulations. Returns a tuple of vmsrt and bfrt (vertex move success rate and bond flip success rate)"""
| ts.single_timestep.argtype=[POINTER(ts_vesicle),POINTER(c_double),POINTER(c_double)]
| vmsrt=c_double(0.0)
| bfsrt=c_double(0.0)
| ts.single_timestep(vesicle,byref(vmsrt),byref(bfsrt))
| return (vmsrt.value, bfsrt.value)
|
| def write_vertex_xml_file(vesicle,timestep_no=0):
| """Writes a vesicle into file with filename 'timestep_XXXXXX.vtu', where XXXXXX is a leading zeroed number given with timestep_no parameter (defaults to 0 if not given"""
| ts.write_vertex_xml_file.argtypes=[POINTER(ts_vesicle),c_int]
| ts.write_vertex_xml_file(vesicle,c_int(timestep_no))
|
|
| def vesicle_free(vesicle):
| """Free memory of the whole vesicle"""
| ts.vesicle_free.argtype=[POINTER(ts_vesicle)]
| ts.vesicle_free(vesicle)
|
| def vesicle_volume(vesicle):
| ts.vesicle_volume.argtype=[POINTER(ts_vesicle)]
| ts.vesicle_volume(vesicle)
|
| def vesicle_area(vesicle):
| ts.vesicle_area.argtype=[POINTER(ts_vesicle)]
| ts.vesicle_area(vesicle)
|
| def gyration_eigen(vesicle):
| ts.gyration_eigen.argtype=[POINTER(ts_vesicle), POINTER(c_double), POINTER(c_double), POINTER(c_double)]
| l1=c_double(0.0)
| l2=c_double(0.0)
| l3=c_double(0.0)
| ts.gyration_eigen(vesicle , byref(l1), byref(l2), byref(l3))
| return (l1.value, l2.value, l3.value)
|
| def vesicle_meancurvature(vesicle):
| ts.vesicle_meancurvature.argtype=[POINTER(ts_vesicle)]
| ts.vesicle_meancurvature.restype=c_double
| return ts.vesicle_meancurvature(vesicle)
|
| def init_cluster_list():
| ts.init_cluster_list.restype=POINTER(ts_cluster_list)
| ret=ts.init_cluster_list()
| return ret
|
| def clusterize_vesicle(vesicle, cluster_list):
| ts.clusterize_vesicle.argtype=[POINTER(ts_vesicle), POINTER(ts_cluster_list)]
| ts.clusterize_vesicle(vesicle, cluster_list)
|
| def cluster_list_free(cluster_list):
| """Free memory of cluster list"""
| ts.cluster_list_free.argtype=[POINTER(ts_cluster_list)]
| ts.cluster_list_free(cluster_list)
|
| def stretchenergy(vesicle, triangle):
| ts.stretchenergy.argtype=[POINTER(ts_vesicle), POINTER(ts_triangle)]
| ts.stretchenergy(vesicle,triangle)
|
| def get_absolute_ulm2(vesicle,l,m):
| ts.get_absolute_ulm2.argtype=[POINTER(ts_vesicle), c_double, c_double]
| ts.get_absolute_ulm2.restype=c_double
| ret=ts.get_absolute_ulm2(vesicle,l,m)
| return ret
|
| def getR0(vesicle):
| ts.getR0.argtype=[POINTER(ts_vesicle)]
| ts.getR0.restype=c_double
| r0=ts.getR0(vesicle)
| return r0
|
| def preparationSh(vesicle,r0):
| ts.preparationSh.argtype=[POINTER(ts_vesicle), c_double]
| ts.preparationSh(vesicle,float(r0))
|
| def calculateUlmComplex(vesicle):
| ts.calculateUlmComplex.argtype=[POINTER(ts_vesicle)]
| ts.calculateUlmComplex(vesicle)
|
| def solve_for_ulm2(vesicle):
| ts.solve_for_ulm2.argtype=[POINTER(ts_vesicle)]
| ts.solve_for_ulm2(vesicle)
|
| def mean_curvature_and_energy(vesicle):
| ts.mean_curvature_and_energy.argtype=[POINTER(ts_vesicle)]
| ts.mean_curvature_and_energy(vesicle)
|
|