def get_aims_calculator(n): #"gas" for gas-phase reactants and "periodic" for a periodic systems if (n == "gas"): return Aims( xc='pbe', spin='none', vdw_correction_hirshfeld="True", relativistic=('atomic_zora', 'scalar'), #use_dipole_correction='True', #default_initial_moment=2.0, compute_forces="true" #output=['mulliken'] ) else: if (n == "periodic"): return Aims( xc='pbe', spin='none', k_grid=(3, 3, 1), vdw_correction_hirshfeld="True", relativistic=('atomic_zora', 'scalar'), use_dipole_correction='True', # default_initial_moment=2.0, compute_forces="true", output=['mulliken'], elsi_restart=("write", 1))
def read_aims_calculator(file): """ found instructions for building an FHI-aims calculator in the output file, read its specifications and return it. """ from ase.calculators.aims import Aims calc = Aims() while True: line = file.readline() if "=======================================================" in line: break else: args = line.split() key = '#' if len(args) > 0: key = args[0] if key == '#': comment = True elif calc.float_params.has_key(key): calc.float_params[key] = float(args[1]) elif calc.exp_params.has_key(key): calc.exp_params[key] = float(args[1]) elif calc.string_params.has_key(key): calc.string_params[key] = args[1] if len(args) > 2: for s in args[2:]: calc.string_params[key] += " "+s elif calc.int_params.has_key(key): calc.int_params[key] = int(args[1]) elif calc.bool_params.has_key(key): try: calc.bool_params[key] = bool(args[1]) except: if key == 'vdw_correction_hirshfeld': calc.bool_params[key] = True elif calc.list_params.has_key(key): if key == 'output': # build output string from args: out_option = '' for arg in args[1:]: out_option +=str(arg)+' ' if calc.list_params['output'] is not None: calc.list_params['output'] += [out_option] else: calc.list_params['output'] = [out_option] else: calc.list_params[key] = list(args[1:]) elif '#' in key: key = key[1:] if calc.input_parameters.has_key(key): calc.input_parameters[key] = args[1] if len(args) > 2: for s in args[2:]: calc.input_parameters[key] += " "+s else: raise TypeError('FHI-aims keyword not defined in ASE: ' + key + '. Please check.') return calc
def __init__(self, h2indices=[0,1], restart=None, ignore_bad_restart_file=False, label=os.curdir, atoms=None, cubes=None, radmul=None, tier=None, **kwargs): Aims.__init__(self,restart=restart, ignore_bad_restart_file=\ ignore_bad_restart_file, label=label,atoms=atoms, \ cubes=cubes, radmul=radmul, tier=tier, **kwargs) h2pes.pes_init() self.h2indices = h2indices implemented_properties = ['energy', 'forces', 'friction'] self.implemented_properties = implemented_properties
def get_aims_calculator(dimensions, k_grid=None, xc="pbe", compute_forces="true", **kwargs): ''' Method to return a "default" FHI-aims calculator. Note: This file should not be changed without consultation, as changes could affect many users in the group. Parameters: dimensions: Integer Determines whether we have a "gas"-phase (0) or "periodic" structure (2 or 3) k_grid: List of integers Gives the k-grid sampling in x-, y- and z- direction. e.g. [3, 3, 3] xc: String XC of choice compute_forces: String Determines whether forces are enabled ("true") or not enabled ("false"). **kwargs: Any other keyword arguments that a user wants to set. TODO: Reorder inputs so most necessary are first i.e. xc, compute_forces, k_grid (I think?) AL, March 2021: Doesn't matter - if named, the arguments are dynamic (i.e. can be any order) ''' from ase.calculators.aims import Aims # Default is suitable for molecular calculations fhi_calc = Aims(spin='none', relativistic=('atomic_zora', 'scalar'), compute_forces=compute_forces, **kwargs) # Set the XC for the calculation. For LibXC, override_warning_libxc *needs* # to be set first, otherwise we get a termination. if "libxc" in xc: fhi_calc.set(override_warning_libxc="true") fhi_calc.set(xc=xc) if dimensions == 2: fhi_calc.set(use_dipole_correction='true') if dimensions >= 2: fhi_calc.set(k_grid=k_grid) return fhi_calc
def my_calc(): return Aims(xc='pbesol', spin='none', relativistic=('atomic_zora', 'scalar'), vdw_correction_hirshfeld='true', k_grid=( 2, 2, 2, ), compute_forces=True, final_forces_cleaned=True)
def setup_control(self, overwrite=False): control = self.dirpath.joinpath("control.in") if control.exists() and (overwrite == False): logger.warning( "File control.in already exists. Set overwrite=True to force overwrite." ) elif not control.exists() or overwrite: logger.info("Writing {} ...".format(control)) calc = Aims(**self.aseargs) calc.write_control(self.structure, str(control), debug=False) calc.write_species(self.structure, filename=control) self.__adjust_control(control)
def test_H2O_aims(): water = Atoms('HOH', [(1, 0, 0), (0, 0, 0), (0, 1, 0)]) water_cube = AimsCube(points=(29, 29, 29), plots=('total_density', 'delta_density', 'eigenstate 5', 'eigenstate 6')) calc = Aims(xc='PBE', output=['dipole'], sc_accuracy_etot=1e-6, sc_accuracy_eev=1e-3, sc_accuracy_rho=1e-6, sc_accuracy_forces=1e-4, cubes=water_cube) water.calc = calc dynamics = QuasiNewton(water, trajectory='square_water.traj') dynamics.run(fmax=0.01)
def run(self): self.prepare_calc_dir() Aims.run(self)
calc = Aims( xc='PBE', run_command='mpirun -np 4 <insert_path>/bin/aims.160210.mpi.x > aims.out', species_dir='<insert path>/aimsfiles/species_defaults/' + basisset, occupation_type=['gaussian', 0.1], sc_iter_limit=100, #spin = 'collinear', relativistic=['atomic_zora', 'scalar'], #default_initial_moment = 0, sc_accuracy_etot=1e-6, sc_accuracy_eev=0.001, sc_accuracy_rho=1e-5, sc_accuracy_forces=1e-3, load_balancing=True, #empty_states=10, k_grid=[12, 12, 1], restart_aims='wvfn.dat', output=[ "eigenvectors", "k_point_list", "hamiltonian_matrix", "overlap_matrix", "band 0.0000 0.0000 0.0000 0.0000 0.0833 0.0000 2 ", "band 0.0000 0.2500 0.0000 0.0000 0.3333 0.0000 2 ", "band 0.0000 0.4167 0.0000 0.0000 0.5000 0.0000 2 ", "band 0.0000 0.8333 0.0000 0.0833 0.0000 0.0000 2 ", "band 0.0833 0.0833 0.0000 0.0833 0.1667 0.0000 2 ", "band 0.0833 0.3333 0.0000 0.0833 0.4167 0.0000 2 ", "band 0.0833 0.5000 0.0000 0.0833 0.6667 0.0000 2 ", "band 0.0833 0.7500 0.0000 0.0833 0.8333 0.0000 2 ", "band 0.1667 0.0000 0.0000 0.1667 0.0833 0.0000 2 ", "band 0.1667 0.1667 0.0000 0.1667 0.3333 0.0000 2 ", "band 0.1667 0.4167 0.0000 0.1667 0.5000 0.0000 2 ", "band 0.1667 0.6667 0.0000 0.1667 0.7500 0.0000 2 ", "band 0.1667 0.8333 0.0000 0.2500 0.0000 0.0000 2 ", "band 0.2500 0.0833 0.0000 0.2500 0.1667 0.0000 2 ", "band 0.2500 0.3333 0.0000 0.2500 0.4167 0.0000 2 ", "band 0.2500 0.5000 0.0000 0.2500 0.6667 0.0000 2 ", "band 0.2500 0.7500 0.0000 0.2500 0.8333 0.0000 2 ", "band 0.3333 0.0000 0.0000 0.3333 0.0833 0.0000 2 ", "band 0.3333 0.1667 0.0000 0.3333 0.3333 0.0000 2 ", "band 0.3333 0.4167 0.0000 0.3333 0.5000 0.0000 2 ", "band 0.3333 0.6667 0.0000 0.3333 0.7500 0.0000 2 ", "band 0.3333 0.8333 0.0000 0.4167 0.0000 0.0000 2 ", "band 0.4167 0.0833 0.0000 0.4167 0.1667 0.0000 2 ", "band 0.4167 0.3333 0.0000 0.4167 0.4167 0.0000 2 ", "band 0.4167 0.5000 0.0000 0.4167 0.6667 0.0000 2 ", "band 0.4167 0.7500 0.0000 0.4167 0.8333 0.0000 2 ", "band 0.5000 0.0000 0.0000 0.5000 0.0833 0.0000 2 ", "band 0.5000 0.1667 0.0000 0.5000 0.3333 0.0000 2 ", "band 0.5000 0.4167 0.0000 0.5000 0.5000 0.0000 2 ", "band 0.5000 0.7500 0.0000 0.5833 0.0833 0.0000 2 ", "band 0.5833 0.4167 0.0000 0.5833 0.7500 0.0000 2 ", "band 0.6667 0.0833 0.0000 0.6667 0.4167 0.0000 2 ", "band 0.6667 0.7500 0.0000 0.7500 0.0833 0.0000 2 ", "band 0.7500 0.4167 0.0000 0.7500 0.7500 0.0000 2 ", "band 0.8333 0.0833 0.0000 0.8333 0.4167 0.0000 2 ", "band 0.8333 0.7500 0.0000 0.9167 0.0833 0.0000 2 ", "band 0.9167 0.4167 0.0000 0.9167 0.7500 0.0000 2 ", ], )
def __init__(self, nodes=1, ppn=8, **kwargs): Aims.__init__(self, **kwargs) self.nodes=nodes self.ppn=ppn
def read_aims_calculator(file): """ found instructions for building an FHI-aims calculator in the output file, read its specifications and return it. """ from ase.calculators.aims import Aims calc = Aims() while True: line = file.readline() if "=======================================================" in line: break else: args = line.split() key = '#' if len(args) > 0: key = args[0] if key == '#': comment = True elif calc.float_params.has_key(key): calc.float_params[key] = float(args[1]) elif calc.exp_params.has_key(key): calc.exp_params[key] = float(args[1]) elif calc.string_params.has_key(key): calc.string_params[key] = args[1] if len(args) > 2: for s in args[2:]: calc.string_params[key] += " " + s elif calc.int_params.has_key(key): calc.int_params[key] = int(args[1]) elif calc.bool_params.has_key(key): try: calc.bool_params[key] = bool(args[1]) except: if key == 'vdw_correction_hirshfeld': calc.bool_params[key] = True elif calc.list_params.has_key(key): if key == 'output': # build output string from args: out_option = '' for arg in args[1:]: out_option += str(arg) + ' ' if calc.list_params['output'] is not None: calc.list_params['output'] += [out_option] else: calc.list_params['output'] = [out_option] else: calc.list_params[key] = list(args[1:]) elif '#' in key or calc.input_parameters.has_key(key): key = key[1:] if calc.input_parameters.has_key(key): calc.input_parameters[key] = args[1] if len(args) > 2: for s in args[2:]: calc.input_parameters[key] += " " + s else: raise TypeError('FHI-aims keyword not defined in ASE: ' + key + '. Please check.') return calc
import sys from ase.build import molecule from ase.optimize import BFGS from ase.calculators.aims import Aims from ase.calculators.socketio import SocketIOCalculator # Environment-dependent parameters -- please configure according to machine # Note that FHI-aim support for the i-PI protocol must be specifically # enabled at compile time, e.g.: make -f Makefile.ipi ipi.mpi species_dir = '/home/aimsuser/src/fhi-aims.171221_1/species_defaults/light' command = 'ipi.aims.171221_1.mpi.x' # This example uses INET; see other examples for how to use UNIX sockets. port = 31415 atoms = molecule('H2O', vacuum=3.0) atoms.rattle(stdev=0.1) aims = Aims(command=command, use_pimd_wrapper=('localhost', port), compute_forces=True, xc='LDA', species_dir=species_dir) opt = BFGS(atoms, trajectory='opt.aims.traj', logfile='opt.aims.log') with SocketIOCalculator(aims, log=sys.stdout, port=port) as calc: atoms.calc = calc opt.run(fmax=0.05)
import sys from ase.io.gromos import read_gromos RUN_COMMAND = '/home/mka/bin/aims.071711_6.serial.x' SPECIES_DIR = '/home/mka/Programs/fhi-aims.071711_6/species_defaults/light/' LOG_FILE = open("ase-qm-mm-output.log","w") sys.stdout = LOG_FILE infile_name = sys.argv[1] CALC_QM1 = Aims(charge = 0, xc = 'pbe', sc_accuracy_etot = 1e-5, sc_accuracy_eev = 1e-2, sc_accuracy_rho = 1e-5, sc_accuracy_forces = 1e-3, species_dir = SPECIES_DIR, run_command = RUN_COMMAND) CALC_QM1.set(output = 'hirshfeld') CALC_QM2 = Aims(charge = 0, xc = 'pbe', sc_accuracy_etot = 1e-5, sc_accuracy_eev = 1e-2, sc_accuracy_rho = 1e-5, sc_accuracy_forces = 1e-3, species_dir = SPECIES_DIR, run_command = RUN_COMMAND) CALC_QM2.set(output = 'hirshfeld')
"outfilename": "aims.out", } dft_settings = { # system settings "xc": "pbe", "spin": "none", "compute_forces": True, } # ################# Set aims calculator ###################### workdir = "aims_rundir" port_aims = 12345 aux_settings = {"label": workdir, "use_pimd_wrapper": ("localhost", port_aims)} calc = Aims(**usr_settings, **dft_settings, **aux_settings) # atoms.set_calculator(calc) # ################# Create Client ############################ # inet port_ipi = 10200 host_ipi = "localhost" client = SocketClient(host=host_ipi, port=port_ipi) # ################# Create ASE SERVER ############################ with SocketIOCalculator(calc, log="socketio.log", port=port_aims) as io_calc: atoms.set_calculator(io_calc) client.run(atoms)
from ase.io import read molecule = read('azo.xyz') slab = molecule aims_bin = 'mpirun -np 4' + ' /data/michelitsch/devAIMS/bin/aims.150528.mpi.x > aims.out' basis_set = '/data/michelitsch/devAIMS/fhiaims_doc/species_defaults/light/' if True: QM1 = Aims(command=aims_bin, xc='PBE', relativistic=('atomic_zora scalar 1.0e-09'), spin='none', species_dir=basis_set, tier=1, #k_grid=cluster_kgrid, smearing=('gaussian', 0.1), sc_accuracy_etot=1e-4, sc_accuracy_rho=1e-6, sc_accuracy_forces=1e-3, output=['hirshfeld'], ) calc_vdw = mbdio(INPUT_FILE='azo.mbd', SETTING_FILE='azo_setting.in', OUTPUT_FILE='azo.log', xc='1', mbd_cfdm_dip_cutoff='200.d0', mbd_scs_dip_cutoff='200.0', mbd_supercell_cutoff='15.d0', mbd_scs_vacuum_axis='.true. .true. .false.',
import os from ase import Atoms from ase.optimize import BFGS from ase.calculators.aims import Aims os.environ['ASE_AIMS_COMMAND'] = 'aims.x' os.environ[ 'AIMS_SPECIES_DIR'] = '/home/alumne/software/FHIaims/species_defaults/light' atoms = Atoms('HOH', positions=[[0, 0, -1], [0, 1, 0], [0, 0, 1]]) calc = Aims(xc='LDA', compute_forces=True) atoms.calc = calc opt = BFGS(atoms, trajectory='opt-aims.traj') opt.run(fmax=0.05)
#!/usr/bin/env python from ase.calculators.aims import Aims from ase import Atom, Atoms # calc = Aims(restart='cluster/pt-relax') Ept=calc.get_potential_energy() # calc = Aims(restart='molecules/co-relax') Eco=calc.get_potential_energy() # calc = Aims(restart='cluster/pt-co-relax') Eptco=calc.get_potential_energy() # CE=Eptco - Ept - Eco print('binding energy = {0} eV'.format(CE))
#!/usr/bin/env python from ase.units import * from ase.calculators.aims import Aims bond_lengths = [1.05, 1.1, 1.15, 1.2, 1.25] energies = [] for d in bond_lengths: calc = Aims(label='molecules/co-{0}'.format(d)) atoms = calc.get_atoms() energies.append(atoms.get_potential_energy()) # fit the data pars = np.polyfit(bond_lengths, energies, 3) xfit = np.linspace(1.05, 1.25) efit = np.polyval(pars, xfit) # first derivative dpars = np.polyder(pars) # find where the minimum is. chose the second one because it is the # minimum we need. droots = np.roots(dpars) # second derivative ddpars = np.polyder(dpars) d_min = droots[np.polyval(ddpars, droots) > 0] # curvature at minimum = force constant in SI units k = np.polyval(ddpars, d_min) / (J / m**2) # mu, reduced mass from ase.data import atomic_masses C_mass = atomic_masses[6] / kg O_mass = atomic_masses[8] / kg mu = 1.0 / (1.0 / C_mass + 1.0 / O_mass) frequency = 1. / (2. * np.pi) * np.sqrt(k / mu) print('The CO vibrational frequency is {0} Hz'.format(*frequency)) print('The CO vibrational frequency is {0} cm^{{-1}}'.format(frequency / 3e10))
import sys from ase.io import read RUN_COMMAND = '/home/mka/bin/aims.071711_6.serial.x' SPECIES_DIR = '/home/mka/Programs/fhi-aims.071711_6/species_defaults/light/' LOG_FILE = open("ase-qm-mm-output.log", "w") sys.stdout = LOG_FILE infile_name = sys.argv[1] CALC_QM1 = Aims(charge=0, xc='pbe', sc_accuracy_etot=1e-5, sc_accuracy_eev=1e-2, sc_accuracy_rho=1e-5, sc_accuracy_forces=1e-3, species_dir=SPECIES_DIR, run_command=RUN_COMMAND) CALC_QM1.set(output='hirshfeld') CALC_QM2 = Aims(charge=0, xc='pbe', sc_accuracy_etot=1e-5, sc_accuracy_eev=1e-2, sc_accuracy_rho=1e-5, sc_accuracy_forces=1e-3, species_dir=SPECIES_DIR, run_command=RUN_COMMAND) CALC_QM2.set(output='hirshfeld')
width=width, basis_threshold=basis_threshold, relativistic=relativistic, x=x) if id is None: continue # perform EOS step atoms.set_cell(cell * x, scale_atoms=True) # set calculator atoms.calc = Aims( label=name + '_' + code + '_' + str(n), species_dir=os.path.join(os.environ['AIMS_SPECIES_DIR'], basis), xc='PBE', kpts=kpts, KS_method='elpa', sc_accuracy_rho=1.e-4, sc_accuracy_eev=5.e-3, occupation_type=['gaussian', width], override_relativity=True, override_illconditioning=True, basis_threshold=basis_threshold, charge_mix_param=0.01, ) atoms.calc.set(**kwargs) # remaining calc keywords t = time.time() atoms.get_potential_energy() c.write(atoms, name=name, basis=basis, linspacestr=linspacestr, kptdensity=kptdensity, width=width,
def calc(self, **kwargs): from ase.calculators.aims import Aims kwargs1 = dict(xc='LDA') kwargs1.update(kwargs) return Aims(command=self.executable, **kwargs1)
from ase import Atoms from ase.visualize import view from ase.calculators.aims import Aims, AimsCube from ase.optimize import QuasiNewton water = Atoms('HOH', [(1, 0, 0), (0, 0, 0), (0, 1, 0)]) water_cube = AimsCube(points=(29, 29, 29), plots=('total_density', 'delta_density', 'eigenstate 5', 'eigenstate 6')) calc = Aims( xc='pbe', sc_accuracy_etot=1e-6, sc_accuracy_eev=1e-3, sc_accuracy_rho=1e-6, sc_accuracy_forces=1e-4, species_dir= '/home/hanke/codes/fhi-aims/fhi-aims.workshop/species_defaults/light/', run_command='aims.workshop.serial.x', cubes=water_cube) water.set_calculator(calc) dynamics = QuasiNewton(water, trajectory='square_water.traj') dynamics.run(fmax=0.01) view(water)
from ase.io import read from ase import Atoms from ase.calculators.aims import Aims BEA = read('x.cif') calc = Aims(xc='pbesol', k_grid=(2, 2, 2), spin='none', relativistic=('atomic_zora', 'scalar'), vdw_correction_hirshfeld='true', relax_geometry='trm 1E-2', relax_unit_cell='full', sc_accuracy_forces='1E-3') BEA.set_calculator(calc) e_BEA = BEA.get_potential_energy() print(e_BEA)
import os from ase import Atoms from ase.optimize import BFGS from ase.calculators.aims import Aims from ase.calculators.socketio import SocketIOCalculator os.environ['ASE_AIMS_COMMAND'] = 'aims.x' os.environ[ 'AIMS_SPECIES_DIR'] = '/home/alumne/software/FHIaims/species_defaults/light' atoms = Atoms('HOH', positions=[[0, 0, -1], [0, 1, 0], [0, 0, 1]]) opt = BFGS(atoms, trajectory='opt-aims-socketio.traj') aims = Aims(xc='LDA', compute_forces=True, use_pimd_wrapper=('UNIX:mysocket', 31415)) with SocketIOCalculator(aims, unixsocket='mysocket') as calc: atoms.calc = calc opt.run(fmax=0.05)
def test_aims_interface(): import tempfile import os from ase.calculators.aims import Aims from ase import Atoms # test the new command handling + legacy behavior aims_command = 'aims.x' aims_command_alternative = 'mpirun -np 4 fhiaims.x' outfilename = 'alternative_aims.out' outfilename_default = 'aims.out' command = '{0:s} > {1:s}'.format(aims_command, outfilename) #command_alternative = '{0:s} > {1:s}'.format(aims_command_alternative, outfilename) command_default = '{0:s} > {1:s}'.format(aims_command, outfilename_default) legacy_command = 'aims.version.serial.x > aims.out' legacy_aims_command = legacy_command.split('>')[0].strip() legacy_outfilename = legacy_command.split('>')[-1].strip() # legacy behavior of empty init calc = Aims() assert calc.command == legacy_command assert calc.outfilename == legacy_outfilename assert calc.aims_command == legacy_aims_command # behavior of empty init with env variable os.environ['ASE_AIMS_COMMAND'] = aims_command_alternative calc = Aims() assert calc.command == '{0} > {1}'.format(aims_command_alternative, outfilename_default) assert calc.outfilename == outfilename_default assert calc.aims_command == aims_command_alternative # legacy behavior of "proper" command calc = Aims(run_command=command) assert calc.command == command assert calc.outfilename == outfilename assert calc.aims_command == aims_command # legacy behavior of an "improper" command calc = Aims(run_command=aims_command) assert calc.command == command_default assert calc.aims_command == aims_command assert calc.outfilename == outfilename_default # fixed "command" behavior calc = Aims(command=command) assert calc.command == command assert calc.outfilename == outfilename assert calc.aims_command == aims_command # novel way to use aims_command, no specific outfile calc = Aims(aims_command=aims_command) assert calc.command == command_default assert calc.outfilename == outfilename_default assert calc.aims_command == aims_command calc = Aims(aims_command=aims_command, outfilename=outfilename) assert calc.command == command assert calc.outfilename == outfilename assert calc.aims_command == aims_command # # testing the setters calc.command = command_default assert calc.outfilename == outfilename_default assert calc.aims_command == aims_command assert calc.command == command_default #calc.set_aims_command(aims_command_alternative) calc.aims_command = aims_command_alternative assert calc.aims_command == aims_command_alternative assert calc.outfilename == outfilename_default assert calc.command == '{} > {}'.format(aims_command_alternative, outfilename_default) calc.outfilename = outfilename assert calc.command == '{} > {}'.format(aims_command_alternative, outfilename) assert calc.aims_command == aims_command_alternative assert calc.outfilename == outfilename # test writing files tmp_dir = tempfile.mkdtemp() water = Atoms('HOH', [(1, 0, 0), (0, 0, 0), (0, 1, 0)]) calc = Aims( xc='PBE', output=['dipole'], sc_accuracy_etot=1e-6, sc_accuracy_eev=1e-3, sc_accuracy_rho=1e-6, species_dir="/data/rittmeyer/FHIaims/species_defaults/light/", sc_accuracy_forces=1e-4, label=tmp_dir, ) try: calc.prepare_input_files() raise AssertionError except ValueError: pass calc.atoms = water calc.prepare_input_files() for f in ['control.in', 'geometry.in']: assert os.path.isfile(os.path.join(tmp_dir, f))
from ase.calculators.aims import Aims from ase.visualize import view from ase.build import fcc111, bulk, surface from ase.constraints import FixAtoms, FixBondLengths from ase.io import write from ase.io import read from ase.calculators.emt import EMT a = 3.909 # approximate lattice constant b = a / 2 calc = Aims(xc='pbe', spin='none', k_grid=(9,9,9), vdw_correction_hirshfeld="True", relativistic=('atomic_zora','scalar'), #use_dipole_correction='True', compute_forces="true", output=['mulliken'], # elsi_restart=("write",1) ) bulk = Atoms('Pd', cell=[(0, b, b), (b, 0, b), (b, b, 0)], pbc=1, calculator=calc) # use EMT potential bulk.get_potential_energy() #traj.write(bulk) energy_bulk=bulk.get_potential_energy() print ("potential-energy-bulk", energy_bulk) #print (energy_bulk)
import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt import numpy as np mydb = connect("mydb.db") atoms = mydb.get_atoms(name='ceo2') energies = [] lattices = [] thetas = [] calc = Aims(label='bulk/ceo2-relax', xc='pbe', spin='none', relativistic = 'atomic_zora scalar', kpts=(9, 9, 9), # specifies the Monkhorst-Pack grid sc_accuracy_etot=1e-5, sc_accuracy_eev=1e-2, sc_accuracy_rho=1e-4, sc_accuracy_forces=1e-3, relax_geometry = 'bfgs 5e-3', relax_unit_cell = 'full') atoms.set_calculator(calc) energies.append(atoms.get_potential_energy()) mydb.write(atoms, name='ceo2-relax', relax=True) lattices.append(norm(atoms.cell[0])) thetas.append(arccos(dot(atoms.cell[0], atoms.cell[1]) / (norm(atoms.cell[0]) * norm(atoms.cell[0])))/pi*180) print('----------------------------') print('# U lattice constant (A) angle (degree) energy (eV) ') print(' {0:1.2f} {1:1.4f} {2:1.2f} {3:1.5f}'
# test the new command handling + legacy behavior aims_command = 'aims.x' aims_command_alternative = 'mpirun -np 4 fhiaims.x' outfilename = 'alternative_aims.out' outfilename_default = 'aims.out' command = '{0:s} > {1:s}'.format(aims_command, outfilename) command_alternative = '{0:s} > {1:s}'.format(aims_command_alternative, outfilename) command_default = '{0:s} > {1:s}'.format(aims_command, outfilename_default) legacy_command = 'aims.version.serial.x > aims.out' legacy_aims_command = legacy_command.split('>')[0].strip() legacy_outfilename = legacy_command.split('>')[-1].strip() # legacy behavior of empty init calc = Aims() assert calc.command == legacy_command assert calc.outfilename == legacy_outfilename assert calc.aims_command == legacy_aims_command # behavior of empty init with env variable os.environ['ASE_AIMS_COMMAND'] = aims_command_alternative calc = Aims() assert calc.command == '{0} > {1}'.format(aims_command_alternative, outfilename_default) assert calc.outfilename == outfilename_default assert calc.aims_command == aims_command_alternative # legacy behavior of "proper" command calc = Aims(run_command=command) assert calc.command == command
def __init__(self, nodes=1, ppn=8, **kwargs): Aims.__init__(self, **kwargs) self.nodes = nodes self.ppn = ppn
from ase.calculators.socketio import SocketIOCalculator # Environment-dependent parameters -- please configure according to machine # Note that FHI-aim support for the i-PI protocol must be specifically # enabled at compile time, e.g.: make -f Makefile.ipi ipi.mpi species_dir = '/home/aimsuser/src/fhi-aims.171221_1/species_defaults/light' command = 'ipi.aims.171221_1.mpi.x' # This example uses INET; see other examples for how to use UNIX sockets. port = 31415 atoms = molecule('H2O', vacuum=3.0) atoms.rattle(stdev=0.1) aims = Aims( command=command, use_pimd_wrapper=('localhost', port), # alternative: ('UNIX:mysocketname', 31415) # (numeric port must be given even with Unix socket) compute_forces=True, xc='LDA', species_dir=species_dir) opt = BFGS(atoms, trajectory='opt.aims.traj', logfile='opt.aims.log') with SocketIOCalculator(aims, log=sys.stdout, port=port) as calc: # For running with UNIX socket, put unixsocket='mysocketname' # instead of port cf. aims parameters above atoms.calc = calc opt.run(fmax=0.05)
from ase import Atoms from ase.calculators.aims import Aims, AimsCube from ase.optimize import QuasiNewton water = Atoms('HOH', [(1, 0, 0), (0, 0, 0), (0, 1, 0)]) water_cube = AimsCube(points=(29, 29, 29), plots=('total_density', 'delta_density', 'eigenstate 5', 'eigenstate 6')) calc = Aims(xc='PBE', output=['dipole'], sc_accuracy_etot=1e-6, sc_accuracy_eev=1e-3, sc_accuracy_rho=1e-6, sc_accuracy_forces=1e-4, cubes=water_cube) water.set_calculator(calc) dynamics = QuasiNewton(water, trajectory='square_water.traj') dynamics.run(fmax=0.01)
from ase import Atoms from ase.io import read from ase.constraints import FixAtoms from ase.optimize import QuasiNewton from ase.calculators.aims import Aims from ase.vibrations import Vibrations BEAH = read('BEAH.cif') calc = Aims(xc='pbesol', relativistic='atomic_zora', 'scalar', k_grid=(2,2,2), vdw_correction='hirshfeld', sc_accuracy_etot=1e-4, sc_accuracy_eev=1e-4, sc_accuracy_rho=1e-4, sc_accuracy_forces=1e-4)) BEAH.set_calculator(calc) from ase.constraints import FixAtoms c = FixAtoms(indices=[i for i in range(0,192)]) BEAH.set_constraint(c) e0 = BEAH.get_potential_energy() QuasiNewton(BEAH).run(fmax=0.05) from ase.vibrations import Vibrations