Skip to content

feat(py): accept m_eff, and export M_E - #9

Open
reneotten wants to merge 1 commit into
mainfrom
fix/expose-m-eff
Open

feat(py): accept m_eff, and export M_E#9
reneotten wants to merge 1 commit into
mainfrom
fix/expose-m-eff

Conversation

@reneotten

Copy link
Copy Markdown
Owner

feat(py): accept m_eff, and export M_E

The Python wrapper's docstring said keyword arguments "match the Rust
DeviceParams field names", but m_eff was hardcoded to 0.9 * M_E in the
binding, so Device(m_eff=...) raised TypeError. The README discusses
m_eff as a tunable fitting parameter, so the documentation actively
pointed at an argument that did not exist.

Accept m_eff as an optional keyword. The default is unchanged.

m_eff is an absolute mass in kilograms, and the natural way to write "0.9
electron masses" is m_eff=0.9, which would silently be ~10^30x too heavy.
Export M_E so the intent can be spelled m_eff=0.19 * negforge.M_E, and
reject values above 1e-25 kg with an error that shows the correct form.
Non-finite and non-positive values are rejected too.

Also documents an asymmetry found while testing this: m_eff only enters
the NEGF hopping t_hop = hbar^2 / (2 m_eff a^2), so it changes local_density_of_states()
and the self-consistent charge, but not calc_current(): the ballistic
Landauer integral in this model assumes unit transmission above the barrier
and carries no mass prefactor. Changing m_eff alone therefore leaves the
ballistic I-V untouched by construction. Pinned by a test so the behaviour
is a stated property rather than a surprise.

The Python wrapper's docstring said keyword arguments "match the Rust
`DeviceParams` field names", but `m_eff` was hardcoded to `0.9 * M_E` in the
binding, so `Device(m_eff=...)` raised TypeError. The README discusses
`m_eff` as a tunable fitting parameter, so the documentation actively
pointed at an argument that did not exist.

Accept `m_eff` as an optional keyword. The default is unchanged.

`m_eff` is an absolute mass in kilograms, and the natural way to write "0.9
electron masses" is `m_eff=0.9`, which would silently be ~10^30x too heavy.
Export `M_E` so the intent can be spelled `m_eff=0.19 * negforge.M_E`, and
reject values above 1e-25 kg with an error that shows the correct form.
Non-finite and non-positive values are rejected too.

Also documents an asymmetry found while testing this: `m_eff` only enters
the NEGF hopping `t_hop = hbar^2/(2 m_eff a^2)`, so it changes the LDOS and
the self-consistent charge but leaves `calc_current()` bit-for-bit
unchanged -- the ballistic Landauer integral assumes unit transmission above
the barrier and carries no mass prefactor. Pinned by a test so the behaviour
is a stated property rather than a surprise.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Python bindings to fully support m_eff as a configurable Device parameter (instead of being hardcoded), and exposes the free-electron mass constant M_E so Python callers can specify effective masses safely in SI units.

Changes:

  • Add optional m_eff keyword argument to the PyO3 Device constructor, preserving the existing default.
  • Export M_E to Python and re-export it from negforge for ergonomic usage (negforge.M_E).
  • Add a core Rust test that pins the intended behavior: m_eff scales t_hop but does not affect the ballistic calc_current() result.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
python/negforge/init.py Re-exports M_E and documents correct m_eff units/usage and its modeled impact.
crates/negforge-py/src/lib.rs Accepts m_eff=None, validates units/range, and exports M_E from the extension module.
crates/negforge-core/src/device.rs Adds a regression test asserting m_eff affects hopping but not ballistic current.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants