Skip to content

Commit

Permalink
Merge pull request #403 from RagnarB83/NEW
Browse files Browse the repository at this point in the history
further fixes for flake8
  • Loading branch information
RagnarB83 authored Jan 25, 2024
2 parents 8d82b5d + a06d56f commit ca9a70f
Show file tree
Hide file tree
Showing 17 changed files with 217 additions and 211 deletions.
6 changes: 3 additions & 3 deletions ash/ash_header.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,13 @@ def print_logo():
███ █▀ ▄████████▀ ███ █▀
"""
ascii_tree = """
ascii_tree = """
[ ▓ ▒ ╒ ▓
╙█ ▓▓ ▓ -µ ╙▄ ¬ ▓▀
▌∩ ▀█▓▌▄▄▓▓▓▄, ▀▄▓▌ ▓ ▀█ ▌ █ ╓▓Γ ▄▓▀¬
╓Γ╘ % ╙▀▀▀▀▀▓▓▄ ▓▓ █▓,╒ ▀▓ ▓▌ Æ▀▓▓▓ ▄▓▓¬ . ▌
▓ ^█ ▌ ▄ ▀▓▓ ▓▓m ▐▓ ▓▓ ▐▌▓▌▓▀ Å▓▓▓▓▀ ▐ ▐▓ ▄
╘▓▌ \ ▀▓▄▐▓ ▐▓ ▀▓▓▓▓m ▓▌▄▓▓█ ▓┘ ▓▓ ▄█▀▀▓▓▄ ▐▓ ▐▄ j▓ ▓
╘▓▌ \\ ▀▓▄▐▓ ▐▓ ▀▓▓▓▓m ▓▌▄▓▓█ ▓┘ ▓▓ ▄█▀▀▓▓▄ ▐▓ ▐▄ j▓ ▓
█ ╙▓ ╙▀▄▄▀▓▓µ ▓ ▄▄▀▀▓▓▓ ▓▓▓Σ▄▓▓▓Γ ▓▓▓▀ █▓▀^▓ ▄▓ ▓ ▐▓ █
▌ ▀▀█,▓▓ ▄╙▀▓▓▓▄▓▌▄▓▌ ▓▓ ▓▓▓▀▓▓▓▓▓ ▓▓▓▓▓▀ ╞ ▓▄▓▀ ╓─ ▓▄ ,▓█▀▀ .▀
▐▄ ▀▓▓ ▓ ▓▓▓▓▓Γ╙▓▄ ▓▓▓▓▓▌▓▓▀▓Γ ▓▓▄▓▓▓▀ ▄ ▓▓▀ ▀ ▐▓▄▓▀ ▄▓
Expand All @@ -159,7 +159,7 @@ def print_logo():
▄▀, ▄█▀▀ ▓¬ ▓τ ▓ ▐▓ ▓ ▓ ¥ ▓ ▀▌
^ ▓▀ █ ▓▀ ▄█¬ ▐▓ ▌ Γ ▐▓τ* ▀█▄
▓ /Γ ƒ▀ⁿ █ ▓ Γ ╓▀▐⌐ ¬▀²
▓ \ ▀ ╙µ ⌡
\\ ▀ ╙µ ⌡
"""
# print(BC.OKBLUE,ascii_banner3,BC.END)
Expand Down
8 changes: 4 additions & 4 deletions ash/interfaces/interface_ASE.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import ash.constants
from ash.functions.functions_general import ashexit, print_line_with_mainheader, print_time_rel, printdebug
from ash.modules.module_singlepoint import Singlepoint
from ash.interfaces.interface_safires import attach_safires_to_ASE
#from ash.interfaces.interface_safires import attach_safires_to_ASE
from ash.modules.module_coords import check_charge_mult

#Interface to limited parts of ASE
Expand Down Expand Up @@ -288,9 +288,9 @@ def write_traj(a=atoms, trajname=trajectoryname):
dyn.attach(write_traj, interval=traj_frequency)

#SAFIRES: attach SAFIRES object to ASE dyn
if safires == True:
attach_safires_to_ASE(atoms=atoms, dyn=dyn, safires_solvent_atomsnum=safires_solvent_atomsnum,
safires_solute=safires_solute, safires_inner_region=safires_inner_region )
#if safires == True:
# attach_safires_to_ASE(atoms=atoms, dyn=dyn, safires_solvent_atomsnum=safires_solvent_atomsnum,
# safires_solute=safires_solute, safires_inner_region=safires_inner_region )

print("")
print("")
Expand Down
2 changes: 1 addition & 1 deletion ash/interfaces/interface_OpenMM.py
Original file line number Diff line number Diff line change
Expand Up @@ -2124,7 +2124,7 @@ def create_cnb(original_nbforce,system_numparticles):
# custom_nonbonded_force.setUseSwitchingFunction(True)
# custom_nonbonded_force.setSwitchingDistance(99999)
print('Adding particles to custom force.')
for index in range(systen_numparticles):
for index in range(system_numparticles):
[charge, sigma, epsilon] = original_nbforce.getParticleParameters(index)
custom_nonbonded_force.addParticle([charge, sigma, epsilon])
# For CustomNonbondedForce we need (unlike NonbondedForce) to create exclusions that correspond to the automatic
Expand Down
2 changes: 1 addition & 1 deletion ash/interfaces/interface_dalton.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import ash.settings_ash
from ash.functions.functions_general import ashexit, BC,print_time_rel
from ash.modules.modules_coords import elemstonuccharges
from ash.modules.module_coords import elemstonuccharges

class DaltonTheory:
def __init__(self, daltondir=None, filename='dalton', printlevel=2,
Expand Down
4 changes: 2 additions & 2 deletions ash/interfaces/interface_pyscf.py
Original file line number Diff line number Diff line change
Expand Up @@ -1876,7 +1876,7 @@ def set_dispersion_options(self, Grad=False):
#self.mf.nlcgrids.atom_grid={'H': (50,194),'F': (50,194)}
#self.mf.nlcgrids.prune=dft.gen_grid.sg1_prune

def set_DF_mf_options(self):
def set_DF_mf_options(self,Grad=False):
#https://pyscf.org/user/df.html
#ASH-default gives PySCF default :optimized JK auxbasis for family if it exists,
# otherwise an even-tempered basis is generated
Expand Down Expand Up @@ -2220,7 +2220,7 @@ def prepare_run(self, current_coords=None, current_MM_coords=None, MMcharges=Non
##############################
#DENSITY FITTING and SGX
##############################
self.set_DF_mf_options()
self.set_DF_mf_options(Grad=Grad)

##############################
#FROZEN ORBITALS in CC
Expand Down
3 changes: 2 additions & 1 deletion ash/knarr/KNARRio/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ def UpdateSettings(job, start_read, listi):
if keyw in parameters:
# convert to correct format
val = convert(val)
if isinstance(val, basestring):
#RB: changed basestring to str Py2toPY3 thing
if isinstance(val, str):
val = convert_bool(val)
parameters[keyw] = val # change value of kw
else:
Expand Down
4 changes: 2 additions & 2 deletions ash/knarr/KNARRio/system_print.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ def GetDate():
def PrintLogo():
print(" K N A R R ")
print(" ___|__ ")
print(" \-\-\-\ ")
print(" \\-\\-\\-\\ ")
print(" /_/_/_/ p> ")
print(" (\_____|_____/) ")
print(" (\\_____|_____/) ")
print(" ~~~~/ / / / /~~~ ")
print(" ~~~~~~~~~~~~~~~~ ")
print(" ")
Expand Down
1 change: 1 addition & 0 deletions ash/knarr/KNARRjobs/opt.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def DoOpt(atoms, calculator, optimizer):

print('\nStarting structural optimization:')
print(' %3ls %9ls %9ls %8ls %8ls %8ls' % ('it', 'Energy', 'dEnergy', 'RMSF', 'MAXF', '|step|'))
step=None
for it in range(maxiter):
calculator.Compute(atoms)
WriteSingleImageTraj('minimization.xyz', atoms.GetNDim(), atoms.GetCoords(),
Expand Down
2 changes: 2 additions & 0 deletions ash/knarr/KNARRjobs/saddle.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ def LanczosMMF(calculator, atoms, opttype=0, tol_max_force=0.026,
if l_it >= l_maxiter - 1:
print('** Warning: Lanczos reached maximum number of iterations')

step=None
for it in range(maxiter):

calculator.Compute(atoms)
Expand Down Expand Up @@ -315,6 +316,7 @@ def NewtonMethod(calculator, atoms, compute_hessian_every=1,
reset_opt = False
print('\nStarting Newton-Raphson saddle point search:')
print(' %3ls %9ls %9ls %8ls %8ls %8ls' % ('it', 'Energy', 'dEnergy', 'RMSF', 'MAXF', '|step|'))
step=None
for it in range(maxiter):

calculator.Compute(atoms)
Expand Down
2 changes: 1 addition & 1 deletion ash/modules/module_highlevel_workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -3560,7 +3560,7 @@ def __init__(self, elements=None, scfsetting='TightSCF', extrainputkeyword='', e

#CHECKS to exit early
if elements == None:
print(BC.FAIL, "\ORCA_MRCI_CBS_Theory requires a list of elements to be given in order to set up basis sets", BC.END)
print(BC.FAIL, "\nORCA_MRCI_CBS_Theory requires a list of elements to be given in order to set up basis sets", BC.END)
print("Example: ORCA_MRCI_CBS_Theory(elements=['C','Fe','S','H','Mo'], basisfamily='def2',cardinals=[2,3], ...")
print("Should be a list containing all elements that a fragment might contain")
ashexit()
Expand Down
4 changes: 2 additions & 2 deletions ash/modules/module_solvation.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ def solvshell ( orcadir='', NumCores='', calctype='', orcasimpleinput_LL='',
run_inputfiles_in_parallel(orcadir, SRPolinpfiles, NumCores)

#GRAB output
SRPol_Allrepsnaps_ABenergy, SRPol_Arepsnaps_ABenergy, SRPol_Brepsnaps_ABenergy=grab_energies_output_ORCA(SRPolinpfiles)
SRPol_Allrepsnaps_ABenergy, SRPol_Arepsnaps_ABenergy, SRPol_Brepsnaps_ABenergy=ash.functions.functions_solv.grab_energies_output_ORCA(SRPolinpfiles)
blankline()

# PART 2.
Expand All @@ -443,7 +443,7 @@ def solvshell ( orcadir='', NumCores='', calctype='', orcasimpleinput_LL='',
#Run the inputfiles
run_inputfiles_in_parallel(orcadir, SRPolinpfiles_Region1, NumCores)
#Grab the energies
SRPol_Allrepsnaps_ABenergy_Region1, SRPol_Arepsnaps_ABenergy_Region1, SRPol_Brepsnaps_ABenergy_Region1 = grab_energies_output_ORCA(
SRPol_Allrepsnaps_ABenergy_Region1, SRPol_Arepsnaps_ABenergy_Region1, SRPol_Brepsnaps_ABenergy_Region1 = ash.functions.functions_solv.grab_energies_output_ORCA(
SRPolinpfiles_Region1)


Expand Down
182 changes: 91 additions & 91 deletions ash/tests/test_ORCA.py
Original file line number Diff line number Diff line change
@@ -1,91 +1,91 @@
from ash import *

def test_ORCA_SP():
"""
Simple Singlepoint ORCA calculation with charge/mult in fragment
"""
#ORCA
orcasimpleinput="! BP86 def2-SVP tightscf notrah"
orcablocks="%scf maxiter 200 end"

fragcoords="""
H 0.0 0.0 0.0
F 0.0 0.0 1.0
"""

#Add coordinates to fragment
HF_frag=Fragment(coordsstring=fragcoords, charge=0, mult=1)

ORCASPcalculation = ORCATheory(orcasimpleinput=orcasimpleinput, orcablocks=orcablocks)

result = Singlepoint(theory=ORCASPcalculation, fragment=HF_frag)

#Clean up
ORCASPcalculation.cleanup()

#Reference energy
ref=-100.350611851152
threshold=1e-9
assert abs(result.energy-ref) < threshold, "Energy-error above threshold"

def test_ORCA_SP2():
"""
Simple Singlepoint ORCA calculation with charge/mult in Singlepoint function
"""
#ORCA
orcasimpleinput="! BP86 def2-SVP tightscf notrah"
orcablocks="%scf maxiter 200 end"

fragcoords="""
H 0.0 0.0 0.0
F 0.0 0.0 1.0
"""

#Add coordinates to fragment
HF_frag=Fragment(coordsstring=fragcoords)

ORCASPcalculation = ORCATheory(orcasimpleinput=orcasimpleinput, orcablocks=orcablocks)

result = Singlepoint(theory=ORCASPcalculation, fragment=HF_frag, charge=0, mult=1)

#Clean up
ORCASPcalculation.cleanup()

#Reference energy
ref=-100.350611851152
threshold=1e-9
assert abs(result.energy-ref) < threshold, "Energy-error above threshold"

def test_ORCA_BS_SP():
"""
Singlepoint Broken-symmetry ORCA calculation with charge/mult in fragment
"""
#ORCA
orcasimpleinput="! BP86 def2-SVP tightscf notrah slowconv"
orcablocks="""
%scf
maxiter 500
diismaxeq 20
directresetfreq 1
end
"""

fragcoords="""
Fe 0.0 0.0 0.0
Fe 0.0 0.0 3.0
"""

#Add coordinates to fragment
Fe2_frag=Fragment(coordsstring=fragcoords, charge=6, mult=1)
ORCABScalc = ORCATheory(orcasimpleinput=orcasimpleinput, orcablocks=orcablocks,
brokensym=True, HSmult=11, atomstoflip=[1])
#Simple Energy SP calc
result = Singlepoint(fragment=Fe2_frag, theory=ORCABScalc)
print("energy:", result.energy)
#Clean up
ORCABScalc.cleanup()

#Reference energy
ref=-2521.60831655367
threshold=1e-6
assert abs(result.energy-ref) < threshold, "Energy-error above threshold"
# from ash import *

# def test_ORCA_SP():
# """
# Simple Singlepoint ORCA calculation with charge/mult in fragment
# """
# #ORCA
# orcasimpleinput="! BP86 def2-SVP tightscf notrah"
# orcablocks="%scf maxiter 200 end"

# fragcoords="""
# H 0.0 0.0 0.0
# F 0.0 0.0 1.0
# """

# #Add coordinates to fragment
# HF_frag=Fragment(coordsstring=fragcoords, charge=0, mult=1)

# ORCASPcalculation = ORCATheory(orcasimpleinput=orcasimpleinput, orcablocks=orcablocks)

# result = Singlepoint(theory=ORCASPcalculation, fragment=HF_frag)

# #Clean up
# ORCASPcalculation.cleanup()

# #Reference energy
# ref=-100.350611851152
# threshold=1e-9
# assert abs(result.energy-ref) < threshold, "Energy-error above threshold"

# def test_ORCA_SP2():
# """
# Simple Singlepoint ORCA calculation with charge/mult in Singlepoint function
# """
# #ORCA
# orcasimpleinput="! BP86 def2-SVP tightscf notrah"
# orcablocks="%scf maxiter 200 end"

# fragcoords="""
# H 0.0 0.0 0.0
# F 0.0 0.0 1.0
# """

# #Add coordinates to fragment
# HF_frag=Fragment(coordsstring=fragcoords)

# ORCASPcalculation = ORCATheory(orcasimpleinput=orcasimpleinput, orcablocks=orcablocks)

# result = Singlepoint(theory=ORCASPcalculation, fragment=HF_frag, charge=0, mult=1)

# #Clean up
# ORCASPcalculation.cleanup()

# #Reference energy
# ref=-100.350611851152
# threshold=1e-9
# assert abs(result.energy-ref) < threshold, "Energy-error above threshold"

# def test_ORCA_BS_SP():
# """
# Singlepoint Broken-symmetry ORCA calculation with charge/mult in fragment
# """
# #ORCA
# orcasimpleinput="! BP86 def2-SVP tightscf notrah slowconv"
# orcablocks="""
# %scf
# maxiter 500
# diismaxeq 20
# directresetfreq 1
# end
# """

# fragcoords="""
# Fe 0.0 0.0 0.0
# Fe 0.0 0.0 3.0
# """

# #Add coordinates to fragment
# Fe2_frag=Fragment(coordsstring=fragcoords, charge=6, mult=1)
# ORCABScalc = ORCATheory(orcasimpleinput=orcasimpleinput, orcablocks=orcablocks,
# brokensym=True, HSmult=11, atomstoflip=[1])
# #Simple Energy SP calc
# result = Singlepoint(fragment=Fe2_frag, theory=ORCABScalc)
# print("energy:", result.energy)
# #Clean up
# ORCABScalc.cleanup()

# #Reference energy
# ref=-2521.60831655367
# threshold=1e-6
# assert abs(result.energy-ref) < threshold, "Energy-error above threshold"
Loading

0 comments on commit ca9a70f

Please sign in to comment.