Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 62 additions & 27 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,29 +1,64 @@
/build*
build_info.h
bin
obj
```
# Compiled and build artifacts
*.o
OUT.*
log.txt
result.out
*.dat
.DS_Store
.cache
.vscode
html
*.obj
*.exe
*.dll
*.so
*.a
*.out

# Dependencies
node_modules/
venv/
.venv/
__pycache__/
.mypy_cache/
.pytest_cache/
target/
.gradle/

# Logs and temp files
*.log
STRU_READIN_ADJUST.cif
*.egg
*.egg-info
build
dist
.idea
time.json
*.pyc
__pycache__
abacus.json
*.npy
toolchain/install/
toolchain/abacus_env.sh
.trae
compile_commands.json
*.tmp
*.swp
*.swo

# Environment
.env
.env.local
*.env.*

# Editors
.vscode/
.idea/

# System files
.DS_Store
Thumbs.db

# Coverage
coverage/
htmlcov/
.coverage

# Compressed files
*.zip
*.gz
*.tar
*.tgz
*.bz2
*.xz
*.7z
*.rar
*.zst
*.lz4
*.lzh
*.cab
*.arj
*.rpm
*.deb
*.Z
*.lz
*.lzo
```
39 changes: 20 additions & 19 deletions source/source_pw/module_pwdft/op_pw_proj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,24 @@ void OnsiteProj<OperatorPW<T, Device>>::init(const int ik_in)
onsite_p->tabulate_atomic(ik_in);
this->tnp = onsite_p->get_tot_nproj();

if(this->has_delta_spin && !this->init_delta_spin)
{
this->init_delta_spin = true;
//prepare ip_iat and lambda_coeff
resmem_int_op()(this->ip_iat, onsite_p->get_tot_nproj());
resmem_complex_op()(this->lambda_coeff, this->ucell->nat * 4);
std::vector<int> ip_iat0(onsite_p->get_tot_nproj());
int ip0 = 0;
for(int iat=0;iat<this->ucell->nat;iat++)
{
for(int ip=0;ip<onsite_p->get_nh(iat);ip++)
{
ip_iat0[ip0++] = iat;
}
}
syncmem_int_h2d_op()(this->ip_iat, ip_iat0.data(), onsite_p->get_tot_nproj());
}

if(this->next_op != nullptr)
{
this->next_op->init(ik_in);
Expand Down Expand Up @@ -130,25 +148,9 @@ void OnsiteProj<OperatorPW<T, Device>>::cal_ps_delta_spin(const int npol, const
}
setmem_complex_op()(this->ps, 0, tnp * m);

if(!this->init_delta_spin)
{
this->init_delta_spin = true;
//prepare ip_iat and lambda_coeff
resmem_int_op()(this->ip_iat, onsite_p->get_tot_nproj());
resmem_complex_op()(this->lambda_coeff, this->ucell->nat * 4);
std::vector<int> ip_iat0(onsite_p->get_tot_nproj());
int ip0 = 0;
for(int iat=0;iat<this->ucell->nat;iat++)
{
for(int ip=0;ip<onsite_p->get_nh(iat);ip++)
{
ip_iat0[ip0++] = iat;
}
}
syncmem_int_h2d_op()(this->ip_iat, ip_iat0.data(), onsite_p->get_tot_nproj());
}

// prepare array of nh_iat and lambda_array to pass to the onsite_ps_op operator
spinconstrain::SpinConstrain<std::complex<double>>& sc = spinconstrain::SpinConstrain<std::complex<double>>::getScInstance();
auto& lambda = sc.get_sc_lambda();
std::vector<std::complex<double>> tmp_lambda_coeff(this->ucell->nat * 4);
for(int iat=0;iat<this->ucell->nat;iat++)
{
Expand All @@ -158,7 +160,6 @@ void OnsiteProj<OperatorPW<T, Device>>::cal_ps_delta_spin(const int npol, const
tmp_lambda_coeff[iat * 4 + 3] = std::complex<double>(-1 * lambda[iat][2], 0.0);
}
syncmem_complex_h2d_op()(this->lambda_coeff, tmp_lambda_coeff.data(), this->ucell->nat * 4);
// TODO: code block above should be moved to the init function

hamilt::onsite_ps_op<Real, Device>()(
this->ctx, // device context
Expand Down
Loading