Skip to content

Add analytical dipole test - #24

Open
hejamu wants to merge 5 commits into
mainfrom
ou-dipole-test
Open

hejamu wants to merge 5 commits into
mainfrom
ou-dipole-test

Conversation

@hejamu

@hejamu hejamu commented Nov 5, 2026 •

Copy link
Copy Markdown
Member

Fixes #11

Changes made in this Pull Request:

  • Added a test that produces a dipole timeseries from a Ornstein-Uhlenbeck process, which has an analytically known spectrum.
  • Fixed factor of 2 (Maybe, should check the derivation of the test)
  • Added example showing the analytical example.

PR Checklist

  • Issue raised/referenced?

📚 Documentation preview 📚: https://spectrumkit--24.org.readthedocs.build/en/24/

@PicoCentauri PicoCentauri left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an amazing and very good test! Thanks @hejamu and @Quewakira !

Comment on lines +6 to +7
The test suite checks the spectrum routes against a dipole whose susceptibility is known
exactly. This example walks through that test, ``TestDebyeRelaxation`` in

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't mention the testsuite. As a user I don't care what you do in the tests and I also don't look at them.

# \qquad \langle \xi_\alpha(t) \xi_\beta(t') \rangle
# = \delta_{\alpha \beta} \, \delta(t - t').
#
# The equation is linear and the noise is uncorrelated with the past, so multiplying by

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# The equation is linear and the noise is uncorrelated with the past, so multiplying by
# The equation is linear and the noise is uncorrelated with the past (no memory), so multiplying by

# \chi''(\omega) = \chi_0 \, \frac{\omega \tau}{1 + \omega^2 \tau^2}, \qquad
# \chi_0 = \frac{\langle \boldsymbol{M}^2 \rangle}{3 V \varepsilon_0 k_B T},
#
# with the loss peak at :math:`\omega \tau = 1`.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a connecting sentence for the next paragraph. Something like we will use this simple system to validate.

Comment on lines +90 to +92
acf = np.array(
[np.mean(np.sum(dipole[: n_frames - k] * dipole[k:], axis=1)) for k in lags]
)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought we want an acf function for this?

# :func:`~spectrumkit.dielectricspectrum.calculate_spectrum_from_dipole` works on the
# dipole, :func:`~spectrumkit.dielectricspectrum.calculate_spectrum_from_current` on the
# current :math:`\boldsymbol{J} = \dot{\boldsymbol{M}}`, here a finite difference. Both
# average the periodogram over 100 segments of 20 ps.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is a periodogram 😆

# current :math:`\boldsymbol{J} = \dot{\boldsymbol{M}}`, here a finite difference. Both
# average the periodogram over 100 segments of 20 ps.

dipole_route = calculate_spectrum_from_dipole(dipole, dt, volume, temperature, segs=100)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we import the functions in the example not in the local namespace but keep them in the spectrumkit to be better visible that these are our functions?

Suggested change
dipole_route = calculate_spectrum_from_dipole(dipole, dt, volume, temperature, segs=100)
dipole_route = spectrumkit.calculate_spectrum_from_dipole(dipole, dt, volume, temperature, segs=100)



def debye(nu):
"""Debye susceptibility at the frequency ``nu`` in THz."""

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strictly speaking this function doesn't care about the units it is only Thz since our time units are ps

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Replace regression tests by physical tests

2 participants