to repeat the former transition npt eqilibrium of XI-water-vapor surface, we are going to cut a piece from the intial bulk-l XI ice lattice. It is no need to be large but should have enough layers in c axis to monitor the change along the surface, since it is a phase transition, the sum of all change among all the layers stands for surface free energy.
In [74]:
import MDAnalysis
import numpy as np
u=MDAnalysis.Universe("bulkih-l.gro")
sel=u.select_atoms("byres prop y < 30.5 and prop x < 30")
sel.residues.resnames.shape
sel.residues.resnames=['SOL']*sel.residues.resnames.shape[0]
dim=u.dimensions+0
dim[:3]=np.max(sel.positions,0)+1
u.dimensions=dim
sel.write("cut.gro")
In [18]:
import MDAnalysis
import numpy as np
from matplotlib import pylab as plt
In [111]:
u=MDAnalysis.Universe("step4-aver.gro")
In [112]:
zinterval=7.41
In [113]:
zstart=8.09
In [114]:
u.select_atoms("byres prop z > 8.0 and prop z < 15")
Out[114]:
In [115]:
16128/18
Out[115]:
In [116]:
u.dimensions
Out[116]:
In [117]:
data=[]
for n in np.linspace(0,u.dimensions[2],1000):
selword="byres prop z < %6.2f" % n
sel=u.select_atoms(selword)
data.append(sel.n_atoms)
In [118]:
plt.plot(np.linspace(0,u.dimensions[2],1000),data,'g--',label='Number of ICE in z axis')
plt.show()
In [119]:
data2=np.array(data[1:])-np.array(data[:-1])
In [120]:
zstart=7.5
In [121]:
np.arange(zstart,u.dimensions[2],zinterval)
Out[121]:
In [122]:
plt.clf()
plt.plot(np.linspace(0,u.dimensions[2],1000)[1:],data2,'b--',label='Number of ICE in z axis')
for n in np.arange(zstart,u.dimensions[2],zinterval):
plt.plot([n,n],[-20,250],'r--')
plt.savefig('n_ice_z.png',dpi=300)
In [124]:
inters=np.arange(zstart,u.dimensions[2],zinterval)
In [170]:
plt.clf()
data=[]
sels=[]
for n in range(len(inters))[:-1]:
#print n
if n==0:
selword="byres prop z < %6.2f" % inters[n]
sel=u.select_atoms(selword)
sels.append(sel)
print selword
data.append(sel.n_atoms)
else:
selword="byres prop z > %6.2f and prop z < %6.2f" % (inters[n],inters[n+1])
print selword
sel=u.select_atoms(selword)
sels.append(sel)
data.append(sel.n_atoms)
plt.plot(data,'g--')
plt.show()
In [77]:
sel.write("mix-0.gro")
In [136]:
np.max(u.atoms.positions)
Out[136]:
In [126]:
u2=MDAnalysis.Universe("ice-long.gro")
In [165]:
sol=u2.select_atoms('byres prop z < 160 and prop z > 134')
In [138]:
np.min(sol.positions,0)
Out[138]:
In [139]:
sels.append(sol)
In [163]:
Out[163]:
In [175]:
for n in range(4,13):
#print n
totf=[0,1]
icf=range(2,n)
ico=range(n,14)
for n_sel,sel in enumerate(sels):
if n_sel in totf:
sel.residues.resnames=["FRZ"]*sel.residues.resids.shape[0]
elif n_sel in icf:
sel.residues.resnames=["ICF"]*sel.residues.resids.shape[0]
elif n_sel in ico:
sel.residues.resnames=["ICO"]*sel.residues.resids.shape[0]
else:
sel.residues.resnames=["SOL"]*sel.residues.resids.shape[0]
sel=np.sum(sels[1:])
u3=MDAnalysis.Merge(sel,sol)
dim=u.dimensions
dim[2]=200
u3.dimensions=dim
u3.atoms.write("mix-%d.gro" % n)
print "No. %d, writing icf at " % n,
print icf,
print ", ico at ",
print ico
print "FRZ NUM: %d,ICF NUM: %d,ICE NUM: %d, SOL NUM: %d" % \
(u3.select_atoms("resname FRZ").n_atoms,u3.select_atoms("resname ICF").n_atoms,\
u3.select_atoms("resname ICO").n_atoms,u3.select_atoms("resname SOL").n_atoms)