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

draft: add a hydrogel builder #103

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

1234somesh
Copy link
Contributor

adding hydrogel feature

pyMBE.py - not sure why it was left out

adding hydrogel feature

pyMBE.py - not sure why it was left out
@pm-blanco pm-blanco added the enhancement New feature or request label Nov 18, 2024
@pm-blanco pm-blanco changed the title hydrogel feature in pyMBE.py draft: hydrogel feature in pyMBE.py Nov 18, 2024
@pm-blanco pm-blanco changed the title draft: hydrogel feature in pyMBE.py draft: add a hydrogel builder Nov 18, 2024
Copy link
Collaborator

@pm-blanco pm-blanco left a comment

Choose a reason for hiding this comment

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

In general, I really like the shape this feature is taking. Currently, it is restricted to only diamond lattice topologies. However, this implementation already allows to build many interesting systems, so I think that we can keep it like this for this PR and work to generalize in further steps. I have several minor comments in specific lines and some other more conceptual ones that we can discuss during our dev meeting. Thank you for your work @1234somesh!

@@ -20,17 +19,16 @@
import itertools
import numpy as np

#pmb = pyMBE.pymbe_library(seed=42)
Copy link
Collaborator

Choose a reason for hiding this comment

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

please remember to clean-up these comments before merging it!

@@ -46,6 +44,8 @@ class LatticeBuilder:
function to draw the simulation box.
"""

# Remove pmb when integrated to main pyMBE.py file
Copy link
Collaborator

Choose a reason for hiding this comment

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

please remember to clean-up these comments before merging it!

diamond_lattice = DiamondLattice(MPC,generic_bond_length)
espresso_system = espressomd.System(box_l = [diamond_lattice.BOXL]*3)
pmb.add_bonds_to_espresso(espresso_system = espresso_system)
lattice_builder = pmb.initialize_lattice_builder(diamond_lattice) # Dont need pmb when integrated to pyMBE.py
Copy link
Collaborator

Choose a reason for hiding this comment

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

please remember to clean-up these comments before merging it!

if not isinstance(diamond_lattice, DiamondLattice):
raise TypeError("Currently only DiamondLattice objects are supported.")
self.lattice_builder = LatticeBuilder(lattice=diamond_lattice)
print(f"LatticeBuilder initialized with MPC={diamond_lattice.MPC} and BOXL={diamond_lattice.BOXL}")
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should add an optional bool verbose argument to control when to print to screen. For example for unit testing we do not want to overflow the output screen with unnecessary prints. The verbose statement could default to True so beginners would get the print to screen and make the software more user friendly.

Comment on lines +76 to +77
del chain_topology[0]
print(chain_topology)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think these lines were added for testing but please remember to remove them or otherwise the sample script breaks!

print(chain_topology)
pmb.define_hydrogel("my_hydrogel",node_topology, chain_topology)
node_positions = pmb.create_hydrogel("my_hydrogel", espresso_system)

Copy link
Collaborator

Choose a reason for hiding this comment

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

There seems to be an issue with the new entries in the pyMBE dataframe related with the hydrogel when reading the pyMBE dataframe. If I modify this code with the following lines, it breaks:

#Save the pyMBE dataframe in a CSV file
pmb.write_pmb_df (filename='df.csv')
#Load the pyMBE dataframe in a CSV file
pmb.read_pmb_df(filename="df.csv")
node_positions = pmb.create_hydrogel("my_hydrogel", espresso_system)
``

name(`str`): Label of the hydrogel to be created. `name` must be defined in the `pmb.df`
espresso_system(`espressomd.system.System`): Instance of a system object from the espressomd library.

Returns:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please document the dictionary that is returned.

del chain_topology[0]
print(chain_topology)
pmb.define_hydrogel("my_hydrogel",node_topology, chain_topology)
node_positions = pmb.create_hydrogel("my_hydrogel", espresso_system)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since the dictionary returned pmb.create_hydrogel actually has more information than only the position of the nodes. What about renaming the variable node_positions to hydrogel_info?

@@ -0,0 +1,331 @@
import numpy as np
Copy link
Collaborator

Choose a reason for hiding this comment

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

You need to add this test to testsuite/CTestTestfile.cmake for the CI to run it:

## In CTestTestfile.cmake
# unit tests
pymbe_add_test(PATH hydrogel_builder.py)

You can also check if your test is covering all lines of code, check our wiki


"""
if not self.check_if_name_is_defined_in_df(name=name, pmb_type_to_be_defined='hydrogel'):
raise ValueError(f"Hydrogel with name '{name}' is not defined in the DataFrame.")
Copy link
Collaborator

Choose a reason for hiding this comment

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

This line seems not to be covered by the CI test.

@pm-blanco pm-blanco added this to the pyMBE 1.0.0 milestone Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants