I have not been able to fix an issue associated with saving a lammps file using the .save function.
My code for constructing united-atom type alkane molecules, and the forcefield .xml file are attached below. While everything worked fine for ethane (ie. chain_length=1) and lammps file was successfully created, it stopped working when chain_length=2. Visualization of propane looked fine, inspection using test_propane.labels also seems to look fine.
Have I overlooked something here?
Thank you,
JY
import mbuild as mb
import warnings
warnings.filterwarnings('ignore')
class CH3(mb.Compound):
def __init__(self):
super(CH3, self).__init__()
self.add(mb.Particle(name='_CH3', pos=[0,0,0]), label='CH3')
self.add(mb.Port(anchor=self['CH3'][0]), label='up')
self['up'].translate([0.154/2, 0, 0])
class CH2(mb.Compound):
def __init__(self):
super(CH2, self).__init__()
self.add(mb.Particle(name='_CH2', pos=[0,0,0]), label='CH2')
self.add(mb.Port(anchor=self['CH2'][0]), label='up')
self.add(mb.Port(anchor=self['CH2'][0]), label='down')
self['up'].translate([0.154/2, 0, 0])
self['down'].translate([-0.154/2, 0, 0])
class Alkane(mb.Compound):
def __init__(self, chain_length=1):
super(Alkane, self).__init__()
last_monomer = CH3()
self.add(last_monomer)
# loop over n = chain_length CH2's to add to Alkane
for _ in range(chain_length-1):
current_monomer = CH2()
mb.force_overlap(move_this=current_monomer,
from_positions=current_monomer['down'],
to_positions=last_monomer['up'])
self.add(current_monomer)
last_monomer=current_monomer
last_cap = CH3()
mb.force_overlap(move_this=last_cap,
from_positions=last_cap['up'],
to_positions=last_monomer['up'])
self.add(last_cap)
Hello,
I have not been able to fix an issue associated with saving a lammps file using the
.save
function.My code for constructing united-atom type alkane molecules, and the forcefield
.xml
file are attached below. While everything worked fine for ethane (ie.chain_length=1
) and lammps file was successfully created, it stopped working whenchain_length=2
. Visualization of propane looked fine, inspection usingtest_propane.labels
also seems to look fine.Have I overlooked something here?
Thank you, JY
Ethane (works fine):
Propane:
Error:
Force field
.xml
file: