Metadata-Version: 2.4
Name: yancc
Version: 0.0.1
Summary: Yet Another NeoClassical Code
Author-email: Rory Conlin <mail@fouriest.net>
License-Expression: MIT
Project-URL: Homepage, https://github.com/f0uriest/yancc
Project-URL: Documentation, https://yancc.readthedocs.io/
Project-URL: Source Code, https://github.com/f0uriest/yancc/
Project-URL: Issues Tracker, https://github.com/f0uriest/yancc/issues
Keywords: neoclassical,transport,stellarator,tokamak,plasma
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: Natural Language :: English
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering
Classifier: Topic :: Scientific/Engineering :: Mathematics
Requires-Python: >=3.10
Description-Content-Type: text/x-rst
License-File: LICENSE
Requires-Dist: equinox<0.14,>=0.11.0
Requires-Dist: interpax<0.4,>=0.3.3
Requires-Dist: jax<0.11,>=0.4.30
Requires-Dist: jaxtyping<0.4,>=0.2.24
Requires-Dist: lineax<0.2,>=0.0.6
Requires-Dist: netcdf4<1.8,>=1.5.4
Requires-Dist: numpy<2.5,>=1.20.0
Requires-Dist: orthax<0.3
Requires-Dist: quadax<0.3,>=0.2.2
Requires-Dist: scipy<1.18,>=1.7.0
Provides-Extra: dev
Requires-Dist: sympy; extra == "dev"
Requires-Dist: desc-opt<=0.17.1; extra == "dev"
Requires-Dist: mpmath; extra == "dev"
Requires-Dist: sphinx<=9.1,>=3.0.0; extra == "dev"
Requires-Dist: sphinx_copybutton<=0.5.2; extra == "dev"
Requires-Dist: sphinx-rtd-theme<=3.1,>=1.0; extra == "dev"
Requires-Dist: sphinx-github-style<=1.2.2,>=1.0; extra == "dev"
Requires-Dist: ruff==0.15.14; extra == "dev"
Requires-Dist: pre-commit<=4.5.1; extra == "dev"
Requires-Dist: pyright<1.2; extra == "dev"
Requires-Dist: pytest<=9.0.3,>=5.0.0; extra == "dev"
Requires-Dist: pytest-cov<=7.1.0,>=2.6; extra == "dev"
Requires-Dist: pytest-split<=0.11,>=0.8.2; extra == "dev"
Requires-Dist: build; extra == "dev"
Dynamic: license-file

.. image:: https://raw.githubusercontent.com/f0uriest/yancc/master/docs/_static/images/logo.png
   :width: 400
   :align: center
   :alt: yancc

Yet Another NeoClassical Code.
==============================
|License|

|Docs| |UnitTests| |Codecov|


``yancc`` solves the drift kinetic equation to compute neoclassical flows and transport
fluxes in toroidal geometry (both tokamaks and stellarators).

Installation
------------

``yancc`` is a pure-Python package built on `JAX <https://github.com/google/jax>`_
and requires Python 3.10 or newer.

From PyPI::

    pip install yancc

From source (for development)::

    git clone https://github.com/f0uriest/yancc.git
    cd yancc
    pip install -e ".[dev]"

JAX provides separate wheels for CPU and GPU backends; see the
`JAX install guide <https://docs.jax.dev/en/latest/installation.html>`_ to pick
the appropriate one for your hardware.

Example: Solving the Drift Kinetic Equation
-------------------------------------------

A minimal end-to-end DKE solve for a single hydrogen species:

.. code-block:: python

    from yancc.field import Field
    from yancc.solve import solve_dke
    from yancc.species import Hydrogen, LocalMaxwellian
    from yancc.velocity_grids import MaxwellSpeedGrid, UniformPitchAngleGrid

    # Field and grids.
    rho = 0.5
    nt, nz, na, nx = 15, 31, 61, 6
    field = Field.from_vmec("wout_NCSX.nc", rho, nt, nz)
    pitchgrid = UniformPitchAngleGrid(na)
    speedgrid = MaxwellSpeedGrid(nx)

    # Single hydrogen species. Density and temperature gradients are with
    # respect to rho = sqrt(normalized toroidal flux), so multiply physical
    # gradients by the minor radius.
    species = [
        LocalMaxwellian(
            Hydrogen,
            temperature=0.8e3,                        # eV
            density=1.5e20,                           # 1/m^3
            dTdrho=-2.0e3 * field.a_minor,
            dndrho=-0.4e20 * field.a_minor,
        )
    ]

    # Radial electric field, in Volts. Erho = -dPhi/drho.
    Er_kV_per_m = 0.5
    Erho = Er_kV_per_m * field.a_minor * 1000

    sol, info = solve_dke(
        field,
        pitchgrid,
        speedgrid,
        species,
        Erho=Erho,
        verbose=2,
        rtol=1e-5,
    )

    print("<Gamma>  =", sol.get("<particle_flux>"))   # particles/(m^2 s)
    print("<Q>      =", sol.get("<heat_flux>"))       # J/(m^2 s)
    print("<V||B>   =", sol.get("<V||B>"))            # T*m/s
    print("<J||B>   =", sol.get("<J||B>"))            # T*A/m^2

See the `documentation <https://yancc.readthedocs.io/>`_ for the monoenergetic
solver, multi-species runs, the full list of output variables, and the API
reference.


.. |License| image:: https://img.shields.io/github/license/f0uriest/yancc?color=blue&logo=open-source-initiative&logoColor=white
    :target: https://github.com/f0uriest/yancc/blob/master/LICENSE
    :alt: License


.. |Docs| image:: https://img.shields.io/readthedocs/yancc?logo=Read-the-Docs
    :target: https://yancc.readthedocs.io/en/latest/?badge=latest
    :alt: Documentation

.. |UnitTests| image:: https://github.com/f0uriest/yancc/actions/workflows/unittest.yml/badge.svg
    :target: https://github.com/f0uriest/yancc/actions/workflows/unittest.yml
    :alt: UnitTests

.. |Codecov| image:: https://codecov.io/gh/f0uriest/yancc/branch/master/graph/badge.svg?token=4WTFZ0ZLLB
    :target: https://codecov.io/gh/f0uriest/yancc
    :alt: Coverage
