Skip to main content

Read lammps dump trajectory.

Project description

ReadLammpsTraj

  • Read lammps dump trajectory

Installation

git clone https://github.com/eastsheng/ReadLammpsTraj
cd ReadLammpsTraj
pip install .

Usage

  • A example to calculate density in demo folder:

    # calculating the density from lammps traj
    # id mol type mass x y z vx vy vz fx fy fz q
    import numpy as np
    import matplotlib.pyplot as plt
    import ReadLammpsTraj as RLT
    from pathlib import Path
    
    def cal_density():
    	path = "./"
    	f = "1000.lammpstrj"
    
    	Path(path+"density/").mkdir(parents=True,exist_ok=True)
    
    	md = RLT.ReadLammpsTraj(path+f)
    	md.read_info()
    	# # number of frames
    	mframe,nframe = 1, 1
    	# # chunk number in z
    	Nz = 100
    	mol_n = [1,1000]
    	# 鍒嗗瓙搴忓彿
    
    	Calculate = True #True#False
    
    	if Calculate==True:
    		rho_nframe = np.zeros(Nz).reshape(Nz,1)
    		for i in range(mframe,nframe+1):
    			position = md.read_mxyz(i)
    			z, rho = md.oneframe_alldensity(position,Nz,density_type="mass")
    			# z, rho = md.oneframe_moldensity(position,Nz,mol_n=mol_n,id_type="mol",density_type="mass")
    
    			rho_nframe = rho_nframe+rho
    
    			print(i,"---",nframe)
    		nf = (nframe-mframe+1)
    		rho=rho_nframe/nf #all
    		print("Average density =",rho.mean(),"g/mL")
    	#---- end ----------------------------------------------
    	plt.rc('font', family='Times New Roman', size=26)
    	fig = plt.figure(figsize=(12,8))
    	fig.subplots_adjust(bottom=0.2,left=0.2)
    	ax=fig.add_subplot(111)
    	ax.plot(z,rho,'r--',label='All',linewidth=2)
    
    	# ax.legend(loc="center")
    	ax.legend(loc="best")
    
    	ax.set_ylabel('Density(g/mL)',fontweight='bold',size=32)
    	ax.set_xlabel('z(脜)',fontweight='bold',size=32)	
    	# ax.set_ylim(-0.05,1.5)
    
    	plt.savefig(path+"density/density.png",dpi=300)
    	plt.show()
    
    
    if __name__ == '__main__':
    	cal_density()
    

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ReadLammpsTraj-1.1.0.tar.gz (5.5 kB view details)

Uploaded Source

File details

Details for the file ReadLammpsTraj-1.1.0.tar.gz.

File metadata

  • Download URL: ReadLammpsTraj-1.1.0.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for ReadLammpsTraj-1.1.0.tar.gz
Algorithm Hash digest
SHA256 2ac67ac87bb57a761dad0780ea06a54e107c5abbc127aac3ac273e38009ab2d8
MD5 93ac888349f5be65d902aa5a2e814c22
BLAKE2b-256 2be661024490d8278be4dbe4f5cb1248fc803544211cf816a1438f08ba9d31ad

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page