No more E501

parent 4744417e
Pipeline #98934050 passed with stage
in 3 minutes and 31 seconds
......@@ -12,5 +12,5 @@ master:
- su user -c 'gpaw install-data --register gpaw-datasets'
- su user -c 'gpaw -P 1 info'
- su user -c 'gpaw test --range linalg/gemm_complex.py,lcao/dos.py'
- flake8 --ignore E722,E303,E221,E731,E203,E262,E202,E402,E502,E127,E201,E305,E241,W291,E302,E225,E128,E261,E251,E265,E226,E231,E129,E741,W293,W503,W504 --exclude "doc/platforms/*" gpaw doc
- flake8 --ignore E722,E303,E221,E731,E203,E262,E202,E402,E502,E127,E201,E305,E241,W291,E302,E225,E128,E261,E251,E265,E226,E231,E129,E741,W293,W503,W504 --exclude "doc/platforms/*,gpaw/lrtddft2/*" gpaw doc
- python -We:invalid -m compileall -f -q gpaw/
from __future__ import print_function
import numpy as np
from ase.units import Bohr, Hartree
from ase.parallel import paropen
......@@ -79,7 +77,8 @@ class ExteriorElectronDensity:
'relative EED weight: eed_weight']), end=' ', file=out)
print(
'#; n k s weight energy occ eed_weight', file=out)
'#; n k s weight energy occ eed_weight',
file=out)
for kpt in wfs.kpt_u:
for n in range(wfs.bd.nbands):
print('%4d %3d %1d %8.5f %10.5f %10.5f %10.5f' %
......
from __future__ import print_function
from math import sqrt
import numpy as np
......@@ -196,7 +195,7 @@ class SimpleStm(STM):
"""
return self.scan_const_density(self.current_to_density(current),
bias)
def scan_const_density(self, density, bias):
"""Get the height image for constant density [e/Angstrom^3].
"""
......@@ -204,7 +203,7 @@ class SimpleStm(STM):
self.heights = heights / Bohr
return self.heights
def write(self, file=None):
"""Write STM data to a file in gnuplot readable tyle."""
......@@ -237,7 +236,8 @@ class SimpleStm(STM):
print('#', file=f)
print('# density=', self.density, '[e/Angstrom^3]', end=' ', file=f)
print(
'(current=', self.density_to_current(self.density), '[nA])', file=f)
'(current=', self.density_to_current(self.density), '[nA])',
file=f)
print('# x[Angs.] y[Angs.] h[Angs.] (-1 is not found)', file=f)
for i in range(nx):
for j in range(ny):
......
......@@ -72,7 +72,8 @@ def vdWradii(symbols, xc):
n += 1
# linear interpolation
ncut = (n_g[n - 1] +
(n_g[n] - n_g[n - 1]) * (R - r_g[n - 1]) / (r_g[n] - r_g[n - 1]))
(n_g[n] - n_g[n - 1]) * (R - r_g[n - 1]) /
(r_g[n] - r_g[n - 1]))
# print "Z, Zrg, ncut", Z, Zrg, ncut
# find own R at this density
......@@ -82,7 +83,8 @@ def vdWradii(symbols, xc):
n += 1
# linear interpolation
R = (r_g[n - 1] +
(r_g[n] - r_g[n - 1]) * (ncut - n_g[n - 1]) / (n_g[n] - n_g[n - 1]))
(r_g[n] - r_g[n - 1]) * (ncut - n_g[n - 1]) /
(n_g[n] - n_g[n - 1]))
radius[symbol] = R * Bohr
radii.append(radius[symbol])
......
......@@ -103,7 +103,8 @@ def get_orbitals_by_energy_shift(opts, setup, **kwargs):
phit_g[1:] /= rgd.r_g[1:]
gcut = rgd.ceil(rsplit)
#tailnorm = np.dot(rgd.dr_g[gcut:],
# (rgd.r_g[gcut:] * orbital_bf.phit_g[gcut:])**2)**0.5
# (rgd.r_g[gcut:] *
# orbital_bf.phit_g[gcut:])**2)**0.5
#print 'tailnorm', tailnorm
dphit_g = orbital_bf.phit_g[:gcut+1] - phit_g[:gcut+1]
bf = BasisFunction(l=orbital_bf.l,
......
# flake8: noqa
import functools
from ase.calculators.calculator import Calculator
......
# flake8: noqa
'''A class for computing the
parameters for Marcus theory
from two constrained DFT
......
......@@ -24,8 +24,8 @@ class PhononPerturbation(Perturbation):
def __init__(self, calc, kd, poisson_solver, dtype=float, **kwargs):
"""Store useful objects, e.g. lfc's for the various atomic functions.
Depending on whether the system is periodic or finite, Poisson's equation
is solved with FFT or multigrid techniques, respectively.
Depending on whether the system is periodic or finite, Poisson's
equation is solved with FFT or multigrid techniques, respectively.
Parameters
----------
......
......@@ -66,7 +66,8 @@ class Phonons(phonons.Phonons):
"""Read force constants from files."""
# Data structure for force constants
self.C_qaavv = [dict([(a, dict([(a_, np.zeros((3, 3), dtype=self.dtype))
self.C_qaavv = [dict([(a, dict([(a_, np.zeros((3, 3),
dtype=self.dtype))
for a_ in self.indices]))
for a in self.indices])
for q in range(self.kd.nibzkpts)]
......@@ -187,7 +188,8 @@ class Phonons(phonons.Phonons):
# Reshape before Fourier transforming
shape = self.D_k.shape
Dq_lmn = self.D_k.reshape(N_c + shape[1:])
DR_lmn = fft.ifftn(fft.ifftshift(Dq_lmn, axes=(0, 1, 2)), axes=(0, 1, 2))
DR_lmn = fft.ifftn(fft.ifftshift(Dq_lmn, axes=(0, 1, 2)),
axes=(0, 1, 2))
if debug:
# Check that D_R is real enough
......
from __future__ import print_function
"""This module implements a linear response calculator class."""
__all__ = ["ResponseCalculator"]
......@@ -380,15 +379,17 @@ class ResponseCalculator:
rhs_G = -1 * rhs_nG[n]
# Solve Sternheimer equation
iter, info = self.linear_solver.solve(self.sternheimer_operator,
psit1_G, rhs_G)
iter, info = self.linear_solver.solve(
self.sternheimer_operator,
psit1_G, rhs_G)
if verbose:
print("\tBand %2.1i -" % n, end=' ')
if info == 0:
if verbose:
print("linear solver converged in %i iterations" % iter)
print("linear solver converged in %i iterations" %
iter)
elif info > 0:
assert False, ("linear solver did not converge in maximum "
"number (=%i) of iterations for "
......
......@@ -118,7 +118,8 @@ class ELF:
# For periodic boundary conditions
if self.paw.wfs.kd.symmetry is not None:
self.paw.wfs.kd.symmetry.symmetrize(self.taut_sG[0], self.paw.wfs.gd)
self.paw.wfs.kd.symmetry.symmetrize(self.taut_sG[0],
self.paw.wfs.gd)
self.nt_grad2_sG[:] = 0.0
......
......@@ -200,6 +200,7 @@ class PointChargePotential(ExternalPotential):
return F_pv * Hartree / Bohr
class CDFTPotential(ExternalPotential):
# Dummy class to make cDFT compatible with new external potential class ClassName(object):
# Dummy class to make cDFT compatible with new external
# potential class ClassName(object):
def __init__(self):
self.name = 'CDFTPotential'
......@@ -207,7 +207,8 @@ class KPointDescriptor:
(w_k[k], self.nbzkpts)))
else:
s += ('%4d: %12.8f %12.8f %12.8f %12.8f\n' %
((k,) + tuple(self.ibzk_kc[k]) + (self.weight_k[k],)))
((k,) + tuple(self.ibzk_kc[k]) +
(self.weight_k[k],)))
elif k == 10:
s += ' ...\n'
return s
......
......@@ -188,7 +188,9 @@ class TCICalculator:
dtype = self.dtype
get_phases = self.get_phases
displacement = DerivativeAtomicDisplacement if derivative else AtomicDisplacement
displacement = (DerivativeAtomicDisplacement
if derivative
else AtomicDisplacement)
ibzk_qc = self.ibzk_qc
nq = len(ibzk_qc)
phit_rcmax_a = self.phit_rcmax_a
......
......@@ -53,7 +53,7 @@ class TightBinding:
Parameters
----------
N_c: tuple or ndarray
Number of unit cells in each direction of the basis vectors.
Number of unit cells in each direction of the basis vectors.
"""
......@@ -70,7 +70,7 @@ class TightBinding:
N_c = np.array(self.N_c)[:, np.newaxis]
R_cN += N_c // 2
R_cN %= N_c
R_cN -= N_c // 2
R_cN -= N_c // 2
self.R_cN = R_cN
def lattice_vectors(self):
......@@ -114,14 +114,15 @@ class TightBinding:
# Time-reversal symmetry
if not len(self.ibzk_kc) == len(self.bzk_kc):
# Broadcast Gamma component
gamma = np.where(np.sum(np.abs(self.ibzk_kc), axis=1) == 0.0)[0]
gamma = np.where(np.sum(np.abs(self.ibzk_kc),
axis=1) == 0.0)[0]
rank, myu = self.kd.get_rank_and_index(0, gamma)
#
#
if self.kd.comm.rank == rank[0]:
A0_xMM = A_qxMM[myu[0]]
else:
A0_xMM = np.zeros_like(A_xMM)
#
#
self.kd.comm.broadcast(A0_xMM, rank[0])
# Add conjugate and subtract double counted Gamma component
......@@ -132,7 +133,8 @@ class TightBinding:
try:
assert np.all(np.abs(A_xMM.imag) < 1e-10)
except AssertionError:
raise ValueError("MAX Im(A_MM): % .2e" % np.amax(np.abs(A_xMM.imag)))
raise ValueError("MAX Im(A_MM): % .2e" %
np.amax(np.abs(A_xMM.imag)))
A_NxMM.append(A_xMM.real)
......@@ -154,13 +156,13 @@ class TightBinding:
S_MM = wfs.S_qMM[kpt.q]
#XXX Converting to full matrices here
tri2full(H_MM)
tri2full(S_MM)
tri2full(S_MM)
H_kMM.append(H_MM)
S_kMM.append(S_MM)
# Convert to arrays
H_kMM = np.array(H_kMM)
S_kMM = np.array(S_kMM)
S_kMM = np.array(S_kMM)
H_NMM = self.bloch_to_real_space(H_kMM)
S_NMM = self.bloch_to_real_space(S_kMM)
......
......@@ -103,7 +103,8 @@ def get_realspace_hs(h_skmm, s_kmm, bzk_kc, weight_k,
# kpts in the transverse directions
offset = np.zeros((3,))
offset[:len(transverse_dirs)] = kpts_shift[transverse_dirs]
bzk_t_kc = monkhorst_pack(tuple(kpts_grid[transverse_dirs]) + (1, )) + offset
bzk_t_kc = monkhorst_pack(
tuple(kpts_grid[transverse_dirs]) + (1, )) + offset
if 'time_reversal' not in symmetry:
symmetry['time_reversal'] = True
if symmetry['time_reversal']:
......
from __future__ import print_function
from gpaw.mpi import world
import numpy as np
from gpaw.lfc import LFC
......@@ -43,7 +42,9 @@ class DensityCollector(Observer):
start = rng
self.ranges.append(range(start, self.nbands))
print(self.ranges)
self.ghat = LFC(self.lcao.wfs.gd, [setup.ghat_l for setup in self.lcao.density.setups],
self.ghat = LFC(self.lcao.wfs.gd, [setup.ghat_l
for setup in
self.lcao.density.setups],
integral=sqrt(4 * pi), forces=False)
self.ghat.set_positions(self.lcao.wfs.spos_ac)
......@@ -53,7 +54,8 @@ class DensityCollector(Observer):
print("# Density file", file=f)
N_c = self.lcao.wfs.gd.N_c
print(N_c[0], N_c[1], N_c[2], file=f)
print("# This header is 10 lines long, then double precision binary data starts.", file=f)
print("# This header is 10 lines long, then double precision "
"binary data starts.", file=f)
for i in range(7):
print("#", file=f)
f.close()
......@@ -77,7 +79,8 @@ class DensityCollector(Observer):
for a in self.lcao.density.D_asp:
ni = self.lcao.density.setups[a].ni
D_asp[a] = np.zeros((1, ni * (ni + 1) // 2))
self.lcao.wfs.calculate_atomic_density_matrices_with_occupation(D_asp, f_un)
self.lcao.wfs.calculate_atomic_density_matrices_with_occupation(
D_asp, f_un)
Q_aL = {}
for a, D_sp in D_asp.items():
Q_aL[a] = np.dot(D_sp.sum(0),
......@@ -142,12 +145,14 @@ class ObsoleteSplitDensityCollector(Observer):
kpt = self.lcao.wfs.kpt_u[0]
for i, (f_n, n_sg) in enumerate(zip(self.f_xn, self.n_xsg)):
n_sg[:] = 0.0 # XXX n_sg just temporary here
self.lcao.wfs.add_to_density_from_k_point_with_occupation(n_sg, kpt, f_n)
self.lcao.wfs.add_to_density_from_k_point_with_occupation(
n_sg, kpt, f_n)
D_asp={}
for a in self.lcao.density.D_asp:
ni = self.lcao.density.setups[a].ni
D_asp[a] = np.zeros((1, ni * (ni + 1) // 2))
self.lcao.wfs.calculate_atomic_density_matrices_with_occupation(D_asp, f_n)
self.lcao.wfs.calculate_atomic_density_matrices_with_occupation(
D_asp, f_n)
for a, D_sp in D_asp.items():
Q_aL = np.dot(D_sp.sum(0),
self.lcao.density.setups[a].Delta_pL)
......@@ -156,7 +161,11 @@ class ObsoleteSplitDensityCollector(Observer):
qfile.close()
if self.lcao.wfs.bd.comm.rank == 0:
gd = self.lcao.wfs.gd
fname = self.filename+"."+str(i)+".%.5f.%d.%d.%d-%d.%d.%d.density" % (self.lcao.time, gd.beg_c[0], gd.beg_c[1], gd.beg_c[2], gd.end_c[0], gd.end_c[1], gd.end_c[2])
fname = (self.filename+"."+str(i)+
".%.5f.%d.%d.%d-%d.%d.%d.density" %
(self.lcao.time, gd.beg_c[0], gd.beg_c[1],
gd.beg_c[2], gd.end_c[0], gd.end_c[1],
gd.end_c[2])
n_sg.astype(np.float32).tofile(fname)
took = time.time()-start
if world.rank == 0:
......@@ -167,7 +176,8 @@ class ObsoleteSplitDensityCollector(Observer):
atoms = read('../geometries/ag13.traj')
atoms.center(vacuum=5)
calc = LCAOTDDFT(mode='lcao', dtype=complex, width=0.01, basis='LDA.dz+5p', xc='LDA', h=0.3,
calc = LCAOTDDFT(mode='lcao', dtype=complex, width=0.01,
basis='LDA.dz+5p', xc='LDA', h=0.3,
mixer=Mixer(0.1,4,weight=100))
atoms.set_calculator(calc)
atoms.get_potential_energy()
......
"""Time dependent density functional perturbation theory."""
from __future__ import print_function
from gpaw.analyse.observers import Observer
from gpaw import GPAW
import ase.io
......@@ -112,7 +111,8 @@ class TDDFPT(GPAW):
# Read the complex smooth potential
tdf = open(Vop_filename + '.sG', 'r')
NG = np.prod(self.hamiltonian.vt_sG.shape)
self.cvt_sG = np.fromfile(tdf, dtype=np.complex128, count=NG).reshape(self.hamiltonian.vt_sG.shape)
self.cvt_sG = np.fromfile(tdf, dtype=np.complex128, count=NG).reshape(
self.hamiltonian.vt_sG.shape)
# Read the complex PAW corrections
tdaf = open(Vop_filename + '.asp', 'r')
......@@ -145,14 +145,16 @@ class TDDFPT(GPAW):
print(self.hamiltonian.vt_sG, np.sum(self.hamiltonian.vt_sG))
Hp_MM = self.wfs.eigensolver.calculate_hamiltonian_matrix(
self.hamiltonian, self.wfs, self.wfs.kpt_u[0], add_kinetic=False, root=-1)
self.hamiltonian, self.wfs, self.wfs.kpt_u[0], add_kinetic=False,
root=-1)
# Imag part
self.hamiltonian.vt_sG[:] = self.cvt_sG.imag
for a, dH_sp in self.hamiltonian.dH_asp.items():
self.hamiltonian.dH_asp[a][:] = self.cH_asp[a].imag
Hm_MM = self.wfs.eigensolver.calculate_hamiltonian_matrix(
self.hamiltonian, self.wfs, self.wfs.kpt_u[0], add_kinetic=False, root=-1)
self.hamiltonian, self.wfs, self.wfs.kpt_u[0], add_kinetic=False,
root=-1)
S_MM = self.wfs.S_qMM[0]
C0_nM = self.wfs.kpt_u[0].C_nM.copy()
......@@ -262,7 +264,8 @@ from gpaw import GPAW
from ase.optimize import BFGS
from gpaw.tddft import photoabsorption_spectrum
from gpaw import PoissonSolver
from gpaw.lcaotddft.tddfpt import TDDFPT, HamiltonianCollector, transform_local_operator
from gpaw.lcaotddft.tddfpt import (TDDFPT, HamiltonianCollector,
transform_local_operator)
# Sodium dimer
atoms = Atoms('H2', positions=[[0.0,0.0,0.0],[0.7,0.0,0.0]])
......@@ -293,7 +296,8 @@ if 1:
photoabsorption_spectrum('H2.dm','H2.spec', width=0.4)
transform_local_operator(gpw_file='H2_gs.gpw', tdop_file='H2.TdHam', fqop_file='H2.FqHam', omega=19.15, eta=1)
transform_local_operator(gpw_file='H2_gs.gpw', tdop_file='H2.TdHam',
fqop_file='H2.FqHam', omega=19.15, eta=1)
tddftpt = TDDFPT('H2_gs.gpw', 'H2.FqHam')
tddftpt.calculate()
......
# flake8: noqa
import os
import io
......
# flake8: noqa
import numpy as np
from gpaw import debug
......
......@@ -43,7 +43,7 @@ def get_coulomb_kernel(pd, N_c, truncation=None, q_v=None, wstc=None):
v_G[0] = 0.0
else:
raise ValueError('Truncation scheme %s not implemented' % truncation)
return v_G.astype(complex)
def calculate_2D_truncated_coulomb(pd, q_v=None, N_c=None):
......@@ -70,7 +70,7 @@ def calculate_2D_truncated_coulomb(pd, q_v=None, N_c=None):
qGp_G = ((qG_Gv[:, Np_c[0]])**2 + (qG_Gv[:, Np_c[1]]**2))**0.5
qGn_G = qG_Gv[:, Nn_c[0]]
v_G = 4 * np.pi / (qG_Gv**2).sum(axis=1)
if np.allclose(qGn_G[0], 0) or pd.kd.gamma:
"""sin(qGn_G * R) = 0 when R = L/2 and q_n = 0.0"""
......@@ -94,7 +94,9 @@ def calculate_1D_truncated_coulomb(pd, q_v=None, N_c=None):
if q_v is not None:
qG_Gv += q_v
else:
raise ValueError('Presently, calculations only work with a small q in the normal direction')
raise ValueError(
'Presently, calculations only work with a small q in the '
'normal direction')
# The periodic direction is determined from k-point grid
Nn_c = np.where(N_c == 1)[0]
......@@ -130,7 +132,7 @@ def calculate_0D_truncated_coulomb(pd, q_v=None):
R = (3 * np.linalg.det(pd.gd.cell_cv) / (4 * np.pi))**(1. / 3.)
qG2_G = (qG_Gv**2).sum(axis=1)
v_G = 4 * np.pi / qG2_G
v_G *= 1.0 - np.cos(qG2_G**0.5 * R)
......@@ -163,7 +165,7 @@ def get_integrated_kernel(pd, N_c, truncation=None, N=100, reduced=False):
qp_q = ((q_qv[:, Np_c[0]])**2 + (q_qv[:, Np_c[1]]**2))**0.5
qn_q = q_qv[:, Nn_c[0]]
V_q = 4 * np.pi / (q_qv**2).sum(axis=1)
a_q = qn_q / qp_q * np.sin(qn_q * R) - np.cos(qn_q * R)
V_q *= 1. + np.exp(-qp_q * R) * a_q
......
from __future__ import print_function
import pickle
import numpy as np
from math import pi
......@@ -250,8 +248,9 @@ class Heterostructure:
self.potential_model(self.myq_abs[iq], self.z_big,
self.z0[k], dipole=True,
delta=delta)
dphi_array[2 * k + 1, iq, i_1: i_2 + 1] = \
fd(z_big[i_1: i_2 + 1]) + 1j * fd2(z_big[i_1: i_2 + 1])
dphi_array[2 * k + 1, iq, i_1: i_2 + 1] = (
fd(z_big[i_1: i_2 + 1]) + 1j *
fd2(z_big[i_1: i_2 + 1]))
return dphi_array
......@@ -261,7 +260,8 @@ class Heterostructure:
z_lim = self.z_lim
z_lim = int(z_lim / dz) * dz
z_grid = np.insert(z, 0, np.flip(np.arange(z[0] - dz, -z_lim - dz, -dz)))
z_grid = np.insert(z, 0, np.flip(np.arange(z[0] - dz,
-z_lim - dz, -dz)))
z_grid = np.append(z_grid, np.arange(z[-1] + dz, z_lim + dz, dz))
return z_grid
......
......@@ -118,11 +118,12 @@ def intYdYdtheta_ex(l1, m1, l2, m2):
pi 2pi
/ / * d Y(u,v)
A = | | Y (u,v) cos(u)*cos(v) --- l'm' sin(u) dv du
LL' / / lm du
LL' / / lm du
0 0
where u = theta and v = phi in the usual notation. Note that the result
is only non-zero if `|l1-l2|` is odd and `|m1-m2|` = 1 (stricter rule applies).
is only non-zero if `|l1-l2|` is odd and `|m1-m2|` = 1
(stricter rule applies).
"""
if abs(l1 - l2) % 2 != 1 or abs(m1 - m2) != 1:
return 0.0
......@@ -170,11 +171,12 @@ def intYdYdtheta_ey(l1, m1, l2, m2):
pi 2pi
/ / * d Y(u,v)
A = | | Y (u,v) cos(u)*sin(v) --- l'm' sin(u) dv du
LL' / / lm du
LL' / / lm du
0 0
where u = theta and v = phi in the usual notation. Note that the result
is only non-zero if `|l1-l2|` is odd and `|m1-m2|` = 1 (stricter rule applies).
is only non-zero if `|l1-l2|` is odd and `|m1-m2|` = 1
(stricter rule applies).
"""
if abs(l1 - l2) % 2 != 1 or abs(m1 - m2) != 1:
return 0.0
......@@ -222,7 +224,7 @@ def intYdYdtheta_ez(l1, m1, l2, m2):
pi 2pi
/ / * d Y(u,v)
A = - | | Y (u,v) sin(u) --- l'm' sin(u) dv du
LL' / / lm du
LL' / / lm du
0 0
where u = theta and v = phi in the usual notation. Note that the result
......@@ -245,11 +247,12 @@ def intYdYdphi_ex(l1, m1, l2, m2):
pi 2pi
/ / * -1 d Y(u,v)
A = - | | Y (u,v) sin(u)*sin(v) --- l'm' sin(u) dv du
LL' / / lm dv
LL' / / lm dv
0 0
where u = theta and v = phi in the usual notation. Note that the result
is only non-zero if `|l1-l2|` is odd and `|m1-m2|` = 1 (stricter rule applies).
is only non-zero if `|l1-l2|` is odd and `|m1-m2|` = 1
(stricter rule applies).
"""
if abs(l1 - l2) % 2 != 1 or abs(m1 - m2) != 1:
return 0.0
......@@ -270,11 +273,12 @@ def intYdYdphi_ey(l1, m1, l2, m2):
pi 2pi
/ / * -1 d Y(u,v)
A = | | Y (u,v) sin(u)*cos(v) --- l'm' sin(u) dv du
LL' / / lm dv
LL' / / lm dv
0 0
where u = theta and v = phi in the usual notation. Note that the result
is only non-zero if `|l1-l2|` is odd and `|m1-m2|` = 1 (stricter rule applies).
is only non-zero if `|l1-l2|` is odd and `|m1-m2|` = 1
(stricter rule applies).
"""
if abs(l1 - l2) % 2 != 1 or abs(m1 - m2) != 1:
return 0.0
......
This diff is collapsed.
# flake8: noqa
import numpy as np
from gpaw.sphere import lmfact
......
# flake8: noqa
import numpy as np
from gpaw.sphere import lmfact
......
......@@ -145,7 +145,7 @@ YL = [# s:
[(1, (6, 0, 1)), (-1, (0, 6, 1)), (-15, (4, 2, 1)), (15, (2, 4, 1))],
[(1, (7, 0, 0)), (-21, (5, 2, 0)), (35, (3, 4, 0)), (-7, (1, 6, 0))]]
norms = ['sqrt(1./4/pi)', 'sqrt(3./4/pi)', 'sqrt(3./4/pi)', 'sqrt(3./4/pi)', 'sqrt(15./4/pi)', 'sqrt(15./4/pi)', 'sqrt(5./16/pi)', 'sqrt(15./4/pi)', 'sqrt(15./16/pi)', 'sqrt(35./32/pi)', 'sqrt(105./4/pi)', 'sqrt(21./32/pi)', 'sqrt(7./16/pi)', 'sqrt(21./32/pi)', 'sqrt(105./16/pi)', 'sqrt(35./32/pi)', 'sqrt(315./16/pi)', 'sqrt(315./32/pi)', 'sqrt(45./16/pi)', 'sqrt(45./32/pi)', 'sqrt(9./256/pi)', 'sqrt(45./32/pi)', 'sqrt(45./64/pi)', 'sqrt(315./32/pi)', 'sqrt(315./256/pi)', 'sqrt(693./512/pi)', 'sqrt(3465./16/pi)', 'sqrt(385./512/pi)', 'sqrt(1155./16/pi)', 'sqrt(165./256/pi)', 'sqrt(11./256/pi)', 'sqrt(165./256/pi)', 'sqrt(1155./64/pi)', 'sqrt(385./512/pi)', 'sqrt(3465./256/pi)', 'sqrt(693./512/pi)', 'sqrt(3003./512/pi)', 'sqrt(9009./512/pi)', 'sqrt(819./64/pi)', 'sqrt(1365./512/pi)', 'sqrt(1365./512/pi)', 'sqrt(273./256/pi)', 'sqrt(13./1024/pi)', 'sqrt(273./256/pi)', 'sqrt(1365./2048/pi)', 'sqrt(1365./512/pi)', 'sqrt(819./1024/pi)', 'sqrt(9009./512/pi)', 'sqrt(3003./2048/pi)', 'sqrt(6435./4096/pi)', 'sqrt(45045./512/pi)', 'sqrt(3465./4096/pi)', 'sqrt(3465./64/pi)', 'sqrt(315./4096/pi)', 'sqrt(315./512/pi)', 'sqrt(105./4096/pi)', 'sqrt(15./1024/pi)', 'sqrt(105./4096/pi)', 'sqrt(315./2048/pi)', 'sqrt(315./4096/pi)', 'sqrt(3465./1024/pi)', 'sqrt(3465./4096/pi)', 'sqrt(45045./2048/pi)', 'sqrt(6435./4096/pi)']
norms = ['sqrt(1./4/pi)', 'sqrt(3./4/pi)', 'sqrt(3./4/pi)', 'sqrt(3./4/pi)', 'sqrt(15./4/pi)', 'sqrt(15./4/pi)', 'sqrt(5./16/pi)', 'sqrt(15./4/pi)', 'sqrt(15./16/pi)', 'sqrt(35./32/pi)', 'sqrt(105./4/pi)', 'sqrt(21./32/pi)', 'sqrt(7./16/pi)', 'sqrt(21./32/pi)', 'sqrt(105./16/pi)', 'sqrt(35./32/pi)', 'sqrt(315./16/pi)', 'sqrt(315./32/pi)', 'sqrt(45./16/pi)', 'sqrt(45./32/pi)', 'sqrt(9./256/pi)', 'sqrt(45./32/pi)', 'sqrt(45./64/pi)', 'sqrt(315./32/pi)', 'sqrt(315./256/pi)', 'sqrt(693./512/pi)', 'sqrt(3465./16/pi)', 'sqrt(385./512/pi)', 'sqrt(1155./16/pi)', 'sqrt(165./256/pi)', 'sqrt(11./256/pi)', 'sqrt(165./256/pi)', 'sqrt(1155./64/pi)', 'sqrt(385./512/pi)', 'sqrt(3465./256/pi)', 'sqrt(693./512/pi)', 'sqrt(3003./512/pi)', 'sqrt(9009./512/pi)', 'sqrt(819./64/pi)', 'sqrt(1365./512/pi)', 'sqrt(1365./512/pi)', 'sqrt(273./256/pi)', 'sqrt(13./1024/pi)', 'sqrt(273./256/pi)', 'sqrt(1365./2048/pi)', 'sqrt(1365./512/pi)', 'sqrt(819./1024/pi)', 'sqrt(9009./512/pi)', 'sqrt(3003./2048/pi)', 'sqrt(6435./4096/pi)', 'sqrt(45045./512/pi)', 'sqrt(3465./4096/pi)', 'sqrt(3465./64/pi)', 'sqrt(315./4096/pi)', 'sqrt(315./512/pi)', 'sqrt(105./4096/pi)', 'sqrt(15./1024/pi)', 'sqrt(105./4096/pi)', 'sqrt(315./2048/pi)', 'sqrt(315./4096/pi)', 'sqrt(3465./1024/pi)', 'sqrt(3465./4096/pi)', 'sqrt(45045./2048/pi)', 'sqrt(6435./4096/pi)'] # noqa
# End of computer generated code
Lmax = len(norms)
......
......@@ -217,9 +217,11 @@ class TDDFT(GPAW):
self.td_hamiltonian, self.td_overlap, self.solver,
self.preconditioner, wfs.gd, self.timer, **propagator_kwargs)
elif propagator.startswith('SITE') or propagator.startswith('SIKE'):
raise DeprecationWarning('Use propagator_kwargs to specify degree.')
raise DeprecationWarning(
'Use propagator_kwargs to specify degree.')
else:
raise RuntimeError('Time propagator %s not supported.' % propagator)
raise RuntimeError(
'Time propagator %s not supported.' % propagator)
if self.rank == 0:
if wfs.kd.comm.size > 1:
......
......@@ -73,7 +73,7 @@ class LinearAbsorbingBoundary(DummyAbsorbingBoundary):
assert gd.orthogonal
#self.v_imag = np.zeros((gd.n_c[0],gd.n_c[1],gd.n_c[2]),dtype=complex)
# self.v_imag = np.zeros((gd.n_c[0],gd.n_c[1],gd.n_c[2]),dtype=complex)
self.v_imag = gd.zeros(dtype=complex)
# If positions array wasn't given, uses the middle point of the grid.
......@@ -104,7 +104,7 @@ class LinearAbsorbingBoundary(DummyAbsorbingBoundary):
if r > self.abc_r:
self.v_imag[i][j][k] = \
-(0+1j) * self.abc_strength*(r-self.abc_r)
-(0 + 1j) * self.abc_strength * (r - self.abc_r)
class P4AbsorbingBoundary(DummyAbsorbingBoundary):
......@@ -144,7 +144,7 @@ class P4AbsorbingBoundary(DummyAbsorbingBoundary):
def set_up(self, gd):
#self.v_imag = np.zeros((gd.n_c[0],gd.n_c[1],gd.n_c[2]),dtype=complex)
# self.v_imag = np.zeros((gd.n_c[0],gd.n_c[1],gd.n_c[2]),dtype=complex)
self.v_imag = gd.zeros(dtype=complex)
# If positions array wasn't given, uses the middle point of the
......@@ -179,14 +179,15 @@ class P4AbsorbingBoundary(DummyAbsorbingBoundary):
if r > self.abc_r:
if r < self.abc_r + self.width:
self.v_imag[i][j][k] = (0+1j) \
* ((np.sqrt(self.abc_strength) -
np.sqrt(self.abc_strength)/self.width**2
* (r-self.abc_r)**2)**2 - self.abc_strength)
self.v_imag[i][j][k] = (
(0 + 1j) *
((np.sqrt(self.abc_strength) -
np.sqrt(self.abc_strength) / self.width**2
* (r - self.abc_r)**2)**2 -
self.abc_strength))
else:
self.v_imag[i][j][k] = -self.abc_strength * (0 +
1j)
#print i, j, k, self.v_imag[i][j][k]
class PML:
......@@ -266,8 +267,12 @@ class PML:
if r > self.abc_range:
self.G[i][j][k] = (1.0 + R * self.abc_strength *
(r - self.abc_range)**2)**-1.0
self.dG[0][i][j][k] = \
-(1.0+R*self.abc_strength*(r-self.abc_range)**2.0)**-2.0*2.0*R*self.abc_strength*(r-self.abc_range)*(x-r0[0])/r
self.dG[0][i][j][k] = (
-(1.0 + R *
self.abc_strength *
(r - self.abc_range)**2.0)**-2.0 * 2.0 * R *
self.abc_strength * (r - self.abc_range) *
(x - r0[0]) / r)
self.dG[1][i][j][k] = -(
1.0 + R * self.abc_strength *
......
# flake8: noqa
# Written by Lauri Lehtovaara, 2008
"""This module defines BiCGStab-class, which implements biconjugate
gradient stabilized method. Requires Numpy and GPAW's own BLAS."""
......
......@@ -55,7 +55,9 @@ class CSCG:
if ( eps <= tolerance ):
self.eps = eps
else:
raise RuntimeError("CSCG method got invalid tolerance (tol = %le < eps = %le)." % (tolerance,eps))
raise RuntimeError(
"CSCG method got invalid tolerance (tol = %le < eps = %le)." %
(tolerance,eps))
self.iterations = -1
......@@ -120,7 +122,10 @@ class CSCG:
# if scale < eps, then convergence check breaks down
if (scale < self.eps).any():
raise RuntimeError("CSCG method detected underflow for squared norm of right-hand side (scale = %le < eps = %le)." % (scale, self.eps))
raise RuntimeError(
"CSCG method detected underflow for squared norm of "
"right-hand side (scale = %le < eps = %le)." %
(scale, self.eps))
#print 'Scale = ', scale
......@@ -145,7 +150,10 @@ class CSCG:
# if abs(beta) / scale < eps, then CSCG breaks down
if ( (i > 0) and
((np.abs(beta) / scale) < self.eps).any() ):
raise RuntimeError("Conjugate gradient method failed (abs(beta)=%le < eps = %le)." % (np.min(np.abs(beta)),self.eps))
raise RuntimeError(
"Conjugate gradient method failed "
"(abs(beta)=%le < eps = %le)." %
(np.min(np.abs(beta)),self.eps))