Skip to content

Adding DPD System initialization - #264

Draft
StephMcCallum wants to merge 17 commits into
cmelab:mainfrom
StephMcCallum:phantomwalk
Draft

Adding DPD System initialization#264
StephMcCallum wants to merge 17 commits into
cmelab:mainfrom
StephMcCallum:phantomwalk

Conversation

@StephMcCallum

Copy link
Copy Markdown
Contributor

Attempting to incorporate the code in PhantomWalk into flowerMD so that we can use the modular class resources. PhantomWalk is a two step packing routine, first a non-self avoiding random walk, then a dpd relaxation simulation which runs in a loop checking energy cutoffs.

As a first pass, it made the most sense to me to put the RandomWalk at the system level, and DPD simulation at the simulation level. I attempted to use the gmso ff file instead of coding the DPD_FF as a class. But, since this file is gmso and not foyer, I was running into some issues. This is where I'm stopping today. The RandomWalk placement seems to be working, but I have not verified.

In tutorials, I'm debugging the workflow in notebook 7. Focusing on getting CG linear mono-disperse systems working.

@review-notebook-app

Copy link
Copy Markdown

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

system = mb.Compound()

# Apply positions to all molecules and add to system
for idx, chain in enumerate(self.all_molecules):

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@chrisjonesBSU
This random walk is similar to yours in path class. I'm not sure if it would be better to loop that in here instead. But I think here we should be able to translate the monomer units if the flowermd molecule is all-atom

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'd suggest leaving this one as a simpler RW implementation. It will be straight forward to either make a different system class that uses a different RW approach, or just go straight from mBuild to flower.

@StephMcCallum

StephMcCallum commented Jun 23, 2026

Copy link
Copy Markdown
Contributor Author

Error from tutorial notebook 7, cell 6. When I try to pass in a gmso xml to BaseXMLForcefield, I get an invalid document error. I think that this function is expecting a Foyer xml file. I tried adding an option for loading a gmso xml, so that the filepath doesn't go to Foyer, then to gmso, but am still getting the same error. @chrisjonesBSU

---------------------------------------------------------------------------
DocumentInvalid                           Traceback (most recent call last)
Cell In[6], line 1
----> 1 system.apply_forcefield(force_field=Bead_Spring_DPD(),r_cut=1.15)

Cell In[5], line 7, in Bead_Spring_DPD.__init__(self, forcefield_files)
      6 def __init__(self, forcefield_files=f"{FF_DIR}/hoomd-dpd-hhp.xml"):
----> 7     super(Bead_Spring_DPD, self).__init__(forcefield_files=forcefield_files,gmso_xml=True)
      8     self.description = "DPD forcefield loaded from an XML file."

File ~/Desktop/cmelab/forks/flowerMD/flowermd/base/forcefield.py:12, in BaseXMLForcefield.__init__(self, forcefield_files, name, gmso_xml)
     11 def __init__(self, forcefield_files=None, name=None,gmso_xml=False):
---> 12     super(BaseXMLForcefield, self).__init__(
     13         forcefield_files=forcefield_files, name=name
     14     )
     15     if gmso_xml==True:
     16         self.gmso_ff = ForceField(forcefield_files or name)

File ~/miniconda3/envs/flowermd-dev/lib/python3.12/site-packages/foyer/forcefield.py:526, in Forcefield.__init__(self, forcefield_files, name, validation, debug)
    524 if validation:
    525     for ff_file_name in preprocessed_files:
--> 526         Validator(ff_file_name, debug)
    527 super(Forcefield, self).__init__(*preprocessed_files)
    529 if len(preprocessed_files) == 1:

File ~/miniconda3/envs/flowermd-dev/lib/python3.12/site-packages/foyer/validator.py:29, in Validator.__init__(self, ff_file_name, debug)
     26 preprocessed_ff_file_name = preprocess_forcefield_files([ff_file_name])
     28 ff_tree = etree.parse(preprocessed_ff_file_name[0])
---> 29 self.validate_xsd(ff_tree)
     31 self.atom_type_names = ff_tree.xpath("/ForceField/AtomTypes/Type/@name")
     32 self.atom_types = ff_tree.xpath("/ForceField/AtomTypes/Type")

File ~/miniconda3/envs/flowermd-dev/lib/python3.12/site-packages/foyer/validator.py:74, in Validator.validate_xsd(ff_tree, xsd_file)
     71     return ValidationError(error_text, keyword, line)
     73 try:
---> 74     xmlschema.assertValid(ff_tree)
     75 except DocumentInvalid as ex:
     76     message = ex.error_log.last_error.message

File src/lxml/etree.pyx:3813, in lxml.etree._Validator.assertValid()

DocumentInvalid: Element 'FFMetaData': This element is not expected., line 2

@StephMcCallum

Copy link
Copy Markdown
Contributor Author

The fix to BaseXMLForcefield seems to be working. However, the dpd xml is not the correct formatting. See tutorial 7 notebook for the latest error, can't match AtomType expression to accepted potentials (although equation is listed under potentials). The AtomType must have an expression

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