nmrsim
nmrsim copied to clipboard
Feat: Add support for spin-1 nuclei
This Pull Request introduces significant enhancements to nmrsim to enable the simulation of spin-1 nuclei as well as mixed-spin systems, such as those involving both proton (1H) and deuterium (2H) nuclei.
Key Changes & Features:
-
Mixed-Spin Support in
SpinSystem: TheSpinSystemclass now accepts a spin quantum number array (s) during initialization, allowing for accurate Hamiltonian construction and peaklist generation for systems with different nuclear spins (e.g., I=1/2 for 1H, I=1 for 2H) or the same nuclear spins (e.g., two 2H atoms I=1). -
ppm_to_hz_from_nuclei_infoFunction: A new utility function,ppm_to_hz_from_nuclei_info, has been added to simplify input by converting chemical shift values in ppm to Hz, correctly accounting for the specific gyromagnetic ratios of different nucleus types. -
reduce_peaksFunction Enhancement: Thereduce_peaksfunction has been updated to robustly handlenp.ndarrayinputs, improving its general usability.
Validation & Testing:
- Comprehensive new tests have been added in
tests/test_mixed_spin_systems.py. - A specific test case simulates the residual 1H signal in the DMSO CD3CD2HSO isotopomer, verifying the correct generation of both the 1H quintet and the 2H doublet signals, demonstrating the end-to-end functionality of these changes.
- All existing tests pass, and no new failures were introduced. The pre-existing
@pytest.mark.xfailtests intest_qm.pycontinue to behave as expected (failing due to known sparse array boolean conversion issues, unrelated to this feature).
Other Changes:
- Added
*.npzfiles to.gitignoreto prevent generated binary cache files from being tracked in version control.
Potential Documentation Update:
This new functionality would benefit from being documented on the Sphinx page. I am available to assist with writing or clarifying examples if guidance on the documentation structure is provided.
Sorry for the delay. Once my summer semester ends next week I will try to look this over.