-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathpSED
More file actions
executable file
·86 lines (72 loc) · 2.31 KB
/
Copy pathpSED
File metadata and controls
executable file
·86 lines (72 loc) · 2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/usr/bin/env python3
# python modules
import sys
import os
import numpy as np
import h5py
# add my modules to path
modulepath = './modules' # CHANGE THIS TO YOUR PATH
sys.path.append(modulepath)
# my modules
import Parsers
import Compressor
import Lattice
import Phonons
import FileIO
import Plot
import Lorentz
### Get the input file
if len(sys.argv) == 1:
input_file = 'INPUT'
elif len(sys.argv) > 2:
print('\nERROR: ./pSED takes 1 or 0 arguments!'
'\nTry \'./pSED help\' for more info.\n')
exit()
elif len(sys.argv) == 2 and (sys.argv[1] == 'h' or sys.argv[1] == 'help' or
sys.argv[1] == 'HELP' or sys.argv[1] == '-h' or sys.argv[1] == '--help' or
sys.argv[1] == '--HELP'):
print('\nUSAGE: ./pSED [input_file]\n\n\'input_file\' should be the name of the file '
'containing the parameters \nto calculate the phonon spectral energy density'
'\n\nIf no input_file name is given, the default is \'INPUT\'\n')
exit()
else:
input_file = str(sys.argv[1])
if not os.path.exists(input_file):
print('\nERROR: file \'{}\' not found!\n'.format(input_file))
exit()
### Read the input parameter file
params = Parsers.parse_input(input_file)
params.with_eigs = False ### disable the feature that includes eigenvectors!
### Plot the stuff
if params.plot_bands:
data = FileIO.read_previous(params)
Plot.plot_bands(data,params)
if not params.plot_slice:
print('\nALL DONE!\n')
exit()
if params.plot_slice:
data = FileIO.read_previous(params)
Plot.plot_slice(data,params)
exit()
### Fit to a Lorentz function
if params.lorentz:
data = FileIO.read_previous(params)
Lorentz.lorentz(data,params)
print('\nALL DONE!\n')
exit()
### Compress the velocity and position data to hdf5
if params.compress:
Compressor.compress(params)
print('\nALL DONE!\n')
exit()
### Open the hdf5 database
params.database = h5py.File(params.database_file,'r')
### Read the PHONOPY and lattice structure data
eigen_vectors = Parsers.parse_eigen_vecs(params)
lattice = Lattice.lattice(params,eigen_vectors)
### Compute the SED
phonons = Phonons.spectral_energy_density(params)
phonons.compute_sed(params,lattice,eigen_vectors)
### Save the data to output files
FileIO.write_output(phonons,params,lattice,eigen_vectors)
print('\nALL DONE!\n')