{"id":37075037,"url":"https://github.com/sandyherho/baron-sakender","last_synced_at":"2026-01-14T08:50:34.406Z","repository":{"id":330538672,"uuid":"1118564602","full_name":"sandyherho/baron-sakender","owner":"sandyherho","description":"JAX-accelerated finite volume solver for 2D ideal magnetohydrodynamics with HLL Riemann solver and Dedner divergence cleaning. Includes comprehensive conservation, turbulence, and information-theoretic diagnostics with CF-compliant NetCDF output.","archived":false,"fork":false,"pushed_at":"2025-12-26T07:24:45.000Z","size":5849,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-12-27T18:17:48.836Z","etag":null,"topics":["cfd","computational-physics","magnetohydrodynamics","toy-models"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/baron-sakender/","language":"Python","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sandyherho.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-12-18T00:34:02.000Z","updated_at":"2025-12-26T07:24:48.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/sandyherho/baron-sakender","commit_stats":null,"previous_names":["sandyherho/baron-sakender"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/sandyherho/baron-sakender","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sandyherho%2Fbaron-sakender","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sandyherho%2Fbaron-sakender/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sandyherho%2Fbaron-sakender/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sandyherho%2Fbaron-sakender/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sandyherho","download_url":"https://codeload.github.com/sandyherho/baron-sakender/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sandyherho%2Fbaron-sakender/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28414694,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T08:38:59.149Z","status":"ssl_error","status_checked_at":"2026-01-14T08:38:43.588Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cfd","computational-physics","magnetohydrodynamics","toy-models"],"created_at":"2026-01-14T08:50:33.687Z","updated_at":"2026-01-14T08:50:34.394Z","avatar_url":"https://github.com/sandyherho.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `baron-sakender`: JAX-Accelerated 2D Ideal MHD Solver\n\n[![DOI](https://zenodo.org/badge/1118564602.svg)](https://doi.org/10.5281/zenodo.18059201)\n[![Tests](https://github.com/sandyherho/baron-sakender/actions/workflows/tests.yml/badge.svg)](https://github.com/sandyherho/baron-sakender/actions/workflows/tests.yml)\n[![PyPI version](https://img.shields.io/pypi/v/baron-sakender.svg)](https://pypi.org/project/baron-sakender/)\n[![Python 3.9+](https://img.shields.io/badge/python-3.9%2B-blue.svg)](https://www.python.org/downloads/)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n[![JAX](https://img.shields.io/badge/JAX-accelerated-9cf.svg)](https://github.com/google/jax)\n[![NumPy](https://img.shields.io/badge/NumPy-%3C2.0-013243.svg)](https://numpy.org/)\n[![SciPy](https://img.shields.io/badge/SciPy-1.7%2B-8CAAE6.svg)](https://scipy.org/)\n[![Matplotlib](https://img.shields.io/badge/Matplotlib-3.4%2B-11557c.svg)](https://matplotlib.org/)\n\n---\n\n\u003e *Baron Sakender is a legendary figure in Javanese folklore, depicted as a European nobleman (often Spanish or Dutch) who voyages to Java to challenge local rulers. His significance lies in the Serat Baron Sakender, a semi-historical narrative interweaving European presence with Javanese cultural legitimacy. By portraying Sakender as a formidable outsider who ultimately submits to Javanese authority, these chronicles served as a sophisticated political instrument for Javanese monarchs to negotiate their sovereignty and preserve cultural primacy during the Dutch colonial era.*\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\".assets/case1_orszag_tang.gif\" alt=\"Orszag-Tang Vortex Simulation\" width=\"600\"\u003e\n\u003c/p\u003e\n\n---\n\nA finite volume solver for the two-dimensional ideal magnetohydrodynamic (MHD) equations with hyperbolic-parabolic divergence cleaning. This implementation employs the HLL approximate Riemann solver and second-order Runge-Kutta time integration, with optional GPU acceleration via JAX.\n\n## Governing Equations\n\nThe ideal MHD system describes the dynamics of electrically conducting fluids permeated by magnetic fields. In conservative form with the Dedner divergence cleaning formulation, the equations read:\n\n$$\n\\partial_t \\mathbf{U} + \\partial_i \\mathbf{F}^i = \\mathbf{S}\n$$\n\nwhere $\\partial_t \\equiv \\partial/\\partial t$ denotes the temporal derivative, $\\partial_i \\equiv \\partial/\\partial x^i$ the spatial derivative with respect to coordinate $x^i$, $\\mathbf{U}$ the state vector, $\\mathbf{F}^i$ the flux tensor, and $\\mathbf{S}$ the source term.\n\n### State Vector\n\nThe conservative state vector $\\mathbf{U} \\in \\mathbb{R}^7$ is defined as:\n\n$$\n\\mathbf{U} = \\begin{pmatrix} \\rho \\\\ \\rho v^x \\\\ \\rho v^y \\\\ B^x \\\\ B^y \\\\ E \\\\ \\psi \\end{pmatrix}\n$$\n\n### Conservation Laws\n\n**Mass conservation:**\n\n$$\n\\partial_t \\rho + \\partial_i (\\rho v^i) = 0\n$$\n\n**Momentum conservation:**\n\n$$\n\\partial_t (\\rho v^j) + \\partial_i \\left( \\rho v^i v^j + P^* \\delta^{ij} - B^i B^j \\right) = 0\n$$\n\nwhere $\\delta^{ij}$ is the Kronecker delta and $P^*$ denotes the total pressure:\n\n$$\nP^* = p + \\frac{1}{2} B^k B_k\n$$\n\n**Magnetic induction with divergence cleaning:**\n\n$$\n\\partial_t B^j + \\partial_i \\left( v^i B^j - B^i v^j \\right) + \\partial^j \\psi = 0\n$$\n\n**Energy conservation:**\n\n$$\n\\partial_t E + \\partial_i \\left[ (E + P^*) v^i - B^i (v_k B^k) \\right] = 0\n$$\n\n**Divergence cleaning (Dedner et al. 2002):**\n\n$$\n\\partial_t \\psi + c_h^2 \\, \\partial_i B^i = -\\frac{c_h^2}{c_p^2} \\psi\n$$\n\n### Closure Relations\n\n**Total energy density:**\n\n$$\nE = \\frac{1}{2} \\rho v^i v_i + \\frac{p}{\\gamma - 1} + \\frac{1}{2} B^i B_i\n$$\n\n**Equation of state (ideal gas):**\n\n$$\np = (\\gamma - 1) \\left( E - \\frac{1}{2} \\rho v^i v_i - \\frac{1}{2} B^i B_i \\right)\n$$\n\n### Characteristic Speeds\n\n**Sound speed:**\n\n$$\nc_s = \\sqrt{\\frac{\\gamma p}{\\rho}}\n$$\n\n**Alfvén speed:**\n\n$$\nv_A = \\frac{|B|}{\\sqrt{\\rho}} = \\sqrt{\\frac{B^i B_i}{\\rho}}\n$$\n\n**Fast magnetosonic speed:**\n\n$$\nc_f = \\sqrt{c_s^2 + v_A^2}\n$$\n\n## Variable Definitions\n\n| Symbol | Description | SI Unit |\n|--------|-------------|---------|\n| $\\rho$ | Mass density | [kg m⁻³] |\n| $v^i$ | Velocity component | [m s⁻¹] |\n| $B^i$ | Magnetic field component | [T] |\n| $p$ | Thermal pressure | [Pa] |\n| $P^*$ | Total pressure (thermal + magnetic) | [Pa] |\n| $E$ | Total energy density | [J m⁻³] |\n| $\\psi$ | Divergence cleaning potential | [T m s⁻¹] |\n| $\\gamma$ | Adiabatic index | [—] |\n| $c_s$ | Sound speed | [m s⁻¹] |\n| $v_A$ | Alfvén speed | [m s⁻¹] |\n| $c_f$ | Fast magnetosonic speed | [m s⁻¹] |\n| $c_h$ | Hyperbolic cleaning speed | [m s⁻¹] |\n| $c_p$ | Parabolic damping rate | [s⁻¹] |\n\n### Normalization (Code Units)\n\nThe code employs dimensionless variables normalized by reference quantities:\n\n| Reference | Symbol | Description |\n|-----------|--------|-------------|\n| $\\rho_0$ | Reference density | [kg m⁻³] |\n| $B_0$ | Reference magnetic field | [T] |\n| $L_0$ | Reference length | [m] |\n| $v_A = B_0 / \\sqrt{\\mu_0 \\rho_0}$ | Alfvén velocity | [m s⁻¹] |\n| $\\tau_A = L_0 / v_A$ | Alfvén time | [s] |\n| $P_0 = B_0^2 / \\mu_0$ | Magnetic pressure | [Pa] |\n\nwhere $\\mu_0 = 4\\pi \\times 10^{-7}$ [H m⁻¹] is the vacuum permeability.\n\n## Numerical Methods\n\n- **Spatial discretization:** Finite volume method on uniform Cartesian grid\n- **Riemann solver:** HLL (Harten-Lax-van Leer) approximate solver\n- **Time integration:** RK2 (Heun's method), second-order accurate\n- **Divergence cleaning:** Hyperbolic-parabolic formulation (Dedner et al. 2002)\n- **Boundary conditions:** Periodic\n- **Positivity preservation:** Density and pressure floors\n\n## Installation\n\n### Requirements\n\n- Python 3.9 or later\n- NumPy \u003c 2.0 (for compatibility with compiled dependencies)\n\n### From Source\n\n```bash\ngit clone https://github.com/sandyherho/baron-sakender.git\ncd baron-sakender\npip install -e \".[dev,netcdf]\"\n```\n\n### Dependencies\n\n**Core:**\n- [NumPy](https://numpy.org/) — Array operations\n- [SciPy](https://scipy.org/) — Scientific computing\n- [JAX](https://github.com/google/jax) — Accelerated numerical computing\n- [Matplotlib](https://matplotlib.org/) — Visualization\n- [pandas](https://pandas.pydata.org/) — Data handling\n- [tqdm](https://github.com/tqdm/tqdm) — Progress bars\n\n**Optional:**\n- [netCDF4](https://unidata.github.io/netcdf4-python/) — CF-compliant output\n- [pytest](https://docs.pytest.org/) — Testing framework\n- [black](https://github.com/psf/black) — Code formatting\n\n## Usage\n\n### Command Line Interface\n\n```bash\n# Run Orszag-Tang vortex (standard benchmark)\nbaron-sakender case1\n\n# Run all test cases\nbaron-sakender --all\n\n# Run with GPU acceleration\nbaron-sakender case1 --gpu\n\n# Run from configuration file\nbaron-sakender -c configs/case1_orszag_tang.txt\n```\n\n### Python API\n\n```python\nfrom baron_sakender import MHDSystem, MHDSolver\n\n# Initialize system\nsystem = MHDSystem(nx=256, ny=256, gamma=5/3)\nsystem.init_orszag_tang()\n\n# Create solver and run\nsolver = MHDSolver(cfl=0.4, use_gpu=False)\nresult = solver.run_with_diagnostics(system, t_end=3.0, save_dt=0.1)\n\n# Access results\ntimes = result['times']\nsnapshots = result['snapshots']\nconservation = result['conservation_history']\n```\n\n### Available Test Cases\n\n| Case | Description | Configuration |\n|------|-------------|---------------|\n| `case1` | Orszag-Tang vortex | Standard MHD turbulence benchmark |\n| `case2` | Strong magnetic field | Low plasma beta ($\\beta = 0.1$) regime |\n| `case3` | Current sheet | Harris-like configuration |\n| `case4` | Alfvén wave | Wave propagation test |\n\n## Output Formats\n\n- **PNG:** Static field plots (density, magnetic pressure, current, vorticity)\n- **GIF:** Animated density evolution\n- **CSV:** Time series of conservation and stability metrics\n- **NetCDF:** CF-1.8 compliant data with full metadata\n\n## Testing\n\n```bash\n# Run all tests\npytest tests/ -v\n\n# Run with coverage\npytest tests/ -v --cov=baron_sakender --cov-report=html\n```\n\n## Project Structure\n\n```\nbaron-sakender/\n├── src/baron_sakender/\n│   ├── core/\n│   │   ├── mhd_system.py    # Physical system definition\n│   │   ├── integrator.py    # JAX-accelerated solver\n│   │   └── metrics.py       # Diagnostic computations\n│   ├── io/\n│   │   ├── config_manager.py\n│   │   └── data_handler.py\n│   ├── visualization/\n│   │   └── animator.py\n│   └── cli.py               # Command line interface\n├── configs/                  # Configuration files\n├── tests/                    # Test suite\n└── pyproject.toml\n```\n\n## References\n\n- Dedner, A., Kemm, F., Kröner, D., Munz, C.-D., Schnitzer, T., \u0026 Wesenberg, M. (2002). Hyperbolic divergence cleaning for the MHD equations. *Journal of Computational Physics*, 175(2), 645–673.\n- Harten, A., Lax, P. D., \u0026 van Leer, B. (1983). On upstream differencing and Godunov-type schemes for hyperbolic conservation laws. *SIAM Review*, 25(1), 35–61.\n- Orszag, S. A., \u0026 Tang, C.-M. (1979). Small-scale structure of two-dimensional magnetohydrodynamic turbulence. *Journal of Fluid Mechanics*, 90(1), 129–143.\n\n## License\n\nMIT License. See [LICENSE](LICENSE) for details.\n\n## Authors\n\nSandy H. S. Herho, Nurjanna J. Trilaksono\n\n## Citation\n\nIf you use this software in your research, please cite:\n\n```bibtex\n@software{baron_sakender,\n  author = {Herho, Sandy H. S. and Trilaksono, Nurjanna J.},\n  title = {baron-sakender: JAX-Accelerated 2D Ideal MHD Solver},\n  year = {2025},\n  url = {https://github.com/sandyherho/baron-sakender}\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsandyherho%2Fbaron-sakender","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsandyherho%2Fbaron-sakender","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsandyherho%2Fbaron-sakender/lists"}