Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
81275b8
Update system.py
panxiang126 Sep 2, 2022
5789e87
Update vasp.py
panxiang126 Sep 2, 2022
467310d
Update outcar.py
panxiang126 Sep 2, 2022
184607e
Update system.py
panxiang126 Sep 2, 2022
df0c3a1
Update system.py
panxiang126 Sep 2, 2022
5705656
Update vasp.py
panxiang126 Sep 2, 2022
e79d23c
Update outcar.py
panxiang126 Sep 2, 2022
285f99c
Update vasp.py
panxiang126 Sep 2, 2022
4a2ae35
Update movement.py
panxiang126 Sep 2, 2022
a5bc199
Update output.py
panxiang126 Sep 2, 2022
c345e5e
Update pwmat.py
panxiang126 Sep 2, 2022
34cc8c5
Update fhi_aims.py
panxiang126 Sep 2, 2022
0a241c1
Update system.py
panxiang126 Sep 2, 2022
2b0c2c0
Update system.py
panxiang126 Sep 2, 2022
a5e0f96
Update vasp.py
panxiang126 Sep 3, 2022
b51c870
Update vasp.py
panxiang126 Sep 3, 2022
ba4fa06
Update pwmat.py
panxiang126 Sep 3, 2022
abd9587
Update fhi_aims.py
panxiang126 Sep 3, 2022
b48b3e5
Update fhi_aims.py
panxiang126 Sep 5, 2022
cdda3d4
Update pwmat.py
panxiang126 Sep 5, 2022
fe0d3a5
Update vasp.py
panxiang126 Sep 5, 2022
26b5966
Update fhi_aims.py
panxiang126 Sep 5, 2022
1c4d660
Update pwmat.py
panxiang126 Sep 5, 2022
e99ee95
Update vasp.py
panxiang126 Sep 5, 2022
8903132
Update pwmat.py
panxiang126 Sep 5, 2022
4f701a3
Update system.py
panxiang126 Sep 6, 2022
9a2029b
Update outcar.py
panxiang126 Sep 6, 2022
2b2c805
Update movement.py
panxiang126 Sep 6, 2022
01d0781
Update outcar.py
panxiang126 Sep 6, 2022
48497c0
Update output.py
panxiang126 Sep 6, 2022
9556898
Update fhi_aims.py
panxiang126 Sep 6, 2022
a8f33c5
Update pwmat.py
panxiang126 Sep 6, 2022
66edac2
Update vasp.py
panxiang126 Sep 6, 2022
308c13c
Update vasp.py
panxiang126 Sep 6, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions dpdata/fhi_aims/output.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import numpy as np
import re
import warnings

latt_patt="\|\s+([0-9]{1,}[.][0-9]*)\s+([0-9]{1,}[.][0-9]*)\s+([0-9]{1,}[.][0-9]*)"
pos_patt_first="\|\s+[0-9]{1,}[:]\s\w+\s(\w+)(\s.*[-]?[0-9]{1,}[.][0-9]*)(\s+[-]?[0-9]{1,}[.][0-9]*)(\s+[-]?[0-9]{1,}[.][0-9]*)"
Expand Down Expand Up @@ -63,7 +64,7 @@ def get_fhi_aims_block(fp) :
return blk
return blk

def get_frames (fname, md=True, begin = 0, step = 1) :
def get_frames (fname, md=True, begin = 0, step = 1, convergence_check=True) :
fp = open(fname)
blk = get_fhi_aims_block(fp)
ret = get_info(blk, type_idx_zero = True)
Expand All @@ -78,6 +79,7 @@ def get_frames (fname, md=True, begin = 0, step = 1) :
all_virials = []

cc = 0
rec_failed = []
while len(blk) > 0 :
if debug:
with open(str(cc),'w') as f:
Expand All @@ -87,9 +89,9 @@ def get_frames (fname, md=True, begin = 0, step = 1) :
coord, _cell, energy, force, virial, is_converge = analyze_block(blk, first_blk=True, md=md)
else:
coord, _cell, energy, force, virial, is_converge = analyze_block(blk, first_blk=False)
if is_converge :
if len(coord) == 0:
break
if len(coord) == 0:
break
if is_converge or not convergence_check:
all_coords.append(coord)

if _cell:
Expand All @@ -101,9 +103,16 @@ def get_frames (fname, md=True, begin = 0, step = 1) :
all_forces.append(force)
if virial is not None :
all_virials.append(virial)
if not is_converge:
rec_failed.append(cc+1)

blk = get_fhi_aims_block(fp)
cc += 1

if len(rec_failed) > 0 :
prt = "so they are not collected." if convergence_check else "but they are still collected due to the requirement for ignoring convergence checks."
warnings.warn(f"The following structures were unconverged: {rec_failed}; "+prt)

if len(all_virials) == 0 :
all_virials = None
else :
Expand Down
4 changes: 2 additions & 2 deletions dpdata/plugins/fhi_aims.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
@Format.register("fhi_aims/md")
@Format.register("fhi_aims/output")
class FhiMDFormat(Format):
def from_labeled_system(self, file_name, md=True, begin = 0, step = 1, **kwargs):
def from_labeled_system(self, file_name, md=True, begin = 0, step = 1, convergence_check=True, **kwargs):
data = {}
data['atom_names'], \
data['atom_numbs'], \
Expand All @@ -14,7 +14,7 @@ def from_labeled_system(self, file_name, md=True, begin = 0, step = 1, **kwargs)
data['energies'], \
data['forces'], \
tmp_virial, \
= dpdata.fhi_aims.output.get_frames(file_name, md = md, begin = begin, step = step)
= dpdata.fhi_aims.output.get_frames(file_name, md = md, begin = begin, step = step, convergence_check=convergence_check)
if tmp_virial is not None :
data['virials'] = tmp_virial
return data
Expand Down
4 changes: 2 additions & 2 deletions dpdata/plugins/pwmat.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
@Format.register("pwmat/output")
class PwmatOutputFormat(Format):
@Format.post("rot_lower_triangular")
def from_labeled_system(self, file_name, begin=0, step=1, **kwargs):
def from_labeled_system(self, file_name, begin=0, step=1, convergence_check=True, **kwargs):
data = {}
data['atom_names'], \
data['atom_numbs'], \
Expand All @@ -21,7 +21,7 @@ def from_labeled_system(self, file_name, begin=0, step=1, **kwargs):
data['energies'], \
data['forces'], \
tmp_virial \
= dpdata.pwmat.movement.get_frames(file_name, begin=begin, step=step)
= dpdata.pwmat.movement.get_frames(file_name, begin=begin, step=step, convergence_check=convergence_check)
if tmp_virial is not None:
data['virials'] = tmp_virial
# scale virial to the unit of eV
Expand Down
4 changes: 2 additions & 2 deletions dpdata/plugins/vasp.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def to_system(self, data, frame_idx=0, **kwargs):
@Format.register("vasp/outcar")
class VASPOutcarFormat(Format):
@Format.post("rot_lower_triangular")
def from_labeled_system(self, file_name, begin=0, step=1, **kwargs):
def from_labeled_system(self, file_name, begin=0, step=1, convergence_check=True, **kwargs):
data = {}
ml = kwargs.get("ml", False)
data['atom_names'], \
Expand All @@ -65,7 +65,7 @@ def from_labeled_system(self, file_name, begin=0, step=1, **kwargs):
data['energies'], \
data['forces'], \
tmp_virial, \
= dpdata.vasp.outcar.get_frames(file_name, begin=begin, step=step, ml=ml)
= dpdata.vasp.outcar.get_frames(file_name, begin=begin, step=step, ml=ml, convergence_check=convergence_check)
if tmp_virial is not None:
data['virials'] = tmp_virial
# scale virial to the unit of eV
Expand Down
17 changes: 13 additions & 4 deletions dpdata/pwmat/movement.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import numpy as np
from ..periodic_table import ELEMENTS
import warnings

def system_info (lines, type_idx_zero = False) :
atom_names = []
Expand Down Expand Up @@ -49,7 +50,7 @@ def get_movement_block(fp) :
return blk

# we assume that the force is printed ...
def get_frames (fname, begin = 0, step = 1) :
def get_frames (fname, begin = 0, step = 1, convergence_check=True) :
fp = open(fname)
blk = get_movement_block(fp)

Expand All @@ -64,20 +65,28 @@ def get_frames (fname, begin = 0, step = 1) :
all_virials = []

cc = 0
rec_failed = []
while len(blk) > 0 :
if cc >= begin and (cc - begin) % step == 0 :
coord, cell, energy, force, virial, is_converge = analyze_block(blk, ntot, nelm)
if is_converge :
if len(coord) == 0:
break
if len(coord) == 0:
break
if is_converge or not convergence_check:
all_coords.append(coord)
all_cells.append(cell)
all_energies.append(energy)
all_forces.append(force)
if virial is not None :
all_virials.append(virial)
if not is_converge:
rec_failed.append(cc+1)

blk = get_movement_block(fp)
cc += 1

if len(rec_failed) > 0 :
prt = "so they are not collected." if convergence_check else "but they are still collected due to the requirement for ignoring convergence checks."
warnings.warn(f"The following structures were unconverged: {rec_failed}; "+prt)

if len(all_virials) == 0 :
all_virials = None
Expand Down
44 changes: 41 additions & 3 deletions dpdata/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ def __init__ (self,
begin = 0,
step = 1,
data = None,
convergence_check = True,
**kwargs) :
"""
Constructor
Expand All @@ -192,14 +193,49 @@ def __init__ (self,
- ``deepmd/raw``: deepmd-kit raw
- ``deepmd/npy``: deepmd-kit compressed format (numpy binary)
- ``vasp/poscar``: vasp POSCAR
- ``vasp/contcar``: vasp contcar
- ``vasp/string``: vasp string
- ``vasp/outcar``: vasp outcar
- ``vasp/xml``: vasp xml
- ``qe/cp/traj``: Quantum Espresso CP trajectory files. should have: file_name+'.in' and file_name+'.pos'
- ``qe/pw/scf``: Quantum Espresso PW single point calculations. Both input and output files are required. If file_name is a string, it denotes the output file name. Input file name is obtained by replacing 'out' by 'in' from file_name. Or file_name is a list, with the first element being the input file name and the second element being the output filename.
- ``abacus/scf``: ABACUS pw/lcao scf. The directory containing INPUT file is required.
- ``abacus/md``: ABACUS pw/lcao MD. The directory containing INPUT file is required.
- ``abacus/relax``: ABACUS pw/lcao relax or cell-relax. The directory containing INPUT file is required.
- ``abacus/relax``: ABACUS pw/lcao relax or cell-relax. The directory containing INPUT file is required.
- ``abacus/stru``: abacus stru
- ``abacus/lcao/scf``: abacus lcao scf
- ``abacus/pw/scf``: abacus pw scf
- ``abacus/lcao/md``: abacus lcao md
- ``abacus/pw/md``: abacus pw md
- ``abacus/lcao/relax``: abacus lcao relax
- ``abacus/pw/relax``: abacus pw relax
- ``siesta/output``: siesta SCF output file
- ``siesta/aimd_output``: siesta aimd output file
- ``pwmat/atom.config``: pwmat atom.config
- ``pwmat/movement``: pwmat movement
- ``pwmat/output``: pwmat output
- ``pwmat/mlmd``: pwmat mlmd
- ``pwmat/final.config``: pwmat final.config
- ``quip/gap/xyz_file``: quip gap xyz_file
- ``quip/gap/xyz``: quip gap xyz
- ``fhi_aims/output``: fhi_aims output
- ``fhi_aims/md``: fhi_aims md
- ``fhi_aims/scf``: fhi_aims scf
- ``pymatgen/structure``: pymatgen structure
- ``pymatgen/molecule``: pymatgen molecule
- ``pymatgen/computedstructureentry``: pymatgen computedstructureentry
- ``amber/md``: amber md
- ``sqm/out``: sqm out
- ``sqm/in``: sqm in
- ``ase/structure``: ase structure
- ``gaussian/log``: gaussian log
- ``gaussian/md``: gaussian md
- ``gaussian/gjf``: gaussian gjf
- ``deepmd/comp``: deepmd comp
- ``deepmd/hdf5``: deepmd hdf5
- ``gromacs/gro``: gromacs gro
- ``cp2k/aimd_output``: cp2k aimd_output
- ``cp2k/output``: cp2k output
type_map : list of str
Needed by formats lammps/lmp and lammps/dump. Maps atom type to name. The atom with type `ii` is mapped to `type_map[ii]`.
If not provided the atom names are assigned to `'Type_1'`, `'Type_2'`, `'Type_3'`...
Expand All @@ -208,7 +244,9 @@ def __init__ (self,
step : int
The number of skipped frames when loading MD trajectory.
data : dict
The raw data of System class.
The raw data of System class.
convergence_check : boolean
Whether to request a convergence check.
"""
self.data = {}
self.data['atom_numbs'] = []
Expand All @@ -224,7 +262,7 @@ def __init__ (self,
return
if file_name is None :
return
self.from_fmt(file_name, fmt, type_map=type_map, begin= begin, step=step, **kwargs)
self.from_fmt(file_name, fmt, type_map=type_map, begin= begin, step=step, convergence_check=convergence_check, **kwargs)

if type_map is not None:
self.apply_type_map(type_map)
Expand Down
18 changes: 13 additions & 5 deletions dpdata/vasp/outcar.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import numpy as np
import re
import warnings

def system_info(lines, type_idx_zero = False):
atom_names = []
Expand Down Expand Up @@ -52,7 +53,7 @@ def get_outcar_block(fp, ml = False):
return blk

# we assume that the force is printed ...
def get_frames(fname, begin = 0, step = 1, ml = False):
def get_frames(fname, begin = 0, step = 1, ml = False, convergence_check=True):
fp = open(fname)
blk = get_outcar_block(fp)

Expand All @@ -66,22 +67,29 @@ def get_frames(fname, begin = 0, step = 1, ml = False):
all_virials = []

cc = 0
rec_failed = []
while len(blk) > 0 :
if cc >= begin and (cc - begin) % step == 0 :
coord, cell, energy, force, virial, is_converge = analyze_block(blk, ntot, nelm, ml)
if is_converge :
if len(coord) == 0:
break
if len(coord) == 0:
break
if is_converge or not convergence_check:
all_coords.append(coord)
all_cells.append(cell)
all_energies.append(energy)
all_forces.append(force)
if virial is not None :
all_virials.append(virial)
if not is_converge:
rec_failed.append(cc+1)

blk = get_outcar_block(fp, ml)
cc += 1


if len(rec_failed) > 0 :
prt = "so they are not collected." if convergence_check else "but they are still collected due to the requirement for ignoring convergence checks."
warnings.warn(f"The following structures were unconverged: {rec_failed}; "+prt)

if len(all_virials) == 0 :
all_virials = None
else :
Expand Down