Open newplay opened 8 months ago
Can you show me the parameters in the config.yaml file that are used for predicting the Hamiltonian of this structure? Did you use the .ckpt model weights file I provided in the repository to predict this band structure, or did you train your own .ckpt file?
You can adjust the displayed range of the y-axis for the predicted bands to [-4, 4] and then compare them with the target bands. We only compare energy bands near the Fermi surface as predictions for very high empty states are unreliable; fortunately, we usually do not use these high energy bands.
Did you use the .ckpt model weights file I provided in the repository to predict this band structure, or did you train your own .ckpt file?
I used the .ckpt model from your dataset in the MoS2 demo, so I think the configuration is the same as yours.
and if change the ylim
to [-4,4]:
I noticed that your hamiltonian_path
parameter in band_cal.yaml is '/home/zjlin/ML_work/HamGNN/Bilayer_MoS2_Demo/database/bilayer_MoS2/Examples/Moire_twisted_bilayer_MoS2/version_0/target_hamiltonian.npy',The target Hamiltonian here is fake because you haven't actually performed the SCF calculation, it is from the openmx_postprocess
. Therefore, you should use "prediction_hamiltonian.npy" to calculate the energy bands.
I noticed that your
hamiltonian_path
parameter in band_cal.yaml is '/home/zjlin/ML_work/HamGNN/Bilayer_MoS2_Demo/database/bilayer_MoS2/Examples/Moire_twisted_bilayer_MoS2/version_0/target_hamiltonian.npy',The target Hamiltonian here is fake because you haven't actually performed the SCF calculation, it is from theopenmx_postprocess
. Therefore, you should use "prediction_hamiltonian.npy" to calculate the energy bands.
Thank you. I trust that's the essence of this issue. I will attempt it later.
Best regards, TzuChing
I noticed that your
hamiltonian_path
parameter in band_cal.yaml is '/home/zjlin/ML_work/HamGNN/Bilayer_MoS2_Demo/database/bilayer_MoS2/Examples/Moire_twisted_bilayer_MoS2/version_0/target_hamiltonian.npy',The target Hamiltonian here is fake because you haven't actually performed the SCF calculation, it is from theopenmx_postprocess
. Therefore, you should use "prediction_hamiltonian.npy" to calculate the energy bands.Thank you. I trust that's the essence of this issue. I will attempt it later.
Best regards, TzuChing
I apologize for the unfortunate news: I changed the target_Hamiltonian.npy
to prediction_Hamiltonian.npy
, but the result remains the same as depicted in the figure above.
Hi, TzuChing. I'm not sure if there is anything wrong with the graph_data.npz you got, but you can try the graph_data.npz I gave here for the bilayer MoS2 with 21.79 degrees. graph_data.npz.zip
Hi, TzuChing. I'm not sure if there is anything wrong with the graph_data.npz you got, but you can try the graph_data.npz I gave here for the bilayer MoS2 with 21.79 degrees. graph_data.npz.zip
Thank you , will try it immediately.
Dear Yang Zhong: May I kindly inquire if you have had the opportunity to execute the 'graph_data' file? I am still experiencing consistent results on my end. If convenient, could you please share the outcomes of your execution? Best regards, TzuChing
Dear Yang Zhong: Apologies for my oversight; I mistakenly executed 'band_cal' without utilizing .ckpt for prediction. I regret any time and effort that you may have been wasted. Moving forward, I will ensure to carefully review the requirements and inspect the source code before seeking assistance. Thank you for your support, and I apologize once again. Best regards, TzuChing
Dear TzuChing,
No problem at all! These things happen, and I understand that troubleshooting can sometimes be a complex process. If you encounter any other issues, feel free to contact me.
Best wishes, Yang Zhong
Dear Yang Zhong: Apologies for my oversight; I mistakenly executed 'band_cal' without utilizing .ckpt for prediction. I regret any time and effort that you may have been wasted. Moving forward, I will ensure to carefully review the requirements and inspect the source code before seeking assistance. Thank you for your support, and I apologize once again. Best regards, TzuChing
Dear Yang Zhong,
I trust this message finds you well. Following the execution of 'HamGNN --config config.yaml,' the 'prediction_hamiltonian.npy' was successfully generated. However, I encountered an issue during the subsequent processing:
Traceback (most recent call last):
File "/home/zjlin/HamGNN/utils_openmx/band_cal.py", line 438, in <module>
main()
File "/home/zjlin/HamGNN/utils_openmx/band_cal.py", line 365, in main
w, v = eigh(a=HK[ik], b=SK[ik])
File "/home/zjlin/anaconda3/envs/HamGNN/lib/python3.9/site-packages/scipy/linalg/_decomp.py", line 593, in eigh
raise LinAlgError('The leading minor of order {} of B is not '
numpy.linalg.LinAlgError: The leading minor of order 557 of B is not positive definite. The factorization of B could not be completed, and no eigenvalues or eigenvectors were computed.
Upon investigation, I used the code snippet below to check the positive definiteness of matrices A and B:
A = np.linalg.eigvals(HK[ik])
B = np.linalg.eigvals(SK[ik])
if A.all() > 0 :
print(f"A is a positive definite matrix")
elif B.all() > 0:
print(f"B is a positive definite matrix")
else:
print(f"A and B are not positive definite")
Surprisingly, the output consistently indicates 'B is a positive definite matrix.' I have also confirmed that the Hamiltonian matrix HK for the k-point is not Hermitian, as indicated by:
is_hermitian = np.allclose(HK[ik], HK[ik].conj().T)
if is_hermitian:
print(f"For k-point {ik}: HK is a Hermitian matrix.")
else:
print(f"For k-point {ik}: HK is NOT a Hermitian matrix.")
The output for this check is "For k-point 0: HK is NOT a Hermitian matrix."
I am seeking your guidance on resolving this issue. Additionally, I would appreciate clarification on whether the Hamiltonian matrix should be Hermitian in HamGNN. In quantum mechanics, it is generally understood that the Hamiltonian should be Hermitian.
Best regards, TzuChing
Hi, TzuChing
The first thing that comes to my mind is whether the graph_data.npz
you used matches the target_hamiltonian.npz
or prediction_hamiltonian.npz
. If they don't match, it will result in non-Hermitian HK and SK constructions. I'm not sure if all the data you used is from the calculations for the same structure. You might be using another graph_data.npz
file by mistake. Matrix 'B' here refers to the overlap matrix S, which we do not predict but directly obtain from openmx calculations. In extremely rare cases, the overlap matrix computed by openmx for certain structures may not be positive definite; I have encountered such situations before.
Theoretically, HamGNN predicts Hamiltonian matrices that strictly satisfy Hermiticity. Before outputting the Hamiltonian matrix, HamGNN will perform symmetrization for Hamiltonian matrix. You can check if target_hamiltonian.npz
has the Hermiticity problem. I am unsure of what minimum error np.allclose function allows when comparing two matrices; you can directly compare the differences between these two matrices, HK[ik]-HK[ik].conj().T, to see how large the error of Hermiticity is.
Best wishes,
Yang Zhong
Dear Yang Zhong,
I trust this message finds you well. Following the execution of 'HamGNN --config config.yaml,' the 'prediction_hamiltonian.npy' was successfully generated. However, I encountered an issue during the subsequent processing:
Traceback (most recent call last): File "/home/zjlin/HamGNN/utils_openmx/band_cal.py", line 438, in <module> main() File "/home/zjlin/HamGNN/utils_openmx/band_cal.py", line 365, in main w, v = eigh(a=HK[ik], b=SK[ik]) File "/home/zjlin/anaconda3/envs/HamGNN/lib/python3.9/site-packages/scipy/linalg/_decomp.py", line 593, in eigh raise LinAlgError('The leading minor of order {} of B is not ' numpy.linalg.LinAlgError: The leading minor of order 557 of B is not positive definite. The factorization of B could not be completed, and no eigenvalues or eigenvectors were computed.
Upon investigation, I used the code snippet below to check the positive definiteness of matrices A and B:
A = np.linalg.eigvals(HK[ik]) B = np.linalg.eigvals(SK[ik]) if A.all() > 0 : print(f"A is a positive definite matrix") elif B.all() > 0: print(f"B is a positive definite matrix") else: print(f"A and B are not positive definite")
Surprisingly, the output consistently indicates 'B is a positive definite matrix.' I have also confirmed that the Hamiltonian matrix HK for the k-point is not Hermitian, as indicated by:
is_hermitian = np.allclose(HK[ik], HK[ik].conj().T) if is_hermitian: print(f"For k-point {ik}: HK is a Hermitian matrix.") else: print(f"For k-point {ik}: HK is NOT a Hermitian matrix.")
The output for this check is "For k-point 0: HK is NOT a Hermitian matrix."
I am seeking your guidance on resolving this issue. Additionally, I would appreciate clarification on whether the Hamiltonian matrix should be Hermitian in HamGNN. In quantum mechanics, it is generally understood that the Hamiltonian should be Hermitian.
Best regards, TzuChing
Hi, TzuChing The first thing that comes to my mind is whether the
graph_data.npz
you used matches thetarget_hamiltonian.npz
orprediction_hamiltonian.npz
. If they don't match, it will result in non-Hermitian HK and SK constructions. I'm not sure if all the data you used is from the calculations for the same structure. You might be using anothergraph_data.npz
file by mistake. Matrix 'B' here refers to the overlap matrix S, which we do not predict but directly obtain from openmx calculations. In extremely rare cases, the overlap matrix computed by openmx for certain structures may not be positive definite; I have encountered such situations before. Theoretically, HamGNN predicts Hamiltonian matrices that strictly satisfy Hermiticity. Before outputting the Hamiltonian matrix, HamGNN will perform symmetrization for Hamiltonian matrix. You can check iftarget_hamiltonian.npz
has the Hermiticity problem. I am unsure of what minimum error np.allclose function allows when comparing two matrices; you can directly compare the differences between these two matrices, HK[ik]-HK[ik].conj().T, to see how large the error of Hermiticity is. Best wishes, Yang ZhongDear Yang Zhong, I trust this message finds you well. Following the execution of 'HamGNN --config config.yaml,' the 'prediction_hamiltonian.npy' was successfully generated. However, I encountered an issue during the subsequent processing:
Traceback (most recent call last): File "/home/zjlin/HamGNN/utils_openmx/band_cal.py", line 438, in <module> main() File "/home/zjlin/HamGNN/utils_openmx/band_cal.py", line 365, in main w, v = eigh(a=HK[ik], b=SK[ik]) File "/home/zjlin/anaconda3/envs/HamGNN/lib/python3.9/site-packages/scipy/linalg/_decomp.py", line 593, in eigh raise LinAlgError('The leading minor of order {} of B is not ' numpy.linalg.LinAlgError: The leading minor of order 557 of B is not positive definite. The factorization of B could not be completed, and no eigenvalues or eigenvectors were computed.
Upon investigation, I used the code snippet below to check the positive definiteness of matrices A and B:
A = np.linalg.eigvals(HK[ik]) B = np.linalg.eigvals(SK[ik]) if A.all() > 0 : print(f"A is a positive definite matrix") elif B.all() > 0: print(f"B is a positive definite matrix") else: print(f"A and B are not positive definite")
Surprisingly, the output consistently indicates 'B is a positive definite matrix.' I have also confirmed that the Hamiltonian matrix HK for the k-point is not Hermitian, as indicated by:
is_hermitian = np.allclose(HK[ik], HK[ik].conj().T) if is_hermitian: print(f"For k-point {ik}: HK is a Hermitian matrix.") else: print(f"For k-point {ik}: HK is NOT a Hermitian matrix.")
The output for this check is "For k-point 0: HK is NOT a Hermitian matrix." I am seeking your guidance on resolving this issue. Additionally, I would appreciate clarification on whether the Hamiltonian matrix should be Hermitian in HamGNN. In quantum mechanics, it is generally understood that the Hamiltonian should be Hermitian. Best regards, TzuChing
Indeed, you are correct! I employed the 'graph_data.npz' from your resources, but for the prediction process, I utilized my own approach. It is now functioning correctly! I sincerely appreciate your invaluable assistance and guidance throughout this process. Thank you very much!
Dear Yang Zhong: I'm tried use the HamGNN model to predict $21.79^\circ$ twist bilayer MoS2 but the result seems very different with the currect result. There's my input below: openmx input file (using
poscar2openmx.py
):pbsnode shell script:
graph_data_gen.yaml:
band_cal.yaml:
The calcutation of overlay matrix clearly complete.
There're result: by HamGNN
by OpenMX
Is there any documentation or action of mine that contains errors?
Best regards, TzuChing