本文整理汇总了Python中ase.io.trajectory.PickleTrajectory.set_constraint方法的典型用法代码示例。如果您正苦于以下问题:Python PickleTrajectory.set_constraint方法的具体用法?Python PickleTrajectory.set_constraint怎么用?Python PickleTrajectory.set_constraint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ase.io.trajectory.PickleTrajectory
的用法示例。
在下文中一共展示了PickleTrajectory.set_constraint方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: runAndStudy
# 需要导入模块: from ase.io.trajectory import PickleTrajectory [as 别名]
# 或者: from ase.io.trajectory.PickleTrajectory import set_constraint [as 别名]
def runAndStudy(params_set, pot_key, save = False):
bond = params_set['bond']
T = params_set['T']
taito = params_set['taito']
dt, fric= params_set['dt'], params_set['fric']
tau = params_set['tau']
width = params_set['width']
ratio = params_set['ratio']
edge = params_set['edge']
ncores = params_set['ncores']
Ld_i = params_set['Ldilde_i']
bend, straight, [matchL_idx, matchR_idx, vec], [L_bend, L_straight], [left_idxs, right_idxs]\
= create_bend_stucture(width, ratio, Ld_i, edge, bond)
mdfile, mdlogfile, mdrelax, simulfile, folder, relaxed \
= get_fileName(pot_key, edge + '_corrStick', width, \
L_bend, L_straight, int(T), taito, key = 'corrStick')
if relaxed:
bend = PickleTrajectory(mdrelax, 'r')[-1]
else:
relaxBend(bend, left_idxs, right_idxs, edge, bond, mdrelax)
bend.set_constraint([])
shift_v = -straight.positions[matchR_idx] + (bend.positions[matchL_idx] + vec)
straight.translate(shift_v)
atoms = bend + straight
cell = [1.5*(L_bend + L_straight), L_bend + L_straight, 20]
atoms.set_cell(cell)
atoms.positions[:,2] = 3.4
trans_vec = trans_atomsKC(straight.positions[matchR_idx], edge, bond)
atoms.translate(trans_vec)
#plot_posits(atoms, edge, bond)
if edge == 'ac':
nx = int((cell[0]/5 - np.min(atoms.positions[:,0]))/(3*bond))
ny = int((cell[1]/5 - np.min(atoms.positions[:,1]))/(np.sqrt(3)*bond))
atoms.translate([nx*3.*bond, ny*np.sqrt(3)*bond, 0])
width_f = np.sqrt(3)/2.*bond*(width - 1)
elif edge == 'zz':
nx = int((cell[0]/5 - np.min(atoms.positions[:,0]))/(np.sqrt(3)*bond))
ny = int((cell[1]/5 - np.min(atoms.positions[:,1]))/(3*bond))
atoms.translate([nx*np.sqrt(3)*bond, ny*3*bond, 0])
width_f = (3./2.*width - 1)*bond
cminx, cmaxx = strip_Hend(atoms, 'right')
left_b = get_idxOfEnds(atoms, cminx, cmaxx)[0]
# CONSTRAINTS
constraints = []
constraints.append(FixAtoms(indices = left_b))
params = {}
params['positions'] = atoms.positions
params['chemical_symbols'] = atoms.get_chemical_symbols()
params['ia_dist'] = 10
params['edge'] = edge
params['bond'] = bond
params['ncores'] = ncores
add_pot = KC_potential_p(params)
constraints.append(add_pot)
atoms.set_constraint(constraints)
##
# CALCULATOR
calc = LAMMPS(parameters=get_lammps_params())
atoms.set_calculator(calc)
##
# DYNAMICS
dyn = Langevin(atoms, dt*units.fs, T*units.kB, fric)
header = '#t [fs], shift y [Angstrom], Rad, theta [rad], hmax [A], epot_tot [eV], ekin_tot [eV], etot_tot [eV], F [eV/angst] \n'
write_line_own(mdlogfile, header, 'w')
traj = PickleTrajectory(mdfile, 'w', atoms)
if T != 0:
# put initial MaxwellBoltzmann velocity distribution
mbd(atoms, T*units.kB)
####
# SIMULATION PARAMS
nframes = 1000
M = int(20*tau/dt)
interval = int(M/nframes)
thres_cancel= 2*bond
stick = 'True'
xmax_idx = np.where(atoms.positions[:,0] == np.max(atoms.positions[:,0]))[0][0]
r_init = atoms.positions[xmax_idx].copy()
R = L_bend/np.pi*3.
print '# data_line: width, length bend, length tail, tail/bend, theta'
print width_f, L_bend, L_straight, L_straight/L_bend, width_f/(2*R)
# SIMULATION LOOP
for i in range(nframes):
#.........这里部分代码省略.........
示例2: shearDyn
# 需要导入模块: from ase.io.trajectory import PickleTrajectory [as 别名]
# 或者: from ase.io.trajectory.PickleTrajectory import set_constraint [as 别名]
def shearDyn(params_set, pot_key, save = False):
bond = params_set['bond']
T = params_set['T']
taito = params_set['taito']
dt, fric= params_set['dt'], params_set['fric']
tau = params_set['tau']
vmax = params_set['vmax']
vMAX = params_set['vMAX']
thres_Z = params_set['thresZ']
width = params_set['width']
ratio = params_set['ratio']
edge = params_set['edge']
atoms, L, W, length_int, b_idxs = \
create_stucture(ratio, width, edge, key = 'top', a = bond)
mdfile, mdlogfile, mdrelax, simulfile, folder, relaxed \
= get_fileName(pot_key, edge + '_twistRod', width, \
length_int, vmax * 1000, int(T), taito)
#view(atoms)
# FIXES
constraints, add_pot, twist, rend_b, rend_t = \
get_constraints(atoms, edge, bond, b_idxs, \
key = 'twist_p', pot = pot_key)
# END FIXES
if relaxed:
atoms = PickleTrajectory(mdrelax, 'r')[-1]
else:
trans = trans_atomsKC(atoms.positions[rend_b], edge, bond)
atoms.translate(trans)
#plot_posits(atoms, edge, bond)
# CALCULATOR LAMMPS
calc = LAMMPS(parameters=get_lammps_params())
atoms.set_calculator(calc)
# END CALCULATOR
# TRAJECTORY
if save: traj = PickleTrajectory(mdfile, 'w', atoms)
else: traj = None
#data = np.zeros((M/interval, 5))
# RELAX
atoms.set_constraint(add_pot)
dyn = BFGS(atoms, trajectory = mdrelax)
dyn.run(fmax=0.05)
dist = np.linalg.norm(atoms.positions[rend_b] - atoms.positions[rend_t])
twist.set_dist(dist)
# FIX AFTER RELAXATION
atoms.set_constraint(constraints)
# DYNAMICS
dyn = Langevin(atoms, dt*units.fs, T*units.kB, fric)
header = '#t [fs], shift y [Angstrom], Rad, theta [rad], hmax [A], epot_tot [eV], ekin_tot [eV], etot_tot [eV], F [eV/angst] \n'
write_line_own(mdlogfile, header, 'w')
if T != 0:
# put initial MaxwellBoltzmann velocity distribution
mbd(atoms, T*units.kB)
y0 = atoms.positions[rend_b, 1]
kink_formed = False
kink_vanished = False
i = 0
print 'width = %i, length = %i, v=%.6f' %(width, length_int, vmax)
M_therm = int(tau / dt)
dyn.run(M_therm)
M = int(2 * L / (np.pi * dt * vmax))
M_min = int(2 * L / (np.pi * dt * vMAX))
dtheta = np.pi / 2 / M
dtheta_max = np.pi / 2 / M_min
interval = int( M / 1000 )
theta, time, m = 0., 0., 0
i_kink = 0
while 0. <= theta:
if not kink_formed:
if theta < np.pi/4:
theta += dtheta_max
else:
theta += dtheta
twist.set_angle(theta)
else:
if i_kink / 10 < m:
#.........这里部分代码省略.........