{"id":22668332,"url":"https://github.com/lanl/cosyr","last_synced_at":"2025-04-12T11:04:26.356Z","repository":{"id":46219549,"uuid":"355343919","full_name":"lanl/cosyr","owner":"lanl","description":"A tool for coherent synchrotron radiation modeling","archived":false,"fork":false,"pushed_at":"2022-05-20T21:46:23.000Z","size":54033,"stargazers_count":12,"open_issues_count":1,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-06-27T00:20:06.786Z","etag":null,"topics":["coherent-synchrotron-radiation","high-performance-computing","particle-beam-dynamics"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lanl.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}},"created_at":"2021-04-06T22:19:23.000Z","updated_at":"2023-05-11T15:43:48.000Z","dependencies_parsed_at":"2022-09-25T05:40:36.471Z","dependency_job_id":null,"html_url":"https://github.com/lanl/cosyr","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lanl%2Fcosyr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lanl%2Fcosyr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lanl%2Fcosyr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lanl%2Fcosyr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lanl","download_url":"https://codeload.github.com/lanl/cosyr/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228911888,"owners_count":17990774,"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","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":["coherent-synchrotron-radiation","high-performance-computing","particle-beam-dynamics"],"created_at":"2024-12-09T15:14:47.042Z","updated_at":"2024-12-09T15:14:48.053Z","avatar_url":"https://github.com/lanl.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\n\u003cimg src=\"docs/logo.png?raw=true\" alt=\"logo\" width=\"150\"\u003e\n\n\n###### Summary\n\nCosyr is a particle beam dynamics simulation code with multi-dimensional [synchrotron radiation](https://en.wikipedia.org/wiki/Synchrotron_radiation) effects. It tackles a fundamental problem of the self-consistent nonlinear dynamics of a particle beam from its complete self-fields, particularly the radiation fields, i.e the [coherent synchrotron radiation (CSR)](http://linkinghub.elsevier.com/retrieve/pii/S016890029700822X) problem. The latter underpins many accelerator design issues in ultra-bright beam applications, as well as those arising in the development of advanced accelerators. It is is actively developed and supports two levels of parallelism with MPI and Kokkos. A related [poster](./docs/CSR_IPAC2021.pdf) was presented at the [IPAC'21](https://www.ipac21.org/index.php#) conference.\n\n![build](https://github.com/lanl/cosyr/actions/workflows/main.yml/badge.svg)\n\n###### Algorithm\nIt is based on the Lienard-Wiechert field formula of the retarded Green’s function for the Maxwell equations. A local cartesian moving mesh is used to follow the trajectory of the beam. For each particle, their fields (or potential) are then calculated on the radiation wavefronts that intersect with the moving mesh. These wavefronts are emitted along the trajectory of the particle at a specified interval. Their discretization points (called wavelets) form another mesh that is naturally adapted to the emission. In particular, these wavefronts are divided into two groups depending on the retarded time: \n\n- **dynamic**: they correspond to the wavefronts associated to a large retarded time (longer than the typical time scale of the beam evolution for instance). Here, the fields are calculated by taking into account the full dependence on the position, velocity and acceleration at emission. \n- **subcycle**: they correspond to the wavefronts that are emitted with a retarded time shorter than the beam evolution time scale. Here, they are treated as if being emitted from subcycle time steps where the emitting particles are assumed to follow the reference trajectory but shifted by their offset from the reference particle. As such, the subcyle wavelets and their fields are precalculated using the reference particle which has the reference energy and experiences only external fields. \n\nThe wavelet fields are then interpolated to the moving mesh, and the contributions from all particles are summed together to obtain the beam self-fields. The beam fields are again interpolated to the particles and are used to push them such as in a conventional [PIC](https://en.wikipedia.org/wiki/Particle-in-cell) method.\nThe algorithm is depicted in the snippet below:\n\n\u003c!--![Algorithm](./docs/algorithm.png)--\u003e\n\u003cimg src=\"docs/principle.png?raw=true\" alt=\"logo\" align=left width=\"380\"\u003e\n\n```\ninitialization  \nfor each time step {  \n  push reference particle  \n  update moving mesh  \n  push other particles  \n  if (emit wavelets) {  \n    update emission data  \n    for each particle {  \n      shift subcycle wavelets\n      emit dynamic wavefront\n      for each wavefront {\n        if wavefront intersects mesh {\n          compute wavelets fields\n        }\n      }\n    }\n    interpolate fields to mesh\n  } \n}\n```\n\nBy doing so, the high frequency radiations can be separated from those that can be resolved on the moving mesh by selecting the wavelets on a given wavefront. In addition, the synchrotron radiation can be emitted from the trajectories of the particles, which dynamically respond to the self-fields. Finally, the algorithm provides multiple levels of parallelism to leverage high performance computing clusters. It is more computationally intensive than other CSR models though. As such, it is currently limited to low energy beams. \n\n\u003c!--\nCosyr consists of three components:\n\n- a field computation kernel,\n- a wavelets-to-mesh interpolation kernel,\n- a particle pusher. \n\nThe particle pusher is similar to those for existing high performance kinetic plasma simulation codes, such as [VPIC](https://github.com/lanl/vpic). Unlike other particle-mesh codes with a local PDE-based field solver that communicates only with neighbors, Cosyr's field solver is based on the retarded Green's function and thus nonlocal both in time and space. Such an approach allows both the decoupling of the time/spatial scales in coherent and incoherent effects, and the improved solution to the beam self-fields. --\u003e\n\n###### Performance\n\nCosyr is designed to leverage multi-GPU nodes. It exploits the fact that the field kernel, wavelets emission and particle update are completely local. For a given beam, a subset of particles is assigned to a MPI rank. The field kernel is primarily parallelized over particles to be run on manycore nodes or GPU. The wavelet-to-mesh interpolation is done in a multithreaded way using [Portage](https://github.com/laristra/portage).\n\n### Build and use\n\nIt can be built on Linux or macOS using [CMake](https://cmake.org).  \nIt requires a [C++14](https://isocpp.org/wiki/faq/cpp14-language) compiler endowed with [OpenMP](https://www.openmp.org).  \nThe field kernels are designed to be run on manycore CPU or GPU.  \nFor optimized builds on Intel KNL, we recommend the Intel compiler.  \nTo run on Nvidia's GPU, it should be compiled with [nvcc](https://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/index.html).  \n\u003e It was not currently tested on AMD's GPU.  \n\n###### Dependencies\n\n- [kokkos](https://github.com/kokkos/kokkos) for the wavefronts and field kernels.\n- [cabana](https://github.com/ECP-copa/Cabana) for the particle pusher.\n- [portage](https://github.com/laristra/portage) for the interpolation step.\n- [pybind](https://github.com/pybind/pybind11) and a [python](https://www.python.org) environment to handle simulation parameters.  \n\nThe instructions to build the project and its dependencies can be found [here](./docs/BUILD.md).   \n\n###### Running\n\nThe simulation parameters are given through an input deck.  \nThe latter is simply a regular Python script.  \nThose parameters are loaded into the Python locals and can changed as needed.  \nA set of examples are given in the [input](./input) directory.  \nIt is also possible to initialize a beam array for the simulation as shown [here](./input/test_beam_remap.py).  \nTo run: `mpirun -np 4 ./cosyr params.py`\n\n### License and contributions\n\nCosyr is developed at Los Alamos National Laboratory (C20129).  \nIt is supported by the Laboratory Directed Research and Development program (LDRD).  \nIt is open source under the [BSD-3 licence](./LICENSE.txt).  \nIt is developed by:\n\n- Chengkun Huang \n- Feiyu Li \n- Hoby Rakotoarivelo\n- Boqian Shen \n\nOther contributors:\n\n- Rao Garimella \n- Thomas Kwan\n- Bruce Carlsten \n- Robert Robey \n- Orion Yeung\n- Parker Pombrio\n\n### Copyright\n© 2021. Triad National Security, LLC. All rights reserved.\nThis program was produced under U.S. Government contract 89233218CNA000001 for Los Alamos\nNational Laboratory (LANL), which is operated by Triad National Security, LLC for the U.S.\nDepartment of Energy/National Nuclear Security Administration. All rights in the program are\nreserved by Triad National Security, LLC, and the U.S. Department of Energy/National Nuclear\nSecurity Administration. The Government is granted for itself and others acting on its behalf a\nnonexclusive, paid-up, irrevocable worldwide license in this material to reproduce, prepare\nderivative works, distribute copies to the public, perform publicly and display publicly, and to permit others to do so.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flanl%2Fcosyr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flanl%2Fcosyr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flanl%2Fcosyr/lists"}