Skip to content

Commit

Permalink
Minor refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
ttadano committed Feb 28, 2024
1 parent 22bf707 commit d905362
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 22 deletions.
2 changes: 1 addition & 1 deletion tools/analyze_phonons.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ def print_cumulative_thermal_conductivity(analyze_obj, cumulative_mode, file_res
+ str(beg_s) + " " + str(end_s) \
+ " " + isotope + " " + file_isotope \
+ " " + str(max_len) + " " \
+ str(d_len) + " " + options.temp + " "\
+ str(d_len) + " " + options.temp + " " \
+ str(options.nsample) + " " \
+ options.gridtype

Expand Down
8 changes: 5 additions & 3 deletions tools/interface/LAMMPS.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,8 @@ def _print_displacements_and_forces(self, lammps_files, file_offset):
f[i, 1],
f[i, 2]))
else:
raise RuntimeError("Could not find ITEM: TIMESTEP keyword in the dump file %s" % lammps_files[0])
raise RuntimeError("Could not find ITEM: "
"TIMESTEP keyword in the dump file %s" % lammps_files[0])

@staticmethod
def _compute_lattice_vector_from_boxparams(box_params):
Expand Down Expand Up @@ -292,7 +293,8 @@ def _print_displacements(self, lammps_files, file_offset):
disp[i, 2]))

else:
raise RuntimeError("Could not find ITEM: TIMESTEP keyword in the dump file %s" % lammps_files[0])
raise RuntimeError("Could not find ITEM: "
"TIMESTEP keyword in the dump file %s" % lammps_files[0])

def _print_atomicforces(self, lammps_files, file_offset):

Expand Down Expand Up @@ -344,7 +346,7 @@ def _set_unit_conversion_factor(self, str_unit):

def _set_output_flags(self, output_flags):
self._print_disp, self._print_force, \
self._print_energy, self._print_born = output_flags
self._print_energy, self._print_born = output_flags

def _set_number_of_zerofill(self, npattern):

Expand Down
14 changes: 7 additions & 7 deletions tools/interface/OpenMX.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,13 @@ def load_initial_structure(self, file_original):
lavec.append([float(t) for t in line.strip().split()])

if ipos_lavec > ipos_coord:
common_settings.extend(lines[:ipos_coord-1])
common_settings.extend(lines[fpos_coord+1:ipos_lavec-1])
common_settings.extend(lines[fpos_lavec+1:])
common_settings.extend(lines[:ipos_coord - 1])
common_settings.extend(lines[fpos_coord + 1:ipos_lavec - 1])
common_settings.extend(lines[fpos_lavec + 1:])
else:
common_settings.extend(lines[:ipos_lavec-1])
common_settings.extend(lines[fpos_lavec+1:ipos_coord-1])
common_settings.extend(lines[fpos_coord+1:])
common_settings.extend(lines[:ipos_lavec - 1])
common_settings.extend(lines[fpos_lavec + 1:ipos_coord - 1])
common_settings.extend(lines[fpos_coord + 1:])

x_frac0 = np.array(x_frac0)
lavec = np.array(lavec).transpose()
Expand Down Expand Up @@ -366,7 +366,7 @@ def _set_unit_conversion_factor(self, str_unit):

def _set_output_flags(self, output_flags):
self._print_disp, self._print_force, \
self._print_energy, self._print_born = output_flags
self._print_energy, self._print_born = output_flags

@property
def nat(self):
Expand Down
14 changes: 7 additions & 7 deletions tools/interface/QE.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@
# or http://opensource.org/licenses/mit-license.php for information.
#
from __future__ import print_function
import numpy as np
import math

import copy
import math
import sys

import numpy as np


class QEParser(object):

Expand Down Expand Up @@ -765,7 +767,7 @@ def _set_unit_conversion_factor(self, str_unit):

def _set_output_flags(self, output_flags):
self._print_disp, self._print_force, \
self._print_energy, self._print_born = output_flags
self._print_energy, self._print_born = output_flags

@property
def nat(self):
Expand Down Expand Up @@ -918,7 +920,7 @@ def _get_coordinates_pwout(self, pwout_file):
line = f.readline()

if not found_tag:
#print("%s tag not found in %s" % (search_flag, pwout_file), file=sys.stderr)
# print("%s tag not found in %s" % (search_flag, pwout_file), file=sys.stderr)
return None

x = self._celldm[0] * np.dot(x, self._inverse_lattice_vector.transpose()) \
Expand Down Expand Up @@ -1030,7 +1032,7 @@ def _get_borninfo_phout(phout_file):

found_tag1 = False
found_tag2 = False

while line:
if search_tag1 in line:
found_tag1 = True
Expand All @@ -1055,5 +1057,3 @@ def _get_borninfo_phout(phout_file):
dielec = np.reshape(np.array(dielec[9:]), (3, 3))
borncharge = np.reshape(np.array(borncharge), (nat2, 3, 3))
return dielec, borncharge[:nat2 // 2, :, :]


5 changes: 3 additions & 2 deletions tools/interface/xTAPP.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,11 +238,12 @@ def _set_unit_conversion_factor(self, str_unit):
else:
raise RuntimeError("This cannot happen.")

self._force_conversion_factor = self._energy_conversion_factor / self._disp_conversion_factor
self._force_conversion_factor = (self._energy_conversion_factor
/ self._disp_conversion_factor)

def _set_output_flags(self, output_flags):
self._print_disp, self._print_force, \
self._print_energy, self._print_born = output_flags
self._print_energy, self._print_born = output_flags

@property
def nat(self):
Expand Down
4 changes: 2 additions & 2 deletions tools/plotband.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ def preprocess_data(files, unitname, normalize_xaxis, emin=None, emax=None):
= gridspec_setup(data_merged, xtickslabels, xticksvars)

return naxes, xticks_grids, xticklabels_grids, \
xmin, xmax, ymin, ymax, data_merged_grids
xmin, xmax, ymin, ymax, data_merged_grids


def run_plot(files, nax, xticks_ax, xticklabels_ax, xmin_ax, xmax_ax, ymin, ymax,
Expand Down Expand Up @@ -318,7 +318,7 @@ def run_plot(files, nax, xticks_ax, xticklabels_ax, xmin_ax, xmax_ax, ymin, ymax
print("Number of files = %d" % nfiles)

nax, xticks_ax, xticklabels_ax, xmin_ax, xmax_ax, ymin, ymax, \
data_merged_ax = preprocess_data(
data_merged_ax = preprocess_data(
files, options.unitname, options.normalize_xaxis, options.emin, options.emax)

run_plot(files, nax, xticks_ax, xticklabels_ax,
Expand Down

0 comments on commit d905362

Please sign in to comment.