pekkosk / hotbit

ASE density-functional tight-binding calculator
GNU General Public License v2.0
63 stars 35 forks source link

Repulsion Fitting in hotbit #20

Open sh-pan opened 6 years ago

sh-pan commented 6 years ago

Hi there, I am using hotbit for parametrization of Cu-M (where M is another transition metal). I am able to get the .elm and Slako tables with no repulsion. However, when I try the fourth step of repulsion fitting, I end up with the following error.

" Fitting repulsion curve between Cu and Cu

Adding a scalable system ['Cu', 'Cu'] with 1 bonds at R=2.4900.

Appending energy curve data from dimer_curve.traj... Traceback (most recent call last): File "CuCu-repfit.py", line 37, in rep.append_energy_curve(weight=1.0,calc=calc0,traj='dimer_curve.traj',comment='dimer curve') File "/home/sha/hotbit/hotbit/parametrization/fitting.py", line 554, in append_energy_curve traj = Trajectory(traj) File "/home/sha/ase/ase/io/trajectory.py", line 48, in Trajectory return TrajectoryReader(filename) File "/home/sha/ase/ase/io/trajectory.py", line 217, in init self._open(filename) File "/home/sha/ase/ase/io/trajectory.py", line 222, in _open self.backend = ulm.open(filename, 'r') File "/home/sha/ase/ase/io/ulm.py", line 78, in open return Reader(filename, index or 0) File "/home/sha/ase/ase/io/ulm.py", line 346, in init fd = builtins.open(fd, 'rb') IOError: [Errno 2] No such file or directory: 'dimer_curve.traj'

" I am not sure what is going wrong. Could someone help me solve this error?

Thanks Sha

pekkosk commented 6 years ago

Have you made a dimer curve for Cu-Cu (using DFT, say)? And the file resides in the present folder?

sh-pan commented 6 years ago

Hi Pekkosk, Thanks for theimmediate reply. The dimer_curve.traj file was in a different folder, which was then changed to the present folder. Now, when I try the same for a cluster, appending energy curve data (homogeneous cluster-similar to Au12, as Au is 5d10 6s1 and Cu is 3d10 4s1), I end up with the following:

">>> rep.append_homogeneous_cluster(weight=1.0,calc=calc2,atoms='Cu12-.xyz') No forces (equilibrium cluster) /home/sha/hotbit/hotbit/containers/bravais.py:28: RuntimeWarning: invalid value encountered in double_scalars a12 = np.dot(cell[0],cell[1])/(d[0]d[1]) /home/sha/hotbit/hotbit/containers/bravais.py:29: RuntimeWarning: invalid value encountered in double_scalars a13 = np.dot(cell[0],cell[2])/(d[0]d[2]) /home/sha/hotbit/hotbit/containers/bravais.py:30: RuntimeWarning: invalid value encountered in double_scalars a23 = np.dot(cell[1],cell[2])/(d[1]*d[2]) Traceback (most recent call last): File "", line 1, in File "/home/sha/hotbit/hotbit/parametrization/fitting.py", line 638, in append_homogeneous_cluster print("\nAppending homogeneous cluster %s..." % atoms.get_name(), file=self.txt) AttributeError: 'Atoms' object has no attribute 'get_name' "

As given in the example, I use the optimised structure (.xyz). Any thoughts on this will be very helpful.

pekkosk commented 6 years ago

Yes, reference to get_name was obsolete; I removed it.

sh-pan commented 6 years ago

Hi Pekkosk, Thanks for the update. Now, while appending the energy curve, it complains about the operand type: "Fitting repulsion curve between Cu and Cu No forces (equilibrium cluster) /home/sha/hotbit/hotbit/containers/bravais.py:28: RuntimeWarning: invalid value encountered in double_scalars a12 = np.dot(cell[0],cell[1])/(d[0]d[1]) /home/sha/hotbit/hotbit/containers/bravais.py:29: RuntimeWarning: invalid value encountered in double_scalars a13 = np.dot(cell[0],cell[2])/(d[0]d[2]) /home/sha/hotbit/hotbit/containers/bravais.py:30: RuntimeWarning: invalid value encountered in double_scalars a23 = np.dot(cell[1],cell[2])/(d[1]*d[2])

Appending homogeneous cluster. Optimization terminated successfully. Current function value: 32.568514 Iterations: 67 Function evaluations: 130 Cluster: V_rep(R)=4.092108 + 8.026017 (r-3.30) Traceback (most recent call last): File "CuCu-repfit.py", line 39, in rep.append_homogeneous_cluster(weight=1.0,calc=calc2,atoms='Cu12-.xyz') File "/home/sha/hotbit/hotbit/parametrization/fitting.py", line 639, in append_homogeneous_cluster com += ';w=%.1f' %weight TypeError: unsupported operand type(s) for +=: 'NoneType' and 'str' "

Moreover, I am trying to model Cu bulk / thin films. I came across the JPCA paper on SCC-DFTB parametrization for Pt-Ru alloys. It was mentioned in the paper that, inclusion of bulk data in the training set affects the accuracy for clusters and hence was not included. So in my case, is it wise to include cluster data (for repulsion fitting) for parametrization of bulk/thin films? Or should I do the fit with all the values and then decide on it?

Thanks for the suggestion.

pekkosk commented 6 years ago

I suspect your arguments are ordered wrong or something. And perhaps the volume of the cell is zero?

You should include everything in the initial fit and then (at the expense of losing transferability) start dropping certain structures if the situation seems to call for that.

sh-pan commented 6 years ago

Hi Pekkosk

"tab={'CuCu':'Cu_Cu_no_repulsion.par'} elm={'Cu':'Cu.elm'} mixer={'name':'Anderson','mixing_constant':0.1,'convergence':1E-9} calc2 = Hotbit(txt='-',elements=elm,mixer=mixer,tables=tab,SCC=True,charge=0) rep = RepulsiveFitting('Cu','Cu',r_cut=3.3,s=1.0) rep.append_homogeneous_cluster(weight=1.0,calc=calc2,atoms='Cu16.xyz') rep.fit() rep.add_comment('Repulsion by Pekka Koskinen') rep.write_par('Cu_Cu_no_repulsion.par',filename='Cu_Cu_repulsion.par') rep.plot('CuCu_repulsion.pdf') "

This is the part of the repfit.py script I used which gave me the above error (in previous comment). The Cu16 is a homogenous cluster which was geometry relaxed using VASP with a neutral charge and with a supercell of 20 20 20 along the xyz. I feed in the converged geometry (Cu16.xyz) in the script. Not sure where I am missing what. Your suggestions with this regard will be very helpful.

Thanks

pekkosk commented 6 years ago

There was a but related to commenting, which I corrected, so it might work now.

sh-pan commented 6 years ago

Thank you Pekkosk. It worked now.

sh-pan commented 6 years ago

Hi Pekkosk This is in continuation with the repulsion fitting for Cu clusters. I have couple of issues as mentioned below:

1) I keep getting this warning on "invalid value encountered in double scalars" when i try to append homogeneous cluster

Adding a scalable system ['Cu'] with 12 bonds at R=2.5456. No forces (equilibrium cluster) /home/sha/hotbit/hotbit/containers/bravais.py:28: RuntimeWarning: invalid value encountered in double_scalars a12 = np.dot(cell[0],cell[1])/(d[0]d[1]) /home/sha/hotbit/hotbit/containers/bravais.py:29: RuntimeWarning: invalid value encountered in double_scalars a13 = np.dot(cell[0],cell[2])/(d[0]d[2]) /home/sha/hotbit/hotbit/containers/bravais.py:30: RuntimeWarning: invalid value encountered in double_scalars a23 = np.dot(cell[1],cell[2])/(d[1]*d[2])

2) When i try to append a cluster of 30 Cu atoms, i get the warning of "Out of iterations"

Appending homogeneous cluster. Traceback (most recent call last): File "CuCu-repfit.py", line 41, in rep.append_homogeneous_cluster(weight=1.0,calc=calc2,atoms='Cu38-min.xyz') File "/home/sha/hotbit/hotbit/parametrization/fitting.py", line 601, in append_homogeneous_cluster f_wr = atoms.get_forces() File "/home/sha/ase/ase/atoms.py", line 734, in get_forces forces = self._calc.get_forces(self) File "/home/sha/hotbit/hotbit/aseinterface.py", line 477, in get_forces self.solve_ground_state(atoms) File "/home/sha/hotbit/hotbit/aseinterface.py", line 394, in solve_ground_state self.st.solve() File "/home/sha/hotbit/hotbit/states.py", line 207, in solve self.e, self.wf = self.solver.get_states(self.calc,dq,self.H0,self.S) File "/home/sha/hotbit/hotbit/solver.py", line 97, in get_states raise RuntimeError('Out of iterations.') RuntimeError: Out of iterations.

How can I increase the number of iterations? The xyz I provide is vasp optimized. Is it just the optimized xyz or the energies along with it for repulsion fitting?

Your suggestions will be of great help. Thanks

pekkosk commented 6 years ago
  1. Have you defined a cell for your cluster? (Looks like you're dividing by zero. This might be the case it the default Atoms cell is used.)
  2. By parameter maxiter. You can also define a mixer (e.g. mixer={'name':'Anderson','mixing_constant':0.05, 'memory':5}')
sh-pan commented 6 years ago

Hi Pekkosk, The maxiter option worked. One more thing....

How do I include the DFT forces for the homogenous cluster in the code for it to append and fit the repulsion potential? Currently, I am only providing the Vasp relaxed xyz (which is an equilibrium geometry with zero forces). How to include distorted geometries (expanded and shrinked bond lengthed cluster?)

pekkosk commented 6 years ago

The DFT forces are already inside the atoms-object given as an argument.

If you want to expand and shrink bonds, then the append_energy_curve is better. The append_homogeneous_cluster should be used rather cautiously (as it assumes the bond length differences to be sufficiently small).

sh-pan commented 6 years ago

Thanks for the reply Pekkosk. I somehow couldn't figure out the argument that calls for DFT-forces. Is it possible to read the DFT forces of each atom in a cluster while fitting repulsion potential? All i provide is this rep.append_homogeneous_cluster(weight=1.0,calc=calc2,atoms='Cu16.xyz')

and get

Appending homogeneous cluster. Optimization terminated successfully. Current function value: 80.768797 Iterations: 75 Function evaluations: 145 Cluster: V_rep(R)=29.063954 + 38.198862 (r-3.30) No forces (equilibrium cluster)

pekkosk commented 6 years ago

Cu16.xyz is here used as a cluster in equilibrium, which is presumably ok. In my opinion, it's neither practical nor sensible to read DFT forces while fitting the repulsion.

sh-pan commented 6 years ago

Ok. I was wondering what does "f_DFT = atoms.get_forces()" do?

pekkosk commented 6 years ago

Here the energies and forces in the atoms-object have been calculated with DFT (or similar method), so f_DFT then represent the "correct" forces for given geometry.

sh-pan commented 6 years ago

Ok. Thanks for the explanation. Is there a way to use "append_energy_curve" for shrinking and expanding bond lengths in a cluster, by adding atoms parameter?

pekkosk commented 6 years ago

I don't understand your question. "append_energy_curve", like most other appending methods, just use pre-calculated trajectories, but don't modify them.