def __init__(self, box=[1, 1, 1]): super(Epoxy_A_10_B_20_C10_2_Blend, self).__init__() if len(box) is not 3: raise ValueError('box shape should be 3. You passed in {}'.format( len(box))) num_a = 10 num_b = 20 num_c10 = 2 for index in range(0, num_a): self.add(A(), label='A[$]') x = random.uniform(-box[0] / 2, box[0] / 2) y = random.uniform(-box[1] / 2, box[1] / 2) z = random.uniform(-box[2] / 2, box[2] / 2) mb.translate(self['A'][-1], [x, y, z]) for index in range(0, num_b): self.add(B(), label='B[$]') x = random.uniform(-box[0] / 2, box[0] / 2) y = random.uniform(-box[1] / 2, box[1] / 2) z = random.uniform(-box[2] / 2, box[2] / 2) mb.translate(self['B'][-1], [x, y, z]) for index in range(0, num_c10): self.add(C10(), label='C10[$]') x = random.uniform(-box[0] / 2, box[0] / 2) y = random.uniform(-box[1] / 2, box[1] / 2) z = random.uniform(-box[2] / 2, box[2] / 2) mb.translate(self['C10'][-1], [x, y, z])
def set_initial_structure(self): print('========INITIAIZING FOR DPD FENE==========') desired_box_volume = ((A.mass * self.num_a) + (B.mass * self.num_b) + (C10.mass * self.num_c10)) / self.density desired_box_dim = (desired_box_volume**(1. / 3.)) self.box = [desired_box_dim, desired_box_dim, desired_box_dim] if self.old_init == True: print("\n\n ===USING OLD INIT=== \n\n") As = my_init.Bead(btype="A", mass=A.mass) Bs = my_init.Bead(btype="B", mass=B.mass) C10s = my_init.PolyBead(btype="C", mass=1.0, N=10) # Hardcode C10, with mon-mass 1.0 snap = my_init.init_system( { As: int(self.num_a), Bs: int(self.num_b), C10s: int(self.num_c10) }, self.density / 10) self.system = hoomd.init.read_snapshot(snap) else: if self.shrink is True: print('Packing {} A particles ..'.format(self.num_a)) mix_box = mb.packing.fill_box(A(), self.num_a, box=self.box) #,overlap=0.5) mix_box = mb.packing.solvate(mix_box, B(), self.num_b, box=self.box) #,overlap=0.5) print('Packing {} B particles ..'.format(self.num_b)) mix_box = mb.packing.solvate(mix_box, C10(), self.num_c10, box=self.box) #,overlap=0.5) print('Packing {} C10 particles ..'.format(self.num_c10)) else: blend = Epoxy_A_10_B_20_C10_2_Blend() mix_box = mb.packing.fill_box(blend, self.n_mul, box=self.box, overlap=0.050) if self.init_file_name.endswith('.hoomdxml'): mix_box.save(self.init_file_name) elif self.init_file_name.endswith('.gsd'): mix_box.save(self.init_file_name, write_ff=False) if self.init_file_name.endswith('.hoomdxml'): self.system = hoomd.deprecated.init.read_xml( self.init_file_name) elif self.init_file_name.endswith('.gsd'): self.system = hoomd.init.read_gsd(self.init_file_name) print('Initial box dimension: {}'.format( self.system.box.dimensions)) snapshot = self.system.take_snapshot(bonds=True) for p_id in range(snapshot.particles.N): p_types = snapshot.particles.types p_type = p_types[snapshot.particles.typeid[p_id]] if p_type == 'A': snapshot.particles.mass[p_id] = A.mass if p_type == 'B': snapshot.particles.mass[p_id] = B.mass if p_type == 'C': snapshot.particles.mass[p_id] = C.mass print(snapshot.bonds.types) snapshot.bonds.types = ['C-C', 'A-B'] self.system.restore_snapshot(snapshot) if self.shrink is True: self.nl = self.get_non_bonded_neighbourlist() self.setup_force_fields(stage=cmn.Stages.MIXING) size_variant = variant.linear_interp([(0, self.system.box.Lx), (self.shrink_time, desired_box_dim)]) md.integrate.mode_standard(dt=self.mix_dt) md.integrate.langevin(group=hoomd.group.all(), kT=self.shrinkT, seed=1223445) #self.seed) resize = hoomd.update.box_resize(L=size_variant) hoomd.run(self.shrink_time) snapshot = self.system.take_snapshot() print('Initial box dimension: {}'.format(snapshot.box)) if self.init_file_name.endswith('.hoomdxml'): deprecated.dump.xml(group=hoomd.group.all(), filename=self.init_file_name, all=True) elif self.init_file_name.endswith('.gsd'): hoomd.dump.gsd(group=hoomd.group.all(), filename=self.init_file_name, overwrite=True, period=None)
def c10_new_position(self): from epoxpy.lib import C10 return C10(c1_pos=[10, 0, 0], rotate_random=False)
def c10(self): from epoxpy.lib import C10 return C10(rotate_random=False)