Added additional tutorials for the dynamical matrix calculator

This commit is contained in:
casievers
2019-02-11 19:46:22 -08:00
parent 490f67d332
commit 4b8621e7ef
27 changed files with 144 additions and 12 deletions

View File

@ -0,0 +1,39 @@
from ase import Atoms, Atom
from ase.calculators.lammpslib import LAMMPSlib
import numpy as np
import matplotlib.pyplot as plt
from mpi4py import MPI
comm = MPI.COMM_WORLD
rank = comm.Get_rank()
GaAs = Atoms([Atom('Ga', (0.0, 0.0, 0.0)),
Atom('As', (1.413425, 1.413425, 1.413425))],
cell=[(0.0, 2.82685, 2.82685), (2.82685, 0.0, 2.82685), (2.82685, 2.82685, 0.0)],
pbc=True,)
cmds = ["pair_style bop", "pair_coeff * * ../../../../../potentials/GaAs.bop.table Ga As",
"comm_modify cutoff 12"]
mends = ["info system",
"dynamical_matrix all eskm 0.000001 file dynmat.dat binary no",
"neigh_modify delay 0"]
N = 5
GaAs = GaAs.repeat([N, N, N])
lammps = LAMMPSlib(lmpcmds=cmds, atom_types={'Ga': 1, 'As': 2}, amendments=mends, log_file='lammps.log')
GaAs.set_calculator(lammps)
GaAs.get_potential_energy()
if rank == 0:
dynmat = np.loadtxt("dynmat.dat")
dynmat = dynmat.reshape(([int(3*(len(dynmat)/3)**0.5), int(3*(len(dynmat)/3)**0.5)]))
eigv = np.linalg.eigvals(dynmat)
eigv.sort()
eigv = np.sqrt(np.abs(eigv))/(2*np.pi)
plt.hist(eigv, 80)
plt.xlabel('Frequency (THz)')
plt.show()

View File

@ -0,0 +1,39 @@
from ase import Atoms, Atom
from ase.calculators.lammpslib import LAMMPSlib
import numpy as np
import matplotlib.pyplot as plt
from mpi4py import MPI
comm = MPI.COMM_WORLD
rank = comm.Get_rank()
GaN = Atoms([Atom('Ga', (1.59, 0.917986928012, 0.0)),
Atom('Ga', (1.59, -0.917986928012, 2.583)),
Atom('N', (1.59, 0.917986928012, 1.98891)),
Atom('N', (1.59, -0.917986928012, 4.57191))],
cell=[(1.59, -2.75396078403, 0.0), (1.59, 2.75396078403, 0.0), (0.0, 0.0, 5.166)],
pbc=True)
cmds = ["pair_style tersoff", "pair_coeff * * ../../../../../potentials/GaN.tersoff Ga N"]
mends = ["info system",
"dynamical_matrix all eskm 0.000001 file dynmat.dat binary no",
"neigh_modify delay 0"]
N = 6
GaN = GaN.repeat([N, N, N])
lammps = LAMMPSlib(lmpcmds=cmds, atom_types={'Ga': 1, 'N': 2}, amendments=mends, log_file='lammps.log')
GaN.set_calculator(lammps)
GaN.get_potential_energy()
if rank == 0:
dynmat = np.loadtxt("dynmat.dat")
dynmat = dynmat.reshape(([int(3*(len(dynmat)/3)**0.5), int(3*(len(dynmat)/3)**0.5)]))
eigv = np.linalg.eigvals(dynmat)
eigv.sort()
eigv = np.sqrt(np.abs(eigv))/(2*np.pi)
plt.hist(eigv, 80)
plt.xlabel('Frequency (THz)')
plt.show()

View File

@ -0,0 +1,57 @@
from ase import Atoms, Atom
from ase.calculators.lammpslib import LAMMPSlib
import numpy as np
import matplotlib.pyplot as plt
from mpi4py import MPI
comm = MPI.COMM_WORLD
rank = comm.Get_rank()
quartz = Atoms(
[Atom('Si', (1.1545226, -1.99969180169, 0.0)),
Atom('Si', (1.1545226, 1.99969180169, 3.6036)),
Atom('Si', (2.6069548, 2.15247249027e-16, 1.8018)),
Atom('O', (1.6724232, -0.624132037742, 0.64378314)),
Atom('O', (1.6724232, 0.624132037742, 2.9598186618)),
Atom('O', (2.1623026, -2.49695388906, 4.2473849418)),
Atom('O', (3.5392742, 1.13629495821, 1.1580150582)),
Atom('O', (3.5392742, -1.13629495821, 2.4455813382)),
Atom('O', (2.1623026, 2.49695388906, 4.76161686))],
cell=[(2.458, -4.257380885, 0.0), (2.458, 4.257380885, 0.0), (0.0, 0.0, 5.4054)],
pbc=True,
)
# number of repeats
N = 3
quartz = quartz.repeat([N, N, N])
header = ['units metal',
'atom_style charge',
'atom_modify map array sort 0 0']
cmds = ["pair_style buck/coul/long 10.0 8.0",
"pair_coeff 1 1 0 1 0",
"pair_coeff 1 2 18003.7572 0.20520 133.5381",
"pair_coeff 2 2 1388.7730 0.36232 175.0000",
"kspace_style ewald 1.0e-12",
"set type 1 charge 2.4",
"set type 2 charge -1.2"]
mends = ["dynamical_matrix all eskm 0.000001 file dynmat.dat binary no",
"neigh_modify delay 0"]
lammps = LAMMPSlib(lmpcmds=cmds, lammps_header=header, amendments=mends, log_file='lammps.log')
quartz.set_calculator(lammps)
quartz.get_potential_energy()
if rank == 0:
dynmat = np.loadtxt("dynmat.dat")
dynmat = dynmat.reshape(([int(3*(len(dynmat)/3)**0.5), int(3*(len(dynmat)/3)**0.5)]))
eigv = np.linalg.eigvals(dynmat)
eigv.sort()
plt.hist(33*np.sqrt(np.abs(eigv))/(2*np.pi), 80)
plt.xlabel('Frequency (cm-1)')
plt.show()

View File

@ -7,7 +7,7 @@ This directory contains the ingredients to calculate a dynamical matrix.
Example:
```
NP=4 #number of processors
mpirun -np $NP lmp_mpi < in.silicon > out.silicon
mpirun -np $NP lmp_mpi -in in.silicon -out out.silicon
```
To test out a different silicon example:
@ -15,7 +15,7 @@ To test out a different silicon example:
LMP_FILE=amorphous_silicon.lmp
cp lmp_bank/$LMP_FILE ./silicon_input_file.lmp
NP=4 #number of processors
mpirun -np $NP lmp_mpi < in.silicon > out.silicon
mpirun -np $NP lmp_mpi -in in.silicon -out out.silicon
```
## Requires: MANYBODY and MOLECULE packages

View File

@ -8,7 +8,7 @@ Example:
```
$THIRD_ORDER=third_order #tensor output file
NP=4 #number of processors
mpirun -np $NP lmp_mpi < in.silicon > out.silicon
mpirun -np $NP lmp_mpi -in in.silicon -out out.silicon
combine.sh third_order
```
@ -18,7 +18,7 @@ $THIRD_ORDER=third_order
$LMP_FILE=amorphous_silicon.lmp
cp lmp_bank/$LMP_FILE ./silicon_input_file.lmp
NP=4 #number of processors
mpirun -np $NP lmp_mpi < in.silicon > out.silicon
mpirun -np $NP lmp_mpi -in in.silicon -out out.silicon
bash combine.sh $THIRD_ORDER
```

View File

@ -168,13 +168,11 @@ void ThirdOrder::options(int narg, char **arg)
if (narg < 0) error->all(FLERR,"Illegal dynamical_matrix command");
int iarg = 0;
const char *filename = "third_order.txt";
std::stringstream fss;
while (iarg < narg) {
if (strcmp(arg[iarg],"file") == 0) {
if (iarg+2 > narg) error->all(FLERR, "Illegal dynamical_matrix command");
fss << arg[iarg + 1] << me;
filename = fss.str().c_str();
filename = arg[iarg + 1];
file_flag = 1;
iarg += 2;
}
@ -189,7 +187,7 @@ void ThirdOrder::options(int narg, char **arg)
iarg += 2;
} else error->all(FLERR,"Illegal dynamical_matrix command");
}
if (file_flag == 1 and me == 0) {
if (file_flag == 1 && me == 0) {
openfile(filename);
}
}
@ -338,10 +336,9 @@ void ThirdOrder::writeMatrix(double *dynmat, int i, int a, int j, int b)
if (!binaryflag && fp) {
clearerr(fp);
for (int k = 0; k < gcount; k++){
double norm = pow(dynmat[k*3], 2)
+ pow(dynmat[k*3+1], 2)
+ pow(dynmat[k+3+2], 2);
if (norm > 1.0e-16)
if (dynmat[k*3] > 1.0e-16
&& dynmat[k*3+1] > 1.0e-16
&& dynmat[k*3+2] > 1.0e-16)
fprintf(fp,
"%d %d %d %d %d %7.8f %7.8f %7.8f\n",
i+1, a + 1, j+1, b + 1, groupmap[k]+1,