Tspostat in python. Flexible and incremental
Samo Penic
2019-03-04 f941040b10aa889555910bafeabdebbe73be9099
Fix in stretching energy calculations. Added stretching energy calculations on veritces with only c0.
1 files modified
34 ■■■■ changed files
poststat.py 34 ●●●● patch | view | raw | blame | history
poststat.py
@@ -32,17 +32,31 @@
    #F=[f*vesicle.contents.tape.contents.F for f in F]
    return F
def sum_stretching_energy(vesicle, only_c0_c0=False):
    return 0.0
def sum_stretching_energy_delete(vesicle, only_c0_c0=False):
    energy=0.0
    for i in range(0,vesicle.contents.tlist.contents.n):
#        if (only_c0_c0 is True
#            and vesicle.contents.tlist.contents.tria[i].contents.vtx[0].contents.c0<1e-15
#            and vesicle.contents.tlist.contents.tria[i].contents.vtx[1].contents.c0<1e-15
#            and vesicle.contents.tlist.contents.tria[i].contents.vtx[2].contents.c0<1e-15):
        if (only_c0_c0 is False or (only_c0_c0 is True
            and vesicle.contents.tlist.contents.tria[i].contents.vertex[0].contents.c<1e-15
            and vesicle.contents.tlist.contents.tria[i].contents.vertex[1].contents.c<1e-15
            and vesicle.contents.tlist.contents.tria[i].contents.vertex[2].contents.c<1e-15)):
            ts.stretchenergy(vesicle,vesicle.contents.tlist.contents.tria[i])
            energy+=vesicle.contents.tlist.contents.tria[i].contents.energy
    return energy
def sum_stretching_energy(vesicle, only_c0_c0=False):
    energy=0.0
    #calculate stretching energy for each triangle
    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
    #count stretching energy for given vertices (whole energy of triangle/3)
    for i in range(0,vesicle.contents.vlist.contents.n):
        if(only_c0_c0 is False or (only_c0_c0 is True and vesicle.contents.vlist.contents.vtx[i].contents.c)):
            cvtx=vesicle.contents.vlist.contents.vtx[i]
            tmpenergy=0
            for j in range(0,cvtx.contents.tristar_no):
                tmpenergy+=cvtx.contents.tristar[j].contents.energy
            energy+=tmpenergy/3.0
    return energy
def get_histogram_data(vesicle):
@@ -75,6 +89,7 @@
        'l3':l3,
        'Nbw/Nb':count_bonds/vesicle.contents.blist.contents.n,
        'StretchingE': sum_stretching_energy(vesicle),
        'StretchingEonlyC0': sum_stretching_energy(vesicle, True),
        'avgFx': avg_normal_force[0],
        'avgFy': avg_normal_force[1],
        'avgFz': avg_normal_force[2]
@@ -115,7 +130,7 @@
        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', 'StretchingE', 'avgFx', 'avgFy', 'avgFz']}
        csvdict={'OuterLoop':['OuterLoop', 'Volume', 'Area', 'lamdba1', 'lambda2', 'lambda3', 'Nbw/Nb', 'hbar', 'StretchingE', 'avgFx', 'avgFy', 'avgFz', 'StretchingEonlyC0']}
    filedict=get_vtu_dict(directory)
    modified=False
    for f in filedict:
@@ -140,7 +155,8 @@
                '{:.17e}'.format(p['StretchingE']),
                '{:.17e}'.format(p['avgFx']),
                '{:.17e}'.format(p['avgFy']),
                '{:.17e}'.format(p['avgFz'])]
                '{:.17e}'.format(p['avgFz']),
                '{:.17e}'.format(p['StretchingEonlyC0'])]
            modified=True
    if modified:
        write_csv(os.path.join(directory,'data_tspoststat.csv'), csvdict)