Compare commits
17 Commits
6ec38a3e08
...
master
Author | SHA1 | Date | |
---|---|---|---|
b60e485691 | |||
28118fbd88 | |||
92221832d6 | |||
c068394f9b | |||
e65ea73992 | |||
8f0bae617d | |||
9b92f0df24 | |||
f4a7e70c82 | |||
b0e29a164a | |||
c35688a49e | |||
83601c45af | |||
0de9394118 | |||
944bbc6a77 | |||
0d5c72dc1f | |||
7176bc5d57 | |||
463fc041f1 | |||
e173828a2d |
@@ -1,7 +1,7 @@
|
|||||||
[metadata]
|
[metadata]
|
||||||
# replace with your username:
|
# replace with your username:
|
||||||
name = guan
|
name = guan
|
||||||
version = 0.1.168
|
version = 0.1.186
|
||||||
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
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
Metadata-Version: 2.4
|
Metadata-Version: 2.4
|
||||||
Name: guan
|
Name: guan
|
||||||
Version: 0.1.168
|
Version: 0.1.186
|
||||||
Summary: An open source python package
|
Summary: An open source python package
|
||||||
Home-page: https://py.guanjihuan.com
|
Home-page: https://py.guanjihuan.com
|
||||||
Author: guanjihuan
|
Author: guanjihuan
|
||||||
|
@@ -8,15 +8,13 @@ src/guan/Hamiltonian_of_examples.py
|
|||||||
src/guan/__init__.py
|
src/guan/__init__.py
|
||||||
src/guan/band_structures_and_wave_functions.py
|
src/guan/band_structures_and_wave_functions.py
|
||||||
src/guan/basic_functions.py
|
src/guan/basic_functions.py
|
||||||
src/guan/custom_classes.py
|
|
||||||
src/guan/data_processing.py
|
src/guan/data_processing.py
|
||||||
src/guan/decorators.py
|
src/guan/decorators.py
|
||||||
src/guan/density_of_states.py
|
src/guan/density_of_states.py
|
||||||
src/guan/deprecated.py
|
|
||||||
src/guan/figure_plotting.py
|
src/guan/figure_plotting.py
|
||||||
src/guan/file_reading_and_writing.py
|
src/guan/file_reading_and_writing.py
|
||||||
src/guan/functions_using_objects_of_custom_classes.py
|
|
||||||
src/guan/machine_learning.py
|
src/guan/machine_learning.py
|
||||||
|
src/guan/others.py
|
||||||
src/guan/quantum_transport.py
|
src/guan/quantum_transport.py
|
||||||
src/guan/topological_invariant.py
|
src/guan/topological_invariant.py
|
||||||
src/guan.egg-info/PKG-INFO
|
src/guan.egg-info/PKG-INFO
|
||||||
|
@@ -13,7 +13,5 @@ from .file_reading_and_writing import *
|
|||||||
from .figure_plotting import *
|
from .figure_plotting import *
|
||||||
from .data_processing import *
|
from .data_processing import *
|
||||||
from .decorators import *
|
from .decorators import *
|
||||||
from .custom_classes import *
|
from .others import *
|
||||||
from .functions_using_objects_of_custom_classes import *
|
|
||||||
from .deprecated import *
|
|
||||||
statistics_of_guan_package()
|
statistics_of_guan_package()
|
@@ -1,12 +1,15 @@
|
|||||||
# Module: band_structures_and_wave_functions
|
# Module: band_structures_and_wave_functions
|
||||||
|
|
||||||
# 计算哈密顿量的本征值
|
# 计算哈密顿量的本征值
|
||||||
def calculate_eigenvalue(hamiltonian):
|
def calculate_eigenvalue(hamiltonian, hermitian=True):
|
||||||
import numpy as np
|
import numpy as np
|
||||||
if np.array(hamiltonian).shape==():
|
if np.array(hamiltonian).shape==():
|
||||||
eigenvalue = np.real(hamiltonian)
|
eigenvalue = np.real(hamiltonian)
|
||||||
else:
|
else:
|
||||||
|
if hermitian:
|
||||||
eigenvalue, eigenvector = np.linalg.eigh(hamiltonian)
|
eigenvalue, eigenvector = np.linalg.eigh(hamiltonian)
|
||||||
|
else:
|
||||||
|
eigenvalue, eigenvector = np.linalg.eig(hamiltonian)
|
||||||
return eigenvalue
|
return eigenvalue
|
||||||
|
|
||||||
# 输入哈密顿量函数(带一组参数),计算一组参数下的本征值,返回本征值向量组
|
# 输入哈密顿量函数(带一组参数),计算一组参数下的本征值,返回本征值向量组
|
||||||
@@ -65,10 +68,13 @@ def calculate_eigenvalue_with_two_parameters(x_array, y_array, hamiltonian_funct
|
|||||||
i0 += 1
|
i0 += 1
|
||||||
return eigenvalue_array
|
return eigenvalue_array
|
||||||
|
|
||||||
# 计算哈密顿量的本征矢(厄密矩阵)
|
# 计算哈密顿量的本征矢
|
||||||
def calculate_eigenvector(hamiltonian):
|
def calculate_eigenvector(hamiltonian, hermitian=True):
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
if hermitian:
|
||||||
eigenvalue, eigenvector = np.linalg.eigh(hamiltonian)
|
eigenvalue, eigenvector = np.linalg.eigh(hamiltonian)
|
||||||
|
else:
|
||||||
|
eigenvalue, eigenvector = np.linalg.eig(hamiltonian)
|
||||||
return eigenvector
|
return eigenvector
|
||||||
|
|
||||||
# 施密特正交化
|
# 施密特正交化
|
||||||
|
@@ -1,11 +0,0 @@
|
|||||||
# Module: custom_classes
|
|
||||||
|
|
||||||
# 原子类
|
|
||||||
class Atom:
|
|
||||||
def __init__(self, name='atom', index=0, x=0, y=0, z=0, energy=0):
|
|
||||||
self.name = name
|
|
||||||
self.index = index
|
|
||||||
self.x = x
|
|
||||||
self.y = y
|
|
||||||
self.z = z
|
|
||||||
self.energy = energy
|
|
File diff suppressed because it is too large
Load Diff
@@ -1,40 +0,0 @@
|
|||||||
# Module: deprecated
|
|
||||||
|
|
||||||
def make_sh_file(sh_filename='a', command_line='python a.py', cpu_num=1, task_name='task', cd_dir=0):
|
|
||||||
import guan
|
|
||||||
print('Warning: The current function name has been deprecated, which will be deleted in the future version. Please change it into guan.make_sh_file_for_qsub().')
|
|
||||||
guan.make_sh_file_for_qsub(sh_filename=sh_filename, command_line=command_line, cpu_num=cpu_num, task_name=task_name, cd_dir=cd_dir)
|
|
||||||
|
|
||||||
def plot_without_starting_fig(plt, fig, ax, x_array, y_array, xlabel='x', ylabel='y', title='', fontsize=20, style='', y_min=None, y_max=None, linewidth=None, markersize=None, color=None, fontfamily='Times New Roman'):
|
|
||||||
import guan
|
|
||||||
print('Warning: The current function name has been deprecated, which will be deleted in the future version. Please change it into guan.plot_without_starting_fig_ax().')
|
|
||||||
guan.plot_without_starting_fig_ax(plt, fig, ax, x_array, y_array, xlabel=xlabel, ylabel=ylabel, title=title, fontsize=fontsize, style=style, y_min=y_min, y_max=y_max, linewidth=linewidth, markersize=markersize, color=color, fontfamily=fontfamily)
|
|
||||||
|
|
||||||
def draw_dots_and_lines_without_starting_fig(plt, fig, ax, coordinate_array, draw_dots=1, draw_lines=1, max_distance=1, line_style='-k', linewidth=1, dot_style='ro', markersize=3):
|
|
||||||
import guan
|
|
||||||
print('Warning: The current function name has been deprecated, which will be deleted in the future version. Please change it into guan.draw_dots_and_lines_without_starting_fig_ax().')
|
|
||||||
guan.draw_dots_and_lines_without_starting_fig_ax(plt, fig, ax, coordinate_array, draw_dots=draw_dots, draw_lines=draw_lines, max_distance=max_distance, line_style=line_style, linewidth=linewidth, dot_style=dot_style, markersize=markersize)
|
|
||||||
|
|
||||||
def get_days_of_the_current_month(str_or_datetime='str'):
|
|
||||||
import guan
|
|
||||||
print('Warning: The current function name has been deprecated, which will be deleted in the future version. Please change it into guan.get_date_array_of_the_current_month().')
|
|
||||||
date_array = guan.get_date_array_of_the_current_month(str_or_datetime=str_or_datetime)
|
|
||||||
return date_array
|
|
||||||
|
|
||||||
def get_days_of_the_last_month(str_or_datetime='str'):
|
|
||||||
import guan
|
|
||||||
print('Warning: The current function name has been deprecated, which will be deleted in the future version. Please change it into guan.get_date_array_of_the_last_month().')
|
|
||||||
date_array = guan.get_date_array_of_the_last_month(str_or_datetime=str_or_datetime)
|
|
||||||
return date_array
|
|
||||||
|
|
||||||
def get_days_of_the_month_before_last(str_or_datetime='str'):
|
|
||||||
import guan
|
|
||||||
print('Warning: The current function name has been deprecated, which will be deleted in the future version. Please change it into guan.get_date_array_of_the_month_before_last().')
|
|
||||||
date_array = guan.get_date_array_of_the_month_before_last(str_or_datetime=str_or_datetime)
|
|
||||||
return date_array
|
|
||||||
|
|
||||||
def pdf_to_text(pdf_path):
|
|
||||||
import guan
|
|
||||||
print('Warning: The current function name has been deprecated, which will be deleted in the future version. Please change it into guan.pdf_to_text_with_pdfminer3k().')
|
|
||||||
content = guan.pdf_to_text_with_pdfminer3k(pdf_path)
|
|
||||||
return content
|
|
@@ -1,7 +1,7 @@
|
|||||||
# Module: file_reading_and_writing
|
# Module: file_reading_and_writing
|
||||||
|
|
||||||
# 使用pickle将变量保存到文件(支持几乎所有对象类型)
|
# 使用pickle将变量保存到文件(支持几乎所有对象类型)
|
||||||
def dump_data(data, filename, file_format='.pkl'):
|
def dump_data(data, filename='a', file_format='.pkl'):
|
||||||
import pickle
|
import pickle
|
||||||
with open(filename+file_format, 'wb') as f:
|
with open(filename+file_format, 'wb') as f:
|
||||||
pickle.dump(data, f)
|
pickle.dump(data, f)
|
||||||
@@ -14,7 +14,7 @@ def load_data(filename, file_format='.pkl'):
|
|||||||
return data
|
return data
|
||||||
|
|
||||||
# 使用NumPy保存数组变量到npy文件(二进制文件)
|
# 使用NumPy保存数组变量到npy文件(二进制文件)
|
||||||
def save_npy_data(data, filename):
|
def save_npy_data(data, filename='a'):
|
||||||
import numpy as np
|
import numpy as np
|
||||||
np.save(filename+'.npy', data)
|
np.save(filename+'.npy', data)
|
||||||
|
|
||||||
@@ -25,7 +25,7 @@ def load_npy_data(filename):
|
|||||||
return data
|
return data
|
||||||
|
|
||||||
# 使用NumPy保存数组变量到TXT文件(文本文件)
|
# 使用NumPy保存数组变量到TXT文件(文本文件)
|
||||||
def save_txt_data(data, filename):
|
def save_txt_data(data, filename='a'):
|
||||||
import numpy as np
|
import numpy as np
|
||||||
np.savetxt(filename+'.txt', data)
|
np.savetxt(filename+'.txt', data)
|
||||||
|
|
||||||
@@ -243,6 +243,177 @@ def write_two_dimensional_data_without_xy_array_and_without_opening_file(matrix,
|
|||||||
f.write(str(element)+' ')
|
f.write(str(element)+' ')
|
||||||
f.write('\n')
|
f.write('\n')
|
||||||
|
|
||||||
|
# 创建一个sh文件用于提交任务(PBS)
|
||||||
|
def make_sh_file_for_qsub(sh_filename='a', command_line='python a.py', cpu_num=1, task_name='task', cd_dir=0, pbs_q=0, queue_name='bigmem', specific_node=0, node_name='node50.cluster'):
|
||||||
|
sh_content = \
|
||||||
|
'#!/bin/sh\n' \
|
||||||
|
+f'#PBS -N {task_name}\n'
|
||||||
|
if pbs_q==1:
|
||||||
|
sh_content += f'#PBS -q {queue_name}\n'
|
||||||
|
if specific_node==0:
|
||||||
|
sh_content += f'#PBS -l nodes=1:ppn={cpu_num}\n'
|
||||||
|
else:
|
||||||
|
sh_content += f'#PBS -l nodes={node_name}:ppn={cpu_num}\n'
|
||||||
|
if cd_dir==1:
|
||||||
|
sh_content += 'cd $PBS_O_WORKDIR\n'
|
||||||
|
sh_content += command_line
|
||||||
|
with open(sh_filename+'.sh', 'w') as f:
|
||||||
|
f.write(sh_content)
|
||||||
|
|
||||||
|
# 创建一个sh文件用于提交任务(Slurm)
|
||||||
|
def make_sh_file_for_sbatch(sh_filename='a', command_line='python a.py', cpu_num=1, task_name='task', cd_dir=0, sbatch_partition=0, partition_name='cpu48'):
|
||||||
|
sh_content = \
|
||||||
|
'#!/bin/sh\n' \
|
||||||
|
+f'#SBATCH --job-name={task_name}\n'
|
||||||
|
if sbatch_partition==1:
|
||||||
|
sh_content += f'#SBATCH --partition={partition_name}\n'
|
||||||
|
sh_content += f'#SBATCH --cpus-per-task={cpu_num}\n'
|
||||||
|
if cd_dir==1:
|
||||||
|
sh_content += 'cd $PBS_O_WORKDIR\n'
|
||||||
|
sh_content += command_line
|
||||||
|
with open(sh_filename+'.sh', 'w') as f:
|
||||||
|
f.write(sh_content)
|
||||||
|
|
||||||
|
# 创建一个sh文件用于提交任务(LSF)
|
||||||
|
def make_sh_file_for_bsub(sh_filename='a', command_line='python a.py', cpu_num=1, task_name='task', cd_dir=0, bsub_q=0, queue_name='score'):
|
||||||
|
sh_content = \
|
||||||
|
'#!/bin/sh\n' \
|
||||||
|
+f'#BSUB -J {task_name}\n'
|
||||||
|
if bsub_q==1:
|
||||||
|
sh_content += f'#BSUB -q {queue_name}\n'
|
||||||
|
sh_content += f'#BSUB -n {cpu_num}\n'
|
||||||
|
if cd_dir==1:
|
||||||
|
sh_content += 'cd $PBS_O_WORKDIR\n'
|
||||||
|
sh_content += command_line
|
||||||
|
with open(sh_filename+'.sh', 'w') as f:
|
||||||
|
f.write(sh_content)
|
||||||
|
|
||||||
|
# qsub 提交任务(PBS)
|
||||||
|
def qsub_task(filename='a', file_format='.sh'):
|
||||||
|
import os
|
||||||
|
os.system('qsub '+filename+file_format)
|
||||||
|
|
||||||
|
# sbatch 提交任务(Slurm)
|
||||||
|
def sbatch_task(filename='a', file_format='.sh'):
|
||||||
|
import os
|
||||||
|
os.system('sbatch '+filename+file_format)
|
||||||
|
|
||||||
|
# bsub 提交任务(LSF)
|
||||||
|
def bsub_task(filename='a', file_format='.sh'):
|
||||||
|
import os
|
||||||
|
os.system('bsub < '+filename+file_format)
|
||||||
|
|
||||||
|
# 复制.py和.sh文件,然后提交任务,实现半手动并行(PBS)
|
||||||
|
def copy_py_sh_file_and_qsub_task(parameter_array, py_filename='a', old_str_in_py='parameter = 0', new_str_in_py='parameter = ', sh_filename='a', task_name='task'):
|
||||||
|
import os
|
||||||
|
parameter_str_array = []
|
||||||
|
for i0 in parameter_array:
|
||||||
|
parameter_str_array.append(str(i0))
|
||||||
|
index = 0
|
||||||
|
for parameter_str in parameter_str_array:
|
||||||
|
index += 1
|
||||||
|
# copy python file
|
||||||
|
old_file = py_filename+'.py'
|
||||||
|
new_file = py_filename+'_'+str(index)+'.py'
|
||||||
|
os.system('cp '+old_file+' '+new_file)
|
||||||
|
with open(new_file, 'r') as f:
|
||||||
|
content = f.read()
|
||||||
|
old_str = old_str_in_py
|
||||||
|
new_str = new_str_in_py+parameter_str
|
||||||
|
content = content.replace(old_str, new_str)
|
||||||
|
with open(py_filename+'_'+str(index)+'.py', 'w') as f:
|
||||||
|
f.write(content)
|
||||||
|
# copy sh file
|
||||||
|
old_file = sh_filename+'.sh'
|
||||||
|
new_file = sh_filename+'_'+str(index)+'.sh'
|
||||||
|
os.system('cp '+old_file+' '+new_file)
|
||||||
|
with open(new_file, 'r') as f:
|
||||||
|
content = f.read()
|
||||||
|
old_str = 'python '+py_filename+'.py'
|
||||||
|
new_str = 'python '+py_filename+'_'+str(index)+'.py'
|
||||||
|
content = content.replace(old_str, new_str)
|
||||||
|
old_str = '#PBS -N '+task_name
|
||||||
|
new_str = '#PBS -N '+task_name+'_'+str(index)
|
||||||
|
content = content.replace(old_str, new_str)
|
||||||
|
with open(sh_filename+'_'+str(index)+'.sh', 'w') as f:
|
||||||
|
f.write(content)
|
||||||
|
# qsub task
|
||||||
|
os.system('qsub '+new_file)
|
||||||
|
|
||||||
|
# 复制.py和.sh文件,然后提交任务,实现半手动并行(Slurm)
|
||||||
|
def copy_py_sh_file_and_sbatch_task(parameter_array, py_filename='a', old_str_in_py='parameter = 0', new_str_in_py='parameter = ', sh_filename='a', task_name='task'):
|
||||||
|
import os
|
||||||
|
parameter_str_array = []
|
||||||
|
for i0 in parameter_array:
|
||||||
|
parameter_str_array.append(str(i0))
|
||||||
|
index = 0
|
||||||
|
for parameter_str in parameter_str_array:
|
||||||
|
index += 1
|
||||||
|
# copy python file
|
||||||
|
old_file = py_filename+'.py'
|
||||||
|
new_file = py_filename+'_'+str(index)+'.py'
|
||||||
|
os.system('cp '+old_file+' '+new_file)
|
||||||
|
with open(new_file, 'r') as f:
|
||||||
|
content = f.read()
|
||||||
|
old_str = old_str_in_py
|
||||||
|
new_str = new_str_in_py+parameter_str
|
||||||
|
content = content.replace(old_str, new_str)
|
||||||
|
with open(py_filename+'_'+str(index)+'.py', 'w') as f:
|
||||||
|
f.write(content)
|
||||||
|
# copy sh file
|
||||||
|
old_file = sh_filename+'.sh'
|
||||||
|
new_file = sh_filename+'_'+str(index)+'.sh'
|
||||||
|
os.system('cp '+old_file+' '+new_file)
|
||||||
|
with open(new_file, 'r') as f:
|
||||||
|
content = f.read()
|
||||||
|
old_str = 'python '+py_filename+'.py'
|
||||||
|
new_str = 'python '+py_filename+'_'+str(index)+'.py'
|
||||||
|
content = content.replace(old_str, new_str)
|
||||||
|
old_str = '#SBATCH --job-name='+task_name
|
||||||
|
new_str = '#SBATCH --job-name='+task_name+'_'+str(index)
|
||||||
|
content = content.replace(old_str, new_str)
|
||||||
|
with open(sh_filename+'_'+str(index)+'.sh', 'w') as f:
|
||||||
|
f.write(content)
|
||||||
|
# sbatch task
|
||||||
|
os.system('sbatch '+new_file)
|
||||||
|
|
||||||
|
# 复制.py和.sh文件,然后提交任务,实现半手动并行(LSF)
|
||||||
|
def copy_py_sh_file_and_bsub_task(parameter_array, py_filename='a', old_str_in_py='parameter = 0', new_str_in_py='parameter = ', sh_filename='a', task_name='task'):
|
||||||
|
import os
|
||||||
|
parameter_str_array = []
|
||||||
|
for i0 in parameter_array:
|
||||||
|
parameter_str_array.append(str(i0))
|
||||||
|
index = 0
|
||||||
|
for parameter_str in parameter_str_array:
|
||||||
|
index += 1
|
||||||
|
# copy python file
|
||||||
|
old_file = py_filename+'.py'
|
||||||
|
new_file = py_filename+'_'+str(index)+'.py'
|
||||||
|
os.system('cp '+old_file+' '+new_file)
|
||||||
|
with open(new_file, 'r') as f:
|
||||||
|
content = f.read()
|
||||||
|
old_str = old_str_in_py
|
||||||
|
new_str = new_str_in_py+parameter_str
|
||||||
|
content = content.replace(old_str, new_str)
|
||||||
|
with open(py_filename+'_'+str(index)+'.py', 'w') as f:
|
||||||
|
f.write(content)
|
||||||
|
# copy sh file
|
||||||
|
old_file = sh_filename+'.sh'
|
||||||
|
new_file = sh_filename+'_'+str(index)+'.sh'
|
||||||
|
os.system('cp '+old_file+' '+new_file)
|
||||||
|
with open(new_file, 'r') as f:
|
||||||
|
content = f.read()
|
||||||
|
old_str = 'python '+py_filename+'.py'
|
||||||
|
new_str = 'python '+py_filename+'_'+str(index)+'.py'
|
||||||
|
content = content.replace(old_str, new_str)
|
||||||
|
old_str = '#BSUB -J '+task_name
|
||||||
|
new_str = '#BSUB -J '+task_name+'_'+str(index)
|
||||||
|
content = content.replace(old_str, new_str)
|
||||||
|
with open(sh_filename+'_'+str(index)+'.sh', 'w') as f:
|
||||||
|
f.write(content)
|
||||||
|
# bsub task
|
||||||
|
os.system('bsub < '+new_file)
|
||||||
|
|
||||||
# 把矩阵写入.md文件(Markdown表格形式)
|
# 把矩阵写入.md文件(Markdown表格形式)
|
||||||
def write_matrix_in_markdown_format(matrix, filename='a'):
|
def write_matrix_in_markdown_format(matrix, filename='a'):
|
||||||
import numpy as np
|
import numpy as np
|
||||||
@@ -250,13 +421,15 @@ def write_matrix_in_markdown_format(matrix, filename='a'):
|
|||||||
dim_0 = matrix.shape[0]
|
dim_0 = matrix.shape[0]
|
||||||
dim_1 = matrix.shape[1]
|
dim_1 = matrix.shape[1]
|
||||||
with open(filename+'.md', 'w', encoding='UTF-8') as f:
|
with open(filename+'.md', 'w', encoding='UTF-8') as f:
|
||||||
|
f.write(f'| Row\Column ')
|
||||||
for i1 in range(dim_1):
|
for i1 in range(dim_1):
|
||||||
f.write(f'| column {i1+1} ')
|
f.write(f'| column {i1+1} ')
|
||||||
f.write('|\n')
|
f.write('|\n')
|
||||||
for i1 in range(dim_1):
|
for i1 in range(dim_1+1):
|
||||||
f.write('| :---: ')
|
f.write('| :---: ')
|
||||||
f.write('|\n')
|
f.write('|\n')
|
||||||
for i0 in range(dim_0):
|
for i0 in range(dim_0):
|
||||||
|
f.write(f'| row {i0+1} ')
|
||||||
for i1 in range(dim_1):
|
for i1 in range(dim_1):
|
||||||
f.write(f'| {matrix[i0, i1]} ')
|
f.write(f'| {matrix[i0, i1]} ')
|
||||||
f.write('|\n')
|
f.write('|\n')
|
||||||
|
@@ -1,62 +0,0 @@
|
|||||||
# functions_using_objects_of_custom_classes
|
|
||||||
|
|
||||||
# 将原子对象列表转成原子字典列表
|
|
||||||
def convert_atom_object_list_to_atom_dict_list(atom_object_list):
|
|
||||||
atom_dict_list = []
|
|
||||||
for atom_object in atom_object_list:
|
|
||||||
atom_dict = {
|
|
||||||
'name': atom_object.name,
|
|
||||||
'index': atom_object.index,
|
|
||||||
'x': atom_object.x,
|
|
||||||
'y': atom_object.y,
|
|
||||||
'z': atom_object.z,
|
|
||||||
'energy': atom_object.energy,
|
|
||||||
}
|
|
||||||
atom_dict_list.append(atom_dict)
|
|
||||||
return atom_dict_list
|
|
||||||
|
|
||||||
# 从原子对象列表中获取 (x, y) 坐标数组
|
|
||||||
def get_coordinate_array_from_atom_object_list(atom_object_list):
|
|
||||||
coordinate_array = []
|
|
||||||
for atom in atom_object_list:
|
|
||||||
x = atom.x
|
|
||||||
y = atom.y
|
|
||||||
coordinate_array.append([x, y])
|
|
||||||
return coordinate_array
|
|
||||||
|
|
||||||
# 从原子对象列表中获取 x 和 y 的最大值和最小值
|
|
||||||
def get_max_min_x_y_from_atom_object_list(atom_object_list):
|
|
||||||
import guan
|
|
||||||
coordinate_array = guan.get_coordinate_array_from_atom_object_list(atom_object_list)
|
|
||||||
x_array = []
|
|
||||||
for coordinate in coordinate_array:
|
|
||||||
x_array.append(coordinate[0])
|
|
||||||
y_array = []
|
|
||||||
for coordinate in coordinate_array:
|
|
||||||
y_array.append(coordinate[1])
|
|
||||||
max_x = max(x_array)
|
|
||||||
min_x = min(x_array)
|
|
||||||
max_y = max(y_array)
|
|
||||||
min_y = min(y_array)
|
|
||||||
return max_x, min_x, max_y, min_y
|
|
||||||
|
|
||||||
# 从原子对象列表中获取满足坐标条件的索引
|
|
||||||
def get_index_via_coordinate_from_atom_object_list(atom_object_list, x=0, y=0, z=0, eta=1e-3):
|
|
||||||
for atom in atom_object_list:
|
|
||||||
x_i = atom.x
|
|
||||||
y_i = atom.y
|
|
||||||
z_i = atom.z
|
|
||||||
index = atom.index
|
|
||||||
if abs(x-x_i)<eta and abs(y-y_i)<eta and abs(z-z_i)<eta:
|
|
||||||
return index
|
|
||||||
|
|
||||||
# 根据原子对象列表来初始化哈密顿量
|
|
||||||
def initialize_hamiltonian_from_atom_object_list(atom_object_list):
|
|
||||||
import numpy as np
|
|
||||||
import guan
|
|
||||||
dim = guan.dimension_of_array(atom_object_list[0].energy)
|
|
||||||
num = len(atom_object_list)
|
|
||||||
hamiltonian = np.zeros((dim*num, dim*num))
|
|
||||||
for i0 in range(num):
|
|
||||||
hamiltonian[i0*dim+0:i0*dim+dim, i0*dim+0:i0*dim+dim] = atom_object_list[i0].energy
|
|
||||||
return hamiltonian
|
|
1356
PyPI/src/guan/others.py
Normal file
1356
PyPI/src/guan/others.py
Normal file
File diff suppressed because it is too large
Load Diff
@@ -26,9 +26,8 @@ import guan
|
|||||||
+ file reading and writing
|
+ file reading and writing
|
||||||
+ figure plotting
|
+ figure plotting
|
||||||
+ data processing
|
+ data processing
|
||||||
+ custom classes
|
|
||||||
+ functions using objects of custom classes
|
|
||||||
+ decorators
|
+ decorators
|
||||||
|
+ others
|
||||||
|
|
||||||
## About this package
|
## About this package
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user