Skip to content

Commit

Permalink
Perform the spline calculation in double precision
Browse files Browse the repository at this point in the history
and make the spline precision 1e-8 to match rascaline
  • Loading branch information
frostedoyster committed Feb 15, 2024
1 parent 183a3a5 commit 1bb1282
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
1 change: 0 additions & 1 deletion torch_spex/le.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,5 @@ def laplacian_eigenstate_basis_derivative(index, r):
laplacian_eigenstate_basis_derivative,
np.sum(n_max_l),
r_cut,
requested_accuracy=1e-6,
)

1 change: 0 additions & 1 deletion torch_spex/physical_LE/physical_LE.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ def function_for_splining_index_derivative(index, r):
function_for_splining_index_derivative,
np.sum(n_max_l),
a,
requested_accuracy=1e-6,
)
print("Number of spline points:", len(spliner.spline_positions))

Expand Down
10 changes: 7 additions & 3 deletions torch_spex/splines.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,9 @@ def __init__(
self.start = start
self.stop = stop

# initialize spline with 11 points
positions = torch.linspace(start, stop, 11)
# initialize spline with 11 points; the spline calculation
# is performed in double precision
positions = torch.linspace(start, stop, 11, dtype=torch.float64)
self.register_buffer("spline_positions", positions)
self.register_buffer("spline_values", values_fn(positions))
self.register_buffer("spline_derivatives", derivatives_fn(positions))
Expand All @@ -91,7 +92,10 @@ def __init__(

half_step = (self.spline_positions[1] - self.spline_positions[0]) / 2
intermediate_positions = torch.linspace(
self.start + half_step, self.stop - half_step, n_intermediate_positions
self.start + half_step,
self.stop - half_step,
n_intermediate_positions,
dtype=torch.float64,
)

estimated_values = self.compute(intermediate_positions)
Expand Down

0 comments on commit 1bb1282

Please sign in to comment.