mirror of https://github.com/phonopy/phono3py.git
Write document and update script slightly for --write-phonon and --read-phonon
This commit is contained in:
parent
ba154d87bf
commit
719de85949
|
@ -3,6 +3,12 @@
|
|||
Change Log
|
||||
==========
|
||||
|
||||
Nov-29-2017
|
||||
-------------------
|
||||
|
||||
- Documentation of ``--write-phonon`` and ``--read-phonon`` options is
|
||||
written.
|
||||
|
||||
Nov-22-2017: version 1.12.5
|
||||
-----------------------------
|
||||
|
||||
|
|
|
@ -720,6 +720,36 @@ be equivalent between them.
|
|||
format. This file can be huge and usually it is not recommended to
|
||||
write it out.
|
||||
|
||||
.. _write_phonon_option:
|
||||
|
||||
``--write-phonon``
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Phonon frequencies, eigenvectors, and grid point addresses are stored
|
||||
in ``phonon-mxxx.hdf5`` file. After writing phonons, phono3py stops
|
||||
without going to calculation.
|
||||
|
||||
::
|
||||
|
||||
% phono3py --fc2 --dim="2 2 2" --mesh="16 16 16" -c POSCAR-unitcell \
|
||||
--nac --write-phoonon
|
||||
|
||||
.. _read_phonon_option:
|
||||
|
||||
``--read-phonon``
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Phonon frequencies, eigenvectors, and grid point addresses are read
|
||||
from ``phonon-mxxx.hdf5`` file and the calculation is continued using
|
||||
these phonon values. This is useful when we want to use fixed phonon
|
||||
eigenvectors that can be different for degenerate bands when using
|
||||
different eigenvalue solvers or different CPU architectures.
|
||||
|
||||
::
|
||||
|
||||
% phono3py --fc2 --fc3 --dim="2 2 2" --mesh="16 16 16" -c POSCAR-unitcell \
|
||||
--nac --read-phoonon --br
|
||||
|
||||
.. _ise_option:
|
||||
|
||||
``--ise``: Imaginary part of self energy
|
||||
|
|
Binary file not shown.
|
@ -1067,6 +1067,8 @@ def write_gamma_detail_to_hdf5(temperature,
|
|||
w.create_dataset('frequency_point', data=frequency_points)
|
||||
return full_filename
|
||||
|
||||
return None
|
||||
|
||||
def write_phonon_to_hdf5(frequency,
|
||||
eigenvector,
|
||||
grid_address,
|
||||
|
@ -1082,30 +1084,34 @@ def write_phonon_to_hdf5(frequency,
|
|||
w.create_dataset('eigenvector', data=eigenvector)
|
||||
return full_filename
|
||||
|
||||
return None
|
||||
|
||||
def read_phonon_from_hdf5(mesh,
|
||||
filename=None,
|
||||
verbose=True):
|
||||
suffix = _get_filename_suffix(mesh, filename=filename)
|
||||
hdf5_filename = "phonon" + suffix + ".hdf5"
|
||||
if not os.path.exists(hdf5_filename):
|
||||
full_filename = "phonon" + suffix + ".hdf5"
|
||||
if not os.path.exists(full_filename):
|
||||
if verbose:
|
||||
print("%s not found." % hdf5_filename)
|
||||
return (None, None, None, None, hdf5_filename)
|
||||
print("%s not found." % full_filename)
|
||||
return (None, None, None, None, full_filename)
|
||||
|
||||
with h5py.File(hdf5_filename, 'r') as f:
|
||||
with h5py.File(full_filename, 'r') as f:
|
||||
frequencies = np.array(f['frequency'][:], dtype='double', order='C')
|
||||
itemsize = frequencies.itemsize
|
||||
eigenvectors = np.array(f['eigenvector'][:],
|
||||
dtype=("c%d" % (itemsize * 2)), order='C')
|
||||
mesh_in_file = np.array(f['mesh'][:], dtype='intc')
|
||||
grid_address = np.array(f['grid_address'][:], dtype='intc', order='C')
|
||||
return (frequencies,
|
||||
eigenvectors,
|
||||
mesh_in_file,
|
||||
grid_address,
|
||||
hdf5_filename)
|
||||
|
||||
return (None, None, None, None, hdf5_filename)
|
||||
assert (mesh_in_file == mesh).all(), "Mesh numbers are inconsistent."
|
||||
|
||||
if verbose:
|
||||
print("Phonons are read from \"%s\"." % full_filename)
|
||||
|
||||
return frequencies, eigenvectors, grid_address
|
||||
|
||||
return None
|
||||
|
||||
def write_ir_grid_points(mesh,
|
||||
mesh_divs,
|
||||
|
|
|
@ -648,8 +648,7 @@ if run_mode is not None:
|
|||
filename = phono3py.write_phonons(filename=output_filename)
|
||||
if filename:
|
||||
if log_level:
|
||||
print("All phonons on grid points are written into \"%s\"." %
|
||||
filename)
|
||||
print("Phonons are written into \"%s\"." % filename)
|
||||
print_end()
|
||||
sys.exit(0)
|
||||
else:
|
||||
|
@ -660,21 +659,19 @@ if run_mode is not None:
|
|||
if settings.get_read_phonon():
|
||||
phonons = read_phonon_from_hdf5(mesh,
|
||||
filename=input_filename,
|
||||
verbose=log_level)
|
||||
if phonons[0] is None:
|
||||
print("Reading phonons from \"%s\" failed." % phonons[4])
|
||||
verbose=(log_level > 0))
|
||||
if phonons is None:
|
||||
print("Reading phonons failed.")
|
||||
if log_level:
|
||||
print_error()
|
||||
sys.exit(1)
|
||||
|
||||
frequencies = phonons[0]
|
||||
eigenvectors = phonons[1]
|
||||
grid_address = phonons[3]
|
||||
grid_address = phonons[2]
|
||||
if phono3py.set_phonon_data(frequencies, eigenvectors, grid_address):
|
||||
if log_level:
|
||||
print("Phonons are read from \"%s\"." % phonons[4])
|
||||
pass
|
||||
else:
|
||||
print("Phonon data in %s are inconsistent to the calculation "
|
||||
"setting." % phonons[4])
|
||||
if log_level:
|
||||
print_error()
|
||||
sys.exit(1)
|
||||
|
|
Loading…
Reference in New Issue