44
55from pathlib import Path
66
7+ from ase .io import read
78import numpy as np
89from pytest import approx
910from typer .testing import CliRunner
@@ -32,6 +33,7 @@ def test_elasticity(tmp_path):
3233 elasticity_path = results_dir / "NaCl-elastic_tensor.dat"
3334 log_path = results_dir / "NaCl-elasticity-log.yml"
3435 summary_path = results_dir / "NaCl-elasticity-summary.yml"
36+ generated_path = results_dir / "NaCl-generated.extxyz"
3537
3638 result = runner .invoke (
3739 app ,
@@ -42,7 +44,9 @@ def test_elasticity(tmp_path):
4244 "--arch" ,
4345 "mace_mp" ,
4446 "--n-strains" ,
45- "10" ,
47+ "2" ,
48+ "--minimize-all" ,
49+ "--write-structures" ,
4650 ],
4751 )
4852
@@ -51,14 +55,25 @@ def test_elasticity(tmp_path):
5155 assert elasticity_path .exists ()
5256 assert log_path .exists ()
5357 assert summary_path .exists ()
58+ assert generated_path .exists ()
5459
5560 written_elasticity = np .loadtxt (elasticity_path )
5661
57- assert written_elasticity [0 ] == approx (27.34894599677472 )
58- assert written_elasticity [- 1 ] == approx (12.287521633256832 )
62+ assert written_elasticity [0 ] == approx (27.368617328271498 )
63+ assert written_elasticity [- 1 ] == approx (2.1775175649257585 )
64+
65+ generated = read (generated_path , index = ":" )
66+ assert len (generated ) == 13
5967
6068 assert_log_contains (log_path , includes = ["Minimising initial structure" ])
6169
70+ with open (log_path ) as io :
71+ logs = yaml .safe_load (io .read ())
72+ optimization_logs = sum (
73+ log ["message" ] == ["Starting geometry optimization" ] for log in logs
74+ )
75+ assert optimization_logs == 13
76+
6277 with open (summary_path , encoding = "utf8" ) as file :
6378 elasticity_summary = yaml .safe_load (file )
6479
@@ -73,4 +88,4 @@ def test_elasticity(tmp_path):
7388 assert elasticity_summary ["emissions" ] > 0
7489
7590 assert "n_strains" in elasticity_summary ["config" ]
76- assert elasticity_summary ["config" ]["n_strains" ] == 10
91+ assert elasticity_summary ["config" ]["n_strains" ] == 2
0 commit comments