Révision cdc1edbe modules/formats.py
b/modules/formats.py | ||
---|---|---|
172 | 172 |
return Atoms(symbols=symbols, positions=positions) |
173 | 173 |
|
174 | 174 |
|
175 |
def read_coords_vasp(file, spec_atoms=tuple()): |
|
176 |
"""Reads the coordinates from VASP OUTCAR and returns an ase.Atoms object. |
|
177 |
|
|
178 |
@param file: The file to read containing the coordinates. |
|
179 |
@param spec_atoms: List of tuples containing the pairs of chemical symbols. |
|
180 |
@return: ase.Atoms object of the coordinates in the file. |
|
181 |
""" |
|
182 |
import os |
|
183 |
import ase.io |
|
184 |
if not os.path.isfile(file): |
|
185 |
err_msg = f"File {file} not found." |
|
186 |
logger.error(err_msg) |
|
187 |
raise FileNotFoundError(err_msg) |
|
188 |
if len(spec_atoms) > 0: |
|
189 |
add_special_atoms(spec_atoms) |
|
190 |
return ase.io.read(file) |
|
191 |
|
|
192 |
|
|
175 | 193 |
def collect_coords(conf_list, code, run_type, spec_atms=tuple()): |
176 | 194 |
"""Directs the reading of coordinates on a set of subdirectories. |
177 | 195 |
|
... | ... | |
196 | 214 |
if code == 'cp2k': |
197 | 215 |
atoms_list.append(read_coords_cp2k(glob(f"{run_type}/{conf}/*-1" |
198 | 216 |
f".restart")[0], spec_atms)) |
199 |
# elif code == 'vasp' |
|
217 |
elif code == 'vasp': |
|
218 |
atoms_list.append(read_coords_vasp(f"{run_type}/{conf}/OUTCAR", |
|
219 |
spec_atms)) |
|
220 |
else: |
|
221 |
err_msg = f"Collect coordinates not implemented for '{code}'." |
|
222 |
logger.error(err_msg) |
|
223 |
raise NotImplementedError(err_msg) |
|
200 | 224 |
return atoms_list |
201 | 225 |
|
202 | 226 |
|
... | ... | |
239 | 263 |
if code == 'cp2k': |
240 | 264 |
energies.append(read_energy_cp2k( |
241 | 265 |
glob(f"{run_type}/{conf}/*.out")[0])) |
266 |
else: |
|
267 |
err_msg = f"Collect energies not implemented for '{code}'." |
|
268 |
logger.error(err_msg) |
|
269 |
raise NotImplementedError(err_msg) |
|
242 | 270 |
|
243 | 271 |
if len(energies) == 0: |
244 | 272 |
err = f"No results found on {run_type}" |
Formats disponibles : Unified diff