forked from abacusmodeling/abacus-develop
-
Notifications
You must be signed in to change notification settings - Fork 140
Resolve the segmentation fault occurring in the pw float implementation #6130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 13 commits
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
7b855e6
add unit test
A-006 4c779e8
add intergrate test
A-006 f9e7710
fix process
A-006 a8d72af
modify jd
A-006 5faf27e
update bug
A-006 4773008
set fftw float
A-006 503bf58
add the float BPCG
A-006 4b5df98
add float test
A-006 16cb172
fix compile bug
A-006 f5c1fc1
fix error
A-006 677e5d6
fix the compile test
A-006 98decc4
Merge branch 'develop' into fft_float2
A-006 f632326
Merge branch 'develop' into fft_float2
A-006 300713c
add
A-006 1dbacf8
remove the test file
A-006 f565945
change the file
A-006 e1601ee
revert bug
A-006 f6fd16d
set the float type
A-006 bed7852
Merge branch 'develop' into fft_float2
A-006 80344ac
reset the FFT_MEASURE
A-006 c60bf81
update unittest
A-006 ed18346
change readme
A-006 1f66367
update threashold
A-006 4c63669
Merge branch 'develop' into fft_float2
A-006 7553e06
use the test file
A-006 385b010
fix unresonable comments
A-006 2e13c7f
update eslover before all runners
A-006 2bf18b9
Merge branch 'develop' into fft_float2
A-006 a224da7
fix compile bug
A-006 59b73f5
fix bug
A-006 f750e10
Merge branch 'develop' into fft_float2
mohanchen d193075
update README
A-006 a9b53a1
change chebyshev MPI part
A-006 5c156e5
Merge branch 'develop' into fft_float2
A-006 d5084f6
add new test
A-006 aa443f1
delete old test
A-006 2d2a550
remove old tests
A-006 b1f144e
add change
A-006 c60d13f
Merge branch 'develop' into fft_float2
A-006 df3c712
update tick
A-006 ca1b0d9
add back marco
A-006 5ca14cd
update change
A-006 be074ab
Merge branch 'develop' into fft_float2
A-006 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
128 changes: 128 additions & 0 deletions
128
source/module_hamilt_pw/hamilt_pwdft/test/structure_factor_test.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
#include "gtest/gtest.h" | ||
#include "gmock/gmock.h" | ||
#include <string> | ||
#include <cmath> | ||
#include <complex> | ||
#include "module_cell/unitcell.h" | ||
#include "module_elecstate/module_dm/test/prepare_unitcell.h" | ||
#define private public | ||
#include "module_parameter/parameter.h" | ||
#include "module_hamilt_pw/hamilt_pwdft/structure_factor.h" | ||
#undef private | ||
/************************************************ | ||
* unit test of class Structure_factor and | ||
***********************************************/ | ||
|
||
/** | ||
* - Tested Functions: | ||
* - Fcoef::create to create a 5 dimensional array of complex numbers | ||
* - Soc::set_fcoef to set the fcoef array | ||
* - Soc::spinor to calculate the spinor | ||
* - Soc::rot_ylm to calculate the rotation matrix | ||
* - Soc::sph_ind to calculate the m index of the spherical harmonics | ||
*/ | ||
|
||
//compare two complex by using EXPECT_DOUBLE_EQ() | ||
InfoNonlocal::InfoNonlocal() | ||
{ | ||
} | ||
InfoNonlocal::~InfoNonlocal() | ||
{ | ||
} | ||
|
||
Magnetism::Magnetism() | ||
{ | ||
} | ||
Magnetism::~Magnetism() | ||
{ | ||
} | ||
|
||
class StructureFactorTest : public testing::Test | ||
{ | ||
protected: | ||
Structure_Factor SF; | ||
std::string output; | ||
ModulePW::PW_Basis* rho_basis; | ||
UnitCell* ucell; | ||
UcellTestPrepare utp = UcellTestLib["Si"]; | ||
Parallel_Grid* pgrid; | ||
std::vector<int> nw = {13}; | ||
int nlocal = 0; | ||
void SetUp() | ||
{ | ||
rho_basis=new ModulePW::PW_Basis; | ||
ucell = utp.SetUcellInfo(nw, nlocal); | ||
ucell->set_iat2iwt(1); | ||
pgrid = new Parallel_Grid; | ||
rho_basis->npw=10; | ||
rho_basis->gcar=new ModuleBase::Vector3<double>[10]; | ||
// for (int ig=0;ig<rho_basis->npw;ig++) | ||
// { | ||
// rho_basis->gcar[ig]=1.0; | ||
// } | ||
} | ||
}; | ||
|
||
TEST_F(StructureFactorTest, set) | ||
{ | ||
const ModulePW::PW_Basis* rho_basis_in; | ||
const int nbspline_in =10; | ||
SF.set(rho_basis_in,nbspline_in); | ||
EXPECT_EQ(nbspline_in, 10); | ||
} | ||
|
||
|
||
TEST_F(StructureFactorTest, setup_structure_factor_double) | ||
{ | ||
rho_basis->npw = 10; | ||
SF.setup_structure_factor(ucell,*pgrid,rho_basis); | ||
|
||
for (int i=0;i< ucell->nat * (2 * rho_basis->nx + 1);i++) | ||
{ | ||
EXPECT_EQ(SF.z_eigts1[i].real(),1); | ||
EXPECT_EQ(SF.z_eigts1[i].imag(),0); | ||
} | ||
|
||
for (int i=0;i< ucell->nat * (2 * rho_basis->ny + 1);i++) | ||
{ | ||
EXPECT_EQ(SF.z_eigts2[i].real(),1); | ||
EXPECT_EQ(SF.z_eigts2[i].imag(),0); | ||
} | ||
|
||
for (int i=0;i< ucell->nat * (2 * rho_basis->nz + 1);i++) | ||
{ | ||
EXPECT_EQ(SF.z_eigts3[i].real(),1); | ||
EXPECT_EQ(SF.z_eigts3[i].imag(),0); | ||
} | ||
} | ||
|
||
TEST_F(StructureFactorTest, setup_structure_factor_float) | ||
{ | ||
PARAM.sys.has_float_data = true; | ||
rho_basis->npw = 10; | ||
SF.setup_structure_factor(ucell,*pgrid,rho_basis); | ||
|
||
for (int i=0;i< ucell->nat * (2 * rho_basis->nx + 1);i++) | ||
{ | ||
EXPECT_EQ(SF.c_eigts1[i].real(),1); | ||
EXPECT_EQ(SF.c_eigts1[i].imag(),0); | ||
} | ||
|
||
for (int i=0;i< ucell->nat * (2 * rho_basis->ny + 1);i++) | ||
{ | ||
EXPECT_EQ(SF.c_eigts2[i].real(),1); | ||
EXPECT_EQ(SF.c_eigts2[i].imag(),0); | ||
} | ||
|
||
for (int i=0;i< ucell->nat * (2 * rho_basis->nz + 1);i++) | ||
{ | ||
EXPECT_EQ(SF.c_eigts3[i].real(),1); | ||
EXPECT_EQ(SF.c_eigts3[i].imag(),0); | ||
} | ||
} | ||
|
||
int main() | ||
{ | ||
testing::InitGoogleTest(); | ||
return RUN_ALL_TESTS(); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
INPUT_PARAMETERS | ||
#Parameters (General) | ||
suffix autotest | ||
pseudo_dir ../../PP_ORB | ||
|
||
gamma_only 0 | ||
calculation scf | ||
symmetry 1 | ||
relax_nmax 1 | ||
out_level ie | ||
smearing_method gaussian | ||
smearing_sigma 0.02 | ||
|
||
#Parameters (3.PW) | ||
ecutwfc 40 | ||
scf_thr 1e-7 | ||
scf_nmax 100 | ||
bndpar 2 | ||
|
||
#Parameters (LCAO) | ||
basis_type pw | ||
ks_solver bpcg | ||
device gpu | ||
precision single | ||
chg_extrap second-order | ||
out_dm 0 | ||
pw_diag_thr 0.00001 | ||
|
||
cal_force 1 | ||
#test_force 1 | ||
cal_stress 1 | ||
#test_stress 1 | ||
|
||
mixing_type broyden | ||
mixing_beta 0.4 | ||
mixing_gg0 1.5 | ||
|
||
pw_seed 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
K_POINTS | ||
0 | ||
Gamma | ||
2 2 2 0 0 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
This test for: | ||
mohanchen marked this conversation as resolved.
Show resolved
Hide resolved
|
||
*GaAs-deformation | ||
*PW | ||
*kpoints 2*2*2 | ||
*sg15 pseudopotential | ||
*smearing_method gauss | ||
*ks_solver bpcg | ||
*mixing_type broyden-kerker | ||
*mixing_beta 0.4 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
ATOMIC_SPECIES | ||
As 1 As_dojo.upf upf201 | ||
Ga 1 Ga_dojo.upf upf201 | ||
|
||
LATTICE_CONSTANT | ||
1 // add lattice constant, 10.58 ang | ||
|
||
LATTICE_VECTORS | ||
5.33 5.33 0.0 | ||
0.0 5.33 5.33 | ||
5.33 0.0 5.33 | ||
ATOMIC_POSITIONS | ||
Direct //Cartesian or Direct coordinate. | ||
|
||
As | ||
0 | ||
1 | ||
0.300000 0.3300000 0.27000000 0 0 0 | ||
|
||
Ga //Element Label | ||
0 | ||
1 //number of atom | ||
0.00000 0.00000 0.000000 0 0 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
etotref -4869.7470518349809936 | ||
etotperatomref -2434.8735259175 | ||
totalforceref 5.207670 | ||
totalstressref 37241.465646 | ||
pointgroupref C_1 | ||
spacegroupref C_1 | ||
nksibzref 8 | ||
totaltimeref 10.28 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
threshold 1 | ||
force_threshold 1 | ||
stress_threshold 1 | ||
fatal_threshold 1 |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.