kdsource

Tool for modeling distributional particle sources for Monte Carlo simulations, with Kernel Density Estimation.

https://github.com/kdsource/kdsource

Science Score: 54.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
    3 of 8 committers (37.5%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (16.7%) to scientific vocabulary
Last synced: 7 months ago · JSON representation ·

Repository

Tool for modeling distributional particle sources for Monte Carlo simulations, with Kernel Density Estimation.

Basic Info
Statistics
  • Stars: 20
  • Watchers: 4
  • Forks: 12
  • Open Issues: 16
  • Releases: 1
Created over 5 years ago · Last pushed over 1 year ago
Metadata Files
Readme License Citation

README.md

logo

KDSource Documentation Status License CMake Python 3.6

This is source version of KDSource, a tool for Monte Carlo particle sources generation using Kernel Density Estimation. Visit our Documentation Page for more details!

KDSource assists Monte Carlo beams and shielding calculations, improving tally results in difficult problems. It allows to model big systems (e.g.: investigation reactor guides hall) thru spatial or temporal coupling of different simulations in different transport codes, implementing as well variance reduction.

It processes particle lists recorded as output of a simulation (e.g.: passing thru a window), to be used as input in another one. It estimates density distribution in energy, position and direction by means of Kernel Density Estimation (KDE) technique, allowing visualizing it as well as using it to produce new particles (artificial, but with the same estimated density). This allows to increase the number of source particles in the second simulation, improving its statistics (variance reduction).

KDSource uses MCPL particle lists format. In its modified version included in this distribution, it allows working with the following Monte Carlo codes: * MCNP * PHITS * McStas * TRIPOLI-4

In TRIPOLI-4 and McStas it is possible "on-the-fly" sampling during simulations, while for the other formats it is necessary to record the source particle list before the simulation.

Contents:

The KDSource package consists in the following tools:

  • Python API: Allows creating, optimizing, analyzing, plotting, and saving KDE sources. Optimización consists in automatic selection of bandwidth. Internally, it uses KDEpy library for KDE.

  • C API: Allows loading the sources saved with Python, and generating new synthetic samples. These follow the estimated distribution, and can be saved in a new MCPL file or be introduced directly in a simulation.

  • Templates and communication files for Monte Carlo codes. Specific files are included for utilization of KDSource tools in McStas y TRIPOLI-4 simulations.

  • Command line API: Allows easily producing samples, based on sources saved with Python. Also allows to access templates and communication files, as well as MCPL applications.

Installation:

Currently, the only implemented installation method is via cloning the GitHub repository and building with CMake and Pip. See bellow for specifical instructions for Linux and Windows.

Linux and Mac

Requirements: Git 2.14+, GCC 9+, CMake 3+, Pip 22+ (Python 3.8+), LibXml2 2.9.3.

If you are on Linux OS you can install libxml2 with:

bash $ sudo apt-get update $ sudo apt-get install libxml2-dev

for Ubuntu, or similarly for other Linux distributions, using the corresponding package manager.

In case you are in MacOS libxml2 can be installed by using Homebrew:

bash $ brew install libxml2 The following mandatory steps are valid for both MacOS and linux systems:

  1. First of all, clone this repository with all its submodules to a local repository.

bash $ git clone --recurse-submodules https://github.com/KDSource/KDSource

  1. Go to source directory and install with cmake:

bash $ cd /path/to/kdsourcesource $ mkdir build && cd build $ cmake .. -DCMAKE_INSTALL_PREFIX=/path/to/kdsourceinstall $ make install $ cd .. Where /path/to/kdsourcesource is the folder where the source distribution of KDSource was cloned, and /path/to/kdsourceinstall is the folder where you wish to install KDSource internal files.

  1. Install Python API with pip:

bash $ cd python $ pip install . $ cd ..

  1. KDSource is ready to be used in /path/to/kdsourceinstall. For example, you can see the kdtool command options with:

bash $ /path/to/kdsourceinstall/bin/kdtool --help

If you wish to have KDSource tools available in your path, execute:

bash $ export PATH=$PATH:/path/to/kdsourceinstall/bin Or add this command to ~/.profile (and update with source ~/.profile).

Windows

Requirements: Git 2.14+, MinGW-GCC 11+, CMake 3+, Pip 22+ (Python 3.8+), LibXml2 2.9.3.

You can install KDSource, including LibXml2, using the INSTALL.ps1 PowerShell script: ```bash

.\INSTALL.ps1 `` The script requires 7-Zip, with7z` command in the system path.

If you prefer a step-by-step approach, you can download libxml2 in the following link: * 64 bits: http://xmlsoft.org/sources/win32/64bit/ * 32 bits: http://xmlsoft.org/sources/win32/ Download and extract the libxml2 and iconv archives, and add the path to the bin subdirectory of each library to the system PATH variable.

Important: The architecture (32 vs 64 bits) of the installed libxml2 and iconv must be the same as the MinGW and CMake architecture. Also make sure that other libxml2 or iconv files with different architecture are not in the PATH, or at least not ahead of the ones to be used.

The following instructions use the PowerShell command prompt, and therefore assume that the bin subdirectory of Git, MinGW and CMake are in the system PATH.

  1. First of all, clone this repository with all its submodules to a local repository.

```bash

git clone --recurse-submodules https://github.com/KDSource/KDSource ```

  1. Go to source directory and install with cmake:

```bash

cd C:\path\to\kdsourcesource mkdir build && cd build cmake .. -DCMAKEINSTALLPREFIX=C:\path\to\kdsourceinstall -G "MinGW Makefiles" set CINCLUDEPATH=C:\path\to\iconv\include mingw32-make install cd .. `` WhereC:\path\to\kdsourcesourceis the folder where the source distribution of KDSource was cloned, andC:\path\to\kdsourceinstallis the folder where you wish to install KDSource internal files.C:\path\to\iconvis the folder whereiconv` was extracted.

  1. Add the C:\\path\\to\\kdsourceinstall\lib subdirectory to the system PATH.

  2. Install Python API with pip:

```bash

cd python pip install . cd .. ```

  1. KDSource is ready to be used in C:\\path\\to\\kdsourceinstall. For example, you can see the kdtool-resample command options with:

```bash

C:\path\to\kdsourceinstall\bin\kdtool-resample --help ```

If you wish to have KDSource tools available in your path, add the bin subdirectory to the system PATH.

Note: Currently, the kdtool application is not available on Windows, but the resampling tool can be invoked directly with kdtool-resample, as shown in the example above.

Usage examples and templates

See the documentation page for usage instructions, tutorials, and a detailed documentation of all the functionalities in KDSource.

Usage examples can be found in the docs/examples subdirectory. At the moment these are: * Verification.ipynb: Analytic example. KDSource is used to generate a source from a particle list sampled from an known correlated distribution, and the generated particles distributions are compared with the analytical density.

Moreover, templates for common usage of KDSource in Monte Carlo simulations can be found in the templates subdirectory, and can be copied to the working directory via the kdtool templates . command. They are: * preproc_tracks.ipynb: Template for the generation of a KDE source from a particle list registered with any of the MCPL-compatible Monte Carlo codes. The generated source can be used as input of any of said codes, generating an unlimited number of particles. * preproc_tally.ipynb: Template for the generation of a volumetric KDE source from a TRIPOLI-4 reaction tally (usually activation). The generated source can be used as input of any of the MCPL-compatible Monte Carlo codes, generating an unlimited number of particles. * postproc.ipynb: Template for collecting integral results of simulations with McStas and/or TRIPOLI-4. * doseplots.ipynb: Template for plotting TRIPOLI-4 volume tallies (usually dose maps). * McStas templates: * kds_instrument_example.instr: Template instrument for using KDSource in McStas. * exe_McStas.sh: Template for executing McStas using KDSource. * TRIPOLI-4 templates: * exe_Tripoli.sh: Template for executing TRIPOLI-4 with KDSource. * KDSource.c: Template for using KDSource as an external source. * template.t4: Template for a TRIPOLI-4 input.

Issues and contributing

If you are having trouble using the package, please let us know by creating a Issue on GitHub and we'll get back to you.

Contributions are very welcome. To contribute, fork the project, create a branch and submit a Pull Request.

Reference

Usage of the KDSource package is allowed in the terms detailed in the LICENSE file. However, if you use it for your work, we would appreciate it if you would use the following reference:

Abbate, O. I., Schmidt, N. S., Prieto, Z. M., Robledo, J. I., Dawidowski, J., Márquez, A. A., & Márquez Damián, J. I. KDSource, a tool for the generation of Monte Carlo particle sources using kernel density estimation [Computer software]. https://github.com/KDSource/KDSource

Owner

  • Name: KDSource
  • Login: KDSource
  • Kind: organization

Citation (CITATION.cff)

# This CITATION.cff file was generated with cffinit.
# Visit https://bit.ly/cffinit to generate yours today!

cff-version: 1.2.0
title: >-
  KDSource, a tool for the generation of Monte Carlo
  particle sources using kernel density estimation
message: >-
  If you use this software, please cite it using the
  metadata from this file.
type: software
authors:
  - given-names: Osiris Inti
    family-names: Abbate
    email: intiabbate@gmail.com
    orcid: 'https://orcid.org/0000-0002-7764-1776'
  - given-names: Norberto Sebastián
    family-names: Schmidt
    email: norberttschmidt@gmail.com
    orcid: 'https://orcid.org/0000-0003-3600-1446'
  - given-names: Zoe Micaela
    family-names: Prieto
    email: zoe.prietom@gmail.com
    orcid: 'https://orcid.org/0000-0001-8641-1588'
  - given-names: Jose Ignacio
    family-names: Robledo
    email: jose.robledo@cab.cnea.gov.ar
    orcid: 'https://orcid.org/0000-0001-8784-2558'
  - given-names: Javier
    family-names: Dawidowski
    email: jdawidowski@gmail.com
    orcid: 'https://orcid.org/0000-0003-0289-7838'
  - given-names: Ariel Aníbal
    family-names: Márquez
    email: arielmqz@gmail.com
  - given-names: José Ignacio
    family-names: Márquez Damián
    email: nachomarquez@gmail.com
    orcid: 'https://orcid.org/0000-0002-9611-914X'

license: GPL-3
repository-code: "https://github.com/KDSource/KDSource"

GitHub Events

Total
  • Issues event: 5
  • Watch event: 2
  • Issue comment event: 2
  • Pull request event: 4
Last Year
  • Issues event: 5
  • Watch event: 2
  • Issue comment event: 2
  • Pull request event: 4

Committers

Last synced: almost 2 years ago

All Time
  • Total Commits: 139
  • Total Committers: 8
  • Avg Commits per committer: 17.375
  • Development Distribution Score (DDS): 0.381
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
inti i****e@g****m 86
nschmidt n****t@f****e 29
Zoe Prieto z****o@i****r 17
Jose Robledo j****2@g****m 2
Jose Robledo 4****o 2
Jose Robledo j****o@u****r 1
Norberto Schmidt n****t@g****m 1
Osiris Inti Abbate 6****e 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: almost 2 years ago

All Time
  • Total issues: 8
  • Total pull requests: 17
  • Average time to close issues: 9 days
  • Average time to close pull requests: about 1 month
  • Total issue authors: 4
  • Total pull request authors: 5
  • Average comments per issue: 0.75
  • Average comments per pull request: 0.24
  • Merged pull requests: 12
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 2
  • Pull requests: 2
  • Average time to close issues: N/A
  • Average time to close pull requests: about 1 hour
  • Issue authors: 1
  • Pull request authors: 2
  • Average comments per issue: 0.0
  • Average comments per pull request: 0.5
  • Merged pull requests: 1
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • zoeprieto (5)
  • inti-abbate (4)
  • ebknudsen (2)
  • jorobledo (2)
  • willend (1)
  • Gimeno0 (1)
  • nicriz (1)
  • mina-acc (1)
Pull Request Authors
  • zoeprieto (13)
  • norberto-schmidt (10)
  • jorobledo (6)
  • Gimeno0 (3)
  • inti-abbate (2)
  • franciscofox (1)
Top Labels
Issue Labels
enhancement (3)
Pull Request Labels

Dependencies

.github/workflows/ci.yml actions
  • actions/checkout master composite
  • actions/setup-python v2 composite
docs/requirements.txt pypi
  • Sphinx *
  • ipykernel *
  • myst-parser *
  • nbsphinx *
  • numpydoc *
  • python *
  • sphinx-rtd-theme *
pyproject.toml pypi
python/pyproject.toml pypi
python/setup.py pypi
  • KDEpy >=1.1.0,<2.0
  • Pillow >=9.0.1,<10.0
  • joblib >=1.0.1,<2.0
  • matplotlib >=3.4.2,<4.0
  • mcpl >=1.3.2,<2.0
  • numpy >=1.20.3,<2.0
  • scikit-learn >=0.24.2,<1.0
  • scipy >=1.6.3,<2.0