From cf9e4a5cb288e45dc807b711e2f5839ebe336726 Mon Sep 17 00:00:00 2001 From: Pureorangeade <161405953+Pureorangeade@users.noreply.github.com> Date: Mon, 1 Apr 2024 21:36:31 +0800 Subject: [PATCH 1/2] Update berryphase.cpp Initialize ik_1 and ik_2 in berryphase.cpp --- source/module_io/berryphase.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/module_io/berryphase.cpp b/source/module_io/berryphase.cpp index ad73c2b41dd..25979f65a8a 100644 --- a/source/module_io/berryphase.cpp +++ b/source/module_io/berryphase.cpp @@ -239,8 +239,8 @@ double berryphase::stringPhase(int index_str, { std::complex zeta(1.0, 0.0); ModuleBase::ComplexMatrix mat(nbands,nbands); - int ik_1; - int ik_2; + int ik_1 = 0; + int ik_2 = 0; ModuleBase::Vector3 G(0.0,0.0,0.0); ModuleBase::Vector3 dk = kv.kvec_c[ k_index[index_str][1] ] - kv.kvec_c[ k_index[index_str][0] ]; //GlobalV::ofs_running << "the std::string index is " << index_str << std::endl; From 176dc4a21f23da76fb38783bd6bf4a614a745f8c Mon Sep 17 00:00:00 2001 From: Pureorangeade <161405953+Pureorangeade@users.noreply.github.com> Date: Mon, 1 Apr 2024 22:00:51 +0800 Subject: [PATCH 2/2] Update berryphase.cpp Initialize modulus in berryphase.cpp --- source/module_io/berryphase.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/module_io/berryphase.cpp b/source/module_io/berryphase.cpp index 25979f65a8a..3c1fd7abf29 100644 --- a/source/module_io/berryphase.cpp +++ b/source/module_io/berryphase.cpp @@ -577,7 +577,7 @@ void berryphase::Macroscopic_polarization(const int npwx, // ion polarization end // calculate Macroscopic polarization modulus because berry phase - int modulus; + int modulus = 0; if( (!lodd) && (GlobalV::NSPIN==1) ) modulus = 2; else modulus = 1;