Skip to content

Commit

Permalink
More significant digits for coordinate files (coord and *.xyz) (#118
Browse files Browse the repository at this point in the history
)

* more significant digits for coordinates

Signed-off-by: Marcel Müller <[email protected]>

* adapt CHANGELOG.md

Signed-off-by: Marcel Müller <[email protected]>

* fix coord file writing

Signed-off-by: Marcel Müller <[email protected]>

---------

Signed-off-by: Marcel Müller <[email protected]>
  • Loading branch information
marcelmbn authored Jan 30, 2025
1 parent 7936e47 commit 55ff200
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed
- version string is now correctly formatted and printed
- precision (# significant digits) of the coordinate files (`get_coord_str` and `get_xyz_str`) increased from 7 to 14

## [0.5.0] - 2024-12-16
### Changed
Expand Down
12 changes: 6 additions & 6 deletions src/mindlessgen/molecules/molecule.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,9 +394,9 @@ def get_xyz_str(self) -> str:
for i in range(self.num_atoms):
xyz_str += (
f"{PSE[self.ati[i] + 1]:<5} "
+ f"{self.xyz[i, 0]:>12.7f} "
+ f"{self.xyz[i, 1]:>12.7f} "
+ f"{self.xyz[i, 2]:>12.7f}\n"
+ f"{self.xyz[i, 0]:>20.14f} "
+ f"{self.xyz[i, 1]:>20.14f} "
+ f"{self.xyz[i, 2]:>20.14f}\n"
)
return xyz_str

Expand Down Expand Up @@ -478,9 +478,9 @@ def get_coord_str(self) -> str:
coord_str = "$coord\n"
for i in range(self.num_atoms):
coord_str += (
f"{self.xyz[i, 0] / BOHR2AA:>12.7f} "
+ f"{self.xyz[i, 1] / BOHR2AA:>12.7f} "
+ f"{self.xyz[i, 2] / BOHR2AA:>12.7f} "
f"{self.xyz[i, 0] / BOHR2AA:>20.14f} "
+ f"{self.xyz[i, 1] / BOHR2AA:>20.14f} "
+ f"{self.xyz[i, 2] / BOHR2AA:>20.14f} "
+ f"{PSE[self.ati[i] + 1]:>5}\n"
)
coord_str += "$end\n"
Expand Down
4 changes: 2 additions & 2 deletions test/test_molecules/test_molecule.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,8 @@ def test_write_coord_to_file(tmp_path):
mol.xyz = np.array([[0.0, 0.0, 0.0], [1.0, 0.0, 0.0]])

expected_content = """$coord
0.0000000 0.0000000 0.0000000 H
1.8897261 0.0000000 0.0000000 F
0.00000000000000 0.00000000000000 0.00000000000000 H
1.88972612590778 0.00000000000000 0.00000000000000 F
$end
"""

Expand Down

0 comments on commit 55ff200

Please sign in to comment.