Skip to content

Commit

Permalink
Remove Lagrange-multiplier from the electrostatic energy (fixes charg…
Browse files Browse the repository at this point in the history
…ed gradient)
  • Loading branch information
thfroitzheim committed Nov 27, 2024
1 parent 337d830 commit 084ddfc
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 22 deletions.
3 changes: 2 additions & 1 deletion src/multicharge/model.F90
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,8 @@ subroutine solve(self, mol, cn, dcndr, dcndL, energy, gradient, sigma, qvec, dqd
end if

if (present(energy)) then
call symv(amat, vrhs, xvec, alpha=0.5_wp, beta=-1.0_wp, uplo='l')
call symv(amat(:, :mol%nat), vrhs(:mol%nat), xvec(:mol%nat), &
& alpha=0.5_wp, beta=-1.0_wp, uplo='l')
energy(:) = energy(:) + vrhs(:mol%nat) * xvec(:mol%nat)
end if

Expand Down
24 changes: 12 additions & 12 deletions test/unit/test_model.f90
Original file line number Diff line number Diff line change
Expand Up @@ -467,12 +467,12 @@ subroutine test_e_mb03(error)

type(structure_type) :: mol
real(wp), parameter :: ref(16) = [&
&-1.13826350631987E-1_wp,-5.62509056571450E-1_wp, 2.40314584307323E-2_wp, &
& 2.34612384482528E-1_wp, 3.24513111881020E-1_wp, 4.02366323905675E-2_wp, &
&-2.17529318207133E-1_wp, 2.75364844977006E-2_wp, 4.02137369467059E-2_wp, &
& 5.04840322940993E-2_wp,-3.53634572772168E-1_wp,-1.87985748794416E-1_wp, &
&-2.52739835528964E-1_wp, 1.24520645208966E-1_wp, 2.69468093358888E-1_wp, &
& 2.15919407508634E-2_wp]
&-2.18698345033562E-1_wp,-1.04793885931268E+0_wp, 4.78963353574572E-2_wp, &
& 5.76566377591676E-1_wp, 7.37187470977927E-1_wp, 8.06020047053305E-2_wp, &
&-4.19837955782898E-1_wp, 5.49627510550566E-2_wp, 8.01486728591565E-2_wp, &
& 1.00618944521776E-1_wp,-6.61715169034150E-1_wp,-3.60531647289563E-1_wp, &
&-4.87729666337974E-1_wp, 2.48257554279938E-1_wp, 6.96027176590956E-1_wp, &
& 4.31679925875087E-2_wp]

call get_structure(mol, "MB16-43", "03")
call gen_test(error, mol, eref=ref)
Expand All @@ -487,12 +487,12 @@ subroutine test_e_mb04(error)

type(structure_type) :: mol
real(wp), parameter :: ref(16) = [&
& 5.48650497749607E-2_wp,-2.25780913208624E-1_wp, 4.35281631902307E-2_wp, &
&-1.57205780814366E-1_wp, 4.09837366864403E-3_wp, 6.31282692438352E-2_wp, &
& 7.48306233723622E-2_wp, 5.87730150647742E-2_wp, 6.10308494414398E-2_wp, &
& 8.63933930367129E-2_wp,-9.99483536957020E-2_wp, 2.02497843626054E-1_wp, &
& 3.47529062386466E-2_wp,-2.37058804560779E-1_wp, 6.74225102943070E-2_wp, &
&-1.36552339896561E-1_wp]
& 1.13974214746111E-1_wp,-4.41735365367827E-1_wp, 8.99036489938394E-2_wp, &
&-2.97539904703271E-1_wp, 8.05174117097006E-3_wp, 1.31105783760276E-1_wp, &
& 1.54594451996644E-1_wp, 1.19929653841255E-1_wp, 1.26056586309101E-1_wp, &
& 1.78439005754586E-1_wp,-1.98703462666082E-1_wp, 4.19630120027785E-1_wp, &
& 7.05569220334930E-2_wp,-4.50925107441869E-1_wp, 1.39289602382354E-1_wp, &
&-2.67853086061429E-1_wp]

call get_structure(mol, "MB16-43", "04")
call gen_test(error, mol, eref=ref)
Expand Down
17 changes: 8 additions & 9 deletions test/unit/test_pbc.f90
Original file line number Diff line number Diff line change
Expand Up @@ -419,15 +419,14 @@ subroutine test_e_formamide(error)

type(structure_type) :: mol
real(wp), parameter :: ref(24) = [&
& 1.89757620852359E-1_wp, 1.89760760029133E-1_wp, 1.89737950594800E-1_wp, &
& 1.89748797090202E-1_wp, 2.03099343220260E-1_wp, 2.03086622963944E-1_wp, &
& 2.03077163423409E-1_wp, 2.03088145719017E-1_wp, 8.99074841863554E-2_wp, &
& 8.99082451986937E-2_wp, 8.99093436347654E-2_wp, 8.99109153737500E-2_wp, &
& 1.64940329265701E-1_wp, 1.64930611448213E-1_wp, 1.64944104143581E-1_wp, &
& 1.64952535219774E-1_wp,-4.28537080109528E-1_wp,-4.28526505049323E-1_wp, &
&-4.28489488988212E-1_wp,-4.28513466458521E-1_wp,-3.29599028782344E-1_wp, &
&-3.29588887030536E-1_wp,-3.29602200135643E-1_wp,-3.29600393007701E-1_wp]

& 4.01878116759118E-1_wp, 4.01884779867146E-1_wp, 4.01836430415694E-1_wp, &
& 4.01859412981015E-1_wp, 4.30132679242368E-1_wp, 4.30105708698129E-1_wp, &
& 4.30085668404029E-1_wp, 4.30108945050621E-1_wp, 1.90400193163051E-1_wp, &
& 1.90401822781550E-1_wp, 1.90404130981992E-1_wp, 1.90407447306916E-1_wp, &
& 3.33868335196572E-1_wp, 3.33848682655264E-1_wp, 3.33875977331594E-1_wp, &
& 3.33893030511429E-1_wp,-8.35635584733599E-1_wp,-8.35614926719694E-1_wp, &
&-8.35542684637248E-1_wp,-8.35589488474056E-1_wp,-6.31079122091240E-1_wp, &
&-6.31059677948463E-1_wp,-6.31085206912995E-1_wp,-6.31081747027041E-1_wp]

call get_structure(mol, "X23", "formamide")
call gen_test(error, mol, eref=ref)
Expand Down

0 comments on commit 084ddfc

Please sign in to comment.