Skip to content

Commit

Permalink
Added the option to change the name of the auxiliary file for NEB cal…
Browse files Browse the repository at this point in the history
…culations
  • Loading branch information
RaphaelRobidas committed Jan 18, 2022
1 parent d0977ef commit 278da66
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 10 deletions.
9 changes: 7 additions & 2 deletions ccinput/calculation.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ class Calculation:
"""
Holds all the data required to generate an input file. Its fields are the parameters likely to change (charge, multiplicity, xyz, calculation type...). The other parameters are contained in the Parameters class (accessed through self.parameters).
"""
def __init__(self, xyz, parameters, type, constraints="", nproc=0, mem=0, charge=0, multiplicity=1, name="calc", header="File created by ccinput", software=""):
def __init__(self, xyz, parameters, type, constraints="", nproc=0, mem=0,
charge=0, multiplicity=1, aux_name="calc2", name="calc",
header="File created by ccinput", software=""):
self.xyz = xyz
self.parameters = parameters
self.type = type
Expand Down Expand Up @@ -58,6 +60,7 @@ def __init__(self, xyz, parameters, type, constraints="", nproc=0, mem=0, charge
self.constraints = constraints

self.name = name
self.aux_name = aux_name
self.header = header

def verify_charge_mult(self):
Expand All @@ -81,7 +84,9 @@ class Parameters:
Holds all the parameters about the computational method. These parameters do not depend on the particular system (e.g. regarding the charge and multiplicity) and can be reused.
"""

def __init__(self, software, solvent="", solvation_model="", solvation_radii="", basis_set="", method="", specifications="", density_fitting="", custom_basis_sets="", **kwargs):
def __init__(self, software, solvent="", solvation_model="",
solvation_radii="", basis_set="", method="", specifications="",
density_fitting="", custom_basis_sets="", **kwargs):

if solvent.strip() != "":
self.solvent = get_abs_solvent(solvent)
Expand Down
4 changes: 2 additions & 2 deletions ccinput/packages/orca.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,14 +202,14 @@ def handle_command(self):
elif self.calc.type == CalcType.MEP:#### Second structure to handle
self.command_line = "NEB "
neb_block = """%neb
product "struct2.xyz"
product "{}.xyz"
nimages {}
end"""
if 'nimages' in self.specifications:
nimages = self.specifications['nimages']
else:
nimages = 8
self.blocks.append(neb_block.format(nimages))
self.blocks.append(neb_block.format(self.calc.aux_name, nimages))

method = get_method(self.calc.parameters.method, "orca")
if self.calc.parameters.theory_level not in ['xtb', 'semi-empirical', 'special']:
Expand Down
43 changes: 41 additions & 2 deletions ccinput/tests/test_orca.py
Original file line number Diff line number Diff line change
Expand Up @@ -1184,7 +1184,7 @@ def test_NEB(self):
H -1.82448 0.94856 3.28105
*
%neb
product "struct2.xyz"
product "calc2.xyz"
nimages 8
end
%pal
Expand Down Expand Up @@ -1222,7 +1222,46 @@ def test_NEB2(self):
H -1.82448 0.94856 3.28105
*
%neb
product "struct2.xyz"
product "calc2.xyz"
nimages 12
end
%pal
nprocs 8
end
"""
self.assertTrue(self.is_equivalent(REF, inp.input_file))

def test_NEB_aux_name(self):
params = {
'nproc': 8,
'type': 'Minimum Energy Path',
'in_file': 'elimination_substrate.xyz',
'auxiliary_file': 'elimination_product.xyz',
'software': 'ORCA',
'specifications': '--nimages 12',
'charge': -1,
'method': 'gfn2-xtb',
'aux_name': 'product',
}

inp = self.generate_calculation(**params)

REF = """!NEB xtb2
*xyz -1 1
C -0.74277 0.14309 0.12635
C 0.71308 -0.12855 -0.16358
Cl 0.90703 -0.47793 -1.61303
H -0.84928 0.38704 1.20767
H -1.36298 -0.72675 -0.06978
H -1.11617 0.99405 -0.43583
H 1.06397 -0.95639 0.44985
H 1.30839 0.75217 0.07028
O -0.91651 0.74066 3.00993
H -1.82448 0.94856 3.28105
*
%neb
product "product.xyz"
nimages 12
end
%pal
Expand Down
11 changes: 7 additions & 4 deletions ccinput/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ def process_calculation(calc):
def generate_calculation(software=None, type=None, method="", basis_set="", \
solvent="", solvation_model="", solvation_radii="", specifications="", \
density_fitting="", custom_basis_sets="", xyz="", in_file="", \
constraints="", nproc=0, mem="", charge=0, multiplicity=1, name="calc", \
header="File created by ccinput", **kwargs):
constraints="", nproc=0, mem="", charge=0, multiplicity=1, aux_name="calc2", \
name="calc", header="File created by ccinput", **kwargs):

if software is None:
raise InvalidParameter("Specify a software package to use (software=...)")
Expand All @@ -46,7 +46,7 @@ def generate_calculation(software=None, type=None, method="", basis_set="", \

calc = Calculation(xyz_structure, params, calc_type, constraints=constraints, \
nproc=nproc, mem=mem, charge=charge, multiplicity=multiplicity, \
name=name, header=header, software=abs_software)
aux_name=aux_name, name=name, header=header, software=abs_software)

return process_calculation(calc)

Expand Down Expand Up @@ -112,6 +112,9 @@ def get_parser():
parser.add_argument('--name', default="calc", type=str,
help='Name of the produced file (unused by some packages)')

parser.add_argument('--aux_name', default="calc2", type=str,
help='Name of the auxiliary file (some calculation types only)')

parser.add_argument('--header', default="File created by ccinput", type=str,
help='Header in produced file (unused by some packages)')

Expand All @@ -128,7 +131,7 @@ def cmd():
solvation_radii=args.solvation_radii, specifications=args.specifications, density_fitting=args.density_fitting, \
custom_basis_sets=args.custom_basis_sets, xyz=args.xyz, in_file=args.file, constraints=args.constraints, \
nproc=args.nproc, mem=args.mem, charge=args.charge, multiplicity=args.mult, \
name=args.name, header=args.header)
aux_name=args.aux_name, name=args.name, header=args.header)
except CCInputException as e:
print("*** {} ***".format(str(e)))
return
Expand Down

0 comments on commit 278da66

Please sign in to comment.