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

Add more descriptions to tutorials, update links to base code #95

Merged
merged 7 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,8 @@ interested in contributing code, please follow the steps below:

New functionalities should be covered by unit tests. If you are adding a new
function/feature/class please follow the existing style for docstrings.

## Questions and comments

Please feel free to create an issue if you have any questions or comments about
flowerMD.
4 changes: 2 additions & 2 deletions tutorials/1-flowerMD-basics.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@
"Now that the molecules are packed in the box, we can apply the forcefield and parameterize particle interactions.\n",
"We use the pre-defined `OPLS` forcefield class, which was created from the [OPLS](https://en.wikipedia.org/wiki/OPLS) XML forcefield, to parameterize particle interactions.\n",
"\n",
"The flowerMD library offers some commonly used forcefields that can be employed to parameterize the interactions within specific systems. Please refer to `flowermd.library.forcefields` for more examples.\n"
"The flowerMD library offers some commonly used forcefields that can be employed to parameterize the interactions within specific systems. Please refer to [flowerMD's documentation](https://flowermd.readthedocs.io/en/latest/forcefields.html) for more examples.\n"
]
},
{
Expand Down Expand Up @@ -530,7 +530,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"The simulation class also allows users to run the simulation under different conditions/ensembles such as NPT ensemble, NVE ensemble and Langevin dynamics. Check out `flowermd/base/simulation.py` for more functionalities."
"The simulation class also allows users to run the simulation under different conditions/ensembles such as NPT ensemble, NVE ensemble and Langevin dynamics. Check out [flowerMD's documentation](https://flowermd.readthedocs.io/en/latest/simulation.html) for more functionalities."
]
},
{
Expand Down
76 changes: 47 additions & 29 deletions tutorials/2-flowerMD-advanced.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,9 @@
}
},
"source": [
"Checkout some polymer examples defined in `flowermd/library/polymers.py`."
"Users can extend the molecule class functionalities by creating subclasses of the `Molecule` base class. This can be achieved by overriding the `_generate` method, which is responsible for generating all the molecules in form of [mbuild compounds](https://mbuild.mosdef.org/en/stable/topic_guides/data_structures.html#compound) and appending them to the `self._molecules` list.\n",
"\n",
"flowerMD implements two subclasses of the `Molecule` class: `Polymer` and `CoPolymer`. Please see [flowerMD's Molecule documentation](https://flowermd.readthedocs.io/en/latest/molecule.html) for more details."
]
},
{
Expand All @@ -241,9 +243,9 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"flowerMD offers a range of predefined forcefield classes that can be used to parameterize a system. Checkout [`flowermd/library/forcefields.py`](https://github.com/cmelab/flowerMD/blob/main/flowermd/library/forcefields.py) to see the list of available forcefields.\n",
"flowerMD offers a range of predefined forcefield classes that can be used to parameterize a system. Checkout [flowerMD's library documentation](https://flowermd.readthedocs.io/en/latest/forcefields.html) to see the list of available forcefields.\n",
"\n",
"To create a custom forcefield object, you can follow these two approaches:"
"Users can also define their own custom forcefields with the following two options:"
]
},
{
Expand All @@ -254,7 +256,7 @@
}
},
"source": [
"### Custom ForceFields (XML-based)"
"### Option 1: XML-based custom forcefields"
]
},
{
Expand All @@ -265,7 +267,9 @@
}
},
"source": [
"Given the path to the XML file of a desired forcefield, users can employ the `FF_from_file` class available in `flowermd.library` to instantiate a forcefield object."
"Given the path to the XML file of a desired forcefield, users can employ the `FF_from_file` class available in `flowermd.library` to instantiate a forcefield object.\n",
"\n",
"*Note*: The XML file should be in the format of [foyer](https://foyer.mosdef.org/en/stable/getting_started/quickstart.html) forcefield files."
]
},
{
Expand All @@ -283,6 +287,15 @@
"benzene_ff = FF_from_file(forcefield_files=\"../flowermd/assets/forcefields/benzene_opls.xml\")"
]
},
{
"cell_type": "markdown",
"source": [
"### Option 2: HOOMD Forces custom forcefields\n"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "markdown",
"metadata": {
Expand All @@ -291,27 +304,40 @@
}
},
"source": [
"Check out [`flowermd/library/forcefields.py`](https://github.com/cmelab/flowerMD/blob/main/flowermd/library/forcefields.py) for more some examples of defining a forcefield using a subclass of `foyer.Forcefield` for specific molecules."
"Users have the flexibility to directly define their own list of HOOMD force objects tailored to specific simulation requirements rather than initiating it from an XML based forcefield. In such cases, users can specify the forces by creating a subclass of the `flowermd.base.BaseHOOMDForcefield` class. This can be achieved by developing `_create_forcefield` method, which is responsible for generating a list of `hoomd.md.force` objects. Below is an example of defining `BreadSpring` custom class that creates HOOMD force objects for a system of coarse-grained beads given the parameters for bonded and non-bonded interactions.\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"cell_type": "code",
"execution_count": null,
"outputs": [],
"source": [
"### HOOMD Forces"
]
"from flowermd.base import BaseHOOMDForcefield\n",
"class BeadSpring(BaseHOOMDForcefield):\n",
" def __init__(self, r_cut, beads, bonds=None, angles=None, dihedrals=None,exclusions=[\"bond\", \"1-3\"]):\n",
" # ...\n",
" hoomd_forces = self._create_forcefield()\n",
" super(BeadSpring, self).__init__(hoomd_forces)\n",
"\n",
" def _create_forcefield(self):\n",
" hoomd_forces = []\n",
" # generate hoomd forces for pair interactions, bonds, angles, dihedrals, etc.\n",
" # ...\n",
" return hoomd_forces\n",
"\n"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "markdown",
"metadata": {
"jupyter": {
"outputs_hidden": false
}
},
"source": [
"Alternatively, users have the flexibility to define their own custom class that handles forces. This can be achieved by implementing a class or method that generates a list of `hoomd.md.force` objects, tailored to specific simulation requirements.\n",
"Check out the `BeadSpring` class in [`flowermd/library/forcefields.py`](https://github.com/cmelab/flowerMD/blob/main/flowermd/library/forcefields.py) for an example of defining HOOMD force objects for a system of coarse-grained beads."
]
"Please also see [flowerMD's Forcefield documentation](https://flowermd.readthedocs.io/en/latest/forcefields.html) for more examples.\n"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "markdown",
Expand Down Expand Up @@ -386,11 +412,10 @@
}
},
"source": [
"Note: Both `Pack` and `Lattice` classes are subclasses of the `System` class. The base `System` class is designed as an abstract class, meaning it's not intended to be directly instantiated.\n",
"\n",
"If you desire to customize a molecule assembly algorithm that suits your specific requirements, you should create a subclass of the `System` class and override the abstract method `_build_system`. This method is responsible for organizing molecules from the `Molecule` class into a simulation box and returning the resulting mbuild compound. \n",
"Note: Both `Pack` and `Lattice` classes are subclasses of the `System` class. The base `System` class is designed as an abstract class, meaning it's not intended to be directly instantiated. Check out `Pack` and `Lattice` [documentation](https://flowermd.readthedocs.io/en/latest/system.html) for more details .\n",
"\n",
"Check out `Pack` and `Lattice` in `flowermd/base/systems.py` for examples of how to define custom assembly algorithms."
"If you desire to customize a molecule assembly algorithm that suits your specific requirements, you should create a subclass of the `System` class and override the abstract method `_build_system`. This method is responsible for organizing molecules from the `Molecule` class into a simulation box and returning the resulting mbuild compound.\n",
"\n"
]
},
{
Expand Down Expand Up @@ -460,13 +485,6 @@
"As mentioned in the previous tutorial, when the `auto_scale` parameter is set to `True` during system building, the parameters of the forcefields will be scaled automatically to range between 0 to 1. The scaling factor for these conversions can be retrieved from `system.reference_values`, which includes scaling factors for energy, length and mass values."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"TODO: (need to talk about units and how to set units)"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down