Skip to content

Commit

Permalink
upload elastic
Browse files Browse the repository at this point in the history
  • Loading branch information
Chentao168 committed Jun 3, 2024
1 parent 2fd8fc0 commit e8c619c
Show file tree
Hide file tree
Showing 86 changed files with 4,944 additions and 68 deletions.
2 changes: 1 addition & 1 deletion _book/abacus-candela.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion _book/abacus-conv.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion _book/abacus-dcu.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion _book/abacus-dos.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion _book/abacus-dpgen.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion _book/abacus-gcc.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion _book/abacus-gpu.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion _book/abacus-hpc.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion _book/abacus-intel.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion _book/abacus-libri.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion _book/abacus-md.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion _book/abacus-nac1.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion _book/abacus-nac2.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion _book/abacus-nac3.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion _book/abacus-namd.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion _book/abacus-ofdft.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion _book/abacus-phonopy.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion _book/abacus-pw.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion _book/abacus-question.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion _book/abacus-sdft.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion _book/abacus-shengbte.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion _book/abacus-sol.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion _book/abacus-surface1.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion _book/abacus-surface2.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion _book/abacus-surface3.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion _book/abacus-surface4.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion _book/abacus-surface5.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion _book/abacus-surface6.html

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions _book/abacus-upf.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion _book/abacus-uspex.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion _book/abacus-wannier.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion _book/algorithm-delta.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion _book/algorithm-mix.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion _book/algorithm-wannier.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion _book/contribute.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion _book/develop-C++.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion _book/develop-addinp.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion _book/develop-design.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion _book/develop-dox.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion _book/develop-format.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion _book/develop-input.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion _book/develop-issue.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion _book/develop-linedete.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion _book/develop-path1.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion _book/develop-path10.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion _book/develop-path11.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion _book/develop-path2.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion _book/develop-path3.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion _book/develop-path4.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion _book/develop-path5.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion _book/develop-path6.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion _book/develop-path7.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion _book/develop-path8.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion _book/develop-path9.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion _book/develop-rule.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion _book/develop-sm1.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion _book/develop-sm2.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion _book/develop-test1.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion _book/develop-test2.html

Large diffs are not rendered by default.

1,224 changes: 1,224 additions & 0 deletions _book/examples/elastic/C_ONCV_PBE-1.0.upf

Large diffs are not rendered by default.

903 changes: 903 additions & 0 deletions _book/examples/elastic/C_gga_7au_100Ry_2s2p1d.orb

Large diffs are not rendered by default.

24 changes: 24 additions & 0 deletions _book/examples/elastic/INPUT
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
INPUT_PARAMETERS
#Parameters (1.General)
suffix C8
calculation relax
esolver_type ksdft
symmetry 1
pseudo_dir ../
orbital_dir ../
cal_stress 1
cal_force 1
#Parameters (2.Iteration)
ecutwfc 100
scf_thr 1e-7
scf_nmax 50
#Parameters (3.Basis)
basis_type lcao
# kpar 8
gamma_only 0
#Parameters (4.Smearing)
smearing_method gaussian
smearing_sigma 0.002
#Parameters (5.Mixing)
mixing_type broyden
mixing_beta 0.7
4 changes: 4 additions & 0 deletions _book/examples/elastic/KPT
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
K_POINTS
0
MP
14 14 14 0 0 0
110 changes: 110 additions & 0 deletions _book/examples/elastic/compute_dfm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
from monty.serialization import loadfn, dumpfn
from pymatgen.analysis.elasticity.elastic import ElasticTensor
from pymatgen.analysis.elasticity.stress import Stress
import glob, os, sys
import numpy as np

def get_stress_vasp(lines: str) -> np.ndarray[3, 3]:
stress = np.zeros([3,3])
for line in lines:
if "in kB" in line:
stress_xx = float(line.split()[2])
stress_yy = float(line.split()[3])
stress_zz = float(line.split()[4])
stress_xy = float(line.split()[5])
stress_yz = float(line.split()[6])
stress_zx = float(line.split()[7])
stress[0] = [stress_xx, stress_xy, stress_zx]
stress[1] = [stress_xy, stress_yy, stress_yz]
stress[2] = [stress_zx, stress_yz, stress_zz]
return stress

def get_stress_abacus(lines: str) -> np.ndarray[3, 3]:
stress = np.zeros([3,3])
for idx, line in enumerate(lines):
if "TOTAL-STRESS (KBAR)" in line:
stress_xx = float(lines[idx+2].split()[0])
stress_yy = float(lines[idx+3].split()[1])
stress_zz = float(lines[idx+4].split()[2])
stress_xy = float(lines[idx+2].split()[1])
stress_yz = float(lines[idx+3].split()[2])
stress_zx = float(lines[idx+2].split()[2])
stress[0] = [stress_xx, stress_xy, stress_zx]
stress[1] = [stress_xy, stress_yy, stress_yz]
stress[2] = [stress_zx, stress_yz, stress_zz]
return stress

try:
run_type = sys.argv[1]
except:
print("Usage: python compute_dfm.py [abacus|vasp]")
sys.exit(1)

if run_type == "abacus":
OUTCAR = "OUT.*/running_*.log"
elif run_type == "vasp":
OUTCAR = "OUTCAR"

cwd = os.getcwd()
# print(cwd)

# equi_stress
equi = glob.glob(os.path.join(cwd, "relax/", OUTCAR))[0]
# print(equi)
with open(equi, "r") as fin:
lines = fin.read().split("\n")
if run_type == "abacus":
equi_stress = Stress(get_stress_abacus(lines) * (-1000))
elif run_type == "vasp":
equi_stress = Stress(get_stress_vasp(lines) * (-1000))
# print(equi_stress)


# read all the task dir
task_dirs = glob.glob("task.*")
lst_strain = []
lst_stress = []
for ii in task_dirs:
os.chdir(os.path.join('./', ii))

strain = loadfn("strain.json")
# print(strain, strain.shape)

stress = np.zeros([3,3])
OUTCAR = glob.glob(OUTCAR)[0]
with open(OUTCAR, "r") as fin:
lines = fin.read().split("\n")
if run_type == "abacus":
stress = get_stress_abacus(lines)
elif run_type == "vasp":
stress = get_stress_vasp(lines)
# print(stress, stress.shape)
os.chdir(cwd)
lst_strain.append(strain)
lst_stress.append(Stress(stress * (-1000)))

# print(lst_strain)
et = ElasticTensor.from_independent_strains(lst_strain, lst_stress, eq_stress=equi_stress, vasp=False)

res_data = {}
ptr_data = '# Elastic Constants in GPa\n'
res_data["elastic_tensor"] = []
for ii in range(6):
for jj in range(6):
res_data["elastic_tensor"].append(et.voigt[ii][jj] / 1e4)
ptr_data += "%7.2f " % (et.voigt[ii][jj] / 1e4)
ptr_data += "\n"
BV = et.k_voigt / 1e4
GV = et.g_voigt / 1e4
EV = 9 * BV * GV / (3 * BV + GV)
uV = 0.5 * (3 * BV - 2 * GV) / (3 * BV + GV)
res_data["BV"] = BV
res_data["GV"] = GV
res_data["EV"] = EV
res_data["uV"] = uV
ptr_data += "# Bulk Modulus BV = %.2f GPa\n" % BV
ptr_data += "# Shear Modulus GV = %.2f GPa\n" % GV
ptr_data += "# Youngs Modulus EV = %.2f GPa\n" % EV
ptr_data += "# Poission Ratio uV = %.2f " % uV
print(ptr_data)
dumpfn(res_data, "elastic.json", indent=4)
96 changes: 96 additions & 0 deletions _book/examples/elastic/gene_dfm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
from pymatgen.core.structure import Structure
from pymatgen.analysis.elasticity.elastic import Strain
from pymatgen.analysis.elasticity.strain import DeformedStructureSet
import os, sys, dpdata, glob
from monty.serialization import dumpfn

try:
run_type = sys.argv[1]
except:
print("Usage: python gene_dfm.py [abacus|vasp]")
sys.exit(1)

cwd = os.getcwd()
path_to_equi = os.path.join(cwd, 'relax')

if run_type == "abacus":
CONTCAR = os.path.join('OUT.*', 'STRU_ION_D')
POSCAR = "STRU"
INCAR = "INPUT"
KPOINTS = "KPT"
elif run_type == "vasp":
CONTCAR = "CONTCAR"
POSCAR = "POSCAR"
INCAR = "INCAR"
KPOINTS = "KPOINTS"

# print(CONTCAR)
equi_contcar = glob.glob(os.path.join(path_to_equi, CONTCAR))[0]
# print(equi_contcar)
if not os.path.exists(equi_contcar):
raise RuntimeError("Please do relaxation first!")

if run_type == "abacus":
stru = dpdata.System(equi_contcar, fmt = "stru")
stru.to("poscar", "POSCAR.tmp")
ss = Structure.from_file("POSCAR.tmp")
os.remove("POSCAR.tmp")
elif run_type == "vasp":
ss = Structure.from_file(equi_contcar)

norm_strains = [-0.010, -0.005, 0.005, 0.010]
shear_strains = [-0.010, -0.005, 0.005, 0.010]

dfm_ss = DeformedStructureSet(ss, symmetry=False, norm_strains=norm_strains, shear_strains=shear_strains)
# print(dfm_ss)
n_dfm = len(dfm_ss)

print("gen with norm " + str(norm_strains))
print("gen with shear " + str(shear_strains))
for ii in range(n_dfm):
output_task = os.path.join('./', "task.%03d" % ii)
os.makedirs(output_task, exist_ok=True)
os.chdir(output_task)
dfm_ss.deformed_structures[ii].to("POSCAR", fmt = "POSCAR")
if run_type == "abacus":
stru = dpdata.System("POSCAR", fmt="vasp/poscar")
n_atoms = len(stru["atom_names"])
atom_mass = []
pseudo = []
orb = []
with open(equi_contcar, "r") as f:
lines = f.readlines()
for idx, line in enumerate(lines):
if "ATOMIC_SPECIES" in line:
for i in range(n_atoms):
atom_mass.append(float(lines[idx+i+1].split()[1]))
pseudo.append(lines[idx+i+1].split()[2])
if "NUMERICAL_ORBITAL" in line:
for i in range(n_atoms):
orb.append(lines[idx+i+1])
if orb == []:
stru.to("stru", "STRU", mass=atom_mass, pp_file=pseudo)
else:
stru.to("stru", "STRU", mass=atom_mass, pp_file=pseudo, numerical_orbital=orb)
os.remove("POSCAR")
os.system("cp ../{} .".format(INCAR))
if run_type == "abacus":
with open(INCAR, "r") as f:
lines = f.readlines()
pseudo_dir = "../"
orb_dir = "../"
for line in lines:
if 'pseudo_dir' in line:
if pseudo_dir != line.split()[1].strip():
line = line.replace(line, 'pseudo_dir ' + pseudo_dir)
if 'orb_dir' in line:
if orb_dir != line.split()[1].strip():
line = line.replace(line, 'orb_dir ' + orb_dir)
with open(INCAR, "w") as f:
f.writelines(lines)
os.system("cp ../{} .".format(KPOINTS))
if run_type == "vasp":
os.system("cp ../POTCAR .")
df = Strain.from_deformation(dfm_ss.deformations[ii])
dumpfn(df.as_dict(), "strain.json", indent=4)
os.chdir(cwd)
24 changes: 24 additions & 0 deletions _book/examples/elastic/relax/INPUT
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
INPUT_PARAMETERS
#Parameters (1.General)
suffix C8
calculation relax
esolver_type ksdft
symmetry 1
pseudo_dir ../
orbital_dir ../
cal_stress 1
cal_force 1
#Parameters (2.Iteration)
ecutwfc 100
scf_thr 1e-7
scf_nmax 50
#Parameters (3.Basis)
basis_type lcao
# kpar 8
gamma_only 0
#Parameters (4.Smearing)
smearing_method gaussian
smearing_sigma 0.002
#Parameters (5.Mixing)
mixing_type broyden
mixing_beta 0.7
4 changes: 4 additions & 0 deletions _book/examples/elastic/relax/KPT
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
K_POINTS
0
MP
14 14 14 0 0 0
29 changes: 29 additions & 0 deletions _book/examples/elastic/relax/STRU
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
ATOMIC_SPECIES
C 12.011 C_ONCV_PBE-1.0.upf upf201

NUMERICAL_ORBITAL
C_gga_7au_100Ry_2s2p1d.orb

LATTICE_CONSTANT
1.889726

LATTICE_VECTORS
3.5736050709821550 0.0000000000000000 0.0000000000000000
0.0000000000000000 3.5736050709821550 0.0000000000000000
0.0000000000000000 0.0000000000000000 3.5736050709821550

ATOMIC_POSITIONS
Direct

C #label
0 #magnetism
8 #number of atoms
0.2500000000000000 0.2500000000000000 0.2500000000000000
0.0000000000000000 0.0000000000000000 0.0000000000000000
0.2500000000000000 0.7500000000000000 0.7500000000000000
0.0000000000000000 0.5000000000000000 0.5000000000000000
0.7500000000000000 0.2500000000000000 0.7500000000000000
0.5000000000000000 0.0000000000000000 0.5000000000000000
0.7500000000000000 0.7500000000000000 0.2500000000000000
0.5000000000000000 0.5000000000000000 0.0000000000000000

4 changes: 4 additions & 0 deletions _book/examples/elastic/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
dpdata
monty
numpy
pymatgen
11 changes: 11 additions & 0 deletions _book/examples/elastic/run_task.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
for i in task.*
do
cd ./$i
pwd
# 超算环境注意修改sub.sh中的内容
sbatch ../sub.sh
# 或者直接运行abacus
# mpirun -n 4 abacus
cd ../
done
7 changes: 7 additions & 0 deletions _book/examples/elastic/sub.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
#SBATCH -p master
#SBATCH -J lcao-elas
#SBATCH -n 6

intel
mpirun -n 6 abacus | tee abacus.out
2 changes: 1 addition & 1 deletion _book/index.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions _book/news.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion _book/search_plus_index.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions abacus-upf.md
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ upfconv.x -u al.upf #利用QE的upflib将UPFv.1转化成UPFv.2格式

## 3. ld1.x

QE 的 atomic 模块中的 `ld1.x` 支持生成赝势。其不仅可以生成模守恒赝势、还支持超软赝势、PAW 方法,支持全相对论、标量(非)相对论赝势(rel, non-rel/sca-rel),其径向波函数支持 [TM](https://journals.aps.org/prb/abstract/10.1103/PhysRevB.43.1993)(更稳定)与 [RRKJ](https://journals.aps.org/prb/abstract/10.1103/PhysRevB.41.1227) 两种方法,支持交换关联近似 7 类 LDA( pz),GGA(pbe, pbesol, revpbe, bp, wc, pw91。
QE 的 atomic 模块中的 `ld1.x` 支持生成赝势。其不仅可以生成模守恒赝势、还支持超软赝势、PAW 方法,支持全相对论、标量(非)相对论赝势(rel, non-rel/sca-rel),其径向波函数支持 [TM](https://journals.aps.org/prb/abstract/10.1103/PhysRevB.43.1993)(更稳定)与 [RRKJ](https://journals.aps.org/prb/abstract/10.1103/PhysRevB.41.1227) 两种方法,支持交换关联近似 7 类 LDA(pz),GGA(pbe, pbesol, revpbe, bp, wc, pw91

下载好 QE 软件后,可以直接安装:

Expand Down Expand Up @@ -497,7 +497,7 @@ element='C Si Ge'
/
&inputp
pseudotype=2,
file_pseudopw='Al.pbe-n-nc.UPF', #输入赝势
file_pseudopw='Al.pbe-n-nc.UPF', #输出赝势
lloc=2,
nlcc=.true.,
tm=.true.
Expand Down
Loading

0 comments on commit e8c619c

Please sign in to comment.