Skip to main content

feff10-rs

Python bindings for FEFF10, a real-space multiple-scattering code for ab initio calculations of X-ray absorption spectra (EXAFS, XANES) and related properties.

Built with PyO3 and maturin for native performance with a Pythonic API.

Installation

pip install feff10-rs

No compiler needed — prebuilt wheels are available for:

Platform Architecture Python
Linux x86_64, aarch64 3.9 – 3.14+
macOS Intel, Apple Silicon 3.9 – 3.14+
Windows x86_64 3.9 – 3.14+

Linux ARM64 wheels require glibc 2.39 or newer (for example, Ubuntu 24.04), matching the native release archive's runtime baseline.

Calculations run each FEFF stage in a fresh Python worker process using the current interpreter. This isolates Fortran state and fatal errors on every platform, including Windows and macOS GUI/notebook hosts. The installed feff10 package must be importable by sys.executable; no worker setup is required in user code.

Quick Start

import feff10

# One-liner: parse, validate, and run
result = feff10.run("feff.inp", "./work")
print(f"Done in {result.total_duration_secs:.1f}s")

# Parse and compare output
xmu = feff10.FeffTable.from_file("./work/xmu.dat")
reference = feff10.FeffTable.from_file("reference_xmu.dat")
rsq = xmu.r_squared(reference, col_x=0, col_y=3)
print(f"R-squared = {rsq*100:.4f}%")

You can also pass raw feff.inp text or a FeffInput object:

# From raw text
result = feff10.run(open("feff.inp").read(), "./work")

# From a FeffInput object
inp = feff10.FeffInput.from_file("feff.inp")
inp.s02 = 0.9
result = feff10.run(inp, "./work")

Working with Input Files

Parsing

# From file
inp = feff10.FeffInput.from_file("feff.inp")

# From string
inp = feff10.FeffInput.parse(content)

# Strict mode — raises FeffParseError on malformed input
inp = feff10.FeffInput.from_file_strict("feff.inp")

Inspecting

inp.edge           # "K", "L3", etc.
inp.s02            # amplitude reduction factor
inp.num_atoms      # number of atoms
inp.num_potentials # number of unique potentials
inp.control        # CONTROL flags (6-element list)
inp.other_cards    # other cards (EXAFS, RPATH, etc.)

for pot in inp.potentials:
    print(f"ipot={pot.ipot}, Z={pot.z}, tag={pot.tag}")

for atom in inp.atoms:
    print(f"({atom.x}, {atom.y}, {atom.z}) ipot={atom.ipot}")

Creating from Scratch

inp = feff10.FeffInput(
    title=["Cu K-edge EXAFS"],
    edge="K",
    s02=1.0,
    potentials=[
        feff10.Potential(ipot=0, z=29, tag="Cu"),
        feff10.Potential(ipot=1, z=29, tag="Cu"),
    ],
    atoms=[
        feff10.Atom(x=0.0, y=0.0, z=0.0, ipot=0, tag="Cu"),
        feff10.Atom(x=0.0, y=1.805, z=1.805, ipot=1, tag="Cu"),
    ],
    other_cards=["EXAFS 20.0", "RPATH 5.5"],
)

Modifying and Writing

inp.edge = "L3"
inp.s02 = 0.85
inp.control = [1, 1, 1, 1, 0, 0]
inp.write_to_file("modified.inp")

Validation

# Validate without running (raises FeffConfigError if invalid)
feff10.validate("feff.inp")

# Or validate a FeffInput object
inp = feff10.FeffInput.from_file("feff.inp")
inp.validate()

Checks: absorber potential (ipot=0) exists, atoms reference valid potentials, no duplicate ipot values, atomic numbers in range, and more.

Running Calculations

Simple (Recommended)

# From file path — validates input automatically
result = feff10.run("feff.inp", "./work")

# From FeffInput object
result = feff10.run(inp, "./work")

Full Control

config = feff10.FeffConfig("./work", inp)
result = feff10.FeffPipeline(config).run()

for sr in result.stages:
    print(f"{sr.stage.executable_name}: {sr.duration_secs:.3f}s")
print(f"Total: {result.total_duration_secs:.3f}s")

Running Specific Stages

config = feff10.FeffConfig(
    "./work", inp,
    stages=[feff10.Stage.RDINP, feff10.Stage.POT, feff10.Stage.XSPH],
)

Progress Callbacks

def on_progress(stage, progress):
    if progress.kind == "starting":
        print(f"  Running {stage.executable_name}...", end="", flush=True)
    else:
        print(f" done ({progress.duration_secs:.2f}s)")

result = feff10.FeffPipeline(config).run_with_progress(on_progress)

Pipeline Stages

FEFF10 has 18 stages, each a separate computational step:

for stage in feff10.Stage.all():
    print(f"{stage.executable_name} (control index {stage.control_index})")

Parsing Output

Reading xmu.dat

result = feff10.run("feff.inp", "./work")
xmu = result.read_xmu()            # convenience on PipelineResult
outputs = result.outputs()         # discover all *.dat outputs

print(xmu.ncols)    # number of columns
print(xmu.nrows)    # number of data points
print(xmu.header)   # comment lines from file header
print(xmu)          # shows first 5 rows
print(len(outputs.files))

Discovering and parsing multiple outputs

outputs = feff10.FeffOutputs.discover("./work")
for f in outputs.files:
    print(f.kind, f.name)

chi = outputs.read_chi()
paths = outputs.read_paths()
print(paths.npaths, paths.total_degeneracy())

Accessing Columns

energy = xmu.column(0)  # or xmu[0]
mu = xmu.column(3)      # or xmu[3]
last = xmu[-1]           # negative indexing

for col in xmu:          # iterate over columns
    print(f"{len(col)} points")

Comparing Spectra

calculated = feff10.FeffTable.from_file("./work/xmu.dat")
reference = feff10.FeffTable.from_file("reference_xmu.dat")

rsq = calculated.r_squared(reference, col_x=0, col_y=3)
print(f"R-squared = {rsq*100:.4f}%")  # lower is better

Pandas Integration

pip install 'feff10-rs[pandas]'
df = xmu.to_dataframe()
print(df.describe())

Error Handling

try:
    result = feff10.FeffPipeline(config).run()
except feff10.FeffPipelineError as e:
    print(f"Pipeline failed: {e}")
except feff10.FeffConfigError as e:
    print(f"Configuration error: {e}")
except feff10.FeffParseError as e:
    print(f"Parse error: {e}")
except feff10.FeffIOError as e:
    print(f"I/O error: {e}")

Exception hierarchy:

  • FeffError — base exception
    • FeffIOError — file I/O errors
    • FeffParseError — input/output parsing errors
    • FeffPipelineError — pipeline execution errors
    • FeffConfigError — configuration validation errors

GIL Behavior

Both run() and run_with_progress() release the Python GIL during FEFF stage execution, allowing other Python threads to run concurrently.

API Summary

Function / Class Description
run(input, work_dir) Run a FEFF calculation (accepts file path, raw text, or FeffInput)
validate(input) Validate input without running (accepts file path, raw text, or FeffInput)
FeffInput Parse, create, modify, and write feff.inp files
Potential Scattering potential (ipot, Z, tag, l_scmt, l_fms, stoich)
Atom Atomic position (x, y, z, ipot, tag, distance)
FeffConfig Calculation configuration (work_dir, input, stages, timeout)
Stage Pipeline stage enum (18 stages: RDINP through RHORRP)
FeffPipeline Execute FEFF calculations with optional progress callbacks
PipelineResult Execution results (stages, work_dir, total_duration_secs)
StageResult Per-stage timing (stage, duration_secs)
StageProgress Progress callback data (kind, duration_secs)
FeffTable Parse xmu.dat output with column access and pandas integration
PathsDat Parse structured paths.dat path-expansion output
FeffOutputs Discover and read output files from a work directory

License

MIT or Apache-2.0. The FEFF10 Fortran source is under its own license.

Links

Release files for feff10-rs 0.2.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for feff10-rs 0.2.3
File
feff10_rs-0.2.3-cp39-abi3-win_amd64.whl CPython 3.9 abi3 Windows x86-64 Details
feff10_rs-0.2.3-cp39-abi3-manylinux_2_39_aarch64.whl CPython 3.9 abi3 Linux glibc 2.39+ ARM64 Details
feff10_rs-0.2.3-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.9 abi3 Linux glibc 2.17+ x86-64 Details
feff10_rs-0.2.3-cp39-abi3-macosx_11_0_arm64.whl CPython 3.9 abi3 macOS 11.0+ ARM64 Details
feff10_rs-0.2.3-cp39-abi3-macosx_10_12_x86_64.whl CPython 3.9 abi3 macOS 10.12+ x86-64 Details

Total release size: 25.2 MB

Release files / feff10_rs-0.2.3-cp39-abi3-win_amd64.whl

Download URL feff10_rs-0.2.3-cp39-abi3-win_amd64.whl
Size 4.4 MB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
cda2dc4278287f117d8d42657718d466fe139c9bce78c8d5bc6b74ff42e3634f
BLAKE2b-256 checksum
How to use checksums
53152cefff6c01781b67e101a9acfff2bd4d4b2d5f8d11b9300a88747e198021
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / feff10_rs-0.2.3-cp39-abi3-manylinux_2_39_aarch64.whl

Download URL feff10_rs-0.2.3-cp39-abi3-manylinux_2_39_aarch64.whl
Size 2.7 MB
Tags CPython 3.9 Linux glibc 2.39+ ARM64 abi3
SHA-256 checksum
How to use checksums
8fd661680d7b6b78451a44c3cf7eedb9d12376edf566183daff5c925c44f9e3f
BLAKE2b-256 checksum
How to use checksums
e4fea33362269c9f6e9cb99c3233b500f3ac68a1c4b5542a32ca6eb40f18511a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / feff10_rs-0.2.3-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL feff10_rs-0.2.3-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 8.5 MB
Tags CPython 3.9 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
7e6fc7cfd42ed6cf0c5fbd4ce53f103536b89fc167fe6030ca503525151d7e01
BLAKE2b-256 checksum
How to use checksums
544906583bd0526ed05b153590893817aeed32b2784e89887c53a311ee4d8158
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / feff10_rs-0.2.3-cp39-abi3-macosx_11_0_arm64.whl

Download URL feff10_rs-0.2.3-cp39-abi3-macosx_11_0_arm64.whl
Size 5.5 MB
Tags CPython 3.9 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
7e7bc32c5378f7f5953dcc4fcf121e1b61dcb128db6834e7da21d5cd4c1a335a
BLAKE2b-256 checksum
How to use checksums
e0668f24d2f9348eb1504c478b00542c2f8b40627ef5b8272b40dbb4a0f59528
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / feff10_rs-0.2.3-cp39-abi3-macosx_10_12_x86_64.whl

Download URL feff10_rs-0.2.3-cp39-abi3-macosx_10_12_x86_64.whl
Size 4.1 MB
Tags CPython 3.9 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
fe6ce2ad1188ea0118e8eab7850cee2c6e6fd7b55880e2b8c197d107680aafd8
BLAKE2b-256 checksum
How to use checksums
a9144da1fc74220f6653b83dbe5a46aa0f763e0eb48c4cf1cd260db0d70fda16
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

0.2.4

5 release files

This release

0.2.3 This release

5 release files

0.2.2

5 release files

0.2.1

5 release files

0.2.0

5 release files

0.1.7

5 release files

0.1.6

5 release files

0.1.5

5 release files

0.1.4

5 release files

0.1.3

5 release files

0.1.2

5 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page