Skip to main content
. 2020 Mar 14;22(3):336. doi: 10.3390/e22030336
Algorithm A2 Program Flow: Field-driven spin dynamics on the graph
  • 1:

    INPUT: Graph G, store as an array of Edge objects with identity of source and destination vertices, and the edges’s weight wij; the defect edges are marked; the number of all edges is Ne, the number of all vertices is N; input Δ,c1;

  • 2:

    Find kmax the maximum number of nearest neighbours among vertices in G; set the external field to hext=kmax; reset time counter;

  • 3:

    Assign Jij=1 to defect bonds, else Jij=+1;

  • 4:

    Attach two types of spins si and mi (for parallel update) to each vertex; initialise the spin state as:

  • 5:

    for all vertices iG do

  • 6:

       set si=1 and mi=1; the magnetisation M=imi=N;

  • 7:

    end for 

  • 8:

    while hext<+kmax do

  • 9:

       Field ramping hext=hext+Δ to trigger spin flips; Reset avalanche counters;

  • 10:

       Flips: reset counter of flipped spins nflip;

  • 11:

       for all vertices iG do

  • 12:

         compute local field hiloc as the sum Jijsj over all nearest neighbours and add the current hext;

  • 13:

         check the orientation of the spin si and the local field and, and with prob. c, flip the spin to align it with the local filed; for parallel update, the auxiliary spin mi is flipped;

  • 14:

         count the number of flipped spins nflip; update M from the number of flipped mi spins;

  • 15:

       end for

  • 16:

       update time t; sample temporal variables;

  • 17:

       Swap spins si=mi at all vertices;

  • 18:

       if nflip>0 then

  • 19:

         go to Flips and repeat the process;

  • 20:

       else

  • 21:

         Determine the avalanche size from the number of flipped spins;

  • 22:

       end if

  • 23:

    end while 

  • 24:

    Sample the data of interest;

  • 25:

    END