Skip to content

Instantly share code, notes, and snippets.

@leelasd
Created July 12, 2015 03:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leelasd/dcaa4af3de566a38094a to your computer and use it in GitHub Desktop.
Save leelasd/dcaa4af3de566a38094a to your computer and use it in GitHub Desktop.
import string
import pandas as pd
df=pd.read_csv('Best_LJS_Zn.csv')
df.SIG=df.SIG*0.1
df.EPS=df.EPS*4.184
with open("top.top", "r") as f:
lines = f.readlines()
for i in range(len(df.SIG)):
SIGMA='%.5e'%df.SIG[i]
EPSILON='%.5e'%df.EPS[i]
new_line=[]
for line in lines:
line=string.replace(line,'SIGMASIGMAL',SIGMA,2)
line=string.replace(line,'EPSILONEPSI',EPSILON,2)
new_line.append(line)
clean_lines = [l.strip() for l in new_line if l.strip()]
outfile='TOPS/topol.top_'+str(i)
with open(outfile, "w") as f:
f.writelines('\n'.join(clean_lines))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment