Ejemplo n.º 1
0
from pyiid.calc.calc_1d import Calc1D
from pyiid.sim.nuts_hmc import NUTSCanonicalEnsemble
from ase.cluster import Octahedron
import matplotlib.pyplot as plt
from ase.visualize import view


# Lets set up the atoms
# We use the Atomic Simulation Environment to take care of our atoms
# atoms = Atoms('Au4', [[0, 0, 0], [3, 0, 0], [0, 3, 0], [3, 3, 0]])
atoms = Octahedron('Au', 2)
view(atoms)
# we can view the atoms by importing ASE's gui
scat = ElasticScatter()
pdf = scat.get_pdf(atoms)
r = scat.get_r()
# Now lets dilate the atoms so that they don't match the pdf
atoms2 = dc(atoms)
atoms2.positions *= 1.05
pdf2 = scat.get_pdf(atoms2)
r = scat.get_r()

# Now we need to define the potential energy surface
calc = Calc1D(
    target_data=pdf,  # The target or experimental data
    exp_function=scat.get_pdf,
    # The function which takes in atoms and produces
    # data like the experiment
    exp_grad_function=scat.get_grad_pdf,  # the function which produces the
    #  gradient of the calculated data
    conv=100,  # conversion from the unitless goodness of fit to eV
Ejemplo n.º 2
0
                  exp_grad_function=s.get_grad_adp_pdf,
                  exp_function=s.get_pdf,
                  conv=100)

calc = Calc1D(target_data=target_pdf,
                  exp_grad_function=null_func,
                  exp_function=s.get_pdf,
                  conv=100)


starting_atoms = atoms.copy()
starting_adps = ADP(atoms, adps=adp_tensor * np.random.random(adp_tensor.shape))
starting_adps.set_calculator(adp_calc)
starting_atoms.info['adps'] = starting_adps

plot_pdf(s.get_r(), target_pdf, s.get_pdf(starting_atoms), show=False,
         save_file='../random/start')

starting_atoms.set_calculator(adp_calc)
traj = classical_dynamics(starting_atoms, .01, 100)

nrg = []
for atoms in traj:
    atoms.set_momenta(atoms.info['adps'].get_positions() * 1000)
    nrg.append(atoms.get_potential_energy())
print(traj[np.argmin(nrg)].info['adps'].get_positions() / adp_tensor)

target_atoms.set_momenta(target_atoms.info['adps'].get_positions() * 1000)

# view(target_atoms)
# view(traj)
Ejemplo n.º 3
0
                  exp_grad_function=s.get_grad_adp_pdf,
                  exp_function=s.get_pdf,
                  conv=100)

calc = Calc1D(target_data=target_pdf,
                  exp_grad_function=null_func,
                  exp_function=s.get_pdf,
                  conv=100)


starting_atoms = atoms.copy()
starting_adps = ADP(atoms, adps=adp_tensor * adp_tensor_target * 1.5)
starting_adps.set_calculator(adp_calc)
starting_atoms.info['adps'] = starting_adps

plot_pdf(s.get_r(), target_pdf, s.get_pdf(starting_atoms), show=False)

starting_atoms.set_calculator(adp_calc)
traj = classical_dynamics(starting_atoms, .01, 100)
nrg = []
for atoms in traj:
    atoms.set_momenta(atoms.info['adps'].get_positions() * 1000)
    nrg.append(atoms.get_potential_energy())
print(traj[np.argmin(nrg)].info['adps'].get_positions() / adp_tensor)

target_atoms.set_momenta(target_atoms.info['adps'].get_positions() * 1000)
view(target_atoms)
view(traj)
plot_pdf(s.get_r(), target_pdf, s.get_pdf(traj[np.argmin(nrg)]), show=False)
save_file = '../janus/'
# need a way to plot the ADPs