Skip to content

Instantly share code, notes, and snippets.

@Kappie
Last active September 15, 2016 12:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Kappie/6add8182186b55fa1956213dc9940761 to your computer and use it in GitHub Desktop.
Save Kappie/6add8182186b55fa1956213dc9940761 to your computer and use it in GitHub Desktop.
function correlation_length = correlation_length(temperature, ~, T)
% construct row of spins, and attach two rows together.
transfer_matrix = ncon({T, construct_a(temperature), T}, {[1 -1 -4], [1 -2 2 -5], [2 -3 -6]});
transfer_matrix = ncon({transfer_matrix, transfer_matrix}, {[-1 -2 -3 1 2 3], [1 2 3 -4 -5 -6]});
% reshape into 2chi^2 x 2chi^2 matrix
[transfer_matrix, ~, ~] = lreshape(transfer_matrix, [1 2 3], [4 5 6]);
eigenvalues = eigs(transfer_matrix, 2);
correlation_length = 1 / log(eigenvalues(1) / eigenvalues(2));
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment