예제 #1
0
##	First, create a key:value dict.
mydict = dict({'sed': 'MARIO', 'dict': 'LUIGI'})
# The following methods are equivalent ways.
# mydict = dict(TEMP_PARAM='80', STRAIN_PARAM='0.02')
# mydict = dict(zip(('TEMP_PARAM', 'STRAIN_PARAM'), ('80', '0.02')))
# mydict = dict([['TEMP_PARAM', '80'], ['STRAIN_PARAM', '0.02']])

## Then simply call the function with the original and new file names.
st.sed(mydict, 'strchgtest.py', 'tmp.newfile')
### And you're done!!!

## If you want to edit the file in-place, i.e. not create a new file,
## then simply make the new file name a blank string.
st.sed(mydict, 'tmp.newfile', '')

## You can also use relative or absolute pathways for the file names.
mydict = dict({'sed': 'MARIO', 'dict': 'LUIGI'})
orig = ntplPATH + '/strchgmod/strchgtest.py'
new = './tmp.newfile'
st.sed(mydict, orig, new)

## ## Now we will try the grep command. This grep implementation uses
## ## the grep -A command.

## Simply pass it the search string, number of lines to pull, the original
## file name and the new file name.
st.grep('Import the module', 4, 'strchgtest.py', 'tmp.newfile')

#cleanup
os.system('rm tmp.newfile')
예제 #2
0
sys.path.append("/home/kevin/projects/Codes")
import ntpy.strchg as st

def freq(kpt, num_atoms_cell, mass, main_file, run_file, name)
# String change
	strchange = dict({'KPT' : str(kpt[0])+ '\t'+ str(kpt[1])+ '\t'+ \
							  str(kpt[2]),
					  'runpath' : main_file
					  'MASS' : str(mass)
					  })

	orig = #name of original file
	new = #name of new file
	st.sed(strchange, orig, new)
	os.system('Some system command')

	# Grep out freqencies
	st.grep('Frequency', 'out.disp.'+ main_file, 
			'out.freq.'+ main_file+ str('.grep'))
	strchange = dict({'Frequency' : ''})
	st.sed(strchange, 'out.freq.'+ main_file+ str('.grep'), 
			'out.freq.'+ main_file+ str('.grep.2'))
	
	# Read in freqencies to sort
	dummy = np.loadtxt('out.freq.'+ main_file, comments='--')
	freq[:] = dummy[0,:] * constc?? * 2.0 * np.pi

	os.system('rm out.freq'+ main_file)

	
예제 #3
0
lat20 = (lj.value('lat20') / lj.value('sigma')) * 1e-10
lat50 = (lj.value('lat50') / lj.value('sigma')) * 1e-10
lat80 = (lj.value('lat80') / lj.value('sigma')) * 1e-10
Length = np.array([lat20 * 4, lat50 * 4, lat80 * 4])

## ## ## Loop over Strains
for istrain in range(GK_num_strains):
	## ## ## Loop over Temperatures
	for itemp in range(GK_num_temps):
		## ## ## Loop over Seeds
		for iseed in range(GK_num_seeds):
			print str(iseed)+ '.' + str(itemp) + '.' + str(istrain)

			## ## ## Extract Correlation for GK
			st.grep(str(GK_total_steps)+' '+str(GK_p), GK_p, 'out.lammps.corr.'+ str(iseed)+ '.' \
					+ str(itemp)+ '.'+ str(istrain), 'out.lammps.corr.'+ str(iseed)+ '.'+ str(itemp) \
					+ '.'+ str(istrain)+ '.grep')
			## Read the file
			str_read = 'out.lammps.corr.'+ str(iseed)+ '.'+ str(itemp)+ '.'+ str(istrain)+ '.grep'
			dummy_array = np.loadtxt(str_read, skiprows = 1)
			GK_JJ[:,1,itemp,istrain] = GK_JJ[:,1,itemp,istrain]+ ((dummy_array[:,3]+ dummy_array[:,4]+ dummy_array[:,5])/3) 
			os.system('rm out.lammps.corr.'+ str(iseed)+ '.'+ str(itemp)+ '.'+ str(istrain)+ '.grep')

			## ## ## Extract Stress from file
			str_read = 'out.lammps.strain.'+ str(iseed)+ '.'+ str(itemp)+ '.'+ str(istrain)
			dummy_array = np.loadtxt(str_read, comments='#')
			Me_stress[itemp, istrain] = Me_stress[itemp, istrain] + dummy_array[Me_d - 1,2]

			## ## ## Extract mean squared displacement
			str_read = 'out.lammps.dis.'+ str(iseed)+ '.'+ str(itemp)+ '.'+ str(istrain)
			dummy_array = np.loadtxt(str_read, comments='#')
예제 #4
0
파일: strchgtest.py 프로젝트: csgorham/ntpy
##	First, create a key:value dict.
mydict = dict({'sed': 'MARIO', 'dict': 'LUIGI'})
# The following methods are equivalent ways.
# mydict = dict(TEMP_PARAM='80', STRAIN_PARAM='0.02')
# mydict = dict(zip(('TEMP_PARAM', 'STRAIN_PARAM'), ('80', '0.02')))
# mydict = dict([['TEMP_PARAM', '80'], ['STRAIN_PARAM', '0.02']])

## Then simply call the function with the original and new file names.
st.sed(mydict, 'strchgtest.py', 'tmp.newfile')
### And you're done!!!

## If you want to edit the file in-place, i.e. not create a new file,
## then simply make the new file name a blank string.
st.sed(mydict, 'tmp.newfile', '')

## You can also use relative or absolute pathways for the file names.
mydict = dict({'sed': 'MARIO', 'dict': 'LUIGI'})
orig = ntplPATH + '/strchgmod/strchgtest.py'
new = './tmp.newfile'
st.sed(mydict, orig, new)

## ## Now we will try the grep command. This grep implementation uses
## ## the grep -A command.

## Simply pass it the search string, number of lines to pull, the original
## file name and the new file name.
st.grep('Import the module', 4, 'strchgtest.py', 'tmp.newfile')

#cleanup
os.system('rm tmp.newfile')