Commit dcc41ba
authored
fix(file IO), fix(global initialization), fix(mass output), feat(channel-bound atoms) (#7)
* Minor file IO bug fix
Fixed a minor bug related to file IO.
Description:
Not providing a .rad file for read_from_CIF, read_from_V1 and read_from_ARC resulted in a type error.
Code to reproduce:
from pyzeo.netstorage import AtomNetwork
atmnet = AtomNetwork.read_from_CIF("EDI.cif")
Example error output:
File "src/pyzeo/extension.pyx", line 512, in pyzeo.extension.AtomNetwork.read_from_CIF
TypeError: expected bytes, NoneType found
Comment:
A unit test "test_read_file.py" was added for validation.
* Minor global state pollution bug fix
Fixed a minor bug related to global state pollution of atomic property tables.
Description:
The global atomic property tables are not reevaluted in subsequent
calculations if only using default zeo++ provided values.
Example:
Reading an AtomNetwork from a file using default Zeo++ atomic radii does not correctly reinitialize the default atomic radii if an AtomNetwork was read in beforehand using custom atomic radii.
Code to reproduce:
from pyzeo.netstorage import AtomNetwork
from pyzeo.extension import lookupRadius
atmnet = AtomNetwork.read_from_CSSR("MgO_vac1.cssr", rad_file="MgO.rad")
atmnet = AtomNetwork.read_from_CSSR("EDI.cssr")
element = "O"
encoded_str = element.encode("utf-8")
element_radius = lookupRadius(encoded_str)
assert element_radius == 1.52, \
f"Wrong element radius. Expected 1.52, got {element_radius}"
Example error output: AssertionError: Wrong element radius. Expected 1.52, got 1.84
Comment:
A test "test_rad_table_init.py" was added for validation.
* Bug fix for mass-related properties
Mass-related properties in surface area and volume calculations are now displayed correctly.
Description:
Previously mass-related properties (Density, surface area and volume
referenced to mass) were not displayed correctly.
Example code:
from pyzeo.netstorage import AtomNetwork
from pyzeo.area_volume import volume
from pyzeo.high_accuracy import high_accuracy_atomnet
atmnet = AtomNetwork.read_from_CSSR("EDI.cssr")
ha_atmnet = atmnet.copy()
high_accuracy_atomnet(ha_atmnet, "DEF")
vol_str = volume(
atmnet,
1.2,
1.2,
50000,
high_accuracy=True,
high_accuracy_atmnet=ha_atmnet
)
decoded_str = vol_str.decode("utf-8")
print(decoded_str)
Previous example output:
@ No filename Unitcell_volume: 307.484 Density: 0 AV_A^3: 22.6493 AV_Volume_fraction: 0.07366 AV_cm^3/g: inf NAV_A^3: 0 NAV_Volume_fraction: 0 NAV_cm^3/g: -nan
New example output:
@ No filename Unitcell_volume: 307.484 Density: 1.62239 AV_A^3: 22.6493 AV_Volume_fraction: 0.07366 AV_cm^3/g: 0.0454022 NAV_A^3: 0 NAV_Volume_fraction: 0 NAV_cm^3/g: 0
Comment:
The tests "test_areavol_mass.py" and "test_surface_area_mass.py" were added for validation of the mass-related outputs in the volume and surface area calculations. The test "test_mass_table_init.py" was added to test the correct initialization of the atomic mass table.
* Added feature: Retrieve channel-bound atom IDs
The IDs of atoms that bound a channel (set of accessible Voronoi nodes) that is found in the structure via Voronoi decomposition, can now be returned.
New python methods:
-VoronoiNetwork.find_channels(channel_radius: float) -> List[Channel], List[bool]
Find channels in a Voronoi network.
Identifies channels (sets of accessible Voronoi nodes) within the associated Voronoi network for a given probe radius.
Args:
channel_radius : float
Radius of probe used to determine the accessibility of void space.
Returns:
1) channels: List of Channel objects representing accessible channels
2) access_info: List of Booleans, where access_info[i] indicates
if Voronoi node i is accessible for the probe
-Channel.find_bounding_atoms(atmnet: AtomNetwork, vornet: VoronoiNetwork) -> List[int]
Get the IDs of all atoms that bound this channel.
An atom is considered to bound a channel if a Voronoi node of the channel is a member of the atom's Voronoi cell.
Args:
atmnet: AtomNetwork object
The atom network structure of the associated channel
vornet: VoronoiNetwork object
The Voronoi network structure of the associated channel
Returns:
List of indices of the atoms that bound this channel
New python properties:
-AtomNetwork.atoms: List[Atom]
-Atom.type: str
Newly declared Cython attributes:
-VoronoiNetwork.bvcells
-VoronoiNetwork.has_bvcells
Basic usage example:
from pyzeo.netstorage import AtomNetwork
atmnet = AtomNetwork.read_from_CSSR("EDI.cssr")
probe_radius = 1.5
vornet, _, _ = atmnet.perform_voronoi_decomposition()
channels, access_info = vornet.find_channels(probe_radius)
num_accessible = access_info.count(True)
print(f"Found {len(channels)} channels in the structure")
print(f"Accessibility info for {len(access_info)} nodes")
print(f"Number of accessible nodes {num_accessible}")
for channel in channels:
atom_ids = channel.find_bounding_atoms(atmnet, vornet)
* Restructured tests and small test bug fix1 parent 0462b04 commit dcc41ba
16 files changed
Lines changed: 645 additions & 30 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
801 | 801 | | |
802 | 802 | | |
803 | 803 | | |
| 804 | + | |
804 | 805 | | |
805 | 806 | | |
806 | 807 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
| |||
154 | 155 | | |
155 | 156 | | |
156 | 157 | | |
| 158 | + | |
157 | 159 | | |
158 | 160 | | |
159 | 161 | | |
| |||
271 | 273 | | |
272 | 274 | | |
273 | 275 | | |
| 276 | + | |
274 | 277 | | |
275 | 278 | | |
276 | 279 | | |
| |||
388 | 391 | | |
389 | 392 | | |
390 | 393 | | |
| 394 | + | |
391 | 395 | | |
392 | 396 | | |
393 | 397 | | |
| |||
508 | 512 | | |
509 | 513 | | |
510 | 514 | | |
| 515 | + | |
511 | 516 | | |
512 | 517 | | |
513 | 518 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| |||
78 | 79 | | |
79 | 80 | | |
80 | 81 | | |
| 82 | + | |
| 83 | + | |
81 | 84 | | |
82 | 85 | | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
87 | 90 | | |
88 | 91 | | |
89 | 92 | | |
| |||
141 | 144 | | |
142 | 145 | | |
143 | 146 | | |
144 | | - | |
| 147 | + | |
145 | 148 | | |
146 | 149 | | |
147 | 150 | | |
| |||
200 | 203 | | |
201 | 204 | | |
202 | 205 | | |
203 | | - | |
| 206 | + | |
204 | 207 | | |
205 | 208 | | |
206 | 209 | | |
| |||
230 | 233 | | |
231 | 234 | | |
232 | 235 | | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
233 | 239 | | |
234 | 240 | | |
| 241 | + | |
| 242 | + | |
235 | 243 | | |
236 | 244 | | |
237 | 245 | | |
| |||
377 | 385 | | |
378 | 386 | | |
379 | 387 | | |
380 | | - | |
| 388 | + | |
0 commit comments