This commit is contained in:
2025-02-28 02:38:46 +08:00
parent 319981909f
commit 9660bd6fc6
8 changed files with 73 additions and 3 deletions

View File

@@ -1,7 +1,7 @@
[metadata]
# replace with your username:
name = guan
version = 0.1.154
version = 0.1.155
author = guanjihuan
author_email = guanjihuan@163.com
description = An open source python package

View File

@@ -1,6 +1,6 @@
Metadata-Version: 2.2
Name: guan
Version: 0.1.154
Version: 0.1.155
Summary: An open source python package
Home-page: https://py.guanjihuan.com
Author: guanjihuan

View File

@@ -8,12 +8,14 @@ src/guan/Hamiltonian_of_examples.py
src/guan/__init__.py
src/guan/band_structures_and_wave_functions.py
src/guan/basic_functions.py
src/guan/custom_classes.py
src/guan/data_processing.py
src/guan/decorators.py
src/guan/density_of_states.py
src/guan/deprecated.py
src/guan/figure_plotting.py
src/guan/file_reading_and_writing.py
src/guan/functions_using_objects_of_custom_classes.py
src/guan/machine_learning.py
src/guan/quantum_transport.py
src/guan/topological_invariant.py

View File

@@ -13,5 +13,7 @@ from .file_reading_and_writing import *
from .figure_plotting import *
from .data_processing import *
from .decorators import *
from .custom_classes import *
from .functions_using_objects_of_custom_classes import *
from .deprecated import *
statistics_of_guan_package()

View File

@@ -0,0 +1,11 @@
# 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

View File

@@ -12,6 +12,38 @@ def import_plt_and_start_fig_ax(adjust_bottom=0.2, adjust_left=0.2, labelsize=20
[label.set_fontname('Times New Roman') for label in labels]
return plt, fig, ax
# 导入plt, fig, ax不显示坐标
def import_plt_and_start_fig_ax_without_axis():
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
plt.subplots_adjust(left=0, bottom=0, right=1, top=1)
plt.axis('off')
return plt, fig, ax
# 保存图片为所有常见的格式
def savefig_with_all_formats(plt, filename, more_dpi=1, tiff=0):
plt.savefig(filename+'.eps')
plt.savefig(filename+'.svg')
plt.savefig(filename+'.pdf')
plt.savefig(filename+'.jpg')
plt.savefig(filename+'.png')
if tiff:
plt.savefig(filename+'.tiff')
if more_dpi:
try:
plt.savefig(filename+'_dpi=300.jpg', dpi=300)
plt.savefig(filename+'_dpi=600.jpg', dpi=600)
plt.savefig(filename+'_dpi=1000.jpg', dpi=1000)
plt.savefig(filename+'_dpi=300.png', dpi=300)
plt.savefig(filename+'_dpi=600.png', dpi=600)
plt.savefig(filename+'_dpi=1000.png', dpi=1000)
if tiff:
plt.savefig(filename+'_dpi=300.tiff', dpi=300)
plt.savefig(filename+'_dpi=600.tiff', dpi=600)
plt.savefig(filename+'_dpi=1000.tiff', dpi=1000)
except:
pass
# 基于plt, fig, ax画图
def plot_without_starting_fig_ax(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'):
if color==None:

View File

@@ -0,0 +1,21 @@
# functions_using_objects_of_custom_classes
# 从原子对象列表中获取 (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
# 根据原子对象列表来初始化哈密顿量
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