0.0.59
This commit is contained in:
parent
2fa7ecd9b2
commit
195a267fcd
@ -231,10 +231,6 @@ guan.write_one_dimensional_data(x_array, y_array, filename='a', format='txt')
|
|||||||
guan.write_two_dimensional_data(x_array, y_array, matrix, filename='a', format='txt')
|
guan.write_two_dimensional_data(x_array, y_array, matrix, filename='a', format='txt')
|
||||||
|
|
||||||
|
|
||||||
# preprocess
|
|
||||||
|
|
||||||
parameter_array = guan.preprocess_for_parallel_calculations(parameter_array_all, cpus=1, task_index=0)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# plot figures
|
# plot figures
|
||||||
@ -247,6 +243,17 @@ guan.plot_contour(x_array, y_array, matrix, xlabel='x', ylabel='y', title='', sh
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# preprocessing
|
||||||
|
|
||||||
|
parameter_array = guan.preprocess_for_parallel_calculations(parameter_array_all, cpus=1, task_index=0)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# bach processing
|
||||||
|
guan.bach_reading_and_plotting(directory, xlabel='x', ylabel='y')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# others
|
# others
|
||||||
|
|
||||||
guan.download_with_scihub(address=None, num=1)
|
guan.download_with_scihub(address=None, num=1)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
[metadata]
|
[metadata]
|
||||||
# replace with your username:
|
# replace with your username:
|
||||||
name = guan
|
name = guan
|
||||||
version = 0.0.57
|
version = 0.0.59
|
||||||
author = guanjihuan
|
author = guanjihuan
|
||||||
author_email = guanjihuan@163.com
|
author_email = guanjihuan@163.com
|
||||||
description = An open source python package
|
description = An open source python package
|
||||||
|
@ -12,16 +12,16 @@
|
|||||||
# # Module 8: quantum_transport
|
# # Module 8: quantum_transport
|
||||||
# # Module 9: topological_invariant
|
# # Module 9: topological_invariant
|
||||||
# # Module 10: read_and_write
|
# # Module 10: read_and_write
|
||||||
# # Module 11: preprocess
|
# # Module 11: plot_figures
|
||||||
# # Module 12: plot_figures
|
# # Module 12: preprocess
|
||||||
# # Module 13: others
|
# # Module 13: bach processing
|
||||||
|
# # Module 14: others
|
||||||
|
|
||||||
# import packages
|
# import packages
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from math import *
|
from math import *
|
||||||
import cmath
|
import cmath
|
||||||
import functools
|
|
||||||
import copy
|
import copy
|
||||||
import guan
|
import guan
|
||||||
|
|
||||||
@ -131,14 +131,17 @@ def three_dimensional_fourier_transform_for_cubic_lattice(k1, k2, k3, unit_cell,
|
|||||||
return hamiltonian
|
return hamiltonian
|
||||||
|
|
||||||
def one_dimensional_fourier_transform_with_k(unit_cell, hopping):
|
def one_dimensional_fourier_transform_with_k(unit_cell, hopping):
|
||||||
|
import functools
|
||||||
hamiltonian_function = functools.partial(guan.one_dimensional_fourier_transform, unit_cell=unit_cell, hopping=hopping)
|
hamiltonian_function = functools.partial(guan.one_dimensional_fourier_transform, unit_cell=unit_cell, hopping=hopping)
|
||||||
return hamiltonian_function
|
return hamiltonian_function
|
||||||
|
|
||||||
def two_dimensional_fourier_transform_for_square_lattice_with_k1_k2(unit_cell, hopping_1, hopping_2):
|
def two_dimensional_fourier_transform_for_square_lattice_with_k1_k2(unit_cell, hopping_1, hopping_2):
|
||||||
|
import functools
|
||||||
hamiltonian_function = functools.partial(guan.two_dimensional_fourier_transform_for_square_lattice, unit_cell=unit_cell, hopping_1=hopping_1, hopping_2=hopping_2)
|
hamiltonian_function = functools.partial(guan.two_dimensional_fourier_transform_for_square_lattice, unit_cell=unit_cell, hopping_1=hopping_1, hopping_2=hopping_2)
|
||||||
return hamiltonian_function
|
return hamiltonian_function
|
||||||
|
|
||||||
def three_dimensional_fourier_transform_for_cubic_lattice_with_k1_k2_k3(unit_cell, hopping_1, hopping_2, hopping_3):
|
def three_dimensional_fourier_transform_for_cubic_lattice_with_k1_k2_k3(unit_cell, hopping_1, hopping_2, hopping_3):
|
||||||
|
import functools
|
||||||
hamiltonian_function = functools.partial(guan.three_dimensional_fourier_transform_for_cubic_lattice, unit_cell=unit_cell, hopping_1=hopping_1, hopping_2=hopping_2, hopping_3=hopping_3)
|
hamiltonian_function = functools.partial(guan.three_dimensional_fourier_transform_for_cubic_lattice, unit_cell=unit_cell, hopping_1=hopping_1, hopping_2=hopping_2, hopping_3=hopping_3)
|
||||||
return hamiltonian_function
|
return hamiltonian_function
|
||||||
|
|
||||||
@ -1443,31 +1446,8 @@ def write_two_dimensional_data(x_array, y_array, matrix, filename='a', format='t
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Module 11: preprocess
|
|
||||||
|
|
||||||
def preprocess_for_parallel_calculations(parameter_array_all, cpus=1, task_index=0):
|
# Module 11: plot figures
|
||||||
num_all = np.array(parameter_array_all).shape[0]
|
|
||||||
if num_all%cpus == 0:
|
|
||||||
num_parameter = int(num_all/cpus)
|
|
||||||
parameter_array = parameter_array_all[task_index*num_parameter:(task_index+1)*num_parameter]
|
|
||||||
else:
|
|
||||||
num_parameter = int(num_all/(cpus-1))
|
|
||||||
if task_index != cpus-1:
|
|
||||||
parameter_array = parameter_array_all[task_index*num_parameter:(task_index+1)*num_parameter]
|
|
||||||
else:
|
|
||||||
parameter_array = parameter_array_all[task_index*num_parameter:num_all]
|
|
||||||
return parameter_array
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Module 12: plot figures
|
|
||||||
|
|
||||||
def plot(x_array, y_array, xlabel='x', ylabel='y', title='', show=1, save=0, filename='a', format='jpg', dpi=300, type='', y_min=None, y_max=None, linewidth=None, markersize=None):
|
def plot(x_array, y_array, xlabel='x', ylabel='y', title='', show=1, save=0, filename='a', format='jpg', dpi=300, type='', y_min=None, y_max=None, linewidth=None, markersize=None):
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
@ -1564,7 +1544,51 @@ def plot_contour(x_array, y_array, matrix, xlabel='x', ylabel='y', title='', sho
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Module 13: others
|
|
||||||
|
# Module 12: preprocessing
|
||||||
|
|
||||||
|
def preprocess_for_parallel_calculations(parameter_array_all, cpus=1, task_index=0):
|
||||||
|
num_all = np.array(parameter_array_all).shape[0]
|
||||||
|
if num_all%cpus == 0:
|
||||||
|
num_parameter = int(num_all/cpus)
|
||||||
|
parameter_array = parameter_array_all[task_index*num_parameter:(task_index+1)*num_parameter]
|
||||||
|
else:
|
||||||
|
num_parameter = int(num_all/(cpus-1))
|
||||||
|
if task_index != cpus-1:
|
||||||
|
parameter_array = parameter_array_all[task_index*num_parameter:(task_index+1)*num_parameter]
|
||||||
|
else:
|
||||||
|
parameter_array = parameter_array_all[task_index*num_parameter:num_all]
|
||||||
|
return parameter_array
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Module 13: bach processing
|
||||||
|
|
||||||
|
def bach_reading_and_plotting(directory, xlabel='x', ylabel='y'):
|
||||||
|
import re
|
||||||
|
import os
|
||||||
|
for root, dirs, files in os.walk(directory):
|
||||||
|
for file in files:
|
||||||
|
if re.search('^txt.', file[::-1]):
|
||||||
|
filename = file[:-4]
|
||||||
|
x_array, y_array = guan.read_one_dimensional_data(filename=filename)
|
||||||
|
guan.plot(x_array, y_array, xlabel=xlabel, ylabel=ylabel, title=filename, show=0, save=1, filename=filename)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Module 14: others
|
||||||
|
|
||||||
## download
|
## download
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user