Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
write_reaction_system: bool
whether or not to write reaction_system table
"""
self.stdout.write('Starting transfer\n')
con = self.connection or self._connect()
self._initialize(con)
self.stdout.write('Finished initialization\n')
cur = con.cursor()
self.stdout.write('Got a cursor\n')
self.stdout.write('Connecting to {0}\n'.format(self.server_name))
nrows = 0
if write_ase:
self.stdout.write('Transfering atomic structures\n')
db = ase.db.connect(filename_sqlite)
n_structures = db.count()
n_blocks = n_structures // block_size + 1
t_av = 0
for block_id in range(start_block, n_blocks):
i = block_id - start_block
t1 = time.time()
b0 = block_id * block_size
b1 = (block_id + 1) * block_size + 1
if block_id + 1 == n_blocks:
b1 = n_structures + 1
rows = list(db.select('{}
def __init__(self, gui):
self.win = win = ui.Window(_('Movie'), self.close)
win.add(_('Image number:'))
self.frame_number = ui.Scale(gui.frame + 1, 1,
len(gui.images),
callback=self.new_frame)
win.add(self.frame_number)
win.add([ui.Button(_('First'), self.click, -1, True),
ui.Button(_('Back'), self.click, -1),
ui.Button(_('Forward'), self.click, 1),
ui.Button(_('Last'), self.click, 1, True)])
play = ui.Button(_('Play'), self.play)
stop = ui.Button(_('Stop'), self.stop)
# TRANSLATORS: This function plays an animation forwards and backwards
# alternatingly, e.g. for displaying vibrational movement
self.rock = ui.CheckButton(_('Rock'))
win.add([play, stop, self.rock])
if len(gui.images) > 150:
skipdefault = len(gui.images) // 150
tdefault = min(max(len(gui.images) / (skipdefault * 5.0),
def test_chemisorption(self):
"""Test the adsorption where there is sufficient distance between the
adsorbate and the surface to distinguish between them even if they
share the same elements.
"""
with open("./structures/mat2d_adsorbate_unknown.json", "r") as fin:
data = json.load(fin)
system = Atoms(
scaled_positions=data["positions"],
cell=1e10*np.array(data["normalizedCell"]),
symbols=data["labels"],
pbc=True,
)
# view(system)
classifier = Classifier()
classification = classifier.classify(system)
self.assertIsInstance(classification, Material2D)
# No defects or unknown atoms, one adsorbate cluster
adsorbates = classification.adsorbates
interstitials = classification.interstitials
substitutions = classification.substitutions
vacancies = classification.vacancies
def test_fcc(self):
"""Test that a primitive NaCl fcc lattice is characterized correctly.
"""
# Create the system
cell = np.array(
[
[0, 2.8201, 2.8201],
[2.8201, 0, 2.8201],
[2.8201, 2.8201, 0]
]
)
cell[0, :] *= 1.05
nacl = Atoms(
symbols=["Na", "Cl"],
scaled_positions=np.array([
[0, 0, 0],
[0.5, 0.5, 0.5]
]),
cell=cell,
)
# Get the data
data = self.get_material3d_properties(nacl)
# Check that the data is valid
self.assertEqual(data.space_group_number, 225)
self.assertEqual(data.space_group_int, "Fm-3m")
self.assertEqual(data.hall_symbol, "-F 4 2 3")
self.assertEqual(data.hall_number, 523)
def test_out_of_cell_small_cell(self):
a = ase.Atoms('CC', positions=[[0.5, 0.5, 0.5],
[1.1, 0.5, 0.5]],
cell=[1, 1, 1], pbc=False)
i1, j1, r1 = neighbour_list("ijd", a, 1.1)
a.set_cell([2, 1, 1])
i2, j2, r2 = neighbour_list("ijd", a, 1.1)
self.assertArrayAlmostEqual(i1, i2)
self.assertArrayAlmostEqual(j1, j2)
self.assertArrayAlmostEqual(r1, r2)
def test_out_of_cell_large_cell(self):
a = ase.Atoms('CC', positions=[[9.5, 0.5, 0.5],
[10.1, 0.5, 0.5]],
cell=[10, 10, 10], pbc=False)
i1, j1, r1 = neighbour_list("ijd", a, 1.1)
a.set_cell([20, 10, 10])
i2, j2, r2 = neighbour_list("ijd", a, 1.1)
self.assertArrayAlmostEqual(i1, i2)
self.assertArrayAlmostEqual(j1, j2)
self.assertArrayAlmostEqual(r1, r2)
def test_c2d_input_format_npz_output_format_xyz(self):
"""c2d NaCl.npz NaCl.xyz"""
print(" RUN test_c2d_input_format_npz_output_format_xyz")
with tempfile.TemporaryDirectory() as tmpdir:
subprocess.run(
[ 'c2d', os.path.join(self.data_path,'NaCl.npz'), 'NaCl.xyz' ],
check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
cwd=tmpdir, env=self.myenv)
xyz = ase.io.read(os.path.join(tmpdir,'NaCl.xyz'))
self.assertEqual(len(xyz),len(self.ref_xyz))
self.assertTrue( ( xyz.symbols == self.ref_xyz.symbols ).all() )
self.assertTrue( ( xyz.get_initial_charges() ==
self.ref_xyz.get_initial_charges() ).all() )
self.assertTrue( ( xyz.cell == self.ref_xyz.cell ).all() )
def test_shrink_wrapped_direct_call(self):
a = io.read('aC.cfg')
r = a.positions
j, dr, i, abs_dr, shift = neighbour_list("jDidS", positions=r,
cutoff=1.85)
self.assertTrue((np.bincount(i) == np.bincount(j)).all())
dr_direct = r[j]-r[i]
abs_dr_from_dr = np.sqrt(np.sum(dr*dr, axis=1))
abs_dr_direct = np.sqrt(np.sum(dr_direct*dr_direct, axis=1))
self.assertTrue(np.all(np.abs(abs_dr-abs_dr_from_dr) < 1e-12))
self.assertTrue(np.all(np.abs(abs_dr-abs_dr_direct) < 1e-12))
self.assertTrue(np.all(np.abs(dr-dr_direct) < 1e-12))
calc = LennardJones()
indiv.set_calculator(calc)
indiv.set_pbc=False
dyn=BFGS(indiv)
try:
dyn.run(fmax=0.01, steps=1000)
aseenergy = indiv.get_potential_energy()
asepress = indiv.get_isotropic_pressure(indiv.get_stress())
except:
aseenergy = 10000
asepress = 10000
indiv.set_pbc=True
#poscaratoms.set_cell([4.275, 4.275, 4.275])
ase.io.write("CONTCAR",indiv, "vasp", direct=True, sort=True, vasp5=True)
fake_osz = open("OSZICAR","wb")
fake_osz.write("Output randomly generated at %s\n" % timestamp)
#fake_osz.write("E0=% 3.8f d E =0.00\n" % randenergy)
fake_osz.write("E0=% 3.8f d E =0.00\n" % aseenergy)
fake_osz.close()
fake_outcar = open("OUTCAR","wb")
fake_outcar.write("Output randomly generated at %s\n" % timestamp)
#fake_outcar.write("external pressure = %3.8f kB Pullay stress = 0.00 kB\n" % randpress)
fake_outcar.write("external pressure = %3.8f kB Pullay stress = 0.00 kB\n" % asepress)
fake_outcar.write("Pretend we have...reached required accuracy\n")
fake_outcar.write("User time (sec): %3.8f" % randtime)
fake_outcar.close()
def test_apply_strain(self):
calc = TersoffScr(**Tersoff_PRB_39_5566_Si_C__Scr)
timestep = 1.0*units.fs
atoms = ase.io.read('cryst_rot_mod.xyz')
atoms.set_calculator(calc)
# constraints
top = atoms.positions[:, 1].max()
bottom = atoms.positions[:, 1].min()
fixed_mask = ((abs(atoms.positions[:, 1] - top) < 1.0) |
(abs(atoms.positions[:, 1] - bottom) < 1.0))
fix_atoms = FixAtoms(mask=fixed_mask)
# strain
orig_height = (atoms.positions[:, 1].max() - atoms.positions[:, 1].min())
delta_strain = timestep*1e-5*(1/units.fs)
rigid_constraints = False
strain_atoms = ConstantStrainRate(orig_height, delta_strain)