Tspostat in python. Flexible and incremental
Samo Penic
2018-05-24 4484c7254fb8cef4dd16c4b6f188c5110efb4b1a
Added stretching energy to tspoststat
2 files modified
27 ■■■■ changed files
poststat.py 18 ●●●● patch | view | raw | blame | history
wrapper.py 9 ●●●● patch | view | raw | blame | history
poststat.py
@@ -14,6 +14,13 @@
            cnt+=1
    return cnt
def sum_stretching_energy(vesicle):
    energy=0.0
    for i in range(0,vesicle.contents.tlist.contents.n):
        ts.stretchenergy(vesicle,vesicle.contents.tlist.contents.tria[i])
        energy+=vesicle.contents.tlist.contents.tria[i].contents.energy
    return energy
def get_histogram_data(vesicle):
    cstlist=ts.init_cluster_list()
    ts.clusterize_vesicle(vesicle,cstlist)
@@ -41,7 +48,8 @@
        'l1':l1,
        'l2':l2,
        'l3':l3,
        'Nbw/Nb':count_bonds/vesicle.contents.blist.contents.n
        'Nbw/Nb':count_bonds/vesicle.contents.blist.contents.n,
        'StretchingE': sum_stretching_energy(vesicle),
        }
    return retval
@@ -74,11 +82,12 @@
def poststat_directory(directory):
    """Function reads existing data_tspoststat and checks if there are new VTUs in the directory that were not poststated. If there are, then they are added to the list"""
    try:
        csvdict=read_csv(os.path.join(directory,'data_tspoststat.csv'))
    except FileNotFoundError:
        #print("no file")
        csvdict={'OuterLoop':['OuterLoop', 'Volume', 'Area', 'lamdba1', 'lambda2', 'lambda3', 'Nbw/Nb hbar']}
        csvdict={'OuterLoop':['OuterLoop', 'Volume', 'Area', 'lamdba1', 'lambda2', 'lambda3', 'Nbw/Nb', 'hbar', 'StretchingE']}
    filedict=get_vtu_dict(directory)
    modified=False
    for f in filedict:
@@ -99,7 +108,8 @@
                '{:.17e}'.format(p['l2']),
                '{:.17e}'.format(p['l3']),
                '{:.17e}'.format(p['Nbw/Nb']),
                '{:.17e}'.format(p['hbar'])]
                '{:.17e}'.format(p['hbar']),
                '{:.17e}'.format(p['StretchingE'])]
            modified=True
    if modified:
        write_csv(os.path.join(directory,'data_tspoststat.csv'), csvdict)
@@ -125,7 +135,7 @@
    #print(sorted(hist.items(), key=lambda x: int(x[0])))
    #ts.vesicle_free(vesicle)        
    #poststat_directory('/tmp/sim1/run0')
    NUM_PROCESSES=3
    NUM_PROCESSES=2
    os.chdir('/home/samo/trisurf-server')
    os.environ.setdefault("DJANGO_SETTINGS_MODULE","web_trisurf.settings")
    django.setup()
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),
@@ -282,5 +285,9 @@
    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)