polarizability for neo#19
Conversation
…n calculate neo polarizability
zc62
left a comment
There was a problem hiding this comment.
See comments. In addition to these comments, have a look at GitHub CI error messages, especially lint. Linter must pass. You have many trailing whitespaces, which can be easily seen if you run git diff --check before you commit.
| def polarizability(mf): | ||
| 'polarizability in CNEO' | ||
|
|
||
| def polarizability(polobj,with_cphf=True): |
| mo_energy = mf.mo_energy | ||
| mo_coeff = mf.mo_coeff | ||
| mo_occ = mf.mo_occ | ||
| #orbv = mo_coeff[:,~occidx] |
There was a problem hiding this comment.
Delete these four lines as they are irrelevant
There was a problem hiding this comment.
I think only 54 is irrelevant mo energy coefficient and occ are used later?
| with comp.mol.with_common_orig(charge_center): | ||
| int1e_r = comp.mol.intor_symmetric('int1e_r', comp=3) | ||
| occidx = mo_occ[t] > 0 | ||
| mocc = mo_coeff[t][:, occidx] |
There was a problem hiding this comment.
Make name consistent with pyscf prop, this should be orbo
| int1e_r = comp.mol.intor_symmetric('int1e_r', comp=3) | ||
| occidx = mo_occ[t] > 0 | ||
| mocc = mo_coeff[t][:, occidx] | ||
| h1[t] = lib.einsum('xuv, ui, vj -> xij', int1e_r, mo_coeff[t], mocc) * comp.charge |
There was a problem hiding this comment.
'xuv, ui, vj -> xij' is perhaps from some old code, should be 'xpq,pi,qj->xij' in pyscf prop and in the previous version.
| vind = polobj.gen_vind(mf, mo_coeff, mo_occ) | ||
| if with_cphf: | ||
| mo1 = cphf.solve(vind, mo_energy, mo_occ, h1, s1,with_f1=with_f1, | ||
| max_cycle=polobj.max_cycle_cphf,tol=polobj.conv_tol, |
There was a problem hiding this comment.
Add space between s1,with_f1 and ...,tol=
| _keys = {'efield'} | ||
|
|
||
| def __init__(self, mol, *args, **kwargs): | ||
| KS.__init__(self, mol, *args, **kwargs) |
| self.stdout = mol.stdout | ||
| self._scf = mf | ||
|
|
||
| self.with_f1 = True # True for CNEO, False for NEO |
There was a problem hiding this comment.
Why is this constant True? Where is the detection?
| self.with_f1 = True # True for CNEO, False for NEO | ||
| self.max_cycle_cphf = 100 | ||
| ### default: 1e-5 is already enough | ||
| self.conv_tol = 1e-5 |
There was a problem hiding this comment.
How? pyscf prop uses 1e-9. You need to provide evidence.
| nucl_dip = 0 | ||
| for t, comp in self.components.items(): | ||
| if t.startswith('n'): | ||
| nucl_dip -= comp.charge * (lib.einsum('xij,ji->x', comp.mol.intor_symmetric('int1e_r', comp=3), dm[t]) - origin) |
There was a problem hiding this comment.
Instead of this, read class ComponentSCF in hf.py, fix the case for quantum nuclei, then here can call component.dip_moment, just like electronic part.
| mf2.scf() | ||
| dipole2 = mf2.dip_moment(unit='au') | ||
|
|
||
| mf5 = neo.KS(mol,xc='b3lyp') |
|
Also need to change the commit message. Learn from existing ones. A short title line, then an empty line, then details. The title line should be <= 50 characters (space included) and details should wrap the line every 72 characters. Your editor of choice should be automatically wrapping the lines for you. |
|
Lint still failed. You perhaps still did not use |
Polarizability for NEO, add NEO-HF dipole
Extend e_field.py polarizability to a class Polarizability for both NEO and CNEO.
Add dipole momentum to neo.HF class for polarizability finite different test.