Skip to content

Instantly share code, notes, and snippets.

@migueldiascosta
Last active July 15, 2025 05:06
Show Gist options
  • Save migueldiascosta/aeae055c024bf26f595b3ed4dcbce341 to your computer and use it in GitHub Desktop.
Save migueldiascosta/aeae055c024bf26f595b3ed4dcbce341 to your computer and use it in GitHub Desktop.
VASP WAVEDERF
--- src/linear_optics.F.orig
+++ src/linear_optics.F
@@ -345,7 +345,7 @@
! write derivative of wavefunctions to file
CALL WRT_CDER_BETWEEN_STATES(WDES, IO%IU0, IU=55)
-! CALL WRT_CDER_BETWEEN_STATES_FORMATTED(WDES,W,IO%IU0,IU=55)
+ CALL WRT_CDER_BETWEEN_STATES_FORMATTED(WDES,W,IO%IU0,IU=55)
IF (LVEL) THEN
CALL FULL_KPOINT_AND_ENERGY_DER( W, LATT_CUR, IO)
# NSPIN, NKPTS, NBANDS
1 841 32
# For each spin, for each kpoint, for each pair of bands NB1 and NB2
# NB1, EN1, OCC1, NB2, EN2, OCC2, CDER_BETWEEN_STATES(NB1,NB2,NK,ISP,1:3)
1 -18.5989351 1.0000000 1 -18.5989351 1.0000000 0.0000000000 0.0000000000 -0.0000000004 -0.0000000000 0.0000000435 -0.0000000000
1 -18.5989351 1.0000000 2 -16.1429541 1.0000000 0.0000004676 -0.0000001834 -0.0000000002 -0.0000000003 0.8846547008 -0.3466510177
1 -18.5989351 1.0000000 3 -12.8232786 1.0000000 -0.0000066300 -0.0000742500 -0.0000000006 -0.0000000068 -0.0000000003 -0.0000000041
1 -18.5989351 1.0000000 4 -9.3065923 1.0000000 -0.0000000005 0.0000000006 0.0000000016 -0.0000000045 0.0000199788 -0.0000536026
1 -18.5989351 1.0000000 5 -8.3559760 1.0000000 0.0652087033 -0.2483286709 0.0000000001 0.0000000001 -0.0000004242 0.0000016157
1 -18.5989351 1.0000000 6 -8.1366643 1.0000000 0.0000004453 0.0000009074 0.0000000000 -0.0000000000 0.1371421367 0.2795881331
1 -18.5989351 1.0000000 7 -6.9591452 1.0000000 -0.0000000000 0.0000000000 0.0000000561 0.0000001794 0.0000000003 0.0000000001
1 -18.5989351 1.0000000 8 -5.3843555 1.0000000 0.0000000465 0.0000000380 0.0000000014 0.0000000011 -0.0000000375 -0.0000000307
1 -18.5989351 1.0000000 9 -5.2970212 1.0000000 0.0000000014 0.0000000024 -0.0000000023 -0.0000000036 -0.0000033581 -0.0000054224
1 -18.5989351 1.0000000 10 -3.6531750 1.0000000 0.0000006168 0.0000003098 -0.0000000048 -0.0000000024 -0.0000000010 -0.0000000004
1 -18.5989351 1.0000000 11 -2.7425965 0.0000000 0.0000000026 0.0000000140 -0.0000000000 0.0000000001 0.0186242405 0.1005702838
1 -18.5989351 1.0000000 12 -1.9966628 0.0000000 0.0000293026 0.0000005026 0.0000000926 0.0000000016 -0.0000000023 -0.0000000000
1 -18.5989351 1.0000000 13 -0.9644240 0.0000000 -0.0864038989 0.0394841246 -0.0000000000 0.0000000000 0.0000000147 -0.0000000067
1 -18.5989351 1.0000000 14 -0.3371825 0.0000000 -0.0000000000 -0.0000000001 -0.0004575886 0.0984670818 0.0000000000 0.0000000000
1 -18.5989351 1.0000000 15 0.7524200 0.0000000 0.0000000073 -0.0000000090 -0.0000000003 0.0000000006 -0.0202475265 0.0271390043
1 -18.5989351 1.0000000 16 0.9515606 0.0000000 0.0000000015 0.0000000002 -0.0000000044 0.0000000035 -0.0000453210 0.0000315711
1 -18.5989351 1.0000000 17 1.4121411 0.0000000 0.0000000001 0.0000000005 0.0000000005 -0.0000000021 -0.0000008021 0.0000020658
1 -18.5989351 1.0000000 18 1.5234387 0.0000000 -0.0000000003 -0.0000000042 -0.0000000001 0.0000000004 0.0002863379 0.0075579397
1 -18.5989351 1.0000000 19 1.7702057 0.0000000 0.0000000006 -0.0000000008 0.0000000007 0.0000000013 -0.0000010213 -0.0000020442
1 -18.5989351 1.0000000 20 1.9546284 0.0000000 -0.0000000047 -0.0000000050 -0.0000000006 -0.0000000004 0.0077713481 0.0084467996
1 -18.5989351 1.0000000 21 2.3841439 0.0000000 -0.0000000004 0.0000000004 0.0000000017 -0.0000000013 -0.0000006343 0.0000002363
1 -18.5989351 1.0000000 22 2.3908252 0.0000000 0.0000000428 -0.0000000280 0.0000031865 -0.0000020813 -0.0000000045 0.0000000029
1 -18.5989351 1.0000000 23 2.5780116 0.0000000 -0.0000000015 0.0000000097 -0.0000000009 0.0000000007 0.0008207337 -0.0119075114
1 -18.5989351 1.0000000 24 2.9191928 0.0000000 0.0011292620 -0.0051436638 -0.0000000001 -0.0000000001 -0.0000000137 0.0000000619
1 -18.5989351 1.0000000 25 3.0702390 0.0000000 -0.0000000002 -0.0000000001 0.0000000050 0.0000000133 -0.0000013542 -0.0000037146
1 -18.5989351 1.0000000 26 3.3765683 0.0000000 0.0000000054 0.0000000168 -0.0000000004 -0.0000000005 -0.0039097355 -0.0100698248
1 -18.5989351 1.0000000 27 3.4066142 0.0000000 -0.0000000006 -0.0000000006 0.0000000112 0.0000000085 0.0000015267 0.0000011348
1 -18.5989351 1.0000000 28 4.3342186 0.0000000 -0.0005137025 -0.0001659271 0.0000000001 -0.0000000000 0.0000000142 0.0000000046
1 -18.5989351 1.0000000 29 4.3709027 0.0000000 0.0000000121 -0.0000000099 -0.0000000011 0.0000000008 -0.0061312136 0.0070220567
1 -18.5989351 1.0000000 30 4.4019626 0.0000000 -0.0000000026 0.0000000010 0.0000000068 -0.0000000035 0.0000062089 -0.0000035624
1 -18.5989351 1.0000000 31 4.5270552 0.0000000 0.0000000000 0.0000000001 -0.0000000128 0.0000000386 -0.0000000000 -0.0000000001
1 -18.5989351 1.0000000 32 5.5593278 0.0000000 -0.0000000041 -0.0000000175 -0.0000000001 -0.0000000007 0.0015129247 0.0087633943
2 -16.1429541 1.0000000 1 -18.5989351 1.0000000 0.0000004676 0.0000001834 -0.0000000002 0.0000000003 0.8846547008 0.3466510177
2 -16.1429541 1.0000000 2 -16.1429541 1.0000000 0.0000000000 0.0000000000 -0.0000000004 -0.0000000000 -0.0000002895 -0.0000000000
2 -16.1429541 1.0000000 3 -12.8232786 1.0000000 0.3935865462 -1.3463786840 0.0000000002 -0.0000000004 0.0000001289 -0.0000004418
2 -16.1429541 1.0000000 4 -9.3065923 1.0000000 -0.0000001081 0.0000001207 0.0000000000 0.0000000000 0.5620303750 -0.6277340651
2 -16.1429541 1.0000000 5 -8.3559760 1.0000000 -0.0000173095 0.0000237276 0.0000000039 -0.0000000054 -0.0000000019 0.0000000028
2 -16.1429541 1.0000000 6 -8.1366643 1.0000000 -0.0000000005 -0.0000000061 -0.0000000004 -0.0000000053 -0.0000024426 -0.0000295130
2 -16.1429541 1.0000000 7 -6.9591452 1.0000000 -0.0000000044 0.0000000624 -0.0000000002 0.0000000040 -0.0000000071 0.0000001004
2 -16.1429541 1.0000000 8 -5.3843555 1.0000000 0.0000000000 -0.0000000001 0.0000000381 0.0000000680 -0.0000000005 -0.0000000003
2 -16.1429541 1.0000000 9 -5.2970212 1.0000000 -0.0000000254 -0.0000001381 -0.0000000001 0.0000000000 0.0356694832 0.1948741376
2 -16.1429541 1.0000000 10 -3.6531750 1.0000000 0.0978889018 0.1089779064 -0.0000000000 -0.0000000000 0.0000000796 0.0000000888
2 -16.1429541 1.0000000 11 -2.7425965 0.0000000 -0.0000000012 0.0000000068 0.0000000002 -0.0000000014 0.0000011286 -0.0000058585
2 -16.1429541 1.0000000 12 -1.9966628 0.0000000 0.1280499250 0.0527265109 -0.0000000001 -0.0000000001 0.0000000100 0.0000000042
2 -16.1429541 1.0000000 13 -0.9644240 0.0000000 0.0000338586 -0.0000018702 -0.0000000077 0.0000000005 0.0000000001 0.0000000000
2 -16.1429541 1.0000000 14 -0.3371825 0.0000000 0.0000000472 -0.0000001187 0.0000028939 -0.0000072855 -0.0000000026 0.0000000064
2 -16.1429541 1.0000000 15 0.7524200 0.0000000 -0.0000000002 -0.0000000003 -0.0000000014 0.0000000009 0.0000120936 -0.0000075213
2 -16.1429541 1.0000000 16 0.9515606 0.0000000 0.0000000072 -0.0000000021 0.0000000007 -0.0000000002 -0.0094473818 0.0022620137
2 -16.1429541 1.0000000 17 1.4121411 0.0000000 -0.0000000006 0.0000000007 0.0000000010 0.0000000002 0.0018283038 -0.0019870247
2 -16.1429541 1.0000000 18 1.5234387 0.0000000 -0.0000000000 0.0000000001 -0.0000000009 0.0000000011 -0.0000003814 0.0000010933
2 -16.1429541 1.0000000 19 1.7702057 0.0000000 -0.0000000001 -0.0000000009 -0.0000000001 -0.0000000003 0.0007213964 0.0080115274
2 -16.1429541 1.0000000 20 1.9546284 0.0000000 -0.0000000002 -0.0000000003 0.0000000008 0.0000000026 -0.0000015601 -0.0000040182
2 -16.1429541 1.0000000 21 2.3841439 0.0000000 -0.0000000032 -0.0000000002 0.0000000007 0.0000000004 -0.0187026914 -0.0003110022
2 -16.1429541 1.0000000 22 2.3908252 0.0000000 -0.0000000001 -0.0000000000 -0.0388991758 0.0080924490 -0.0000000000 0.0000000001
2 -16.1429541 1.0000000 23 2.5780116 0.0000000 -0.0000000002 -0.0000000004 -0.0000000025 0.0000000047 0.0000015970 -0.0000033725
2 -16.1429541 1.0000000 24 2.9191928 0.0000000 0.0000009241 -0.0000013814 0.0000000472 -0.0000000706 0.0000000012 -0.0000000019
2 -16.1429541 1.0000000 25 3.0702390 0.0000000 0.0000000010 -0.0000000429 0.0000000001 -0.0000000004 0.0016728140 -0.0702063069
2 -16.1429541 1.0000000 26 3.3765683 0.0000000 -0.0000000000 0.0000000002 -0.0000000004 -0.0000000015 0.0000000084 -0.0000026676
2 -16.1429541 1.0000000 27 3.4066142 0.0000000 -0.0000000233 -0.0000000369 -0.0000000004 0.0000000004 -0.0245712176 -0.0393524542
2 -16.1429541 1.0000000 28 4.3342186 0.0000000 0.0000045001 0.0000036831 -0.0000000174 -0.0000000143 -0.0000000010 -0.0000000008
2 -16.1429541 1.0000000 29 4.3709027 0.0000000 0.0000000008 -0.0000000004 -0.0000000040 0.0000000004 -0.0000029885 0.0000015548
2 -16.1429541 1.0000000 30 4.4019626 0.0000000 -0.0000000244 0.0000000037 0.0000000023 0.0000000012 -0.0059947865 0.0008901283
2 -16.1429541 1.0000000 31 4.5270552 0.0000000 0.0000000033 -0.0000000040 -0.0000000008 0.0000000008 0.0000000222 -0.0000000269
2 -16.1429541 1.0000000 32 5.5593278 0.0000000 0.0000000002 -0.0000000018 -0.0000000024 0.0000000029 -0.0000000579 0.0000002812
@debmalyakan
Copy link

Hi Miguel,
Thanks for this nice WAVEDER. Can you explain me what are the last 6 columns mean in the WAVEDER? What's the order of CDER?

Best,
Debmalya Ray

@jmmshn
Copy link

jmmshn commented Aug 31, 2022

@migueldiascosta
Do you know the SI units for the matrix elements here?
I have not been able to find that information anywhere.

@kaynat-alvi
Copy link

Can anyone please confirm the units of momentum matrix elements written in WAVEDERF file?

@migueldiascosta
Copy link
Author

Can anyone please confirm the units of momentum matrix elements written in WAVEDERF file?

afaik, angstrom (see e.g. https://www.vasp.at/forum/viewtopic.php?p=31086#p31074 and https://www.vasp.at/forum/viewtopic.php?p=31086#p31099)

@migueldiascosta
Copy link
Author

what is difference between waveder and wavederf ? i dont know where to put that code given here ?

WAVEDERF is simply the formatted (text) version of WAVEDER (binary)

the code is part of VASP, but the call is commented by default, one needs to uncomment it to get WAVEDERF (besides WAVEDER)

@migueldiascosta
Copy link
Author

not sure how/why people are finding this old gist but fwiw the context was this addition to pymatgen: https://github.com/materialsproject/pymatgen/pull/220/files

@kaynat-alvi
Copy link

can you please add a readme file, it would be easier to know whats happening in the code

@migueldiascosta
Copy link
Author

this is a gist, it was simply a way to share an example with some that requested it. I'm more inclined to delete it.

@jmmshn
Copy link

jmmshn commented Jun 24, 2025

@kaynat-alvi, this implements the optics logic from VASP in python
https://github.com/materialsproject/pymatgen/blob/master/src/pymatgen/io/vasp/optics.py
The code and tests for the code inside the pymatgen repo might help you interact with waveder and wavederf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment