Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
341 commits
Select commit Hold shift + click to select a range
4a28be4
Modified eig_omp.cpp to handle single-precision floats too (Horace us…
mducle Jan 20, 2019
79c9406
Modified chol_omp.cpp to handle singles
mducle Jan 20, 2019
5d94149
Cleanup code, updated spinwavefast
mducle Jan 20, 2019
2abd95a
Cleanup. Added Linux mex. Removed horace_disp.m
mducle Jan 22, 2019
6f9838a
Merge pull request #6 from mducle/horace-dev
Jan 22, 2019
7b0e3dc
More fixes for symbolic
Jan 22, 2019
6012cc3
Fixed bugs in eig_omp again (stupid pointers!)
mducle Jan 23, 2019
3d24fea
Added damped harmonic (bcc-Fe) and coord transform (pcsmo) to horace_sqw
mducle Jan 23, 2019
2cba061
Added linux compiled eig_omp.mexa64
mducle Jan 23, 2019
c33a842
Merge pull request #7 from mducle/horace-dev
Jan 23, 2019
15a3ae1
Updated sw_release to ignore git files
mducle Jan 23, 2019
e415ac1
Update before pre-release
Jan 25, 2019
f3978e7
Merge pull request #14 from SpinW/master
Jan 28, 2019
f63ddb4
Fix sw_plotspec
Jan 28, 2019
c02ff27
Merge branch 'plotbug' into development
Jan 31, 2019
79718cf
Latest compiled mex files (OSX)
Feb 1, 2019
62308ee
Fix readme link
wardsimon Feb 1, 2019
72f0f39
Merge branch 'master' into development
wardsimon Mar 11, 2019
b98dabf
Fix addaniso for atom types
Mar 16, 2019
e03581a
Merge remote-tracking branch 'origin/development' into development
wardsimon Mar 18, 2019
8049e08
Fix addg.m for atom types
wardsimon Mar 18, 2019
cf6f130
sw_plotspec lengend change
wardsimon Mar 22, 2019
6e7c882
Fix for tooltip hit.
wardsimon Apr 3, 2019
e53eeea
Jenkins file test 1
Apr 4, 2019
ae1c36d
Merge pull request #24 from SpinW/development
Apr 4, 2019
2f27fff
Documentation and mex fallback
wardsimon Apr 24, 2019
4cac1a6
Fixed sw_update
wardsimon Apr 24, 2019
fccdfd2
Text fixes for V3.1
wardsimon Apr 25, 2019
b85966d
README update
Apr 25, 2019
a33d6c5
Update DOI for v3.1
Apr 25, 2019
fb5aac6
Bug fix for sw_update
wardsimon Apr 29, 2019
af6b705
Merge remote-tracking branch 'origin/master'
wardsimon Apr 29, 2019
688a8aa
AB fix for newline fn introduced in Matlab 2016b
mducle Jun 10, 2019
43153c5
Merge pull request #30 from mducle/markdown_matlab2017a_bugfix
Jun 11, 2019
79644e0
Minor documentation fix.
Fellow-baka Jul 2, 2019
89b3de0
Add back eigshuffle for spinwavefast
wardsimon Jul 19, 2019
c6f5704
Merge pull request #31 from Fellow-baka/patch-1
Jul 29, 2019
a637878
Fixed a bug in handling incommensurate structs in spinwavefast
mducle Aug 20, 2019
0540446
Delete functionSignatures.json
Sep 4, 2019
48e23af
Merge pull request #33 from mducle/spinwavefast_incomm_bug
Sep 4, 2019
0233d7e
#36: Fix sw_readspec to read arb number of modes
mducle Apr 6, 2020
cfd16c7
#36: Add option to penalize imag modes in fitspec
mducle Apr 6, 2020
2483de8
Fix format Vsave for twins (mat2cell)
mducle Aug 3, 2020
93c3c4d
Merge pull request #44 from mducle/vsave_twin
wardsimon Aug 6, 2020
cbee996
Merge pull request #37 from mducle/36_fitspec_fixes
wardsimon Aug 6, 2020
1d37369
Update README.md
wardsimon Aug 6, 2020
16b10e2
Update README [ci skip]
wardsimon Mar 15, 2021
e86204b
Update README.md
wardsimon Mar 15, 2021
2ba2f49
Update README.md
wardsimon Mar 30, 2021
3137099
Fix bug in CIF xyz reader
mducle Jul 4, 2021
679a87a
Part-revert a6378783 in spinwavefast incommensurate
mducle Jul 15, 2021
e015286
Update README.md
wardsimon May 5, 2022
329dfa0
Merge development branch (#80)
rebeccafair May 11, 2022
97b6220
Port CI from SpinW4 (#81)
rebeccafair May 11, 2022
ca28eeb
Add unit tests for spinw creation (#84)
rebeccafair May 17, 2022
d6fffc9
Add CHANGELOG.rst (#86)
rebeccafair May 25, 2022
fd55c23
More additions to spinw.m tests (#88)
rebeccafair Jun 8, 2022
aeb4fdc
Add unit tests for addX methods of spinw class (#85)
RichardWaiteSTFC Jun 27, 2022
674dd30
Add unit tests for gencoupling (#89)
RichardWaiteSTFC Jul 1, 2022
70a6a81
Test spinwave.m (#92)
rebeccafair Jul 18, 2022
98ae5c7
Add tests for field (#100)
rebeccafair Aug 8, 2022
66ac715
Add test for genlattice (#99)
RichardWaiteSTFC Aug 16, 2022
4d02dbd
Test genmagstr (#97)
rebeccafair Aug 17, 2022
9e8a1ff
Swap order of actual and expected value args in super class verify_xx…
RichardWaiteSTFC Aug 18, 2022
37e2ac7
Update checkout, codecov, and upload-artifacts in actions (#112)
rebeccafair Oct 28, 2022
f2fcb71
Add unit tests optmagsteep (#108)
RichardWaiteSTFC Nov 2, 2022
91cc80a
Test optmagk (#111)
rebeccafair Nov 15, 2022
fcc5e19
Add symbolic system test based on NiPS3 (#113)
mducle Nov 15, 2022
1c9c2bb
Update readme to reflect the github action (#114)
granrothge Nov 21, 2022
e1995a9
Update actions versions (Node.js 12 deprecation) (#116)
RichardWaiteSTFC Nov 28, 2022
6375d51
Add unit tests intmatrix (#110)
RichardWaiteSTFC Nov 28, 2022
dd1f956
Add performance test for supercell calc BiFeO3
RichardWaiteSTFC Nov 28, 2022
08843f3
Add performance test for FM chain with large number qpts
RichardWaiteSTFC Dec 5, 2022
8277072
Fix BiFeO3 spinewave calc for hermit=1 (handle imag evalues)
RichardWaiteSTFC Dec 6, 2022
86b5fb2
Add spinw version to save directory of profile results
RichardWaiteSTFC Dec 6, 2022
8fa2e9a
Do not do hermit=1 calc for BiFeO3 supercell
RichardWaiteSTFC Dec 7, 2022
bfbd175
Add mex preference/setting to profile result directory name
RichardWaiteSTFC Dec 8, 2022
c9011d9
Add optmagstr tests (#117)
rebeccafair Dec 8, 2022
2341834
Add system test for supercell and incommensurate spinwave calc consis…
RichardWaiteSTFC Dec 8, 2022
9e42590
Loop over mex true/false in tests
RichardWaiteSTFC Dec 9, 2022
b0e60e3
Add option to run profile script without profile and add tic/toc
RichardWaiteSTFC Jan 10, 2023
9e1a1a0
Add performance test runner script
RichardWaiteSTFC Jan 12, 2023
bf992d9
Add test to explicitly check rotc can be an inversion (#122)
RichardWaiteSTFC Jan 19, 2023
67de88e
Remove git checkout from script runner
RichardWaiteSTFC Jan 19, 2023
7e25821
Save profile results to directory named with short commit sha
RichardWaiteSTFC Jan 19, 2023
70a7aeb
Write tic/toc timings to file (not stdout)
RichardWaiteSTFC Jan 19, 2023
99c8ec6
Run sripts with profile on and off
RichardWaiteSTFC Jan 19, 2023
98dac56
Add do_profile to filename of tic toc timings
RichardWaiteSTFC Jan 24, 2023
3bae6a3
Don't write ASCiI summary if no results
RichardWaiteSTFC Jan 25, 2023
00d766a
Add input to run tests multiple times
RichardWaiteSTFC Jan 25, 2023
0e3abfb
Add helper func to avg. times and write to file
RichardWaiteSTFC Jan 29, 2023
e78f47e
Only use hermit=true for mex enabled in incom. calc in BiFeO3 test
RichardWaiteSTFC Jan 30, 2023
62bfbf0
Make sure profiler off if not profiling
RichardWaiteSTFC Jan 31, 2023
96e635c
Use different nqpt in FMchain test on linux
RichardWaiteSTFC Jan 31, 2023
c17f4b6
Fix bugs in regex searching for files on linux
RichardWaiteSTFC Feb 3, 2023
9c85e13
Only profile FMchain in not on linux (set nqpts back to 1e7)
RichardWaiteSTFC Feb 3, 2023
1d1d4eb
Replace writelines function with fprintf
RichardWaiteSTFC Feb 6, 2023
c189abd
Use fixed width in format string for test name
RichardWaiteSTFC Feb 7, 2023
c5e297c
Add release note for spinwave speedup
RichardWaiteSTFC Feb 7, 2023
6560586
Better formatting of column names in avg. tic/toc files
RichardWaiteSTFC Feb 8, 2023
36b1978
Add is_daaas function to utilities and use in FMchain script
RichardWaiteSTFC Feb 10, 2023
35fccdd
Merge pull request #124 from SpinW/74_performance_for_spinwave
RichardWaiteSTFC Feb 14, 2023
fc33872
Only retrieve pref in sw_timeit if no tid set
RichardWaiteSTFC Feb 13, 2023
ce94dc1
Pre-allocate memory for Sab array
RichardWaiteSTFC Feb 13, 2023
9c71313
Merge pull request #125 from SpinW/123_replace_mmat_with_mtimesx_if_mex
RichardWaiteSTFC Feb 21, 2023
bc043d9
Fix out-of-memory error in mmat
mducle Mar 24, 2023
fe11c16
Add mmat unit test; address review comments
mducle Mar 24, 2023
692683e
Add mex to spinwave unit tests (#129)
RichardWaiteSTFC Mar 30, 2023
0b6b28e
Double needed mem limit in mmat and add note
mducle Mar 31, 2023
688ecbc
Remove mock return value namespace collision
mducle Mar 31, 2023
8f4eecf
Merge pull request #133 from SpinW/refactor_mmat
RichardWaiteSTFC Apr 3, 2023
4ede5fa
Improve tests (#138)
mducle Apr 18, 2023
80d30ff
PySpinW implementation (#143)
wardsimon May 17, 2023
415d143
Add pyspinw system test (#142)
RichardWaiteSTFC Jun 12, 2023
df2a40d
New release v32 (#144)
mducle Jun 12, 2023
12b0b45
Correct equations for q-range in sw_instrument (#134)
mducle Jun 27, 2023
92551aa
Fix sw_issymspec to recognise powder spectra (#146)
mducle Jun 27, 2023
49880bc
Test sw_egrid (#130)
rebeccafair Jul 6, 2023
d9752ca
a function to put out MDH files
granrothge Aug 24, 2023
a6c707a
add needed function
granrothge Aug 31, 2023
df28fb6
moved read_struct to inside sw_spec2MDHisto.m
granrothge Sep 1, 2023
a7e84c3
added code to overwrite existing file
granrothge Sep 1, 2023
720147b
added more description to the help files
granrothge Sep 1, 2023
d5aed00
updated struct reader
granrothge Sep 5, 2023
1e4618d
updated to handle off axis directions
granrothge Sep 6, 2023
a586024
slight editing to comments
granrothge Sep 6, 2023
32cb8b7
add a prototype test script
granrothge Sep 6, 2023
99adabc
added more tests
granrothge Sep 8, 2023
e238e26
streamlined tests
granrothge Sep 11, 2023
ea5ea33
Merge pull request #149 from granrothge/MDH_writer
RichardWaiteSTFC Sep 12, 2023
65c49a3
Fix syntax error reported by user #151
mducle Nov 1, 2023
b0ee48d
Force R2023a in gh-actions build_wheel (R2023b just released)
mducle Nov 1, 2023
6835ab2
Add release note
RichardWaiteSTFC Dec 6, 2023
735d30a
Merge pull request #153 from SpinW/151_fourier_sublat_bug
RichardWaiteSTFC Dec 7, 2023
950ad3b
Add vispy plotting of crystal structure to pyspinw (#161)
RichardWaiteSTFC Jan 17, 2024
ce8dd43
Updates to multidimensional histo writer (#166)
granrothge Feb 29, 2024
f11cf75
Add new mex to run inner loop of spinwave.m in parallel (#163)
mducle Apr 9, 2024
0c2f294
Add energy resolution option when binning eigenvalues onto grid in sw…
RichardWaiteSTFC Apr 15, 2024
74422b7
swloop mex (part II) (#173)
mducle Apr 15, 2024
3384ffa
Copy eigenvalues from `D` to `omega` when hermit=false and no mex
RichardWaiteSTFC May 2, 2024
5b5f4c2
Move copy of eigvals from D to omega inside hermit false branch
RichardWaiteSTFC May 3, 2024
4bb01e3
Add test to assert omega found with hermit=false & mex=false
RichardWaiteSTFC May 3, 2024
2b98670
Fix CI
mducle Apr 25, 2024
c046e97
Merge pull request #182 from SpinW/181_fix_fastmode_hermit_false_bug_…
RichardWaiteSTFC May 3, 2024
3e8b492
Minor Bugfixes (#180)
mducle May 20, 2024
3705737
Class interface to fit powder spectra (#174)
RichardWaiteSTFC May 20, 2024
3b929c4
Bug fixes for sw_fitpowder (#189)
RichardWaiteSTFC May 29, 2024
89c63fa
RELEASE PySpinW v4 (#190)
mducle May 31, 2024
1b52407
sw_fitpower improvements (#191)
RichardWaiteSTFC Jul 12, 2024
0c12cb1
Add function to ndbase to estimate hessian using cost-function
RichardWaiteSTFC Jul 24, 2024
51295a5
Add unit test
RichardWaiteSTFC Aug 1, 2024
7a1b9dc
Allow negative absolute steps
RichardWaiteSTFC Aug 1, 2024
f9b4a76
Update tolerances
RichardWaiteSTFC Aug 1, 2024
01ca8fe
Add option to vary only some parameters (e.g. if any fixed)
RichardWaiteSTFC Aug 1, 2024
d933df3
Add options to set cost func tolerance and number iterations
RichardWaiteSTFC Aug 1, 2024
074a8d4
Optionally output cost function value at parameters passed
RichardWaiteSTFC Aug 1, 2024
bc5fb9e
Add method to sw_fitpowder to estimate parameter errors
RichardWaiteSTFC Aug 1, 2024
f8a65ba
Add test for powder class parameter error estimation
RichardWaiteSTFC Aug 2, 2024
5a39203
Use arguments block rather than varargin
RichardWaiteSTFC Aug 14, 2024
2cbaeb3
Clarifications and typos in docs strings
RichardWaiteSTFC Aug 14, 2024
13bfc5d
Add max step to warning and undo last step doubling if unsuccessful
RichardWaiteSTFC Aug 14, 2024
006571a
Output optional struct, update test and powder fitting method
RichardWaiteSTFC Aug 14, 2024
479e28f
Output errors same length as parameters vector in powder fitting
RichardWaiteSTFC Aug 14, 2024
6bc1b64
Merge pull request #198 from SpinW/estimate_fit_parameter_uncertainties
RichardWaiteSTFC Aug 15, 2024
d859b68
Add powder fitting tutorial (#199)
RichardWaiteSTFC Aug 16, 2024
e41f848
Release workflow update (#202)
mducle Sep 6, 2024
b41a233
Add unit test for ndbase.simplex optimiser
RichardWaiteSTFC Sep 10, 2024
5d41c84
Make class to eval cost function and transform bound parameters
RichardWaiteSTFC Sep 11, 2024
3037248
Support fixing parameters
RichardWaiteSTFC Sep 12, 2024
a59b2a5
Call new class in ndbase.simplex
RichardWaiteSTFC Sep 12, 2024
0ce5c39
Fix bug for fixed params and add unit test
RichardWaiteSTFC Sep 12, 2024
7f7163c
Add unit test for all params fixed in minimiser
RichardWaiteSTFC Sep 16, 2024
732fed5
Tidy up simplex and fix bug with all params fixed
RichardWaiteSTFC Sep 16, 2024
b481405
Add unit test for function string
RichardWaiteSTFC Sep 16, 2024
2e1d995
Add support for char function in wrapper class
RichardWaiteSTFC Sep 16, 2024
cb6f318
Correct wrapper doc string
RichardWaiteSTFC Sep 16, 2024
f70d22c
Rename wrapper class
RichardWaiteSTFC Sep 16, 2024
297c341
Add unit test for cost function wrapper
RichardWaiteSTFC Sep 16, 2024
ae1500d
Fix formatting in simplex
RichardWaiteSTFC Sep 16, 2024
897d8a0
Fix fitspec test - MaxIter=1 returns initial parameter
RichardWaiteSTFC Sep 23, 2024
a8f91d1
Calc unweighted residuals if no/invalid errors in data struct
RichardWaiteSTFC Sep 23, 2024
959c38f
Optional inital cost_val and return jacobuan in estimate_hessian
RichardWaiteSTFC Sep 27, 2024
65d0cfc
Add function to evaluate weighted residuals in cost func wrapper
RichardWaiteSTFC Sep 27, 2024
2474a3a
Add LM minimiser (currently only supports scalar functions)
RichardWaiteSTFC Sep 27, 2024
d8b14e9
Support least_squares residuals in lm4
RichardWaiteSTFC Sep 30, 2024
7bf3529
Improve inversion for ill-conditioned matrices
RichardWaiteSTFC Sep 30, 2024
b94c4c7
Add missing factors of 2
RichardWaiteSTFC Sep 30, 2024
d1e8605
Fix bug in finite difference not resetting parameter vector
RichardWaiteSTFC Oct 1, 2024
e284a58
Fix bug with diff step length if parameters fixed
RichardWaiteSTFC Oct 1, 2024
40c9095
Fix bug where absolute and fracatinal step confused if 1 parameter
RichardWaiteSTFC Oct 1, 2024
b00c3d3
Add lm4 to optimiser to unit test
RichardWaiteSTFC Oct 1, 2024
42ac713
Update docstrings with MINUIT and lmfit references and info
RichardWaiteSTFC Oct 18, 2024
edf304b
Fix path in build_pyspinw.yml causing test failure
RichardWaiteSTFC Oct 18, 2024
0d60de2
Add tolerance used as constant property
RichardWaiteSTFC Oct 18, 2024
a7a4772
Add option to pass vector of fixed params to wrapper and add tests
RichardWaiteSTFC Oct 18, 2024
f8497bc
Avoid calling @(p) p for unbound parameters
RichardWaiteSTFC Oct 18, 2024
f60fc5c
Allow any non-finite value to indicate no bound
RichardWaiteSTFC Oct 24, 2024
73f604a
Merge pull request #204 from SpinW/implment_bounds_in_ndbase_minimisers
RichardWaiteSTFC Nov 1, 2024
dd978e2
Merge branch 'master' into add_new_LM_minimiser
RichardWaiteSTFC Nov 1, 2024
44a6290
Add support for function handles returning residal arrays
RichardWaiteSTFC Nov 4, 2024
3dc3f2f
Support resid_handle option in sw_fitpowder
RichardWaiteSTFC Nov 4, 2024
520e53c
Support resid_handle in bg fitting of pwader class
RichardWaiteSTFC Nov 5, 2024
e579fe2
Correct doc-strings for simplex and lm4
RichardWaiteSTFC Nov 15, 2024
5c3f460
Change nu_dn default to 5 after benchmarking with NIST datasets
RichardWaiteSTFC Nov 15, 2024
8cb0a1a
Use lsqnonlin method to reset invalid parameters within bounds
RichardWaiteSTFC Nov 15, 2024
5b72585
Add vary arg to simplex and lm4 (and tests)
RichardWaiteSTFC Nov 15, 2024
1fc202a
Fix typos in doc string
RichardWaiteSTFC Nov 18, 2024
7e87dee
Merge pull request #208 from SpinW/add_new_LM_minimiser
RichardWaiteSTFC Nov 18, 2024
a7e78cd
Fix bug in estimate_scale_factor - background already added to ycalc
RichardWaiteSTFC Jan 8, 2025
f7dd48e
Add new function to fit bg and scale parameters to all data
RichardWaiteSTFC Jan 8, 2025
127156e
Support any ndbase optimizer in fit_background
RichardWaiteSTFC Jan 8, 2025
d04fe5c
Add method to plot background region on figures
RichardWaiteSTFC Jan 9, 2025
9aa01e4
Add function (and tests) to set background region
RichardWaiteSTFC Jan 9, 2025
4c25403
Set sensible background when changing strategy
RichardWaiteSTFC Jan 9, 2025
2869cff
Handle edges/nans properly in avg. of error when taking 1D cuts
RichardWaiteSTFC Jan 9, 2025
cc82c7f
Add method to clear background region
RichardWaiteSTFC Feb 7, 2025
d028253
Fix out-of-bounds bug in mex code
mducle Feb 21, 2025
a2bf25c
Force using gcc-12 on Ubuntu as Matlab ships with older libgxx
mducle Feb 22, 2025
ecfd2c9
Merge pull request #214 from SpinW/mexboundsbug
RichardWaiteSTFC Feb 24, 2025
4f519a1
Fix uiopen path change in R2024b causing recursion bug #215
mducle Feb 28, 2025
91e673b
Support general polynomial background in Q and en
RichardWaiteSTFC Mar 17, 2025
4464c7f
Add unit tests for setting polynomial order
RichardWaiteSTFC Mar 17, 2025
0ad70f0
Use 2D data Q bins when replace 1D cuts
RichardWaiteSTFC Apr 28, 2025
df70190
Set SigP to 0 for fixed parameters in lm4
RichardWaiteSTFC Apr 29, 2025
40eca62
Fix bug for 1D cuts now using 2D Q bins
RichardWaiteSTFC Apr 29, 2025
7a6a70e
Update tutorial to include setting bg strategy and setting bg region
RichardWaiteSTFC Apr 29, 2025
7b470aa
Add method to export data in struct form
RichardWaiteSTFC May 16, 2025
f8e4567
Fix rebin_powspec_to_1D_cuts bug causing test failure
RichardWaiteSTFC May 19, 2025
17e2b1c
Add unit tests for export_data method
RichardWaiteSTFC May 19, 2025
484018d
Update tutorial with changing polynomial order
RichardWaiteSTFC May 19, 2025
e934108
Swap order of bg parameters (Q first) and add bg param labels
RichardWaiteSTFC Jun 2, 2025
12657f6
Update changing bg strategy tests with non-identical bg parameters
RichardWaiteSTFC Jun 2, 2025
718275e
Add ability to set background parameters, bounds etc. using string
RichardWaiteSTFC Jun 2, 2025
4031e9f
Add tests for setting bg parameters etc. with string labels
RichardWaiteSTFC Jun 2, 2025
4dfae05
Fix bug in background param label order
RichardWaiteSTFC Jun 5, 2025
a7b4b0e
Add method to nicely print/display parameters
RichardWaiteSTFC Jun 5, 2025
016b604
Update tutorial with parameter display
RichardWaiteSTFC Jun 5, 2025
6b7cf80
Fix size mismatch by assigning chunk of eigenvalues
RichardWaiteSTFC Jun 6, 2025
eacac5a
Add test with q-points chunked fastmode=true, hermit=false nomex
RichardWaiteSTFC Jun 6, 2025
84529bc
Fix bugs identified by C. Balz
mducle Aug 5, 2025
ba7a369
Merge pull request #224 from SpinW/balzbugs
RichardWaiteSTFC Aug 5, 2025
f0c6c2a
Stop scaling covariance by variance of residuals
RichardWaiteSTFC Sep 3, 2025
5263316
Fix bug in getting qcens of cuts when using binning in 2D data
RichardWaiteSTFC Sep 3, 2025
6e687a1
Improve plot formatting
RichardWaiteSTFC Sep 3, 2025
78177cf
Support char and cell of char in bg param setter
RichardWaiteSTFC Sep 3, 2025
4734e78
Save file when export data
RichardWaiteSTFC Sep 3, 2025
8e0376c
Add check for integer npoly
RichardWaiteSTFC Sep 3, 2025
92bbcd3
Remove comment form tutorial docs
RichardWaiteSTFC Sep 3, 2025
6ae56d9
Support specifying 1D cuts with array of q-values and test
RichardWaiteSTFC Sep 9, 2025
dc06a4b
Merge pull request #210 from SpinW/more_usability_improvements_sw_fit…
RichardWaiteSTFC Sep 10, 2025
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
66 changes: 66 additions & 0 deletions +sw_tests/+performance_tests/BiFeO3.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
function BiFeO3()
% setup
bfo = spinw;
bfo.genlattice('lat_const', [5.58 5.58 13.86], 'angled', [90 90 120], ...
'sym', 'R 3 c');
bfo.addatom('r', [0 0 0.2212], 'S', 2.5, 'label', 'MFe3');
bfo.gencoupling('maxDistance', 20)
bfo.addmatrix('label', 'J1', 'value', 0.69029);
bfo.addmatrix('label', 'J2', 'value', 0.2)
bfo.addcoupling('mat', 'J1', 'bond', 1)
bfo.addcoupling('mat', 'J2', 'bond', 2)
bfo.addmatrix('label', 'D', 'value', [1 -1 0]*0.185)
bfo.addcoupling('mat', 'D', 'bond', 2)
bfo.optmagk('kbase', [1; 1; 0], 'seed', 1);
bfo.optmagsteep('random',false,'TolX', 1e-12);

% test parameters
% add omega tol for imag eigenvalues (ignored if hermit=0)
spinwave_args_common = {{[-1/2 0 0], [0 0 0], [1/2 1/2 0], 30}, ...
'sortMode', false, 'hermit', 0, ...
'omega_tol', 0.05};
egrid_args = {'component','Sperp','Evect',0:0.1:5, 'imagChk', 0};
inst_args = {'dE',0.1};

% do a spin wave calculation for incommensurate case ([nExt=[1,1,1])
% and commensurate nExt=0.01 - which corresponds to a supercell of
% [11 11 1]
for do_supercell = 0:1
if do_supercell
nExt = 0.01;
bfo.genmagstr('nExt', nExt)
mexs = 1; % requires ~100GB RAM with no mex
else
nExt = [1,1,1];
mexs = 0:1;
end
for mex = mexs
swpref.setpref('usemex', logical(mex))
if mex && ~do_supercell
hermits = 0:1;
else
% chol throws error as matrix is not positive-definite
hermits = 0;
end
for hermit = hermits
for optmem = 0:5:10
spinwave_args = [spinwave_args_common, ...
'hermit', hermit, 'optmem', optmem];
test_name = [mfilename(), '_mex_', ...
num2str(swpref.getpref('usemex').val), ...
'_nExt_', regexprep(num2str(nExt), ' +', '_'), ...
'_hermit_', num2str(hermit), ...
'_optmem_', num2str(optmem)];
sw_tests.utilities.profile_spinwave(test_name, bfo, ...
spinwave_args,...
egrid_args, ...
inst_args, ...
0:1);
end
end
end
end



end
45 changes: 45 additions & 0 deletions +sw_tests/+performance_tests/FMchain.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
function FMchain()
% setup
FMchain = spinw;
FMchain.genlattice('lat_const',[3 8 8],'angled',[90 90 90])
FMchain.addatom('r', [0 0 0],'S', 1,'label','MCu1')
FMchain.gencoupling('maxDistance',7)
FMchain.addmatrix('value',-eye(3),'label','Ja')
FMchain.addcoupling('mat','Ja','bond',1);
FMchain.genmagstr('mode','direct', 'k',[0 0 0], ...
'n',[1 0 0],'S',[0; 1; 0]);


% test parameters
if sw_tests.utilities.is_daaas()
do_profiles = 0; % for some reason profile takes > 12 hrs on IDAaaS
else
do_profiles = 0:1;
end
spinwave_args_common = {{[0 0 0], [1 0 0], 1e7}, ...
'sortMode', false};
egrid_args = {'component','Sperp','Evect',0:0.1:5};
inst_args = {'dE',0.1};

for mex = 0:1
swpref.setpref('usemex', logical(mex))
for hermit = 0:1
for optmem = 0:5:10
spinwave_args = [spinwave_args_common, ...
'hermit', hermit, 'optmem', optmem];
test_name = [mfilename() '_mex_', ...
num2str(swpref.getpref('usemex').val), ...
'_hermit_', num2str(hermit), ...
'_optmem_' num2str(optmem)];
sw_tests.utilities.profile_spinwave(test_name, FMchain, ...
spinwave_args, ...
egrid_args, ...
inst_args, ...
do_profiles);
end
end
end



end
233 changes: 233 additions & 0 deletions +sw_tests/+system_tests/systemtest_spinwave.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,233 @@
classdef systemtest_spinwave < matlab.unittest.TestCase
% Base class for all systems test of spinwave.m based on tutorials

properties
generate_reference_data = false;
reference_data = [];
reference_data_dir = fullfile('.', 'test_data', 'system_tests');
relToll = 0.01;
absToll = 1e-6;
swobj = [];
cleanup_warnings = {};
end

methods (TestClassSetup)
function get_reference_data(testCase)
if isempty(testCase.reference_data_file)
return
end
fname = fullfile(testCase.reference_data_dir, testCase.reference_data_file);
if ~exist(testCase.reference_data_dir, 'dir')
mkdir(testCase.reference_data_dir);
end
if ~exist(fname, 'file') || testCase.generate_reference_data
testCase.generate_reference_data = true;
tmp = []; save(fname, 'tmp');
warning('Generating reference data');
else
testCase.reference_data = load(fname);
end
end
function disable_mex_setup(testCase)
swpref.setpref('usemex', false);
end
end

methods (TestClassTeardown)
function save_reference_data(testCase)
if testCase.generate_reference_data
fname = fullfile(testCase.reference_data_dir, testCase.reference_data_file);
ref_dat = load(fname);
ref_dat = rmfield(ref_dat, 'tmp');
save(fname, '-struct', 'ref_dat');
end
end
function disable_mex_teardown(testCase)
swpref.setpref('usemex', false);
end
end

methods (Static)
function out = get_hash(obj)
% Calculates a hash for an object or struct using undocumented built-ins
% Based on DataHash (https://uk.mathworks.com/matlabcentral/fileexchange/31272-datahash)
Engine = java.security.MessageDigest.getInstance('MD5');
Engine.update(getByteStreamFromArray(obj));
out = typecast(Engine.digest, 'uint8');
end
function out = sanitize_data(in_dat)
if isstruct(in_dat)
out = sanitize_struct(in_dat);
elseif iscell(in_dat)
out = sanitize_cell(in_dat);
elseif isnumeric(in_dat)
out = sanitize(in_dat);
else
out = in_dat;
end
end
end

methods
function out = approxMatrix(testCase, actual, expected, frac_not_match)
% Checks if two arrays are approximately the same with most entries equal but a fraction not
if iscell(actual)
out = actual;
for ii = 1:numel(actual)
out{ii} = testCase.approxMatrix(actual{ii}, expected{ii}, frac_not_match);
end
else
diff = abs(actual - expected);
rel_diff = diff ./ expected;
if (numel(find((diff > testCase.absToll) & (rel_diff > testCase.relToll))) / numel(actual)) < frac_not_match
out = expected;
else
out = actual;
end
end
end
function [actual, expected] = verify_eigval_sort(testCase, actual, expected, nested)
if nargin < 4
nested = 0;
end
if iscell(actual)
for ii = 1:numel(actual)
[actual{ii}, expected{ii}] = testCase.verify_eigval_sort(actual{ii}, expected{ii}, nested);
end
else
% Checks if actual and expected eigenvalues match, otherwise try a different sorting
import matlab.unittest.constraints.*
theseBounds = RelativeTolerance(testCase.relToll) | AbsoluteTolerance(testCase.absToll);
comparator = IsEqualTo(expected, 'Within', theseBounds);
if ~comparator.satisfiedBy(actual)
if nested > 1
actual = sort(abs(actual));
expected = sort(abs(expected));
else
actual = sort(actual, 'ComparisonMethod', 'real');
expected = sort(expected, 'ComparisonMethod', 'real');
end
if nested < 2
[actual, expected] = testCase.verify_eigval_sort(actual, expected, nested + 1);
end
end
end
end
function fieldname = get_fieldname(testCase, pars)
if isempty(pars)
fieldname = 'data';
elseif ischar(pars)
fieldname = pars;
else
fieldname = ['d' reshape(dec2hex(testCase.get_hash(pars)),1,[])];
end
end
function save_test_data(testCase, data, pars)
filename = fullfile(testCase.reference_data_dir, testCase.reference_data_file);
tmpstr.(testCase.get_fieldname(pars)) = data;
save(filename, '-append', '-struct', 'tmpstr');
end
function verify_test_data(testCase, test_data, ref_data)
import matlab.unittest.constraints.IsEqualTo
import matlab.unittest.constraints.RelativeTolerance
import matlab.unittest.constraints.AbsoluteTolerance
theseBounds = RelativeTolerance(testCase.relToll) | AbsoluteTolerance(testCase.absToll);
test_data = testCase.sanitize_data(test_data);
ref_data = testCase.sanitize_data(ref_data);
testCase.verifyThat(test_data, IsEqualTo(ref_data, 'Within', theseBounds));
end
function generate_or_verify(testCase, spec, pars, extrafields, approxSab, tolSab)
if nargin < 5
approxSab = false;
elseif nargin == 5
tolSab = 0.05;
end
if testCase.generate_reference_data
data.input = struct(testCase.swobj);
data.spec = {spec.omega spec.Sab};
if isfield(spec, 'swConv'); data.spec = [data.spec {spec.swConv}]; end
if isfield(spec, 'swInt'); data.spec = [data.spec {spec.swInt}]; end
if nargin > 3
extras = fieldnames(extrafields);
for ii = 1:numel(extras)
data.(extras{ii}) = extrafields.(extras{ii});
end
end
testCase.save_test_data(data, pars);
else
ref_data = testCase.reference_data.(testCase.get_fieldname(pars));
test_data.input = struct(testCase.swobj);
[spec.omega, ref_data.spec{1}] = testCase.verify_eigval_sort(spec.omega, ref_data.spec{1});
test_data.spec = {spec.omega spec.Sab};
if isfield(spec, 'swConv'); test_data.spec = [test_data.spec {spec.swConv}]; end
if isfield(spec, 'swInt'); test_data.spec = [test_data.spec {spec.swInt}]; end
if nargin > 3
extras = fieldnames(extrafields);
for ii = 1:numel(extras)
test_data.(extras{ii}) = extrafields.(extras{ii});
end
end
if any(approxSab)
% For the Sab or Sabp tensor, just check that a fraction of entries match
test_data.spec{2} = testCase.approxMatrix(spec.Sab, ref_data.spec{2}, tolSab);
if numel(test_data.spec) == 4
test_data.spec{4} = testCase.approxMatrix(spec.swInt, ref_data.spec{4}, tolSab);
end
if isfield(test_data, 'Sabp')
test_data.Sabp = testCase.approxMatrix(test_data.Sabp, ref_data.Sabp, tolSab);
end
if isfield(test_data, 'V')
test_data.V = testCase.approxMatrix(test_data.V, ref_data.V, tolSab);
end
end
testCase.verify_test_data(test_data, ref_data);
end
end
function generate_or_verify_generic(testCase, data, fieldname)
if testCase.generate_reference_data
testCase.save_test_data(data, fieldname);
else
testCase.verify_test_data(data, testCase.reference_data.(fieldname));
end
end
function disable_warnings(testCase, varargin)
testCase.cleanup_warnings = [testCase.cleanup_warnings, ...
{onCleanup(@(c) cellfun(@(c) warning('on', c), varargin))}];
cellfun(@(c) warning('off', c), varargin);
end
end

end

function out = sanitize(array)
out = array;
out(abs(out) > 1e8) = 0;
end

function sanitized = sanitize_struct(in_dat)
fnam = fieldnames(in_dat);
for ii = 1:numel(fnam)
if isnumeric(in_dat.(fnam{ii}))
sanitized.(fnam{ii}) = sanitize(in_dat.(fnam{ii}));
elseif isstruct(in_dat.(fnam{ii}))
sanitized.(fnam{ii}) = sanitize_struct(in_dat.(fnam{ii}));
elseif iscell(in_dat.(fnam{ii}))
sanitized.(fnam{ii}) = sanitize_cell(in_dat.(fnam{ii}));
else
sanitized.(fnam{ii}) = in_dat.(fnam{ii});
end
end
end

function sanitized = sanitize_cell(in_dat)
sanitized = in_dat;
for ii = 1:numel(in_dat)
if isnumeric(in_dat{ii})
sanitized{ii} = sanitize(in_dat{ii});
elseif isstruct(in_dat{ii})
sanitized{ii} = sanitize_struct(in_dat{ii});
elseif iscell(in_dat{ii})
sanitized{ii} = sanitize_cell(in_dat{ii});
end
end
end
Loading