Skip to content

Commit

Permalink
remove random_sequence param from copolymer class
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisjonesBSU committed Oct 25, 2023
1 parent f4bf132 commit 1357ea4
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
8 changes: 4 additions & 4 deletions flowermd/base/molecule.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,8 +506,6 @@ class CoPolymer(Molecule):
Manually define the sequence of 'A' and 'B' monomers.
Leave as None if generating random sequences.
Example: sequence = "AABAABAAB"
random_sequence : bool, default False
Creates a random 'A' 'B' sequence as a function of the AB_ratio.
AB_ratio : float, default 0.50
The relative weight of A to B monomer types.
Used when generating random sequences.
Expand All @@ -524,7 +522,6 @@ def __init__(
num_mols,
force_field=None,
sequence=None,
random_sequence=False,
AB_ratio=0.50,
seed=24,
):
Expand All @@ -535,7 +532,10 @@ def __init__(
if len(num_mols) != len(self.lengths):
raise ValueError("Number of molecules and lengths must be equal.")
self.sequence = sequence
self.random_sequence = random_sequence
if not self.sequence:
self.random_sequence = True
else:
self.random_sequence = False
self.AB_ratio = AB_ratio
self.seed = seed
self._A_count = 0
Expand Down
12 changes: 6 additions & 6 deletions flowermd/library/polymers.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,19 @@ def __init__(self, lengths, num_mols, **kwargs):
class PEKK(CoPolymer):
"""Create a Poly(ether-ketone-ketone) (PEKK) chain.
The CoPolymer class is used to create a polymer chain with two different
monomer types, represented by the para and meta isomeric forms of PEKK.
Creates a polymer chain with two different monomer types,
represented by the para (T) and meta (I) isomeric forms of PEKK.
Parameters
----------
lengths : int, required
The number of monomer repeat units in the chain.
num_mols : int, required
The number of chains to create.
random_sequence : bool, default False
Creates a random 'A' 'B' sequence as a function of the AB_ratio.
sequence : str, default None
Manually define the sequence of para (T) and meta (I) monomers.
Leave as None if generating random sequences.
Example: sequence = "TTITTITTI"
TI_ratio : float, required
The ratio of meta to para isomers in the chain.
Expand All @@ -119,7 +121,6 @@ def __init__(
num_mols,
force_field=None,
sequence=None,
random_sequence=False,
TI_ratio=0.50,
seed=24,
):
Expand All @@ -130,7 +131,6 @@ def __init__(
num_mols=num_mols,
force_field=force_field,
sequence=sequence,
random_sequence=random_sequence,
AB_ratio=TI_ratio,
seed=seed,
)
Expand Down
2 changes: 1 addition & 1 deletion flowermd/tests/base/test_molecule.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ def test_copolymer_with_sequence(self, polyethylene, polyDME):
sequence="ABA",
)
assert copolymer.n_particles == 22
assert copolymer.random_sequence is False
assert ("C", "C", "C", "C") in copolymer.topology_information[
"dihedral_types"
]
Expand Down Expand Up @@ -283,7 +284,6 @@ def test_copolymer_random_sequence(self, polyethylene, polyDME):
monomer_B=polyethylene,
lengths=[3],
num_mols=[1],
random_sequence=True,
seed=42,
)
# sequence is BAA
Expand Down
6 changes: 6 additions & 0 deletions flowermd/tests/library/test_polymers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from flowermd.library import (
PEEK,
PEKK,
PPS,
LJChain,
PEKK_meta,
Expand All @@ -27,6 +28,11 @@ def test_pekk_meta(self):
monomer = mb.load(chain.smiles, smiles=True)
assert chain.n_particles == (monomer.n_particles * 5) - 8

def test_pekk(self):
chain = PEKK(lengths=5, num_mols=1, TI_ratio=0.50)
assert chain.random_sequence is True
assert chain.AB_ratio == 0.50

def test_pekk_para(self):
chain = PEKK_para(lengths=5, num_mols=1)
monomer = mb.load(chain.smiles, smiles=True)
Expand Down

0 comments on commit 1357ea4

Please sign in to comment.