Skip to content

Commit de7a3a0

Browse files
committed
use only last block for pressure convergence
1 parent 29fd253 commit de7a3a0

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

calphy/phase.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -598,8 +598,12 @@ def process_pressure(self,):
598598

599599
#now we can check if it converted
600600
file = os.path.join(self.simfolder, "avg.dat")
601-
lx, ly, lz, ipress = np.loadtxt(file, usecols=(1, 2, 3, 4), unpack=True)
602-
lxpc = ipress
601+
#we have to clean the data, so as just the last block is selected
602+
lx, ly, lz, lxpc = np.loadtxt(file, usecols=(1, 2, 3, 4), unpack=True)
603+
lx = lx[-ncount+1:]
604+
ly = ly[-ncount+1:]
605+
lz = lx[-ncount+1:]
606+
lxpc = lxpc[-ncount+1:]
603607
mean = np.mean(lxpc)
604608
std = np.std(lxpc)
605609
volatom = np.mean((lx*ly*lz)/self.natoms)
@@ -612,16 +616,20 @@ def finalise_pressure(self,):
612616
ncount = int(self.calc.md.n_small_steps)//int(self.calc.md.n_every_steps*self.calc.md.n_repeat_steps)
613617

614618
file = os.path.join(self.simfolder, "avg.dat")
615-
lx, ly, lz, ipress = np.loadtxt(file, usecols=(1, 2, 3, 4), unpack=True)
616-
lxpc = ipress
619+
lx, ly, lz, lxpc = np.loadtxt(file, usecols=(1, 2, 3, 4), unpack=True)
620+
lx = lx[-ncount+1:]
621+
ly = ly[-ncount+1:]
622+
lz = lx[-ncount+1:]
623+
lxpc = lxpc[-ncount+1:]
624+
617625
mean = np.mean(lxpc)
618626
std = np.std(lxpc)
619627
volatom = np.mean((lx*ly*lz)/self.natoms)
620628

621629
self.calc._pressure = mean
622-
self.lx = np.round(np.mean(lx[-ncount+1:]), decimals=3)
623-
self.ly = np.round(np.mean(ly[-ncount+1:]), decimals=3)
624-
self.lz = np.round(np.mean(lz[-ncount+1:]), decimals=3)
630+
self.lx = np.round(np.mean(lx), decimals=3)
631+
self.ly = np.round(np.mean(ly), decimals=3)
632+
self.lz = np.round(np.mean(lz), decimals=3)
625633
self.volatom = volatom
626634
self.vol = self.lx*self.ly*self.lz
627635
self.rho = self.natoms/(self.lx*self.ly*self.lz)

0 commit comments

Comments
 (0)