-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Correct formula `cutoff_radius` - Correct failure handling of `cutoff_fractional`
- Loading branch information
ndaelman
committed
Aug 8, 2024
1 parent
db23f37
commit c26c547
Showing
2 changed files
with
45 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from nomad.units import ureg | ||
import numpy as np | ||
from . import logger | ||
|
||
from nomad_simulations.schema_packages.basis_set import APWPlaneWaveBasisSet | ||
|
||
|
||
def test_cutoff(): | ||
"""Test the quantitative results when computing certain plane-wave cutoffs.""" | ||
p_unit = '1 / angstrom' | ||
ref_cutoff_radius = 1.823 * ureg(p_unit) | ||
pw = APWPlaneWaveBasisSet(cutoff_energy=500 * ureg('eV')) | ||
assert np.isclose(pw.cutoff_radius.to(p_unit).magnitude, ref_cutoff_radius.magnitude, atol=1e-3) # reference computed by ChatGPT 4o | ||
|
||
pw.set_cutoff_fractional(1 / ref_cutoff_radius, logger) | ||
assert np.isclose(pw.cutoff_fractional, 1, rtol=1e-2) | ||
|
||
def test_cutoff_failure(): | ||
"""Test modes where `cutoff_fractional` is not computed.""" | ||
# missing cutoff_energy | ||
pw = APWPlaneWaveBasisSet() | ||
pw.set_cutoff_fractional(ureg.angstrom, logger) | ||
assert pw.cutoff_fractional is None | ||
|
||
# missing mt_radius | ||
pw = APWPlaneWaveBasisSet(cutoff_energy=500 * ureg('eV')) | ||
pw.set_cutoff_fractional(None, logger) | ||
assert pw.cutoff_fractional is None | ||
|
||
# cutoff_fractional already set | ||
pw = APWPlaneWaveBasisSet(cutoff_energy=500 * ureg('eV'), cutoff_fractional=1) | ||
pw.set_cutoff_fractional(ureg.angstrom, logger) | ||
assert pw.cutoff_fractional == 1 |
c26c547
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Coverage Report