Skip to content
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

Fix reference data for entangled units "dimer" test on Julia 1.11 #326

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
22 changes: 15 additions & 7 deletions test/test_entangled_units.jl
Original file line number Diff line number Diff line change
Expand Up @@ -66,20 +66,20 @@ end
set_field!(esys, [0, 0, 10])
randomize_spins!(esys)
minimize_energy!(esys)
esys.sys_origin.dipoles[1][3] ≈ -1/2
esys.sys_origin.dipoles[2][3] ≈ -1/2
@test esys.sys_origin.dipoles[1][3] ≈ -1/2
@test esys.sys_origin.dipoles[2][3] ≈ -1/2

set_field!(esys, [0, 0, -10])
randomize_spins!(esys)
minimize_energy!(esys)
esys.sys_origin.dipoles[1][3] ≈ 1/2
esys.sys_origin.dipoles[2][3] ≈ 1/2
@test esys.sys_origin.dipoles[1][3] ≈ 1/2
@test esys.sys_origin.dipoles[2][3] ≈ 1/2

set_field!(esys, [0, 0, 0])
randomize_spins!(esys)
minimize_energy!(esys; g_tol=1e-14)
norm(esys.sys_origin.dipoles[1]) < 1e-14
norm(esys.sys_origin.dipoles[2]) < 1e-14
@test norm(esys.sys_origin.dipoles[1]) < 1e-14
@test norm(esys.sys_origin.dipoles[2]) < 1e-14

# Test inter-bond exchange
pc = Sunny.as_general_pair_coupling(interactions.pair[1], esys.sys)
Expand Down Expand Up @@ -124,7 +124,15 @@ end
end
add_sample!(sc, esys)
res = intensities(sc, qpts; energies, kT=0.05)
intensities_ref = [-0.0009151914880177183 -0.002340042772876626 -0.0037316702420023395 -0.002340042772876612 -0.0009151914880177183; 0.02116154679963919 0.05967703767242055 0.009161242329689078 0.03233210977077469 0.02116154679963919; -0.04206086791537969 -0.2227189243447692 -0.12040711429107293 -0.025389877189384635 -0.04206086791537969; 0.3962131659090294 2.7150236439903197 4.3968225602687 0.5625477581811109 0.3962131659090294; 8.48497330044607 17.689468342820923 14.169270995083266 3.1979660472637534 8.48497330044607; 17.1145045637742 21.877166922282075 10.751399167760733 3.8125499846147113 17.1145045637742; 8.490961712258231 5.100854031990811 0.6862255516496436 0.8503635473494539 8.490961712258231; -0.3334143274663385 -0.966097718147396 -0.1252420669485946 -0.2868227954981837 -0.3334143274663385; 0.07518063142323421 0.2337350060517672 0.13638239262286792 0.012717547170902647 0.07518063142323421; -0.09925761646769077 -0.29077390054022495 -0.03237049466881591 -0.290773900540224 -0.09925761646769077]

# Julia 1.11 slightly changes the SVD, which leads to a different
# decomposition of "general" pair interactions. Small numerical differences
# can be amplified over a long dynamical trajectory.
@static if v"1.10" <= VERSION < v"1.11-"
intensities_ref = [-0.0009151914880177183 -0.002340042772876626 -0.0037316702420023395 -0.002340042772876612 -0.0009151914880177183; 0.02116154679963919 0.05967703767242055 0.009161242329689078 0.03233210977077469 0.02116154679963919; -0.04206086791537969 -0.2227189243447692 -0.12040711429107293 -0.025389877189384635 -0.04206086791537969; 0.3962131659090294 2.7150236439903197 4.3968225602687 0.5625477581811109 0.3962131659090294; 8.48497330044607 17.689468342820923 14.169270995083266 3.1979660472637534 8.48497330044607; 17.1145045637742 21.877166922282075 10.751399167760733 3.8125499846147113 17.1145045637742; 8.490961712258231 5.100854031990811 0.6862255516496436 0.8503635473494539 8.490961712258231; -0.3334143274663385 -0.966097718147396 -0.1252420669485946 -0.2868227954981837 -0.3334143274663385; 0.07518063142323421 0.2337350060517672 0.13638239262286792 0.012717547170902647 0.07518063142323421; -0.09925761646769077 -0.29077390054022495 -0.03237049466881591 -0.290773900540224 -0.09925761646769077]
elseif v"1.11" <= VERSION
intensities_ref = [-0.005898711265804917 0.00037194381298070534 -0.007139302988678504 0.0003719438129806763 -0.005898711265804917; -0.021174997374043665 0.04366825611810105 0.007169734714023062 0.05743679447787905 -0.021174997374043665; -0.0898921215977289 -0.026851190523929185 -0.21509883592744028 -0.13293335904345077 -0.0898921215977289; 0.07554637005717268 1.0310198342691788 7.6305129282212 2.0138084437390957 0.07554637005717268; 9.029181600659825 4.6645584970233935 26.007406182009305 12.508876537699672 9.029181600659825; 19.33194294971418 4.561683298052969 21.585685225141788 15.176512232105381 19.33194294971418; 9.190329239958585 0.5342077291704622 2.3267523495368336 3.3977085221103662 9.190329239958585; -0.5730586490317443 -0.36243855204206615 -0.2377418272654857 -0.7846957436907301 -0.5730586490317443; 0.4227065393257319 -0.0978593259945275 0.5472087416056827 0.03159040448673515 0.4227065393257319; -0.08949094320156001 -0.3280980521751531 0.015933918006198686 -0.32809805217515364 -0.08949094320156001]
end
@test isapprox(res.data, intensities_ref)
end

Expand Down
Loading