glotzerlab / hoomd-examples

HOOMD-blue example scripts.
BSD 3-Clause "New" or "Revised" License
33 stars 15 forks source link

Add patchy particle tutorial #84

Closed tcmoore3 closed 1 year ago

tcmoore3 commented 1 year ago

Description

Adds a tutorial showing how to model patchy particles in HPMC. It uses the Kern–Frenkel model as an example.

Resolves: #47

Checklist:

review-notebook-app[bot] commented 1 year ago

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

tcmoore3 commented 1 year ago

pre-commit.ci autofix

joaander commented 1 year ago

@tommy-waltmann The base case of isotropic interactions is covered in the reference documentation, which is the first hit which searching for "hpmc pair" in the documentation. Let me know If you have suggestions for how to make this more findable or think there should be a quick start guide.

The main goal of this tutorial is to teach how to implement patchy particle interactions, which is a more complex and often asked for topic. The title should be: "Modelling patchy particles". While this PR includes only HPMC, we plan to add MD after #1412 is merged.

tommy-waltmann commented 1 year ago

@tommy-waltmann The base case of isotropic interactions is covered in the reference documentation, which is the first hit which searching for "hpmc pair" in the documentation. Let me know If you have suggestions for how to make this more findable or think there should be a quick start guide.

The main goal of this tutorial is to teach how to implement patchy particle interactions, which is a more complex and often asked for topic. The title should be: "Modelling patchy particles". While this PR includes only HPMC, we plan to add MD after #1412 is merged.

That all sounds good, let's move forward with Josh's title suggestion.

Charlottez112 commented 1 year ago

The base case of isotropic interactions is covered in the reference documentation, which is the first hit which searching for "hpmc pair" in the documentation. Let me know If you have suggestions for how to make this more findable or think there should be a quick start guide.

I think the title now is fine. To me the title summarizes exactly the tutorial, and personally I would appreciate a quick start guide for adding isotropic interactions

joaander commented 1 year ago

I think the title now is fine. To me the title summarizes exactly the tutorial, and personally I would appreciate a quick start guide for adding isotropic interactions

OK, feel free to open an issue and/or pull request to add e.g. an isotropic square well to the how-to guides.

Charlottez112 commented 1 year ago

I think the title now is fine. To me the title summarizes exactly the tutorial, and personally I would appreciate a quick start guide for adding isotropic interactions

OK, feel free to open an issue and/or pull request to add e.g. an isotropic square well to the how-to guides.

Just did. Unfortunately I won't be able to write this guide as I have no experience with this. I would be happy to help review it though.

joaander commented 1 year ago

I think the title now is fine. To me the title summarizes exactly the tutorial, and personally I would appreciate a quick start guide for adding isotropic interactions

OK, feel free to open an issue and/or pull request to add e.g. an isotropic square well to the how-to guides.

Just did. Unfortunately I won't be able to write this guide as I have no experience with this. I would be happy to help review it though.

Thanks. I moved the issue to the hoomd-blue repository as that is where howto guides are hosted. The howto would copy code from CPPPotential example block and add a Sphere integrator before it. To be complete, it should also create a simulation with a trivial state (not shown here):

mc = hoomd.hpmc.integrate.Sphere()
mc.shape['A'] = dict(diameter=1.0)

sq_well = '''float rsq = dot(r_ij, r_ij);
                    if (rsq < 1.21f)
                        return -1.0f;
                    else
                        return 0.0f;
            '''
patch = hoomd.hpmc.pair.user.CPPPotential(r_cut=1.1, code=sq_well,
                                          param_array=[])
mc.pair_potential = patch
sim.run(10)

Note that the 1.21f has confused many users. In the final howto, we should set r_interaction = 1.1 and then use a f-string to compute r_interaction * r_interaction in the check. The howto should also link to the patchy particle tutorial/

joaander commented 1 year ago

See https://github.com/glotzerlab/hoomd-blue/pull/1508 for the isotropic howto guide. @Charlottez112, I requested your review as requested.

tcmoore3 commented 1 year ago

pre-commit.ci autofix