Skip to content

Added Kipton's spherical cap update and include Gaussian spin update. #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 5, 2021

Conversation

mswwilson
Copy link
Contributor

No description provided.

@mswwilson mswwilson assigned mswwilson and ColeMiles and unassigned mswwilson Oct 27, 2021

E_next = E_curr + local_energy_change(WLS.system, pos, new_spin) / ps

Δln_g = ln_g_tmp[E_curr] - ln_g_tmp[E_next]

if (Δln_g >= 0) || ( rand(WLS.rng) <= exp(Δln_g) )
if (Δln_g >= 0) || ( rand() <= exp(Δln_g) )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did this lose WLS.rng?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops. It should use WLS.rng.

@@ -247,7 +292,7 @@ function run!(WLS::WangLandau)
Δln_g = WLS.ln_g[E_curr] - WLS.ln_g[E_next]

# accept move
if (Δln_g >= 0) || ( rand(WLS.rng) <= exp(Δln_g) )
if (Δln_g >= 0) || ( rand() <= exp(Δln_g) )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here -- is the removal of WLS.rng intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also should use WLS.rng

-r y 0
z*y/r z x/r ]
S′ = Vec3(x′, z′, y′)
return R*S′
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really minor style comment, but maybe move the return R*S' outside of the if/else?

Copy link
Member

@kbarros kbarros Oct 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is interesting to me that this (Cole's suggested modification) indeed works even though the local variables R and S' are not defined before the if/else/end block.


ℓ = sqrt(S[1]^2 + S[2]^2)
function spherical_cap_update(S::Vec3, cos_max_angle::Float64, ξ1::Float64, ξ2::Float64)::Vec3
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function has been added, but just verifying that it seems like the WangLandau isn't actually using it? (Using the gaussian_spin_update instead?)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, I guess which one to pick is sort of a wash according to benchmarks.

-ℓ*x + S[3]*z
)
"""
Generate a random unit spin that is normally distributed about the direction
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd maybe consider changing the name of this function and/or the docstring. The function isn't actually generating any randomness, right? It's really just doing a vector addition and re-normalization.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should be passing the rng to the "sample" functions instead of the randomly sampled numbers. (For background, I originally organized the code this way because it made it easier to test things, but now that we know it works, I think it's cleaner to pass the rng).

Copy link
Contributor Author

@mswwilson mswwilson Oct 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I had it calling randn() originally (hence the missing WLS.rng in the other comments).

Just saw Kipton's comment about passing the rng - I can do that

@kbarros
Copy link
Member

kbarros commented Nov 1, 2021

Gentle ping. I think this can be merged with some minor changes. I guess it makes sense to pass the rng to spherical_cap_update, for example.

@mswwilson
Copy link
Contributor Author

Sorry for the delay. I should be able to make these changes in little bit.

@mswwilson
Copy link
Contributor Author

I made the changes here, so not sure it's ready to merge now. I passed a Random.AbstractRNG type as a parameter to the update functions.

@kbarros kbarros merged commit dfefecc into main Nov 5, 2021
@kbarros kbarros deleted the WLupdate branch November 5, 2021 01:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants