Skip to content
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

Input file support for target_acceptance for Monte-Carlo moves #94

Merged
merged 10 commits into from
Feb 9, 2017

Conversation

g-bauer
Copy link
Contributor

@g-bauer g-bauer commented Jan 24, 2017

This PR adds input file support for adding MC moves with a target acceptance (see #23). Also, the update_amplitude_frequency - which is needed to achieve the acceptance - can be set from the input.

  • Extract unsigned integer from TOML
  • Add key for target_acceptance
  • Add key for update_delta_every (since all our displacements are called delta) update_frequency
  • Add example input file
  • Add tests in input/tests
  • Add documentation

Open questions:

  • How to handle the case, where an acceptance is given, but no update_frequency? Set default? Error?
    • Solution: Throw error telling the user to specify update_frequency.
  • How to handle the case, where an update_frequency is given, but no acceptance? Ignore? Set default for acceptance?
    • Solution: Accept input. Updates don't change scaling factor.

I'd be happy to discuss naming of keys and any other kind of feedback.

if config.get("update_delta_every").is_some() {
let update_amplitude = try!(extract::uint(
"update_delta_every", config, "Monte-Carlo propagator"));
mc.set_amplitude_update_frequency(update_amplitude);
Copy link
Member

Choose a reason for hiding this comment

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

I would use the same name in input and code. Either update_delta_every or update_frequency (I prefer the second), but the same one.

This help users of the code to dive in and write rust code: they are already familiar with the naming of functions.

temperature with unit.

- Optional keys:
* `update_delta_every` (uint): After this number of steps of a move, `delta` values
Copy link
Member

Choose a reason for hiding this comment

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

unsigned integer or positive integer or just integer might be more readable than uint here.

@@ -0,0 +1,41 @@
# run via:
# cargo run ethane.toml --release
Copy link
Member

Choose a reason for hiding this comment

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

Should we merge this with the mc_npt_ethane.rs example ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What do you mean by "merge"? Use this instead of the other example?

Copy link
Member

Choose a reason for hiding this comment

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

I believe both examples run the same simulation? If so the .rs file could just read this input and run the corresponding simulation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yepp, they both run the same simulation. I thought it would be good to show how to do the exact same thing using both methods.

We can change the .rs though if that makes more sense.

Copy link
Member

@Luthaf Luthaf Jan 29, 2017

Choose a reason for hiding this comment

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

OK, let's keep it. I am a bit worried about examples proliferation, I don't know what is the best way to showcase the code. Too many examples might be overwhelming, and too few is worst.

But we can figure it later!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's true. I think having a lot of examples is a good thing for now. We can sort out examples showing features later.

@Luthaf
Copy link
Member

Luthaf commented Jan 26, 2017

How to handle the case, where an acceptance is given, but no update_frequency? Set default? Error?
How to handle the case, where an update_frequency is given, but no acceptance? Ignore? Set default for acceptance?

I would go for the conservative way: accept update_frequency without acceptance, but not the reverse.

@g-bauer g-bauer force-pushed the input_mcmove_acceptance branch from 293895e to 1c28a13 Compare February 8, 2017 21:26
@g-bauer g-bauer changed the title [WIP] Input file support for target_acceptance for Monte-Carlo moves Input file support for target_acceptance for Monte-Carlo moves Feb 8, 2017
{type = "Translate", delta = "1 A", frequency = 2},
{type = "Rotate", delta = "20 deg", molecule = "CO2.xyz"},
{type = "Resize", pressure = "10 bar", delta = "3 A^3", frequency = 0.001},
{type = "Translate", delta = "1 A", frequency = 2, target_acceptance = 0.5},
Copy link
Member

Choose a reason for hiding this comment

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

I prefer if we do not have target_acceptance in the main examples, but only in the corresponding documentation. Else people will think it is mandatory and start to copy-paste it everywhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I can change that. From my experience, setting an acceptance (or having it set to 0.5 by the program) is the default behavior in most codes I know.

update_frequency = -1
#^ 'update_frequency' must be a positive integer in Monte-Carlo propagator
moves = [
{type = "Rotate", delta = "6 A", frequency = 0.3, target_acceptance = 0.5}
Copy link
Member

Choose a reason for hiding this comment

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

Could you add "bad" tests setting target_acceptance to something below 0 and above 1?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. Currently, this is not checked within input but in core. It will panic with a hint to the mcmove source file. Should we catch this in the input directly?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, panics in core are more to check that the API is respected, but we should always respect the API from the input crate. I think it is better for the user experience to get errors instead of panics.

@Luthaf
Copy link
Member

Luthaf commented Feb 9, 2017

@g-bauer, could you also squash together related commits (the fix whitespace ones; the add examples ones; ...)

@g-bauer g-bauer mentioned this pull request Feb 9, 2017
22 tasks
@g-bauer
Copy link
Contributor Author

g-bauer commented Feb 9, 2017

@g-bauer, could you also squash together related commits (the fix whitespace ones; the add examples ones; ...)

I'll try. Fingers crossed that I'm not killing my branch. My commits are still a mess, i vow improvement 😄

Edit: Aaaaaand I forgot to add the new input tests 😞

@g-bauer g-bauer force-pushed the input_mcmove_acceptance branch 2 times, most recently from 91f2aaa to 14f91fa Compare February 9, 2017 20:14
Updated documentation due to review.

Added more input tests.

Fixed newlines.
@g-bauer g-bauer force-pushed the input_mcmove_acceptance branch from 14f91fa to f7821ed Compare February 9, 2017 20:21
@Luthaf
Copy link
Member

Luthaf commented Feb 9, 2017

Edit: Aaaaaand I forgot to add the new input tests 😞

Did you? I see them in the last commit. Or you pushed a change after your comment?

@g-bauer
Copy link
Contributor Author

g-bauer commented Feb 9, 2017

Or you pushed a change after your comment?

🙄

@Luthaf Luthaf merged commit 05f12f4 into lumol-org:master Feb 9, 2017
@g-bauer g-bauer deleted the input_mcmove_acceptance branch February 9, 2017 20:46
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.

2 participants