This commit is contained in:
guanjihuan 2024-11-22 12:53:49 +08:00
parent fc304f4c3b
commit 5b9a2d7267
4 changed files with 43 additions and 3 deletions

View File

@ -1,7 +1,7 @@
[metadata] [metadata]
# replace with your username: # replace with your username:
name = guan name = guan
version = 0.1.125 version = 0.1.126
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

View File

@ -1,6 +1,6 @@
Metadata-Version: 2.1 Metadata-Version: 2.1
Name: guan Name: guan
Version: 0.1.125 Version: 0.1.126
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

View File

@ -65,12 +65,47 @@ 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):
import numpy as np import numpy as np
eigenvalue, eigenvector = np.linalg.eigh(hamiltonian) eigenvalue, eigenvector = np.linalg.eigh(hamiltonian)
return eigenvector return eigenvector
# 施密特正交化
def schmidt_orthogonalization(eigenvector):
import numpy as np
num = eigenvector.shape[1]
for i in range(num):
for i0 in range(i):
eigenvector[:, i] = eigenvector[:, i] - eigenvector[:, i0]*np.dot(eigenvector[:, i].transpose().conj(), eigenvector[:, i0])/(np.dot(eigenvector[:, i0].transpose().conj(),eigenvector[:, i0]))
eigenvector[:, i] = eigenvector[:, i]/np.linalg.norm(eigenvector[:, i])
return eigenvector
# 通过QR分解正交化
def orthogonalization_with_qr(eigenvector):
import numpy as np
Q, R = np.linalg.qr(eigenvector)
return Q
# 通过SVD正交化
def orthogonalization_with_svd(eigenvector):
import numpy as np
U, sigma, VT = np.linalg.svd(eigenvector)
return U
# 通过scipy.linalg.orth正交化
def orthogonalization_with_scipy_linalg_orth(eigenvector):
import scipy
Q = scipy.linalg.orth(eigenvector)
return Q
# 验证是否正交
def verify_orthogonality(eigenvector):
import numpy as np
identity = np.eye(eigenvector.shape[1])
product = np.dot(eigenvector.transpose().conj(), eigenvector)
return np.allclose(product, identity)
# 通过二分查找的方法获取和相邻波函数一样规范的波函数 # 通过二分查找的方法获取和相邻波函数一样规范的波函数
def find_vector_with_the_same_gauge_with_binary_search(vector_target, vector_ref, show_error=1, show_times=0, show_phase=0, n_test=1000, precision=1e-6): def find_vector_with_the_same_gauge_with_binary_search(vector_target, vector_ref, show_error=1, show_times=0, show_phase=0, n_test=1000, precision=1e-6):
import numpy as np import numpy as np

View File

@ -481,6 +481,11 @@ def convert_wordpress_xml_to_markdown(xml_file='./a.xml', convert_content=1, rep
with open(cleaned_filename, 'w', encoding='utf-8') as md_file: with open(cleaned_filename, 'w', encoding='utf-8') as md_file:
md_file.write(markdown_content) md_file.write(markdown_content)
# 凯利公式
def kelly_formula(p, b, a=1):
f=(p/a)-((1-p)/b)
return f
# 获取所有股票 # 获取所有股票
def all_stocks(): def all_stocks():
import numpy as np import numpy as np