From f039f4c3e44d77456521013030fb3e955e7d9a61 Mon Sep 17 00:00:00 2001 From: Miha <miha.fosnaric@fe.uni-lj.si> Date: Mon, 25 Mar 2019 09:04:14 +0000 Subject: [PATCH] Merge branch 'master' of https://bitbucket.org/samop/trisurf-manager --- trisurf/wrapper.py | 90 ++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 88 insertions(+), 2 deletions(-) diff --git a/trisurf/wrapper.py b/trisurf/wrapper.py index 7fb1cca..45ddcd7 100644 --- a/trisurf/wrapper.py +++ b/trisurf/wrapper.py @@ -82,10 +82,11 @@ ('znorm', c_double), ('area', c_double), ('volume', c_double), + ('energy', c_double), ] class ts_triangle_list(Structure): - _fields_=[('n',c_uint),('tria', POINTER(POINTER(ts_triangle)))] + _fields_=[('n',c_uint),('a0',c_double),('tria', POINTER(POINTER(ts_triangle))),] ts_cell._fields_=[ @@ -145,6 +146,8 @@ ('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), @@ -199,9 +202,92 @@ ts_cluster._fields_=[('nvtx',c_uint),('idx',c_uint),('vtx', POINTER(POINTER(ts_vertex)))] class ts_cluster_list(Structure): - _fields_=[('n',c_uint),('poly',POINTER(POINTER(ts_cluster)))] + _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) + + + -- Gitblit v1.9.3