openmc-source-plotter


Nameopenmc-source-plotter JSON
Version 0.7.0 PyPI version JSON
download
home_page
SummaryA Python package for extracting and plotting the locations, directions, energy distributions of OpenMC source particles.
upload_time2024-03-08 14:48:15
maintainer
docs_urlNone
author
requires_python>=3.8
licenseMIT License Copyright (c) 2021 Fusion Energy Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords energy plot source particle coordinates direction openmc gamma
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![CI with install](https://github.com/fusion-energy/openmc_source_plotter/actions/workflows/ci_with_install.yml/badge.svg?branch=main)](https://github.com/fusion-energy/openmc_source_plotter/actions/workflows/ci_with_install.yml)

[![Upload Python Package](https://github.com/fusion-energy/openmc_source_plotter/actions/workflows/python-publish.yml/badge.svg)](https://github.com/fusion-energy/openmc_source_plotter/actions/workflows/python-publish.yml)

A Python package for plotting the positions, directions or energy distributions of OpenMC sources.

# Installation

You will need to have OpenMC version 0.14.0 or newer installed first.

```bash
pip install openmc_source_plotter
```

# Features

The package provides three plotting functions that can plot source data from openmc objects.
- ```plot_source_energy```
- ```plot_source_position```
- ```plot_source_direction```
- ```plot_gamma_emission```
 
Additionally the package provides a convienient method of sampling particles
- ```sample_initial_particles```


# Example plots

Below are some basic examples, for more examples see the [examples folder](https://github.com/fusion-energy/openmc_source_plotter/tree/main/examples) for example usage scripts.


## Plot of energy distribution of the source

:link:[Link](https://github.com/fusion-energy/openmc_source_plotter/blob/main/examples/example_plot_source_energy.py) to example script.

![openmc particle source energy plot](https://user-images.githubusercontent.com/8583900/143615694-a3578115-f8a2-4971-bf26-458177b4f113.png)

## Plot of energy distribution of two sources

:link:[Link](https://github.com/fusion-energy/openmc_source_plotter/blob/main/examples/example_plot_two_source_energies.py) to example script.

![openmc particle source energy plot](https://user-images.githubusercontent.com/8583900/151376414-fb1555eb-61d1-4c82-bc4d-a05f62819c5d.png)

## Plot direction of particles

:link:[Link](https://github.com/fusion-energy/openmc_source_plotter/blob/main/examples/example_plot_source_direction.py) to example script.

![openmc particle source direction plot](https://user-images.githubusercontent.com/8583900/143615706-3b3a8467-0233-42d6-a66c-d536c80a01d8.png)


## Plot position of particles

:link:[Link](https://github.com/fusion-energy/openmc_source_plotter/blob/main/examples/example_plot_source_position.py) to example script.


![openmc particle source position plot](https://user-images.githubusercontent.com/8583900/179424915-bee56a87-6214-46ef-8625-92b8f4cbd1b3.png)

## Plot labeled gamma lines from material

:link:[Link](https://github.com/fusion-energy/openmc_source_plotter/blob/main/examples/example_gamma_spec_plot.py) to example script.

![gamma spec with labels](examples/gamma_spec.png)


## Extract particle objects

A list of ```openmc.Particle``` objects can be obtained using ```model.sample_initial_particles()``` or ```openmc.SourceBase.sample_initial_particles()```

```python
import openmc
from openmc_source_plotter import sample_initial_particles

settings = openmc.Settings()
settings.particles = 1
settings.batches = 1
my_source = openmc.IndependentSource()
my_source.energy = openmc.stats.muir(e0=14080000.0, m_rat=5.0, kt=20000.0)
settings.source = my_source
materials = openmc.Materials()
sph = openmc.Sphere(r=100, boundary_type="vacuum")
cell = openmc.Cell(region=-sph)
geometry = openmc.Geometry([cell])

model = openmc.Model(geometry, materials, settings)

particles = sample_initial_particles(this=model, n_samples=10)

print(particles)
>>>[<SourceParticle: neutron at E=1.440285e+07 eV>, <SourceParticle: neutron at E=1.397691e+07 eV>, <SourceParticle: neutron at E=1.393681e+07 eV>, <SourceParticle: neutron at E=1.470896e+07 eV>, <SourceParticle: neutron at E=1.460563e+07 eV>, <SourceParticle: neutron at E=1.420684e+07 eV>, <SourceParticle: neutron at E=1.413932e+07 eV>, <SourceParticle: neutron at E=1.412428e+07 eV>, <SourceParticle: neutron at E=1.464779e+07 eV>, <SourceParticle: neutron at E=1.391648e+07 eV>]

print(particles[0].E)
>>>1.440285e+07
```

## Related packages

Tokamak sources can also be plotted using the [openmc-plasma-source](https://github.com/fusion-energy/openmc-plasma-source) package

![openmc_source_plotter_openmc-plasma-source_tokamak](https://user-images.githubusercontent.com/8583900/187487894-ba0bd025-46f2-4c7d-8b15-3d260aed47a0.png)

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "openmc-source-plotter",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "energy,plot,source,particle,coordinates,direction,openmc,gamma",
    "author": "",
    "author_email": "Jonathan Shimwell <mail@jshimwell.com>",
    "download_url": "https://files.pythonhosted.org/packages/73/aa/8e9c291cb401a2a9a188b3d28eec4f2bf208f9cfd32010296feeaaae46b6/openmc_source_plotter-0.7.0.tar.gz",
    "platform": null,
    "description": "[![CI with install](https://github.com/fusion-energy/openmc_source_plotter/actions/workflows/ci_with_install.yml/badge.svg?branch=main)](https://github.com/fusion-energy/openmc_source_plotter/actions/workflows/ci_with_install.yml)\n\n[![Upload Python Package](https://github.com/fusion-energy/openmc_source_plotter/actions/workflows/python-publish.yml/badge.svg)](https://github.com/fusion-energy/openmc_source_plotter/actions/workflows/python-publish.yml)\n\nA Python package for plotting the positions, directions or energy distributions of OpenMC sources.\n\n# Installation\n\nYou will need to have OpenMC version 0.14.0 or newer installed first.\n\n```bash\npip install openmc_source_plotter\n```\n\n# Features\n\nThe package provides three plotting functions that can plot source data from openmc objects.\n- ```plot_source_energy```\n- ```plot_source_position```\n- ```plot_source_direction```\n- ```plot_gamma_emission```\n \nAdditionally the package provides a convienient method of sampling particles\n- ```sample_initial_particles```\n\n\n# Example plots\n\nBelow are some basic examples, for more examples see the [examples folder](https://github.com/fusion-energy/openmc_source_plotter/tree/main/examples) for example usage scripts.\n\n\n## Plot of energy distribution of the source\n\n:link:[Link](https://github.com/fusion-energy/openmc_source_plotter/blob/main/examples/example_plot_source_energy.py) to example script.\n\n![openmc particle source energy plot](https://user-images.githubusercontent.com/8583900/143615694-a3578115-f8a2-4971-bf26-458177b4f113.png)\n\n## Plot of energy distribution of two sources\n\n:link:[Link](https://github.com/fusion-energy/openmc_source_plotter/blob/main/examples/example_plot_two_source_energies.py) to example script.\n\n![openmc particle source energy plot](https://user-images.githubusercontent.com/8583900/151376414-fb1555eb-61d1-4c82-bc4d-a05f62819c5d.png)\n\n## Plot direction of particles\n\n:link:[Link](https://github.com/fusion-energy/openmc_source_plotter/blob/main/examples/example_plot_source_direction.py) to example script.\n\n![openmc particle source direction plot](https://user-images.githubusercontent.com/8583900/143615706-3b3a8467-0233-42d6-a66c-d536c80a01d8.png)\n\n\n## Plot position of particles\n\n:link:[Link](https://github.com/fusion-energy/openmc_source_plotter/blob/main/examples/example_plot_source_position.py) to example script.\n\n\n![openmc particle source position plot](https://user-images.githubusercontent.com/8583900/179424915-bee56a87-6214-46ef-8625-92b8f4cbd1b3.png)\n\n## Plot labeled gamma lines from material\n\n:link:[Link](https://github.com/fusion-energy/openmc_source_plotter/blob/main/examples/example_gamma_spec_plot.py) to example script.\n\n![gamma spec with labels](examples/gamma_spec.png)\n\n\n## Extract particle objects\n\nA list of ```openmc.Particle``` objects can be obtained using ```model.sample_initial_particles()``` or ```openmc.SourceBase.sample_initial_particles()```\n\n```python\nimport openmc\nfrom openmc_source_plotter import sample_initial_particles\n\nsettings = openmc.Settings()\nsettings.particles = 1\nsettings.batches = 1\nmy_source = openmc.IndependentSource()\nmy_source.energy = openmc.stats.muir(e0=14080000.0, m_rat=5.0, kt=20000.0)\nsettings.source = my_source\nmaterials = openmc.Materials()\nsph = openmc.Sphere(r=100, boundary_type=\"vacuum\")\ncell = openmc.Cell(region=-sph)\ngeometry = openmc.Geometry([cell])\n\nmodel = openmc.Model(geometry, materials, settings)\n\nparticles = sample_initial_particles(this=model, n_samples=10)\n\nprint(particles)\n>>>[<SourceParticle: neutron at E=1.440285e+07 eV>, <SourceParticle: neutron at E=1.397691e+07 eV>, <SourceParticle: neutron at E=1.393681e+07 eV>, <SourceParticle: neutron at E=1.470896e+07 eV>, <SourceParticle: neutron at E=1.460563e+07 eV>, <SourceParticle: neutron at E=1.420684e+07 eV>, <SourceParticle: neutron at E=1.413932e+07 eV>, <SourceParticle: neutron at E=1.412428e+07 eV>, <SourceParticle: neutron at E=1.464779e+07 eV>, <SourceParticle: neutron at E=1.391648e+07 eV>]\n\nprint(particles[0].E)\n>>>1.440285e+07\n```\n\n## Related packages\n\nTokamak sources can also be plotted using the [openmc-plasma-source](https://github.com/fusion-energy/openmc-plasma-source) package\n\n![openmc_source_plotter_openmc-plasma-source_tokamak](https://user-images.githubusercontent.com/8583900/187487894-ba0bd025-46f2-4c7d-8b15-3d260aed47a0.png)\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2021 Fusion Energy  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "A Python package for extracting and plotting the locations, directions, energy distributions of OpenMC source particles.",
    "version": "0.7.0",
    "project_urls": {
        "Bug Tracker": "https://github.com/fusion-energy/openmc_source_plotter/issues",
        "Homepage": "https://github.com/fusion-energy/openmc_source_plotter"
    },
    "split_keywords": [
        "energy",
        "plot",
        "source",
        "particle",
        "coordinates",
        "direction",
        "openmc",
        "gamma"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1a5cd9c8a83b44dfc5c168c5b0bb0694319112f6433aad4f32983e75e067b910",
                "md5": "ff750c61e2293c4258e0eeecb43af378",
                "sha256": "332f50f88a3f4cd70ee5b96b2afb4f293397b2ebb88675cfba048272ad4ae12f"
            },
            "downloads": -1,
            "filename": "openmc_source_plotter-0.7.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "ff750c61e2293c4258e0eeecb43af378",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 8663,
            "upload_time": "2024-03-08T14:48:13",
            "upload_time_iso_8601": "2024-03-08T14:48:13.403643Z",
            "url": "https://files.pythonhosted.org/packages/1a/5c/d9c8a83b44dfc5c168c5b0bb0694319112f6433aad4f32983e75e067b910/openmc_source_plotter-0.7.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "73aa8e9c291cb401a2a9a188b3d28eec4f2bf208f9cfd32010296feeaaae46b6",
                "md5": "b4297d98659746fc8d0f6d049b82ab77",
                "sha256": "d1a5c9cd7ab22a5ceb2528d71f03e5a987d1f6a1fb559bcfaf74be6679088d23"
            },
            "downloads": -1,
            "filename": "openmc_source_plotter-0.7.0.tar.gz",
            "has_sig": false,
            "md5_digest": "b4297d98659746fc8d0f6d049b82ab77",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 38072,
            "upload_time": "2024-03-08T14:48:15",
            "upload_time_iso_8601": "2024-03-08T14:48:15.921798Z",
            "url": "https://files.pythonhosted.org/packages/73/aa/8e9c291cb401a2a9a188b3d28eec4f2bf208f9cfd32010296feeaaae46b6/openmc_source_plotter-0.7.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-08 14:48:15",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "fusion-energy",
    "github_project": "openmc_source_plotter",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "openmc-source-plotter"
}
        
Elapsed time: 0.19804s