How to use the ase.io.write function in ase

To help you get started, we’ve selected a few ase examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github uw-cmg / MAST / test / gatest / fake_vasp.py View on Github external
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()
github rosswhitfield / ase / doc / ase / io / iopng.py View on Github external
# creates: io1.png io2.png io3.png

from ase import Atoms
from ase.build import fcc111, add_adsorbate
from ase.io import write, read

adsorbate = Atoms('CO')
adsorbate[1].z = 1.1
a = 3.61
slab = fcc111('Cu', (2, 2, 3), a=a, vacuum=7.0)
add_adsorbate(slab, adsorbate, 1.8, 'ontop')

write('io1.png', slab * (3, 3, 1), rotation='10z,-80x')
write('io2.pov', slab * (3, 3, 1), rotation='10z,-80x',
      transparent=False, run_povray=True)
d = a / 2**0.5
write('io3.pov', slab * (2, 2, 1),
      bbox=(d, 0, 3 * d, d * 3**0.5),
      transparent=False, run_povray=True)

write('slab.xyz', slab)
a = read('slab.xyz')
a.get_cell()
a.get_pbc()
write('slab.traj', slab)
b = read('slab.traj')
b.get_cell()
b.get_pbc()
github SUNCAT-Center / CatalysisHubBackend / apps / catKitDemo / __init__.py View on Github external
if return_data:
                    calculation_data.setdefault(
                        dft_params['calculator'],
                        {}) .setdefault(
                        dft_params['functional'],
                        {}) .setdefault(
                        'gas',
                        {}) .setdefault(
                        '{molecule_name}_gas'.format(
                            **locals()),
                        molecule)
                else:
                    with StringIO.StringIO() as mem_file:
                        #  Castep file writer needs name
                        mem_file.name = 'Catalysis-Hub.Org Structure'
                        ase.io.write(mem_file, molecule, format=SUFFIX)
                        zf.writestr(molecule_path, mem_file.getvalue())

        data.append(calculation_data)

    if return_data:
        return data

    zf.close()
    zip_mem_file.seek(0)
    return flask.send_file(
        zip_mem_file,
        attachment_filename="{calcstr}.zip".format(**locals()),
        as_attachment=True,
        mimetype='application/x-zip-compressed',
    )
github rosswhitfield / ase / ase / calculators / turbomole.py View on Github external
a = read('coord').get_positions()
                if np.allclose(a, atoms.get_positions(), rtol=0, atol=1e-13):
                    return
            else:
                return

        changes = self.check_state(atoms, tol=1e-2)
        if 'positions' in changes:
            # print(two atoms obj are different')
            self.reset()
        else:
            # print('two atoms obj are slightly different')
            if self.parameters['use redundant internals']:
                self.reset()

        write('coord', atoms)
        self.atoms = atoms.copy()
        self.update_energy = True
        self.update_forces = True
        self.update_geometry = True
        self.update_hessian = True
github rosswhitfield / ase / ase / calculators / demon / demon.py View on Github external
if not len(auxis) == 0:
                self._write_basis(f, atoms, auxis, string='AUXIS')

            augment = self.parameters['augment']
            if not len(augment) == 0:
                self._write_basis(f, atoms, augment, string='AUGMENT')

            # write geometry
            self._write_atomic_coordinates(f, atoms)

            # write pickle of Parameters
            pickle.dump(self.parameters,
                        open(self.label + '/deMon_parameters.pckl', 'wb'))

            # write xyz file for good measure.
            ase.io.write(self.label + '/deMon_atoms.xyz', self.atoms)
github wolverton-research-group / qmpy / qmpy / io / ase_mapper.py View on Github external
def write(structure, **kwargs):
    atoms = structure_to_atoms(structure)
    return ase.io.write(atoms, **kwargs)
github rosswhitfield / ase / doc / tutorials / interface-h2o.py View on Github external
# Now we can use wrap
W.wrap()
write('WL_wrap.png', W)

# Match the water lattice to the slab by rescaling
cell1 = np.array([cell[0], cell[1], cellW[2]])
W.set_cell(cell1, scale_atoms=True)
# Set the positions of the water to be 1.5 aangstrom above the slab.
p = slab.get_positions()
W.center(vacuum=p[:, 2].max() + 1.5, axis=2)

# Finally use extend to combine the slab and waterlayer
interface = slab.copy()
interface.extend(W)
interface.center(vacuum=6, axis=2)
write('interface-h2o-wrap.png', interface)
github rosswhitfield / ase / doc / tutorials / N2Cu-Dissociation1.py View on Github external
add_adsorbate(slab,N2mol,height=1.0,position='fcc')

# Use the EMT calculator for the forces and energies:
slab.calc = EMT()

# We don't want to worry about the Cu degrees of freedom,
# so fix these atoms:

mask = [atom.symbol == 'Cu' for atom in slab]
slab.set_constraint(FixAtoms(mask=mask))

# Relax the structure
relax = QuasiNewton(slab)
relax.run(fmax=0.05)
print('initial state:', slab.get_potential_energy())
write('N2.traj', slab)

# Now the final state.
# Move the second N atom to a neighboring hollow site:
slab[-1].position[0] = slab[-2].position[0] + 0.25 * slab.cell[0,0]
slab[-1].position[1] = slab[-2].position[1]
# and relax.
relax.run()
print('final state:  ', slab.get_potential_energy())
write('2N.traj', slab)
github rosswhitfield / ase / ase / optimize / activelearning / aidneb.py View on Github external
'nearest_observations': selects the observations which
                positions are nearest to the positions of the Atoms to test.

            For instance, if *max_train_data* is set to 50 and
            *max_train_data_strategy* to 'lowest energy', the surrogate model
            will be built in each iteration with the 50 lowest energy
            observations collected so far.

        """

        # Convert Atoms and list of Atoms to trajectory files.
        if isinstance(start, Atoms):
            io.write('initial.traj', start)
            start = 'initial.traj'
        if isinstance(end, Atoms):
            io.write('final.traj', end)
            end = 'final.traj'
        interp_path = None
        if interpolation != 'idpp' and interpolation != 'linear':
            interp_path = interpolation
        if isinstance(interp_path, list):
            io.write('initial_path.traj', interp_path)
            interp_path = 'initial_path.traj'

        # NEB parameters.
        self.start = start
        self.end = end
        self.n_images = n_images
        self.mic = mic
        self.rrt = remove_rotation_and_translation
        self.neb_method = neb_method
        self.spring = k
github libAtoms / pymatnest / ns_run.py View on Github external
del(move_args_pre)
   	    del(conf_pre)

	# walk clone targets
	if ns_args['debug'] >= 4:
	    for i in np.where(status[rank,:] == 'c_s')[0]:
		print print_prefix, "INFO: 30 clone source ", rank, i
	clone_walk_ind = np.where(status[rank,:] == 'c_t_a')[0]
	for i_at in clone_walk_ind:
	    if ns_args['debug'] >= 4:
		print print_prefix, "INFO: 40 WALK clone_target ", rank, i_at
	    walk_stats = walk_single_walker(walkers[i_at], movement_args, Emax_of_step, KEmax)
            # if tracking all configs, save this one that has been walked
            if track_traj_io is not None:
                walkers[i_at].info['iter'] = i_ns_step
                ase.io.write(track_traj_io, walkers[i_at], format=ns_args['config_file_format'])
	    #print "WALK on rank ", rank, "at iteration ", i_ns_step, " walker ", i_at
	    if ns_args['debug'] >= 10 and size <= 1:
		walkers[i_at].info['n_walks'] += movement_args['n_model_calls_expected']
	    accumulate_stats(walk_stats_cumul, walk_stats)

	if ns_args['debug'] >= 20:
	    print print_prefix, "%30s" % ": LOOP_TE POST_CLONE_WALK 25 ",i_ns_step, [ eval_energy(at) for at in walkers ]
	    print print_prefix, "%30s" % ": LOOP_PE POST_CLONE_WALK 26 ",i_ns_step, [ eval_energy(at, do_KE=False) for at in walkers ]

	# check that everything that should have been changed has, and things that shouldn't have, haven't
	if ns_args['debug'] >= 10:
            final_PE_loc = [ eval_energy(at, do_KE=False) for at in walkers ]
            final_E_loc = [ eval_energy(at) for at in walkers ]
            if comm is not None:
                final_PE = np.array(comm.allgather(final_PE_loc)).flatten()
                final_E = np.array(comm.allgather(final_E_loc)).flatten()