-
Notifications
You must be signed in to change notification settings - Fork 18
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
Conversation
src/input/src/simulations/mc.rs
Outdated
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); |
There was a problem hiding this comment.
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.
doc/src/input/mc.md
Outdated
temperature with unit. | ||
|
||
- Optional keys: | ||
* `update_delta_every` (uint): After this number of steps of a move, `delta` values |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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.
I would go for the conservative way: accept |
293895e
to
1c28a13
Compare
target_acceptance
for Monte-Carlo movestarget_acceptance
for Monte-Carlo moves
doc/src/input/mc.md
Outdated
{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}, |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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} |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
@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 😞 |
Added example.
Fixed whitespace in example.
91f2aaa
to
14f91fa
Compare
Updated documentation due to review. Added more input tests. Fixed newlines.
14f91fa
to
f7821ed
Compare
Did you? I see them in the last commit. Or you pushed a change after your comment? |
🙄 |
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.target_acceptance
update_delta_every
(since all our displacements are calleddelta
)update_frequency
Open questions:
update_frequency
.I'd be happy to discuss naming of keys and any other kind of feedback.