Esempio n. 1
0
atoms.set_calculator(qmmm_pot)

# *** Set up the initial QM region ****

qm_list = update_hysteretic_qm_region(atoms, [], orig_crack_pos,
                                      qm_inner_radius, qm_outer_radius)
qmmm_pot.set_qm_atoms(qm_list)

# ********* Setup and run MD ***********

# Set the initial temperature to 2*simT: it will then equilibriate to
# simT, by the virial theorem
MaxwellBoltzmannDistribution(atoms, 2.0 * sim_T)

# Initialise the dynamical system
dynamics = LOTFDynamics(atoms, timestep, extrapolate_steps)


# Print some information every time step
def printstatus():
    if dynamics.nsteps == 1:
        print """
State      Time/fs    Temp/K     Strain      G/(J/m^2)  CrackPos/A D(CrackPos)/A 
---------------------------------------------------------------------------------"""

    log_format = (
        '%(label)-4s%(time)12.1f%(temperature)12.6f' +
        '%(strain)12.5f%(G)12.4f%(crack_pos_x)12.2f    (%(d_crack_pos_x)+5.2f)'
    )

    atoms.info['label'] = dynamics.state_label  # Label for the status line
Esempio n. 2
0
        try:
            defect.params['core']
        except KeyError:
            defect.params['core'] = np.array([98.0, 98.0, 1.49])

        defect = set_quantum(defect, params.n_core)
        MaxwellBoltzmannDistribution(defect, 2.0 * sim_T)
        if dyn_type == 'eam':
            dynamics = VelocityVerlet(defect, timestep)
            dynamics.attach(pass_print_context(defect, dynamics))
        elif dyn_type == 'LOTF':
            defect.info['core'] = np.array([98.0, 98.0, 1.49])
            print 'Initializing LOTFDynamics'
            verbosity_push(PRINT_VERBOSE)
            dynamics = LOTFDynamics(defect,
                                    timestep,
                                    params.extrapolate_steps,
                                    check_force_error=False)
            dynamics.set_qm_update_func(update_qm_region)
            dynamics.attach(pass_print_context(defect, dynamics))
            dynamics.attach(traj_writer, print_interval, defect)
        else:
            print 'No dyn_type chosen', 1 / 0

        trajectory = AtomsWriter('{0}.traj.xyz'.format(input_file))
        print 'Running Crack Simulation'
        dynamics.run(nsteps)
        #Write cooked i.e. thermalized ceel to file.
        defect.set_cutoff(3.0)
        defect.calc_connect()
        new_core = pp_nye_tensor(defect, dis_type=dis_type)
        defect.info['core'] = new_core
Esempio n. 3
0
# *** Set up the initial QM region ****

qm_list = update_hysteretic_qm_region(atoms, [], orig_crack_pos,
                                      qm_inner_radius, qm_outer_radius)
qmmm_pot.set_qm_atoms(qm_list)

# ********* Setup and run MD ***********

# Set the initial temperature to 2*simT: it will then equilibriate to
# simT, by the virial theorem
MaxwellBoltzmannDistribution(atoms, 2.0 * sim_T)

# Initialise the dynamical system
dynamics = LOTFDynamics(atoms,
                        timestep,
                        extrapolate_steps,
                        check_force_error=True)


# Print some information every time step
def printstatus():
    if dynamics.nsteps == 1:
        print """
State      Time/fs    Temp/K     Strain      G/(J/m^2)  CrackPos/A D(CrackPos)/A 
---------------------------------------------------------------------------------"""

    log_format = (
        '%(label)-4s%(time)12.1f%(temperature)12.6f' +
        '%(strain)12.5f%(G)12.4f%(crack_pos_x)12.2f    (%(d_crack_pos_x)+5.2f)'
    )
Esempio n. 4
0
      MaxwellBoltzmannDistribution(atoms, 2.0*sim_T)
  # Save frames to the trajectory every `traj_interval` time steps
  # but only when interpolating
  trajectory = AtomsWriter(os.path.join(params.rundir, params.traj_file))
  # Initialise the dynamical system
  system_timer('init_dynamics')
  if params.extrapolate_steps == 1:
      dynamics = VelocityVerlet(atoms, params.timestep)
      check_force_error = False
      if not params.classical:
          qmmm_pot.set(calc_weights=True)
      dynamics.state_label = 'D'
  else:
    print 'Initializing LOTF Dynamics'
    dynamics = LOTFDynamics(atoms, params.timestep,
                            params.extrapolate_steps,
                            check_force_error=check_force_error)
  system_timer('init_dynamics')
#Function to update the QM region at the beginning of each extrapolation cycle   
  if not check_force_error:
      if params.extrapolate_steps == 1:
          if not params.classical:
              dynamics.attach(update_qm_region, 1, dynamics.atoms)
      else:
      # choose appropriate update function for defects or crack.
      # or grainboundary.
        print 'Setting Update Function'
        if geom =='disloc':
          dynamics.set_qm_update_func(update_qm_region)
        elif geom =='crack':
          dynamics.set_qm_update_func(update_qm_region_crack)
Esempio n. 5
0
      print 'Running WITH EAM as embedded cluster'
      qm_pot_file  = os.path.join(pot_dir, 'PotBH_fakemod.xml')
      print qm_pot_file
      mm_init_args = 'IP EAM_ErcolAd do_rescale_r=T r_scale=1.01' # Classical potential
      qm_pot       = Potential(mm_init_args, param_filename=qm_pot_file, cutoff_skin=cutoff_skin)
      qmmm_pot     = set_qmmm_pot(atoms, atoms.params['CrackPos'], mm_pot, qm_pot)

    strain_atoms = fix_edges(atoms)

    print 'Setup dynamics'
#If input_file is crack.xyz the cell has not been thermalized yet.
#Otherwise it will recover temperature from the previous run.
    print 'Attaching trajectories to dynamics'
    trajectory = AtomsWriter(traj_file)
#Only wriates trajectory if the system is in the LOTFDynamicas
#Interpolation 
    atoms.wrap()
    atoms.set_cutoff(3.0)
    atoms.calc_connect()
    print 'Running Crack Simulation'
    RELAXATION = False
    if RELAXATION:
      dynamics = FIRE(atoms)
      dynamics.attach(pass_trajectory_context(trajectory, dynamics), traj_interval, dynamics)
      dynamics.run(fmax=0.1)
    else:
      dynamics = LOTFDynamics(atoms, timestep, extrapolate_steps)
      dynamics.attach(pass_trajectory_context(trajectory, dynamics), traj_interval, dynamics)
      nsteps    = 2000
      dynamics.run(nsteps)
Esempio n. 6
0
      pickle.dump(crack_dict,f)

# Save frames to the trajectory every `traj_interval` time steps.
  trajectory = AtomsWriter(os.path.join(rundir, traj_file))
# Initialise the dynamical system
  system_timer('init_dynamics')
  if extrapolate_steps == 1:
      dynamics = VelocityVerlet(atoms, timestep)
      check_force_error = False
      if not classical:
          qmmm_pot.set(calc_weights=True)
      dynamics.state_label = 'D'
  else:
    print 'Initializing LOTF Dynamics'
    dynamics = LOTFDynamics(atoms, timestep,
                            extrapolate_steps,
                            check_force_error=check_force_error)
  system_timer('init_dynamics')
# Function to update the QM region at the beginning of each extrapolation cycle   
  if not check_force_error:
    if extrapolate_steps == 1:
      if not classical:
        dynamics.attach(update_qm_region, 1, dynamics.atoms)
    else:
# Choose appropriate update function for defects or crack or grainboundary
      print 'Setting Update Function'
      if geom =='disloc':
        dynamics.set_qm_update_func(update_qm_region)
      elif geom =='crack':
        if quantumregion == 'Crack':
          dynamics.set_qm_update_func(update_qm_region_crack)
Esempio n. 7
0
atoms.set_calculator(qmmm_pot)
del_keys = ['force', 'forces', 'forces0']
array_keys = atoms.arrays.keys()
prop_keys = atoms.properties.keys()
for key in del_keys:
    if key in array_keys:
        del (atoms.arrays[key])

#under construction
if False:
    np.random.seed(42)
    MaxwellBoltzmannDistribution(atoms, 2.0 * sim_T)

check_force_error = False
dynamics = LOTFDynamics(atoms,
                        timestep,
                        extrapolate_steps,
                        check_force_error=check_force_error)


def log_pred_corr_errors(dynamics, logfile):
    logline = '%s err %10.1f%12.6f%12.6f\n' % (
        dynamics.state_label, dynamics.get_time() / units.fs,
        dynamics.rms_force_error, dynamics.max_force_error)
    print logline
    logfile.write(logline)


if check_force_error:
    pred_corr_logfile = open('pred-corr-error.txt', 'w')
    dynamics.attach(log_pred_corr_errors, 1, dynamics, pred_corr_logfile)
Esempio n. 8
0
  return check_if_cracked

def update_qm_region_context(qmmm_pot, mm_pot, atoms):
  def update_qm_region(atoms):
    crack_pos = find_crack_tip_stress_field(atoms, calc=mm_pot)
    qm_list   = qmmm_pot.get_qm_atoms()
    qm_list   = update_hysteretic_qm_region(atoms, qm_list, crack_pos, qm_inner_radius, 
                                            qm_outer_radius, update_marks=True)
    qmmm_pot.set_qm_atoms(qm_list)
#lets try setting the atoms object properties by hand?
    atoms.hybrid[:] = HYBRID_NO_MARK
    atoms.hybrid[qm_list] = HYBRID_ACTIVE_MARK
  return update_qm_region

if __name__=='__main__':
#Randomize initial positions
  np.random.seed()
  MaxwellBoltzmannDistribution(atoms, 2.0*sim_T)
#dynamics = VelocityVerlet(atoms, timestep)
  dynamics = LOTFDynamics(atoms, timestep, extrapolate_steps)
  dynamics.attach(check_if_cracked, 1, atoms)
  dynamics = LOTFDynamics(atoms, timestep, extrapolate_steps)
  dynamics.set_qm_update_func(update_qm_region)
#Writing the trajectory
  trajectory = AtomsWriter(traj_file)
  dynamics.attach(traj_writer, traj_interval, dynamics)
  dynamics.attach(printstatus)
  print 'Running Crack Simulation'
  dynamics.run(nsteps)
  print 'Crack Simulation Finished'