Python tools to build MCNP geometry inputs.
Project description
MCgeometry
MCgeometry is a lightweight Python module for building MCNP geometry inputs from
Python objects.
It provides containers for:
- surfaces (
Surfaces) - cells (
Cells) - materials (
Materials) - geometry/input writing (
MCNP)
Repository layout
mcgeometry/
__init__.py
Surfaces.py
Cells.py
Materials.py
MCNP.py
Source.py
Tally.py
Traslation.py
Requirements
- Python 3.8+ (recommended)
numpyis used bySource.py
Installation
From PyPI (after publication):
pip install mcgeometry
From source (repository root):
pip install -e .
This enables imports without manually setting PYTHONPATH.
Quick start
Example: create a simple world box containing one spherical cell and generate the MCNP input text.
from mcgeometry import Surfaces, Cells, Materials, MCNP
# 1) Define surfaces
surfaces = Surfaces()
surfaces.rpp("world", p_min=[-100, -100, -100], p_max=[100, 100, 100])
surfaces.sph("sphere", c=[0, 0, 0], r=10)
# 2) Define materials
materials = Materials()
materials.add_material("vacuum", rho=0.0)
materials.add_material("water", zzaid_comp=[["1001.80c", 2], ["8016.80c", 1]], rho=1.0)
# 3) Define cells
cells = Cells(surfaces, Outer_World_Surface="world")
cells.add_cell("sphere_cell", material="water", surface_name="sphere", imp_n=1)
# 4) Build MCNP input string
mcnp = MCNP(cells, surfaces, materials)
input_text = mcnp.Write()
print(input_text)
Examples
The examples/ folder contains runnable scripts:
examples/basic_geometry.py: minimal geometry/material/cell setup and MCNP input generation.
Run:
python examples/basic_geometry.py
How to add this module to the Python path
If you are developing from this repository (without packaging/installing), Python
must be able to find the project root (the folder that contains mcgeometry/).
Option 1: Temporary (current shell session)
From the repository root:
export PYTHONPATH="$PWD:$PYTHONPATH"
Then import normally:
from mcgeometry import Surfaces, Cells, Materials, MCNP
Option 2: Permanent (your shell profile)
Add this line to ~/.zshrc (zsh) or ~/.bashrc (bash):
export PYTHONPATH="/absolute/path/to/mcgeometry/repo:$PYTHONPATH"
Reload your shell:
source ~/.zshrc
Option 3: In code (single script/notebook)
import sys
sys.path.append("/absolute/path/to/mcgeometry/repo")
from mcgeometry import Surfaces, Cells, Materials, MCNP
Notes
- The package exports most core classes through
mcgeometry/__init__.py, so importing frommcgeometryis the simplest entry point. - The project currently uses the
Traslationnaming used in source files. - The API now also includes standardized aliases:
- class alias:
Translation(keepsTraslationfor compatibility) MCNP.write*methods (keepsMCNP.Write*for compatibility)
- class alias:
SourceandTallymodules are currently under development and still need full validation before production use.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mcgeometry-0.1.0.tar.gz.
File metadata
- Download URL: mcgeometry-0.1.0.tar.gz
- Upload date:
- Size: 21.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2af5e1cf7eaacd6cd8aa90b682f05dc8ea4214ca0fabfd52c9cc015f1d78f2c4
|
|
| MD5 |
f14b568e717595eae2588ee5f081a649
|
|
| BLAKE2b-256 |
0f2550fb38dc037467b8fbbc852b78b218e8087aa3318e407e178252f58ab2fc
|
File details
Details for the file mcgeometry-0.1.0-py3-none-any.whl.
File metadata
- Download URL: mcgeometry-0.1.0-py3-none-any.whl
- Upload date:
- Size: 22.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
03e20ac4cd54ed3fdff02293a44290fde4f0ef17f76d61df0cda628b4eeb6e32
|
|
| MD5 |
4d2551c6def85955440e2487a18f2fd5
|
|
| BLAKE2b-256 |
32dbbca527fc9d2fe23254ad85be6b5875c1f797a552e6e2fba210b1665b657a
|