Skip to content

Conversation

@YigitElma
Copy link
Collaborator

@YigitElma YigitElma commented Nov 12, 2025

  • Adds a new convenience class FourierChebyshevField which has a couple of methods to be compatible with optimization,
    • init : only resolution info
    • build : creates grid and transforms
    • fit : given params and profiles (these change during optimization), fits a new Fourier-Chebyshev series.
    • evaluate : Evaluate the series at requested point.

Example usage will be,

interpolater = FourierChebyshevField(L=eq.L_grid, M=eq.M_grid, N=eq.N_grid)
interpolater.build(eq)
data_fit = interpolater.fit(eq.params_dict, {"iota": eq.iota})

rtz, _, aux = _trace_particles(
    field=interpolator,  # normally you pass eq here
    y0=x0,
    model=model,
    model_args=args,
    ts=ts,
    params=None,   # normally you pass eq.params_dict here
    max_steps=int((ts[-1] - ts[0]) / 1e-8),
    min_step_size=1e-8,
    stepsize_controller=PIDController(rtol=1e-4, atol=1e-4, dtmin=1e-8),
    saveat=SaveAt(ts=ts),
    solver=Tsit5(),
    adjoint=RecursiveCheckpointAdjoint(),
    event=event,
    chunk_size=None,
    options={},    # this passes extra stuff to field computation, not needed here
    throw=False,
    return_aux=True,
)

Todo:

  • trace_particles should initialize FourierChebyshevField and by default use it. Add a flag to use Equilibrium field
  • plot_particle_trajectories etc should also be able to use the interpolated field.
  • Look at the spectral convergence (ideally lower res for basis vectors might be good, but current code is simpler and with batching might not be inefficient)
  • Consider adding spline version too?

f0uriest and others added 30 commits September 10, 2024 11:05
…article based on the dimension of the initial conditions. `particle_tracer.py` and `optimization.py` are adapted to this change.

Optimization doesn't work yet
Automatically chooses single or multiparticle based on the dimension of
the initial conditions. `particle_tracer.py` and `optimization.py` are
adapted to this change.

Optimization doesn't work yet
YigitElma and others added 9 commits December 6, 2025 12:37
…#2027)

Updates the requirements on
[nbsphinx](https://github.com/spatialaudio/nbsphinx) to permit the
latest version.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/spatialaudio/nbsphinx/releases">nbsphinx's
releases</a>.</em></p>
<blockquote>
<h2>nbsphinx 0.9.8</h2>
<p><a
href="https://pypi.org/project/nbsphinx/0.9.8/">https://pypi.org/project/nbsphinx/0.9.8/</a></p>
<ul>
<li>Re-enable Sphinx 8.2+</li>
<li>Support <code>text/x-rst</code> MIME type in raw cells</li>
<li>Support for <code>mathjax4_config</code></li>
</ul>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/spatialaudio/nbsphinx/blob/master/NEWS.rst">nbsphinx's
changelog</a>.</em></p>
<blockquote>
<p>Version 0.9.8 -- 2025-11-28 -- PyPI__ -- diff__</p>
<ul>
<li>Re-enable Sphinx 8.2+</li>
<li>Support <code>text/x-rst</code> MIME type in raw cells</li>
<li>Support for <code>mathjax4_config</code></li>
</ul>
<p>__ <a
href="https://pypi.org/project/nbsphinx/0.9.8/">https://pypi.org/project/nbsphinx/0.9.8/</a>
__ <a
href="https://github.com/spatialaudio/nbsphinx/compare/0.9.7...0.9.8">https://github.com/spatialaudio/nbsphinx/compare/0.9.7...0.9.8</a></p>
<p>Version 0.9.7 -- 2025-03-03 -- PyPI__ -- diff__</p>
<ul>
<li>Disable Sphinx 8.2+ (for now)</li>
</ul>
<p>__ <a
href="https://pypi.org/project/nbsphinx/0.9.7/">https://pypi.org/project/nbsphinx/0.9.7/</a>
__ <a
href="https://github.com/spatialaudio/nbsphinx/compare/0.9.6...0.9.7">https://github.com/spatialaudio/nbsphinx/compare/0.9.6...0.9.7</a></p>
<p>Version 0.9.6 -- 2024-12-24 -- PyPI__ -- diff__</p>
<ul>
<li>Markdown: allow lists without leading blank line</li>
</ul>
<p>__ <a
href="https://pypi.org/project/nbsphinx/0.9.6/">https://pypi.org/project/nbsphinx/0.9.6/</a>
__ <a
href="https://github.com/spatialaudio/nbsphinx/compare/0.9.5...0.9.6">https://github.com/spatialaudio/nbsphinx/compare/0.9.5...0.9.6</a></p>
<p>Version 0.9.5 -- 2024-08-13 -- PyPI__ -- diff__</p>
<ul>
<li>Miscellaneous fixes</li>
</ul>
<p>__ <a
href="https://pypi.org/project/nbsphinx/0.9.5/">https://pypi.org/project/nbsphinx/0.9.5/</a>
__ <a
href="https://github.com/spatialaudio/nbsphinx/compare/0.9.4...0.9.5">https://github.com/spatialaudio/nbsphinx/compare/0.9.4...0.9.5</a></p>
<p>Version 0.9.4 -- 2024-05-06 -- PyPI__ -- diff__</p>
<ul>
<li>Require <code>docutils &gt;= 0.18.1</code></li>
<li>Minor fixes, documentation and CI updates</li>
</ul>
<p>__ <a
href="https://pypi.org/project/nbsphinx/0.9.4/">https://pypi.org/project/nbsphinx/0.9.4/</a>
__ <a
href="https://github.com/spatialaudio/nbsphinx/compare/0.9.3...0.9.4">https://github.com/spatialaudio/nbsphinx/compare/0.9.3...0.9.4</a></p>
<p>Version 0.9.3 -- 2023-08-27 -- PyPI__ -- diff__</p>
<ul>
<li>Fix gallery regression in Sphinx 7.2</li>
</ul>
<p>__ <a
href="https://pypi.org/project/nbsphinx/0.9.3/">https://pypi.org/project/nbsphinx/0.9.3/</a>
__ <a
href="https://github.com/spatialaudio/nbsphinx/compare/0.9.2...0.9.3">https://github.com/spatialaudio/nbsphinx/compare/0.9.2...0.9.3</a></p>
<p>Version 0.9.2 -- 2023-05-24 -- PyPI__ -- diff__</p>
<ul>
<li>Improve support for <code>sphinx_immaterial</code> theme</li>
<li>Improve support for links starting with <code>#</code></li>
<li>Add support for in-text citations</li>
<li>LaTeX: Add support for admonition titles</li>
</ul>
<p>__ <a
href="https://pypi.org/project/nbsphinx/0.9.2/">https://pypi.org/project/nbsphinx/0.9.2/</a>
__ <a
href="https://github.com/spatialaudio/nbsphinx/compare/0.9.1...0.9.2">https://github.com/spatialaudio/nbsphinx/compare/0.9.1...0.9.2</a></p>
<p>Version 0.9.1 -- 2023-03-14 -- PyPI__ -- diff__</p>
<ul>
<li>pandoc: disable &quot;smart&quot; option only for version 2.0+</li>
</ul>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/spatialaudio/nbsphinx/commit/4f07420639de321d63681ee8c560f73cb0c4a85f"><code>4f07420</code></a>
Release 0.9.8</li>
<li><a
href="https://github.com/spatialaudio/nbsphinx/commit/75d6770733a5ef44553759449309a769c0329609"><code>75d6770</code></a>
Avoid a logging error</li>
<li><a
href="https://github.com/spatialaudio/nbsphinx/commit/dd96f11edb14f7c2027c7ef50663f8c05a014278"><code>dd96f11</code></a>
DOC: Update URL for the &lt;img&gt; element</li>
<li><a
href="https://github.com/spatialaudio/nbsphinx/commit/d97c0111c4af0423216d217234d87ed73013958d"><code>d97c011</code></a>
Add support for mathjax4_config (<a
href="https://redirect.github.com/spatialaudio/nbsphinx/issues/854">#854</a>)</li>
<li><a
href="https://github.com/spatialaudio/nbsphinx/commit/4882668244e8c0d7b36d0743f9fbc1a48d3160da"><code>4882668</code></a>
Fix nbsphinx_assume_equations to work with newer versions of Sphinx</li>
<li><a
href="https://github.com/spatialaudio/nbsphinx/commit/95372a74c543565b5e02357db5e248fb865a8326"><code>95372a7</code></a>
CI: use &quot;uv&quot; for &quot;publish&quot; workflow</li>
<li><a
href="https://github.com/spatialaudio/nbsphinx/commit/9ce8c26cfa363a357b760ed1b0cc45ecb92de1f4"><code>9ce8c26</code></a>
setup.py -&gt; pyproject.toml</li>
<li><a
href="https://github.com/spatialaudio/nbsphinx/commit/394b9ee5611109db6b234e44e2b61da8e939ac8d"><code>394b9ee</code></a>
DOC: use anonymous hyperlinks for embedded URLs</li>
<li><a
href="https://github.com/spatialaudio/nbsphinx/commit/ab8592199d6637045b6f77992f10138590130d6b"><code>ab85921</code></a>
Bump actions/upload-artifact from 4 to 5</li>
<li><a
href="https://github.com/spatialaudio/nbsphinx/commit/76122c23c9568305eb6da15abd5278981e8960b1"><code>76122c2</code></a>
Bump actions/download-artifact from 4 to 6</li>
<li>Additional commits viewable in <a
href="https://github.com/spatialaudio/nbsphinx/compare/0.8.12...0.9.8">compare
view</a></li>
</ul>
</details>
<br />


Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Rory Conlin <wconlin@princeton.edu>
@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

Base automatically changed from rc/particles to master December 8, 2025 22:43
@github-actions
Copy link
Contributor

github-actions bot commented Dec 9, 2025

Memory benchmark result

|               Test Name                |      %Δ      |    Master (MB)     |      PR (MB)       |    Δ (MB)    |    Time PR (s)     |  Time Master (s)   |
| -------------------------------------- | ------------ | ------------------ | ------------------ | ------------ | ------------------ | ------------------ |
  test_objective_jac_w7x                 |    3.78 %    |     3.813e+03      |     3.957e+03      |    144.13    |       39.78        |       36.26        |
  test_proximal_jac_w7x_with_eq_update   |   -1.27 %    |     6.663e+03      |     6.579e+03      |    -84.80    |       162.72       |       161.50       |
  test_proximal_freeb_jac                |    0.41 %    |     1.316e+04      |     1.321e+04      |    53.79     |       84.83        |       83.43        |
  test_proximal_freeb_jac_blocked        |    0.41 %    |     7.461e+03      |     7.492e+03      |    30.73     |       72.51        |       73.21        |
  test_proximal_freeb_jac_batched        |   -1.25 %    |     7.538e+03      |     7.444e+03      |    -94.36    |       72.91        |       73.10        |
  test_proximal_jac_ripple               |   -2.37 %    |     3.608e+03      |     3.523e+03      |    -85.50    |       65.70        |       65.71        |
  test_proximal_jac_ripple_bounce1d      |   -0.08 %    |     3.566e+03      |     3.564e+03      |    -2.77     |       76.55        |       76.55        |
  test_eq_solve                          |    0.60 %    |     1.992e+03      |     2.004e+03      |    12.00     |       93.79        |       94.69        |

For the memory plots, go to the summary of Memory Benchmarks workflow and download the artifact.

@codecov
Copy link

codecov bot commented Dec 11, 2025

Codecov Report

❌ Patch coverage is 77.69231% with 29 lines in your changes missing coverage. Please review.
✅ Project coverage is 95.67%. Comparing base (3753ff0) to head (7b21b40).

Files with missing lines Patch % Lines
desc/particles.py 76.98% 29 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2012      +/-   ##
==========================================
- Coverage   95.75%   95.67%   -0.09%     
==========================================
  Files         102      102              
  Lines       28344    28471     +127     
==========================================
+ Hits        27142    27239      +97     
- Misses       1202     1232      +30     
Files with missing lines Coverage Δ
desc/compute/_basis_vectors.py 100.00% <100.00%> (ø)
desc/particles.py 88.15% <76.98%> (-4.34%) ⬇️

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@YigitElma
Copy link
Collaborator Author

For some reason, this suffers from GPU synchronisation miserably, and for more particles, it is slower than direct approach.

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.

7 participants