11#include "clib.h"
2+ #include "math.h"
3+ #include "complex.h"
24
35//compute the S \cdot (S_i \times S_j)
46inline double volume (double S [3 ], double Si [3 ], double Sj [3 ]) {
@@ -17,7 +19,7 @@ double skyrmion_number(double *spin, double *charge,
1719 *
1820 * The *spin array is the vector field for a two dimensional
1921 * lattice with dimensions nx * ny
20- * (we can take a slice of a bulk from Python and pass it here,
22+ * (we can take a slice of a bulk from Python and pass it here,
2123 * remember to do the ame for the neighbours matrix)
2224 * The array follows the order:
2325 * [Sx0 Sy0 Sz0 Sx1 Sy1 Sz1 ... ]
@@ -50,17 +52,17 @@ double skyrmion_number(double *spin, double *charge,
5052 *
5153 * Then, we use the follwing expression:
5254 *
53- * Q = S_i \dot ( S_{i+1} \times S_{j+1} )
55+ * Q = S_i \dot ( S_{i+1} \times S_{j+1} )
5456 * + S_i \dot ( S_{i-1} \times S_{j-1} )
5557 *
5658 * This expression is based on the publication PRL 108, 017601 (2012)
5759 * where Q is called "finite spin chirality". The idea comes from
5860 * discrete chiral quantities in Hall effect studies. For example, at
5961 * the end of page 3 in Rep. Prog. Phys. 78 (2015) 052502, it
6062 * is argued:
61- * scalar chirality (...) , which measures the volume enclosed
63+ * scalar chirality (...) , which measures the volume enclosed
6264 * by the three spins of the elementary triangle and, similarly to
63- * (the vector chirlity) is sensitive to the sense of spin's
65+ * (the vector chirlity) is sensitive to the sense of spin's
6466 * rotation in the x–y plane
6567 *
6668 * Hence we are taking the triangles formed by (i, i+1, j+1)
@@ -72,12 +74,12 @@ double skyrmion_number(double *spin, double *charge,
7274 *
7375 * Recently, other ways to calculate a discrete skyrmion number have
7476 * been proposed: http://arxiv.org/pdf/1601.08212.pdf
75- * Phys. Rev. B 93, 024417
76- *
77+ * Phys. Rev. B 93, 024417
78+ *
7779 * also based on using three spins using triangles. This could be
78- * useful for applying to a hexagonal lattice in the future.
80+ * useful for applying to a hexagonal lattice in the future.
7981 *
80- */
82+ */
8183
8284 int i , j ;
8385 int index , id ;
@@ -91,7 +93,7 @@ double skyrmion_number(double *spin, double *charge,
9193 for (i = 0 ; i < nxy ; i ++ ) {
9294 index = 3 * i ;
9395
94- /* The starting index of the nearest neighbours for the
96+ /* The starting index of the nearest neighbours for the
9597 * i-th spin */
9698 int id_nn = 6 * i ;
9799
@@ -156,6 +158,64 @@ double skyrmion_number(double *spin, double *charge,
156158
157159}
158160
161+ double dot (double * a , double * b ){
162+ double dp = 0 ;
163+ int i ;
164+
165+ for (i = 0 ; i < 3 ; i ++ ) dp += a [i ] * b [i ];
166+ return dp ;
167+ }
168+
169+ double compute_BergLuscher_angle (double * s1 , double * s2 , double * s3 ){
170+ double rho ;
171+ double complex exp ;
172+ double crossp [3 ];
173+
174+ crossp [0 ] = s2 [1 ] * s3 [2 ] - s2 [2 ] * s3 [1 ];
175+ crossp [1 ] = s2 [2 ] * s3 [0 ] - s2 [0 ] * s3 [2 ];
176+ crossp [2 ] = s2 [0 ] * s3 [1 ] - s2 [1 ] * s3 [0 ];
177+
178+ rho = sqrt (2 * (1 + dot (& s1 [0 ], & s2 [0 ]))
179+ * (1 + dot (& s2 [0 ], & s3 [0 ]))
180+ * (1 + dot (& s3 [0 ], & s1 [0 ]))
181+ );
182+
183+ exp = (1 + dot (& s1 [0 ], & s2 [0 ])
184+ + dot (& s2 [0 ], & s3 [0 ])
185+ + dot (& s3 [0 ], & s1 [0 ])
186+ + I * dot (& s1 [0 ], & crossp [0 ])
187+ ) / rho ;
188+
189+ return 2 * cimagl (clog (exp )) / (4 * WIDE_PI );
190+
191+ }
192+
193+ double skyrmion_number_BergLuscher (double * spin , double * charge ,
194+ int nx , int ny , int nz , int * ngbs ) {
195+
196+ int n = nx * ny * nz ;
197+ int i , spin_index , nn_index ;
198+ double total_sum = 0 ;
199+
200+ for (i = 0 ; i < n ; i ++ ){
201+
202+ spin_index = 3 * i ;
203+ nn_index = 6 * ngbs [i ];
204+
205+ charge [i ] = compute_BergLuscher_angle (& spin [spin_index ],
206+ & spin [nn_index + 0 ],
207+ & spin [nn_index + 2 ]
208+ );
209+ charge [i ] += compute_BergLuscher_angle (& spin [spin_index ],
210+ & spin [nn_index + 1 ],
211+ & spin [nn_index + 3 ]
212+ );
213+ total_sum += charge [i ];
214+ }
215+
216+ return total_sum ;
217+ }
218+
159219//compute the first derivative respect to x and for the whole mesh
160220//assume 2d pbc is used
161221void compute_px_py_c (double * spin , int nx , int ny , int nz , double * px , double * py ){
0 commit comments