예제 #1
0
def wrap_cc(cell1, pts):
    """
    Function finds the indices of atoms making tetrahedrons

    Parameters
    -------------
    cell1 :
        The simulation cell ( a 3*4 numpy array where the first 3 columns are the
        cell vectors and the last column is the box origin)
    pts :
        Position of atoms in initial cell, the atoms within an rCut of the initial cell.

    Returns
    ------------
    pts1 :
        Position of atoms in initial cell, the atoms within an rCut of the initial cell,
        and the Voronoi coordinates as the new set of atoms.

    """
    data = ovd.DataCollection()
    data.objects.append(cell1)
    particles = ovd.Particles()
    particles.create_property('Position', data=pts)
    data.objects.append(particles)

    # Create a new Pipeline with a StaticSource as data source:
    pipeline = Pipeline(source=StaticSource(data=data))

    pipeline.modifiers.append(ovm.WrapPeriodicImagesModifier())
    data1 = pipeline.compute()
    pts1 = np.array(data1.particle_properties['Position'][...])
    return pts1
예제 #2
0
def ovito_dxa(atoms, replicate_z=3):
    from ovito.io.ase import ase_to_ovito
    from ovito.modifiers import ReplicateModifier, DislocationAnalysisModifier
    from ovito.pipeline import StaticSource, Pipeline

    data = ase_to_ovito(atoms)
    pipeline = Pipeline(source=StaticSource(data=data))
    pipeline.modifiers.append(ReplicateModifier(num_z=replicate_z))
    dxa = DislocationAnalysisModifier(
        input_crystal_structure=DislocationAnalysisModifier.Lattice.BCC)
    pipeline.modifiers.append(dxa)

    data = pipeline.compute()
    return (np.array(data.dislocations.segments[0].true_burgers_vector),
            data.dislocations.segments[0].length / replicate_z,
            data.dislocations.segments[0])
예제 #3
0
def write_lammps_data(ftxt, atoms, **kwargs):
  # FAIL: use ase.io.write(ftxt, atoms, format='lammps-data', atom_style='charge')
  from ovito.io import export_file
  from ovito.pipeline import StaticSource, Pipeline
  from ovito.io.ase import ase_to_ovito
  atoms.set_initial_charges(atoms.get_initial_charges())
  dc = ase_to_ovito(atoms)
  #dc.particles.masses = np.ones(len(atoms))
  #dc.particles_.create_property('masses', data=atoms.get_masses())
  pl = Pipeline(source=StaticSource(data=dc))
  export_file(pl, ftxt, 'lammps/data', atom_style='charge')#**kwargs)
             replica = 0
             min_nb_atoms = 100
             while (atoms*(replica,replica,replica)).get_number_of_atoms()<min_nb_atoms:
                 replica+=1
             atoms *= (replica, replica, replica)
         # if str(atoms.info['target']) == '227':
         """
         if str(atoms.info['target']) == '227' or str(atoms.info['target']) == '221':
             pass
         """
         #if False:
         #    pass
         #else:
         # atoms = atoms*(2, 2, 2)
         data = ase_to_ovito(atoms)
         node = Pipeline(source=StaticSource(data=data))
 
         node.modifiers.append(modifier)
         #node.modifiers.append(CommonNeighborAnalysisModifier(mode=CommonNeighborAnalysisModifier.Mode.FixedCutoff))
         # node.modifiers.append(CommonNeighborAnalysisModifier(mode=CommonNeighborAnalysisModifier.Mode.AdaptiveCutoff))
         #node.modifiers.append(AcklandJonesModifier())
 
         # node.modifiers.append(BondAngleAnalysisModifier())
         # node.modifiers.append(PolyhedralTemplateMatchingModifier(rmsd_cutoff=0.0))
 
         # Let OVITO's data pipeline do the heavy work.
         node.compute()
 
         # A two-dimensional array containing the three CNA indices
         # computed for each bond in the system.
         atom_classes = list(node.output.particle_properties['Structure Type'].array)
예제 #5
0
# Skip execution of this example script during testing if ASE is not installed.
import sys
try:
    import ase
except:
    sys.exit()
# >>>>>>>>>>>>>>>>>>>>>>> begin example snippet >>>>>>>>>>>>>>>>>>
from ovito.pipeline import StaticSource, Pipeline
from ovito.io.ase import ase_to_ovito
from ase.atoms import Atoms

# The ASE Atoms object to convert:
ase_atoms = Atoms('CO', positions=[(0, 0, 0), (0, 0, 1.1)])

# Create a new Pipeline with a StaticSource as data source:
pipeline = Pipeline(source=StaticSource())

# Convert the ASE object; use the StaticSource as destination container:
ase_to_ovito(ase_atoms, pipeline.source)
예제 #6
0
from ovito.pipeline import TrajectoryLineGenerator, Pipeline
from ovito.io import import_file
from ovito.vis import TrajectoryLineDisplay

# Load a particle simulation sequence:
pipeline = import_file('simulation.*.dump')

# Create a second pipeline for the trajectory lines:
traj_pipeline = Pipeline()

# Create data source and assign it to the second pipeline.
# The first pipeline provides the particle positions.
traj_pipeline.source = TrajectoryLineGenerator(source_pipeline=pipeline,
                                               only_selected=False)

# Generate the trajectory lines by sampling the
# particle positions over the entire animation interval.
traj_object = traj_pipeline.source.generate()

# Configure trajectory line display:
traj_object.display.width = 0.4
traj_object.display.color = (1, 0, 0)
traj_object.display.shading = TrajectoryLineDisplay.Shading.Flat

# Insert both pipelines into the scene to make both the particles and
# the trajectory lines visible in rendered images:
pipeline.add_to_scene()
traj_pipeline.add_to_scene()