From d55c9a0ed8f4c9e6667e79fe6aaebb4a90e89be4 Mon Sep 17 00:00:00 2001 From: Philip Loche Date: Fri, 17 Jan 2025 10:36:24 +0100 Subject: [PATCH] some minor cleanup --- src/torchpme/calculators/calculator.py | 6 +++--- src/torchpme/tuning/ewald.py | 6 ++---- src/torchpme/tuning/p3m.py | 2 -- src/torchpme/tuning/pme.py | 2 -- 4 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/torchpme/calculators/calculator.py b/src/torchpme/calculators/calculator.py index 627283e5..4c8798a9 100644 --- a/src/torchpme/calculators/calculator.py +++ b/src/torchpme/calculators/calculator.py @@ -40,9 +40,9 @@ def __init__( ): super().__init__() - assert isinstance(potential, Potential), ( - f"Potential must be an instance of Potential, got {type(potential)}" - ) + assert isinstance( + potential, Potential + ), f"Potential must be an instance of Potential, got {type(potential)}" self.device = "cpu" if device is None else device self.dtype = torch.get_default_dtype() if dtype is None else dtype diff --git a/src/torchpme/tuning/ewald.py b/src/torchpme/tuning/ewald.py index c4fe039d..dbc70814 100644 --- a/src/torchpme/tuning/ewald.py +++ b/src/torchpme/tuning/ewald.py @@ -7,8 +7,6 @@ from ..utils import _validate_parameters from .tuner import GridSearchTuner, TuningErrorBounds -TWO_PI = 2 * math.pi - def tune_ewald( charges: torch.Tensor, @@ -162,8 +160,8 @@ def err_kspace( return ( self.prefac**0.5 / smearing - / torch.sqrt(TWO_PI**2 * self.volume / (lr_wavelength) ** 0.5) - * torch.exp(-(TWO_PI**2) * smearing**2 / (lr_wavelength)) + / torch.sqrt((2 * torch.pi) ** 2 * self.volume / (lr_wavelength) ** 0.5) + * torch.exp(-((2 * torch.pi) ** 2) * smearing**2 / (lr_wavelength)) ) def err_rspace(self, smearing: torch.Tensor, cutoff: torch.Tensor) -> torch.Tensor: diff --git a/src/torchpme/tuning/p3m.py b/src/torchpme/tuning/p3m.py index 54df212e..4f2eb4f7 100644 --- a/src/torchpme/tuning/p3m.py +++ b/src/torchpme/tuning/p3m.py @@ -8,8 +8,6 @@ from ..utils import _validate_parameters from .tuner import GridSearchTuner, TuningErrorBounds -TWO_PI = 2 * math.pi - # Coefficients for the P3M Fourier error, # see Table II of http://dx.doi.org/10.1063/1.477415 A_COEF = [ diff --git a/src/torchpme/tuning/pme.py b/src/torchpme/tuning/pme.py index b78bf2da..dda3d210 100644 --- a/src/torchpme/tuning/pme.py +++ b/src/torchpme/tuning/pme.py @@ -8,8 +8,6 @@ from ..utils import _validate_parameters from .tuner import GridSearchTuner, TuningErrorBounds -TWO_PI = 2 * math.pi - def tune_pme( charges: torch.Tensor,