Skip to content

Commit bb4f4e4

Browse files
author
Zanthoxylum
committed
merge: 同步 origin/develop(#7980-#7984 测试去 access hack、#7975 EXX 提示等)
2 parents c92ecc8 + 688d0c7 commit bb4f4e4

142 files changed

Lines changed: 4299 additions & 4140 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

source/CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,16 @@ if(NOT MSVC)
211211
list(APPEND _abacus_linalg_libs m)
212212
endif()
213213

214+
# The mtblas archives bundle their own OpenBLAS objects. They must come after
215+
# the standalone BLAS/LAPACK/ScaLAPACK above so that the linker resolves the
216+
# BLAS symbols from the standalone BLAS instead of the bundled copy.
217+
if(USE_DSP)
218+
list(APPEND _abacus_linalg_libs
219+
${MTBLAS_FFT_DIR}/libmtblas/lib/libmtblas.a
220+
${MTBLAS_FFT_DIR}/libmtblas/lib/libmtblasdev.a
221+
${MTBLAS_FFT_DIR}/libmtblas/lib/libmtfft.a)
222+
endif()
223+
214224
target_link_libraries(abacus_linalg_libs INTERFACE ${_abacus_linalg_libs})
215225
target_include_directories(abacus_linalg_libs INTERFACE ${_abacus_linalg_include_dirs})
216226

source/Makefile.Objects

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,7 @@ OBJS_DFPT=dfpt_hamilt_shift.o\
399399
dfpt_stern.o
400400

401401
OBJS_HAMILT_LCAO=hamilt_lcao.o\
402+
hamilt_lcao_factory.o\
402403
operator_lcao.o\
403404
ekinetic.o\
404405
ekinetic_fs.o\
@@ -746,8 +747,8 @@ OBJS_LCAO=evolve_elec.o\
746747
boundary_fix.o\
747748
upsi.o\
748749
force_stress_lcao.o\
749-
force_lcao_gamma.o\
750-
force_lcao_k.o\
750+
force_stress_assemble.o\
751+
force_stress_terms.o\
751752
stress_tools.o\
752753
edm.o\
753754
pulay_fs_center2.o\

source/source_base/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,6 @@ add_library(
8989
)
9090

9191
target_link_libraries(base PUBLIC container)
92-
if (USE_DSP)
93-
target_link_libraries(base PUBLIC ${MTBLAS_FFT_DIR}/libmtblas/lib/libmtblas.a)
94-
target_link_libraries(base PUBLIC ${MTBLAS_FFT_DIR}/libmtblas/lib/libmtblasdev.a)
95-
endif()
9692
add_subdirectory(module_container)
9793

9894
if(ENABLE_COVERAGE)

source/source_base/mathzone.h

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
#define MATHZONE_H
33

44
#include "global_function.h"
5+
#include "matrix.h"
56
#include "matrix3.h"
7+
#include "tool_quit.h"
68
#include "vector3.h"
79
#include "realarray.h"
810

@@ -171,9 +173,42 @@ class Mathzone
171173
proj.y = std::abs( latvec[1] * (latvec[2] ^ latvec[0]).normalize() );
172174
proj.z = std::abs( latvec[2] * (latvec[0] ^ latvec[1]).normalize() );
173175
return proj;
174-
}
176+
}
175177
};
176178

179+
/**
180+
* @brief Remove the uniform net-force component in place (Newton's 3rd law).
181+
*
182+
* Subtract the per-component mean force so the total force sums to zero. This
183+
* is a pure matrix operation, independent of symmetry. Shared by the PW and
184+
* LCAO force paths. Not applied when an external field (gate/efield) is present.
185+
*
186+
* @param[in] nat number of atoms
187+
* @param[in,out] force per-atom Cartesian forces, nat x 3, modified in place
188+
*/
189+
inline void remove_net_force(const int nat, ModuleBase::matrix& force)
190+
{
191+
if (nat <= 0 || force.nr < nat || force.nc < 3)
192+
{
193+
ModuleBase::WARNING_QUIT("remove_net_force",
194+
"nat must be positive and force must have at least nat x 3 elements");
195+
}
196+
for (int i = 0; i < 3; i++)
197+
{
198+
double sum = 0.0;
199+
for (int iat = 0; iat < nat; iat++)
200+
{
201+
sum += force(iat, i);
202+
}
203+
const double compen = sum / nat;
204+
for (int iat = 0; iat < nat; ++iat)
205+
{
206+
force(iat, i) -= compen;
207+
}
208+
}
209+
return;
210+
}
211+
177212
} // namespace ModuleBase
178213

179214
#endif

source/source_base/memory_recorder.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,13 @@ class Memory
8787
return total;
8888
}
8989

90+
/// @brief Whether the record tables are currently allocated. record()
91+
/// allocates them on first use and finish() releases them again.
92+
static bool is_initialized(void)
93+
{
94+
return init_flag;
95+
}
96+
9097
static void finish(std::ofstream &ofs);
9198

9299
/**

source/source_base/test/memory_test.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ namespace GlobalV
2525
* - std::ofstream file
2626
*/
2727

28-
#define private public
2928
#include "../memory_recorder.h"
30-
#undef private
3129

3230
class MemoryTest : public testing::Test
3331
{
@@ -141,14 +139,11 @@ TEST_F(MemoryTest, printall)
141139

142140
TEST_F(MemoryTest, finish)
143141
{
144-
*ModuleBase::Memory::name = "tmp_name";
145-
*ModuleBase::Memory::class_name = "tmp_class_name";
146-
*ModuleBase::Memory::consume = 100.0;
147-
ModuleBase::Memory::init_flag = true;
148142
ofs.open("tmp");
149-
// total memory is an internal parameter and added inside the class Memory
143+
// record() allocates the tables and adds the entry that finish() then prints
144+
// and releases; total memory is an internal parameter added inside Memory
150145
ModuleBase::Memory::record("Charge_Mixing","Rrho",1024*1024,"ModuleBase::Vector3<double>");
151146
EXPECT_NO_THROW(ModuleBase::Memory::finish(ofs));
152147
ofs.close();
153-
EXPECT_FALSE(ModuleBase::Memory::init_flag);
148+
EXPECT_FALSE(ModuleBase::Memory::is_initialized());
154149
}

source/source_basis/module_ao/orb_nonlocal.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ class Numerical_Nonlocal
2424
Numerical_Nonlocal();
2525
~Numerical_Nonlocal();
2626

27+
// This class owns the raw Proj array; copying it would alias the buffer
28+
// and cause double free, so copy semantics are explicitly forbidden.
29+
Numerical_Nonlocal(const Numerical_Nonlocal&) = delete;
30+
Numerical_Nonlocal& operator=(const Numerical_Nonlocal&) = delete;
31+
2732
const int& getLmax() const { return this->lmax; }
2833

2934
const int& getType() const { return this->type; }

source/source_basis/module_pw/CMakeLists.txt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,8 @@ add_library(
4444
)
4545

4646
if (USE_DSP)
47-
target_link_libraries(planewave PRIVATE
48-
${MTBLAS_FFT_DIR}/libmtblas/lib/libmtfft.a)
49-
target_compile_definitions( planewave PUBLIC
50-
FFT_DAT_DIR="${MTBLAS_FFT_DIR}/datfile/mt_fft_blas.dat")
47+
target_compile_definitions( planewave PUBLIC
48+
FFT_DAT_DIR="${MTBLAS_FFT_DIR}/datfile/mt_fft_blas.dat")
5149
endif()
5250
if(ENABLE_COVERAGE)
5351
add_coverage(planewave)

source/source_cell/klist.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,13 @@ class K_Vectors : public ModuleCell::ReciprocalGrid
120120
this->nkstot_nospin = value;
121121
}
122122

123+
/// @brief Set the spin multiplicity: 1 (no doubling, also for non-collinear
124+
/// nspin=4) or 2 (LSDA, k points split into up/down).
125+
void set_spin_mult(int value)
126+
{
127+
this->spin_mult = value;
128+
}
129+
123130
bool get_is_mp() const
124131
{
125132
return is_mp;

source/source_cell/module_neighbor/sltk_grid_driver.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,15 @@ class Grid_Driver : public Grid
166166
return adj_info.box[i];
167167
}
168168

169+
/**
170+
* @brief Get the whole adjacent atom information.
171+
* @return adjacent atom information
172+
*/
173+
const AdjacentAtomInfo& getAdjacentInfo() const
174+
{
175+
return adj_info;
176+
}
177+
169178
private:
170179
mutable AdjacentAtomInfo adj_info; ///< adjacent atom information
171180
bool test_deconstructor; ///< test deconstructor flag

0 commit comments

Comments
 (0)