https://github.com/jloveric/twofluid-ai-generated
AI Generated code for "Approximate Riemann solver for the two-fluid plasma model"
https://github.com/jloveric/twofluid-ai-generated
aigc cfd mhd numerical-methods plasma pytorch shockwave-evolution-modelling two-fluid windsurf
Last synced: 25 days ago
JSON representation
AI Generated code for "Approximate Riemann solver for the two-fluid plasma model"
- Host: GitHub
- URL: https://github.com/jloveric/twofluid-ai-generated
- Owner: jloveric
- Created: 2024-11-24T18:02:45.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2024-11-25T15:37:14.000Z (5 months ago)
- Last Synced: 2025-02-03T21:46:09.674Z (3 months ago)
- Topics: aigc, cfd, mhd, numerical-methods, plasma, pytorch, shockwave-evolution-modelling, two-fluid, windsurf
- Language: Python
- Homepage:
- Size: 1.76 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Two-Fluid Plasma Model Simulation
This code was completely written by Claude in Windsurf with user prompting.
This repository contains a PyTorch implementation of a two-fluid plasma model based on ["Approximate Riemann solver for the two-fluid plasma model"](https://www.aa.washington.edu/sites/aa/files/research/cpdlab/docs/Shumlak_JCP2003.pdf).
## Features
- Separate conservation equations for electron and ion fluids
- Full Maxwell's equations
- GPU-accelerated using PyTorch
- Second-order spatial reconstruction with minmod limiter
- TVD Runge-Kutta time integration
- Configurable charge parameters
- Shock-capturing capability## Installation
This project uses Poetry for dependency management. To install:
```bash
poetry install --no-root
```## Usage
Run the shock simulation with default parameters:
```bash
poetry run python shock_simulation.py
```Configure simulation parameters:
```bash
poetry run python shock_simulation.py --resolution 500 --final-time 0.2 --plot-interval 0.01 --charge 10.0
```Options:
- `--resolution, -r`: Number of spatial grid points (default: 500)
- `--final-time, -t`: Final simulation time (default: 0.2)
- `--plot-interval, -p`: Time between plots (default: 0.01)
- `--charge, -c`: Magnitude of species charge (ion: +charge, electron: -charge) (default: 10.0)## Development History
The complete development conversation between the human developer and Claude 3.5 Sonnet is available in [TRANSCRIPT.md](TRANSCRIPT.md). This transcript shows the iterative process of implementing the model, debugging issues, and making improvements.
[A YouTube video of an attempt to develop this code with AI](https://www.youtube.com/watch?v=NQ3hNe5bxxc)
## Latest Simulation Results

The image shows the final state of the simulation with:
- Density profiles for electrons and ions
- Velocity components
- Electric and magnetic field components
- Temperature evolution## Implementation Details
The simulation uses normalized units where:
- Ion mass = 1.0
- Speed of light = 1.0
- μ₀ = 1.0, ε₀ = 1.0
- Configurable charge parameter (default: qi = +10, qe = -10)Initial conditions are based on a modified Brio-Wu shock setup with:
- Density discontinuity (1.0 vs 0.125)
- Pressure discontinuity (0.5 vs 0.05)
- Magnetic field discontinuity
- Zero initial velocities