{"id":31132481,"url":"https://github.com/cchandre/gc2d","last_synced_at":"2026-05-01T21:33:42.817Z","repository":{"id":315247645,"uuid":"1058712312","full_name":"cchandre/GC2D","owner":"cchandre","description":"Guiding-center dynamics in plasma physics","archived":false,"fork":false,"pushed_at":"2025-10-08T15:12:27.000Z","size":39,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-10-08T17:34:30.108Z","etag":null,"topics":["hamiltonian","numpy","plasma-physics","pyhamsys","scipy","symplectic-integrator"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cchandre.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-09-17T12:59:03.000Z","updated_at":"2025-10-08T15:12:30.000Z","dependencies_parsed_at":"2025-09-17T15:15:18.523Z","dependency_job_id":"5fb8bccb-99be-4fde-9463-776ce200a1f2","html_url":"https://github.com/cchandre/GC2D","commit_stats":null,"previous_names":["cchandre/gc2d"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/cchandre/GC2D","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cchandre%2FGC2D","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cchandre%2FGC2D/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cchandre%2FGC2D/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cchandre%2FGC2D/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cchandre","download_url":"https://codeload.github.com/cchandre/GC2D/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cchandre%2FGC2D/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279001890,"owners_count":26083197,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-09T02:00:07.460Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["hamiltonian","numpy","plasma-physics","pyhamsys","scipy","symplectic-integrator"],"created_at":"2025-09-18T05:00:56.291Z","updated_at":"2026-05-01T21:33:42.799Z","avatar_url":"https://github.com/cchandre.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Guiding-center dynamics in plasma physics\n\n___\n## Simplified two-dimensional guiding-center dynamics\n\n- [`gc2ds_classes.py`](https://github.com/cchandre/GC2D/blob/main/gc2ds_classes.py): contains the GC classes and main functions defining the GC dynamics\n\n- [`run_gc2ds.py`](https://github.com/cchandre/GC2D/blob/main/run_gc2ds.py): example of a run file to reproduce the computations done in [[Mauger, Chandre (2026)]()]\n\nOnce [`run_gc2ds.py`](https://github.com/cchandre/GC2D/blob/main/run_gc2ds.py) has been edited with the relevant parameters, run the file as \n```sh\npython3 run_gc2ds.py\n```\nor in batch mode\n```sh\nnohup python3 -u run_gc2ds.py \u0026\u003egc2d.out \u003c /dev/null \u0026\n```\nThe list of Python packages and their version are specified in [`requirements.txt`](https://github.com/cchandre/GC2D/blob/main/requirements.txt)\n\n###  Main parameters of the class GC2Ds\n\n- *A*: Amplitude of the electrostatic potential\n- *M*: Number of modes in the electrostatic potential\n- *seed*: Seed for the random phases $\\phi_{nm}$ of the electrostatic potential (optional; default=27)\n\n$$ V(x,y,t) =\\sum_{n, m=1}^M \\frac{A}{(n^2+m^2)^{3/2}} {\\rm e}^{i(n x+my +\\phi_{nm} -t) } $$\n\n#### Example \n```python\nparams = {\"A\": 1.0, \"M\": 16, \"seed\": 42}\ngc = GC2Ds(params)\n```\n\n### Key methods\n\nSince GC2Ds is s subclass of HamSys (from the python package [`pyhamsys`](https://pypi.org/project/pyhamsys/)), it inherits all its methods, including:\n\n- `integrate`: Integrate numerically the trajectories of the system defined by the element of the class GC2Ds from the initial conditions defined by the function `initial_conditions`. \n\n- `compute_lyapunov`: Compute the Lyapunov spectrum.\n\n- `save_data`: Save simulation results to a `.mat` file with metadata.\n\nIn addition, GC2Ds has the following key methods:\n\n- `initial_conditions`: Generate starting (*x*, *y*) positions—random or on a regular grid.\n\n- `y_dot`: Time derivative of positions for integration.\n\n- `k_dot`: Scalar diagnostic of the potential field.\n\n- `potential`: Potential value at time t and position *z*=(*x*, *y*), and its first and second derivatives, obtained by specifying (*dx*, *dy*).\n\n- `hamiltonian`: Total Hamiltonian (sum of the potentials for each trajectory).\n\n- `y_dot_lyap`: Extended system (equations of motion and tangent flow) for Lyapunov-exponent calculations.\n\n- `plot_sol`: 2-D plot of a solution obtained by the function `integrate` (for Poincaré sections).\n\n#### `initial_conditions`\n\nGenerate initial 2-D coordinates for trajectories on a periodic domain.\n\n#### Parameters\n\n-   **n_traj**: Number of points. For `\"fixed\"`, rounded to a perfect square for a square grid.\n-   **x**, **y**: (min, max) ranges; default `(0, 2π)`.\n-   **kind**: `\"random\"` for uniform random samples, `\"fixed\"` for a regular grid.\n-   **seed**: Random seed when `type=\"random\"`.\n\n#### Returns\n\n1-D `xp.ndarray` of length `2*n_traj`: all x's followed by all y's.\n\n#### Example\n\n``` python\nz0 = gc.initial_conditions(50, type=\"random\", seed=123)\nz0 = gc.initial_conditions(100, x=(0, np.pi), y=(0, np.pi), type=\"fixed\")\n```\n\n### Reference\n\nF. Mauger, C. Chandre, *Extended phase-space symplectic integration for electron dynamics*, [Physical Review E 113, 045301 (2026)](https://doi.org/10.1103/7ghc-htf8)\n\n```bibtex\n@article{GC2Ds,\n  title = {Extended phase-space symplectic integration for electron dynamics},\n  author = {François Mauger and Cristel Chandre},\n  journal = {Physical Review E},\n  volume = {113},\n  pages = {045301},\n  year = {2026},\n  doi = {10.1103/7ghc-htf8},\n}\n```\n---\nFor more information: \u003ccristel.chandre@cnrs.fr\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcchandre%2Fgc2d","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcchandre%2Fgc2d","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcchandre%2Fgc2d/lists"}