Skip to content
Open
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
9 changes: 9 additions & 0 deletions source/source_estate/elecstate_pw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "source_base/timer.h"
#include "source_hamilt/module_xc/xc_functional.h"
#include "source_io/module_parameter/parameter.h"
#include "source_lcao/module_deltaspin/spin_constrain.h"
#include "source_pw/module_pwdft/vnl_pw.h"

namespace elecstate {
Expand Down Expand Up @@ -56,6 +57,14 @@ ElecStatePW<T, Device>::~ElecStatePW()
delmem_complex_op()(this->wfcr_another_spin);
}

template<typename T, typename Device>
double ElecStatePW<T, Device>::get_spin_constrain_energy()
{
spinconstrain::SpinConstrain<std::complex<double>>& sc
= spinconstrain::SpinConstrain<std::complex<double>>::getScInstance();
return sc.cal_escon();
}

template<typename T, typename Device>
void ElecStatePW<T, Device>::init_rho_data()
{
Expand Down
2 changes: 2 additions & 0 deletions source/source_estate/elecstate_pw.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ class ElecStatePW : public ElecState

virtual void cal_tau(const psi::Psi<T, Device>& psi);

double get_spin_constrain_energy() override;

//! calculate becsum for uspp
void cal_becsum(const psi::Psi<T, Device>& psi);

Expand Down
2 changes: 1 addition & 1 deletion source/source_lcao/module_deltaspin/spin_constrain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ template <typename TK>
double SpinConstrain<TK>::cal_escon()
{
this->escon_ = 0.0;
if (!this->is_Mi_converged)
if (this->lambda_.empty() || this->Mi_.empty())
{
return this->escon_;
}
Expand Down
2 changes: 1 addition & 1 deletion source/source_lcao/module_deltaspin/spin_constrain.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ inline ModuleBase::Vector3<double> pauli_to_moment(const std::complex<double> oc
{
return ModuleBase::Vector3<double>(
weight * (occ[1] + occ[2]).real(),
-weight * (occ[1] - occ[2]).imag(),
weight * (occ[1] - occ[2]).imag(),
weight * (occ[0] - occ[3]).real()
);
}
Expand Down
6 changes: 3 additions & 3 deletions tests/17_DS_DFTU/14_PW_DS_S4_XYZ/result.ref
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
etotref -6366.562922988214
etotperatomref -3183.2814614941
totaltimeref 4.23
etotref -6369.19895097706
etotperatomref -3184.59947548853
totaltimeref 1.0
6 changes: 3 additions & 3 deletions tests/17_DS_DFTU/15_PW_DS_S4_Z/result.ref
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
etotref -6366.562433916121
etotperatomref -3183.2812169581
totaltimeref 4.26
etotref -6369.198273166801
etotperatomref -3184.5991365834007
totaltimeref 1.0
6 changes: 3 additions & 3 deletions tests/17_DS_DFTU/16_PW_DS_S4_XY/result.ref
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
etotref -6366.562695059035
etotperatomref -3183.2813475295
totaltimeref 4.19
etotref -6369.198274098935
etotperatomref -3184.5991370494676
totaltimeref 1.0
6 changes: 3 additions & 3 deletions tests/17_DS_DFTU/19_PW_DFTU_DS_S4_XY/result.ref
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
etotref -6355.9841673819892094
etotperatomref -3177.9920836910
totaltimeref 5.88
etotref -6360.5554588729937677
etotperatomref -3180.277729436497
totaltimeref 1.0
6 changes: 3 additions & 3 deletions tests/17_DS_DFTU/21_PW_DFTU_DS_S4_Z/result.ref
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
etotref -6355.9834051938123594
etotperatomref -3177.9917025969
totaltimeref 5.46
etotref -6360.5554655414534864
etotperatomref -3180.2777327707267
totaltimeref 1.0
6 changes: 3 additions & 3 deletions tests/17_DS_DFTU/41_PW_DS_S4_Thr10_XY/result.ref
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
etotref -6366.564253345298
etotperatomref -3183.2821266726
totaltimeref 7.03
etotref -6369.198254647004
etotperatomref -3184.599127323502
totaltimeref 1.0
Loading