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

Gibbs Ensemble scripts #4243

Merged
merged 4 commits into from
Jun 7, 2021
Merged

Gibbs Ensemble scripts #4243

merged 4 commits into from
Jun 7, 2021

Conversation

jhossbach
Copy link
Contributor

This is an updated version of #3903

Several updates were performed:

  • Multiprocessing and Communication via the internal Pipes was used instead of subprocessing and communicating via socket
  • The sample system no longer uses correction terms but a truncation of 5 sigma instead

This updated way of communication between processes is far more efficient than using TCP connections which is either a result of an increase in latency or the multiprocessing module uses internal methods to efficiently use nonblocking communication between the processes.

The simulation has the following structure:

  • The run_sim.py script starts the clients and controls them (same functionality as the socket script in WIP: Gibbs ensemble scripts #3903)
  • The gibbs_client_class.py script contains the client class with the methods needed
  • The client_system.py script initializes the system in every box

@jonaslandsgesell
Copy link
Member

jonaslandsgesell commented May 11, 2021

Would you mind investigating using MD moves instead of MC moves to propagate the internal states of each system. Just instead of moving 1 particle and computing exp(-beta Delta E_pot) in an MC step, run x MD steps (e.g. 10-100) and compute exp(-beta Delta E_pot) from before and after running MD.
This would allow to simulate polymer systems and should have much faster decaying autocorrelations of observables.

Running MD will require that you initialize to the velocities with a Maxwellian distribution like e.g. in

vel[0] = std::sqrt(temperature) * m_normal_distribution(m_generator);
after creation or when you insert new particles etc.

You will also have to avoid inserting particles closer than e.g. 0.9 sigma to avoid instabilities in the MD (see

if (d_min < exclusion_radius)
) for fulfilling detailed balance you may then also not remove particles which were closer than this exclusion radius. You can just use the logic from within the reaction ensemble here.

@RudolfWeeber
Copy link
Contributor

RudolfWeeber commented May 11, 2021 via email

samples/gibbs_ensemble/condor_queue.sub Outdated Show resolved Hide resolved
samples/gibbs_ensemble/create_fits.py Show resolved Hide resolved
samples/gibbs_ensemble/create_fits.py Outdated Show resolved Hide resolved
samples/gibbs_ensemble/create_fits.py Outdated Show resolved Hide resolved
samples/gibbs_ensemble/create_fits.py Outdated Show resolved Hide resolved
samples/gibbs_ensemble/run_sim.py Outdated Show resolved Hide resolved
samples/gibbs_ensemble/run_sim.py Outdated Show resolved Hide resolved
samples/gibbs_ensemble/run_sim.py Show resolved Hide resolved
samples/gibbs_ensemble/run_sim.py Show resolved Hide resolved
samples/gibbs_ensemble/client_system.py Outdated Show resolved Hide resolved
@jhossbach
Copy link
Contributor Author

jhossbach commented May 11, 2021

For now I updated some comments, added docstrings and copyright disclaimers. Things that still need to be done:

  • Create README.md
  • Use subclass instead of free function in client_system to give rise to possible truncation correction
  • Actually implement truncation correction for better evaluation with the literature available
  • Rewrite the create_fits script to a more pythonic way
  • Add uncertainties to the plot
  • Add more commenting for lists throughout all scripts
  • Change the move counters to be Enum dict entries
  • Update the trial move functions to return True/False and no longer use the 'global' keyword
  • Update the Client class to save particle information via the ParticleHandle.to_dict() function

Copy link
Contributor

@RudolfWeeber RudolfWeeber left a comment

Choose a reason for hiding this comment

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

Thank you. Just two minor issues left

samples/gibbs_ensemble/gibbs_ensemble.py Outdated Show resolved Hide resolved
samples/gibbs_ensemble/gibbs_ensemble.py Outdated Show resolved Hide resolved
samples/gibbs_ensemble/client_system.py Outdated Show resolved Hide resolved
Copy link
Member

@jngrad jngrad left a comment

Choose a reason for hiding this comment

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

Here is a review from the point of view of code maintainability. I'm not sure the shell script can be tested, unless we can extract the number of steps as an external variable and call the script from a python subprocess.

samples/gibbs_ensemble/run_for_several_kT.sh Outdated Show resolved Hide resolved
samples/gibbs_ensemble/run_for_several_kT.sh Outdated Show resolved Hide resolved
samples/gibbs_ensemble/run_for_several_kT.sh Outdated Show resolved Hide resolved
samples/gibbs_ensemble/run_sim.py Outdated Show resolved Hide resolved
samples/gibbs_ensemble/run_sim.py Show resolved Hide resolved
samples/gibbs_ensemble/run_for_several_kT.sh Outdated Show resolved Hide resolved
@jngrad
Copy link
Member

jngrad commented May 14, 2021

@jhossbach please apply suggested changes with option "Add suggestion to batch", we have limited CI resources :-)

@RudolfWeeber
Copy link
Contributor

RudolfWeeber commented May 14, 2021 via email

@jhossbach
Copy link
Contributor Author

jhossbach commented May 18, 2021

With fe1f069 I did a last sweep over the plot script. Please review it again.

Thank you. Just two minor issues left

Copy link
Member

@KaiSzuttor KaiSzuttor left a comment

Choose a reason for hiding this comment

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

looks very good, i just have added a few minor comments

samples/gibbs_ensemble/client_system.py Outdated Show resolved Hide resolved
samples/gibbs_ensemble/create_fits.py Outdated Show resolved Hide resolved
samples/gibbs_ensemble/create_fits.py Outdated Show resolved Hide resolved
samples/gibbs_ensemble/create_fits.py Outdated Show resolved Hide resolved
samples/gibbs_ensemble/create_fits.py Outdated Show resolved Hide resolved
samples/gibbs_ensemble/create_fits.py Outdated Show resolved Hide resolved
samples/gibbs_ensemble/create_fits.py Outdated Show resolved Hide resolved
samples/gibbs_ensemble/create_fits.py Show resolved Hide resolved
samples/gibbs_ensemble/create_fits.py Show resolved Hide resolved
samples/gibbs_ensemble/gibbs_ensemble.py Outdated Show resolved Hide resolved
@RudolfWeeber RudolfWeeber changed the title WIP: Gibbs Ensemble scripts (Update of #3903) Gibbs Ensemble scripts (Update of #3903) Jun 3, 2021
@RudolfWeeber
Copy link
Contributor

From my side, we're good, here.

@jngrad jngrad self-assigned this Jun 3, 2021
@jngrad
Copy link
Member

jngrad commented Jun 3, 2021

I'll have another look and rebase the PR. There are 68 commits, many of which are fixups and reverts.

Copy link
Member

@jngrad jngrad left a comment

Choose a reason for hiding this comment

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

A few suggestions. They have been addressed in 684a12d

samples/gibbs_ensemble/run_sim.py Outdated Show resolved Hide resolved
samples/gibbs_ensemble/run_sim.py Outdated Show resolved Hide resolved
samples/gibbs_ensemble/create_fits.py Outdated Show resolved Hide resolved
@jngrad
Copy link
Member

jngrad commented Jun 3, 2021

The PR was rebased to remove accidentally committed files from the git history and squash the fixups. I've also added copyright headers and wrapped long lines (see git diff 02c06cbc94c..7fe8f511489233).

@jngrad jngrad added the Python label Jun 3, 2021
@jngrad jngrad added this to the Espresso 4.2 milestone Jun 3, 2021
Copy link
Member

@jngrad jngrad left a comment

Choose a reason for hiding this comment

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

ok from my side

@jngrad jngrad removed their assignment Jun 3, 2021
@jngrad
Copy link
Member

jngrad commented Jun 3, 2021

@RudolfWeeber don't forget to change your review from "Requested changes" to "Accepted", then it can be merged

@jngrad jngrad changed the title Gibbs Ensemble scripts (Update of #3903) Gibbs Ensemble scripts Jun 7, 2021
@jngrad jngrad dismissed RudolfWeeber’s stale review June 7, 2021 10:18

Requested changes were applied.

@jngrad jngrad added the automerge Merge with kodiak label Jun 7, 2021
@kodiakhq kodiakhq bot merged commit 21b5025 into espressomd:python Jun 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Merge with kodiak Python
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants