Skip to main content

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)
  • numpy is used by Source.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 from mcgeometry is the simplest entry point.
  • The project currently uses the Traslation naming used in source files.
  • The API now also includes standardized aliases:
    • class alias: Translation (keeps Traslation for compatibility)
    • MCNP.write* methods (keeps MCNP.Write* for compatibility)
  • Source and Tally modules are currently under development and still need full validation before production use.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcgeometry-0.1.0.tar.gz (21.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcgeometry-0.1.0-py3-none-any.whl (22.9 kB view details)

Uploaded Python 3

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

Hashes for mcgeometry-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2af5e1cf7eaacd6cd8aa90b682f05dc8ea4214ca0fabfd52c9cc015f1d78f2c4
MD5 f14b568e717595eae2588ee5f081a649
BLAKE2b-256 0f2550fb38dc037467b8fbbc852b78b218e8087aa3318e407e178252f58ab2fc

See more details on using hashes here.

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

Hashes for mcgeometry-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 03e20ac4cd54ed3fdff02293a44290fde4f0ef17f76d61df0cda628b4eeb6e32
MD5 4d2551c6def85955440e2487a18f2fd5
BLAKE2b-256 32dbbca527fc9d2fe23254ad85be6b5875c1f797a552e6e2fba210b1665b657a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page