bayesnegf 0.2.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 James M. F. Morris & Andrea Vezzoli
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,101 @@
1
+ Metadata-Version: 2.4
2
+ Name: bayesnegf
3
+ Version: 0.2.1
4
+ Summary: Bayesian Hamiltonian inference for single-molecule junctions using NEGF and dynamic nested sampling.
5
+ Author-email: "James M. F. Morris" <jamesmo@liverpool.ac.uk>, Andrea Vezzoli <andrea.vezzoli@liverpool.ac.uk>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/Molecular-Electronics-Liverpool/bayesnegf
8
+ Project-URL: Repository, https://github.com/Molecular-Electronics-Liverpool/bayesnegf
9
+ Requires-Python: >=3.10
10
+ Description-Content-Type: text/markdown
11
+ License-File: LICENSE
12
+ Requires-Dist: numpy>=2.0
13
+ Requires-Dist: scipy
14
+ Requires-Dist: pandas
15
+ Requires-Dist: dynesty
16
+ Requires-Dist: tqdm
17
+ Requires-Dist: corner
18
+ Requires-Dist: matplotlib
19
+ Dynamic: license-file
20
+
21
+ # BayesNEGF
22
+
23
+ [![DOI](https://zenodo.org/badge/1459965894.svg)](https://doi.org/10.5281/zenodo.24379288)
24
+
25
+ ## About
26
+
27
+ Bayesian inference on single-molecule electronics data for quantum transport. Uses dynamic nested sampling (dynesty) and non-equilibrium Green's functions (NEGF) to parameterise transport models and extract transmission spectra.
28
+
29
+
30
+ ### Current Version
31
+
32
+ Barebones implementation in v0.2.1 similar to the initial scripts found in our recent work.
33
+ Plans to extend this to a more user friendly general framework in the future are underway.
34
+ This codebase currently only supports the SSH tight-binding model.
35
+
36
+ Version 0.2.0 update: Reimplementation of transmission calculations to improve speed and accuracy. Approximately an order of magntude faster than the previous implementation (v0.1.0).
37
+
38
+
39
+ ## How to Cite
40
+
41
+ If you use bayesnegf or its code, please cite according to the CITATION.cff file or the format below:
42
+
43
+ > J. M. F. Morris, and A. Vezzoli (2026). bayesnegf: A Single-Molecule Bayesian Inference Quantum Transport Package, (Version 0.2.1), https://doi.org/10.5281/zenodo.24379288
44
+
45
+
46
+ ## Installation
47
+
48
+ Requires python >= 3.10
49
+
50
+ ### Install from PyPI (Recommended)
51
+ To install the core `bayesnegf` library to use in your own scripts, run:
52
+ ```bash
53
+ pip install bayesnegf
54
+ ```
55
+
56
+ ### Installing from Source (For Development and Example Scripts)
57
+ If you wish to run or modify the scripts in `scripts/` or modify the source code, clone the repository and install:
58
+
59
+ ```bash
60
+ git clone https://github.com/Molecular-Electronics-Liverpool/bayesnegf.git
61
+ cd bayesnegf
62
+ pip install .
63
+ ```
64
+
65
+
66
+ ## Repository Structure & Modules
67
+
68
+ | Module | Description |
69
+ | --- | --- |
70
+ | src/bayesnegf/transmission.py | SSH Hamiltonian, Stark shifts, WBL self-energies, NEGF transmission function calculation. |
71
+ | src/bayesnegf/iv.py | Landauer–B&uuml;ttiker current integration. |
72
+ | src/bayesnegf/optimisation.py | Prior transform and log-likelihood functions for `dynesty` |
73
+ | scripts/run_bayesnegf.py | Runs dynamic nested sampling on exp median I-V file in parallel. |
74
+ | scripts/post_process.py | Slices posterior distributions and calculates the weighted I-V and T(E) and credible interval |
75
+ | scripts/extract_parameters.py | Calculates the weighted medians, credible intervals and derived quantities of the posterior parameters |
76
+ | scripts/plot_corner.py | Produces the weighted corner plots of the posterior space. |
77
+
78
+
79
+ ## Example Usage (Cn = 8 SSH chain)
80
+
81
+ **1. Run the sampling (args: input_file, output_dir, N_atoms)**
82
+ ```bash
83
+ python scripts/run_bayesnegf.py ./data/C8_Med.txt ./Processed 8
84
+ ```
85
+ **2. Post-process the SSH chains and generate I-V and T(E) envelopes (run with --help for slicing options)**
86
+ ```bash
87
+ python scripts/post_process.py --raw_file ./Processed/C8_Med_RawChain.txt --save_dir ./Processed --N 8 --exp_file ./data/C8_Med.txt
88
+ ```
89
+
90
+
91
+ ## Future Plans
92
+
93
+ **Planned extensions:**
94
+
95
+ * **The Single Level Model - SLM (Breit-Wigner):** The simplest model a molecular junction can take. With optional temperature dependence.
96
+
97
+ * **The 2-Level Model:** A step up from the SLM, for tracking transport gap trends.
98
+
99
+ * **o/m/p-Benzene Model:** An abstracted model for archetypal quantum interfering systems to locate DQI nodes.
100
+
101
+ * **Joint-Conditioning:** Enabling combinations of I-V curves, dI/dV, d2I/dV2 (from analogue sources e.g. lock-in methods), polar environments etc to improve the likelihood function and increase constraints.
@@ -0,0 +1,81 @@
1
+ # BayesNEGF
2
+
3
+ [![DOI](https://zenodo.org/badge/1459965894.svg)](https://doi.org/10.5281/zenodo.24379288)
4
+
5
+ ## About
6
+
7
+ Bayesian inference on single-molecule electronics data for quantum transport. Uses dynamic nested sampling (dynesty) and non-equilibrium Green's functions (NEGF) to parameterise transport models and extract transmission spectra.
8
+
9
+
10
+ ### Current Version
11
+
12
+ Barebones implementation in v0.2.1 similar to the initial scripts found in our recent work.
13
+ Plans to extend this to a more user friendly general framework in the future are underway.
14
+ This codebase currently only supports the SSH tight-binding model.
15
+
16
+ Version 0.2.0 update: Reimplementation of transmission calculations to improve speed and accuracy. Approximately an order of magntude faster than the previous implementation (v0.1.0).
17
+
18
+
19
+ ## How to Cite
20
+
21
+ If you use bayesnegf or its code, please cite according to the CITATION.cff file or the format below:
22
+
23
+ > J. M. F. Morris, and A. Vezzoli (2026). bayesnegf: A Single-Molecule Bayesian Inference Quantum Transport Package, (Version 0.2.1), https://doi.org/10.5281/zenodo.24379288
24
+
25
+
26
+ ## Installation
27
+
28
+ Requires python >= 3.10
29
+
30
+ ### Install from PyPI (Recommended)
31
+ To install the core `bayesnegf` library to use in your own scripts, run:
32
+ ```bash
33
+ pip install bayesnegf
34
+ ```
35
+
36
+ ### Installing from Source (For Development and Example Scripts)
37
+ If you wish to run or modify the scripts in `scripts/` or modify the source code, clone the repository and install:
38
+
39
+ ```bash
40
+ git clone https://github.com/Molecular-Electronics-Liverpool/bayesnegf.git
41
+ cd bayesnegf
42
+ pip install .
43
+ ```
44
+
45
+
46
+ ## Repository Structure & Modules
47
+
48
+ | Module | Description |
49
+ | --- | --- |
50
+ | src/bayesnegf/transmission.py | SSH Hamiltonian, Stark shifts, WBL self-energies, NEGF transmission function calculation. |
51
+ | src/bayesnegf/iv.py | Landauer–B&uuml;ttiker current integration. |
52
+ | src/bayesnegf/optimisation.py | Prior transform and log-likelihood functions for `dynesty` |
53
+ | scripts/run_bayesnegf.py | Runs dynamic nested sampling on exp median I-V file in parallel. |
54
+ | scripts/post_process.py | Slices posterior distributions and calculates the weighted I-V and T(E) and credible interval |
55
+ | scripts/extract_parameters.py | Calculates the weighted medians, credible intervals and derived quantities of the posterior parameters |
56
+ | scripts/plot_corner.py | Produces the weighted corner plots of the posterior space. |
57
+
58
+
59
+ ## Example Usage (Cn = 8 SSH chain)
60
+
61
+ **1. Run the sampling (args: input_file, output_dir, N_atoms)**
62
+ ```bash
63
+ python scripts/run_bayesnegf.py ./data/C8_Med.txt ./Processed 8
64
+ ```
65
+ **2. Post-process the SSH chains and generate I-V and T(E) envelopes (run with --help for slicing options)**
66
+ ```bash
67
+ python scripts/post_process.py --raw_file ./Processed/C8_Med_RawChain.txt --save_dir ./Processed --N 8 --exp_file ./data/C8_Med.txt
68
+ ```
69
+
70
+
71
+ ## Future Plans
72
+
73
+ **Planned extensions:**
74
+
75
+ * **The Single Level Model - SLM (Breit-Wigner):** The simplest model a molecular junction can take. With optional temperature dependence.
76
+
77
+ * **The 2-Level Model:** A step up from the SLM, for tracking transport gap trends.
78
+
79
+ * **o/m/p-Benzene Model:** An abstracted model for archetypal quantum interfering systems to locate DQI nodes.
80
+
81
+ * **Joint-Conditioning:** Enabling combinations of I-V curves, dI/dV, d2I/dV2 (from analogue sources e.g. lock-in methods), polar environments etc to improve the likelihood function and increase constraints.
@@ -0,0 +1,31 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "bayesnegf"
7
+ version = "0.2.1"
8
+ description = "Bayesian Hamiltonian inference for single-molecule junctions using NEGF and dynamic nested sampling."
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ requires-python = ">=3.10"
12
+ authors = [
13
+ { name = "James M. F. Morris", email = "jamesmo@liverpool.ac.uk" },
14
+ { name = "Andrea Vezzoli", email = "andrea.vezzoli@liverpool.ac.uk" },
15
+ ]
16
+ dependencies = [
17
+ "numpy>=2.0",
18
+ "scipy",
19
+ "pandas",
20
+ "dynesty",
21
+ "tqdm",
22
+ "corner",
23
+ "matplotlib",
24
+ ]
25
+
26
+ [project.urls]
27
+ Homepage = "https://github.com/Molecular-Electronics-Liverpool/bayesnegf"
28
+ Repository = "https://github.com/Molecular-Electronics-Liverpool/bayesnegf"
29
+
30
+ [tool.setuptools.packages.find]
31
+ where = ["src"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
File without changes
@@ -0,0 +1,39 @@
1
+ import numpy as np
2
+ from . import transmission as tran
3
+
4
+ # Generates a current value for a given voltage
5
+ def current(N, H, gamma_L, gamma_R, V_applied, E_start, E_end, alpha=0.5, g=1.0, kT=0.025, E_points=200, dE_target=0.01, starkON=True):
6
+
7
+ # Chemical potentials of leads fixed symmetric, Stark handles asymmetry.
8
+ V = V_applied
9
+ mu_L = V / 2.0
10
+ mu_R = -V / 2.0
11
+
12
+ pad = 15.0 * kT
13
+ E_low = max(E_start, min(mu_L, mu_R) - pad)
14
+ E_high = min(E_end, max(mu_L, mu_R) + pad)
15
+ if E_low >= E_high:
16
+ raise ValueError("Energy range is invalid. Ensure that E_start < E_end and that the energy range covers the chemical potentials.")
17
+ return 0.0
18
+
19
+ if E_points is None:
20
+ n_pts = max(50, int(np.ceil((E_high - E_low) / dE_target)) + 1)
21
+ else:
22
+ n_pts = E_points
23
+
24
+ Energies, T_E = tran.transmission(N, E_low, E_high, H, gamma_L, gamma_R, V, alpha, n_pts, g, starkON)
25
+
26
+ f_L = tran.fermi_dirac(Energies, mu_L, kT)
27
+ f_R = tran.fermi_dirac(Energies, mu_R, kT)
28
+
29
+ I = T_E * (f_L - f_R)
30
+ dE = Energies[1] - Energies[0]
31
+ Integral = np.trapezoid(I, dx=dE)
32
+
33
+ G0 = 7.748092e-5 # units: S
34
+
35
+ current = G0 * Integral
36
+
37
+ return current
38
+
39
+
@@ -0,0 +1,69 @@
1
+ import numpy as np
2
+ from . import iv as IV
3
+ from . import transmission as tran
4
+
5
+ def prior_transform(u, N):
6
+ x = np.array(u)
7
+
8
+ t_scale = -10.00 + (u[0] * 6.00)
9
+ BO = 0.4 + (u[1] * 0.2)
10
+
11
+ t1 = BO * t_scale
12
+ t2 = (1 - BO) * t_scale
13
+
14
+ # Calculates half the HL gap assuming neutral half filled compound setting eps=0 for simplicity and WLOG
15
+ H = tran.SSH(N, 0, t1, t2)
16
+ evals = np.linalg.eigvalsh(H)
17
+ homo_idx = (N // 2) - 1
18
+ lumo_idx = N // 2
19
+ half_gap = (evals[lumo_idx] - evals[homo_idx]) / 2.0
20
+
21
+ x[0] = BO
22
+ x[1] = t_scale
23
+
24
+ if half_gap < 1e-6:
25
+ half_gap = 1e-6
26
+
27
+ x[2] = -half_gap + (u[2] * (2.0 * half_gap))
28
+ x[3] = 0.35 + u[3] * 0.3 # alpha: [0.35, 0.65]
29
+
30
+ # log_uniform sampling for couplings
31
+ gamma_upper = -2
32
+ gamma_lower = -0.001
33
+ log_gammaL = np.log10(abs(gamma_lower)) + (u[4] * (np.log10(abs(gamma_upper)) - np.log10(abs(gamma_lower))))
34
+ log_gammaR = np.log10(abs(gamma_lower)) + (u[5] * (np.log10(abs(gamma_upper)) - np.log10(abs(gamma_lower))))
35
+
36
+ x[4] = -(10**log_gammaL)
37
+ x[5] = -(10**log_gammaR)
38
+
39
+ return x
40
+
41
+ def log_likelihood(params, V_exp, I_exp, sigma_exp, N, E_start, E_end):
42
+
43
+ BO, t_scale, eps, alpha, gammaL, gammaR = params
44
+ t1 = BO * t_scale
45
+ t2 = (1 - BO) * t_scale
46
+
47
+ try:
48
+ H = tran.SSH(N, eps, t1, t2)
49
+
50
+ I_theory = np.zeros_like(V_exp)
51
+
52
+ for i, V in enumerate(V_exp):
53
+ # Theoretical current in nA at 300 K
54
+ I_theory[i] = IV.current(N, H, gammaL, gammaR, V, E_start, E_end, alpha=alpha, g=1.0, kT=0.0256, E_points=None, dE_target=0.01, starkON=True) / 1e-9
55
+
56
+
57
+ except Exception:
58
+ return -np.inf
59
+
60
+ log_I_exp = np.log10(np.abs(I_exp) + 1e-3)
61
+ log_I_theory = np.log10(np.abs(I_theory) + 1e-3)
62
+
63
+ sigma2 = sigma_exp**2
64
+ log_L = -0.5 * np.sum((log_I_exp - log_I_theory) ** 2 / sigma2 + np.log(sigma2))
65
+
66
+ if np.isnan(log_L):
67
+ return -np.inf
68
+
69
+ return log_L
@@ -0,0 +1,123 @@
1
+ import numpy as np
2
+ import scipy.linalg as la
3
+
4
+ # Fermi-Dirac distribution
5
+ def fermi_dirac(E, mu, kT=0.025):
6
+ exponent = np.clip((E - mu) / kT, -500, 500)
7
+ return 1.0 / (np.exp(exponent) + 1.0)
8
+
9
+ # Oligoyne SSH Hamiltonian
10
+ def SSH(N, eps, t_1, t_2):
11
+ H = np.zeros((N,N))
12
+ np.fill_diagonal(H, eps)
13
+
14
+ for i in range(N-1):
15
+ if i % 2 ==0:
16
+ beta = t_1
17
+ else:
18
+ beta = t_2
19
+
20
+ H[i,i+1] = beta
21
+ H[i+1,i] = beta
22
+
23
+ return H
24
+
25
+ # Degenerate form of Hamiltonian for orthogonal pi systems - see Jorgensen et al. J. Phys. Chem. A, 2021 - Not used here.
26
+ def SSHdual(N, eps, t_1, t_2):
27
+ H_diag = SSH(N, eps, t_1, t_2)
28
+ H_off_diag = np.zeros_like(H_diag)
29
+ H = np.block([
30
+ [H_diag, H_off_diag],
31
+ [H_off_diag, H_diag]
32
+ ])
33
+ return H
34
+
35
+ # Stark Shift Matrix
36
+ def stark(N, V_applied, alpha=0.5, g=1.0):
37
+
38
+ V = V_applied * g
39
+ shift = (0.5 - alpha) * V
40
+
41
+ diagonals = np.linspace(V/2, -V/2, N) + shift
42
+ stark_shift = np.diag(diagonals)
43
+
44
+ return stark_shift
45
+
46
+ # Self energy matrix under the WBL
47
+ def sigma(N, gamma_L, gamma_R):
48
+ sigma = np.zeros((N,N), dtype=complex)
49
+ sigma[0,0] = -1j * np.abs(gamma_L)
50
+ sigma[-1,-1] += -1j * np.abs(gamma_R)
51
+ return sigma
52
+
53
+ def transmission_old(N, E_start, E_end, H, gamma_L, gamma_R, V, alpha, E_points, g=1.0, starkON=True):
54
+ eta = 1e-9
55
+ if starkON:
56
+ H_v = H + stark(N, V, alpha, g)
57
+ else:
58
+ H_v = H
59
+ Sigma = sigma(N, gamma_L, gamma_R)
60
+ energy_range = np.linspace(E_start, E_end, E_points)
61
+
62
+ # Vectorised implementation for efficiency
63
+ E_3D = energy_range[:, np.newaxis, np.newaxis] * np.eye(N)
64
+ kernels = E_3D + (1j * eta) * np.eye(N) - H_v - Sigma
65
+ GR_all = np.linalg.inv(kernels)
66
+ gr_0_last_all = GR_all[:, 0, -1]
67
+ Transmission_E = 4 * np.abs(gamma_L) * np.abs(gamma_R) * (np.abs(gr_0_last_all) ** 2)
68
+
69
+ return energy_range, Transmission_E
70
+
71
+ def transmission(N, E_start, E_end, H, gamma_L, gamma_R, V, alpha, E_points, g=1.0, starkON=True):
72
+ eta = 1e-9
73
+ if starkON:
74
+ H_v = H + stark(N, V, alpha, g)
75
+ else:
76
+ H_v = H
77
+
78
+ Sigma = sigma(N, gamma_L, gamma_R)
79
+ energy_range = np.linspace(E_start, E_end, E_points)
80
+
81
+ base_kernel = -(H_v + Sigma)
82
+ kernels = np.broadcast_to(base_kernel, (E_points, N, N)).copy()
83
+ idx = np.arange(N)
84
+ kernels[:, idx, idx] += energy_range[:, np.newaxis] + (1j * eta)
85
+
86
+ b = np.zeros((E_points, N, 1), dtype=complex)
87
+ b[:, -1, 0] = 1.0
88
+ gr_last_col = np.linalg.solve(kernels, b)
89
+
90
+ gr_0_last_all = gr_last_col[:, 0, 0]
91
+ Transmission_E = 4 * np.abs(gamma_L) * np.abs(gamma_R) * (np.abs(gr_0_last_all) ** 2)
92
+
93
+ return energy_range, Transmission_E
94
+
95
+ # Sacrifices avoiding Py loops in favour of solving using a banded matrix algorithm. Should go from O(N^3) to O(N) for long chains.
96
+ # Native python Thomas algorithm would be slow in python. Useful for long chains. Py overhead slowed it down too much for this work.
97
+ def transmission_banded(N, E_start, E_end, H, gamma_L, gamma_R, V, alpha, E_points, g=1.0, starkON=True):
98
+ eta = 1e-9
99
+ if starkON:
100
+ H_v = H + stark(N, V, alpha, g)
101
+ else:
102
+ H_v = H
103
+ Sigma = sigma(N, gamma_L, gamma_R)
104
+
105
+ energy_range = np.linspace(E_start, E_end, E_points)
106
+ Transmission_E = np.zeros(E_points)
107
+
108
+ # https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.solve_banded.html
109
+ ab = np.zeros((3, N), dtype=complex)
110
+ ab[0, 1:] = -np.diag(H_v, k=1) #Upper diagonal bit k=0 (default) is diagonal
111
+ ab[2, :-1] = -np.diag(H_v, k=-1) #Lower diagonal bit
112
+ main_diag = -np.diag(H_v) - np.diag(Sigma) + (1j * eta)
113
+
114
+ # vector to extract the last col of inv Green func
115
+ b = np.zeros(N, dtype=complex)
116
+ b[-1] = 1.0 #set last element = 1.0
117
+
118
+ for i, E in enumerate(energy_range):
119
+ ab[1, :] = E + main_diag
120
+ x = la.solve_banded((1, 1), ab, b)
121
+ Transmission_E[i] = 4 * np.abs(gamma_L) * np.abs(gamma_R) * (np.abs(x[0]) ** 2)
122
+
123
+ return energy_range, Transmission_E
@@ -0,0 +1,101 @@
1
+ Metadata-Version: 2.4
2
+ Name: bayesnegf
3
+ Version: 0.2.1
4
+ Summary: Bayesian Hamiltonian inference for single-molecule junctions using NEGF and dynamic nested sampling.
5
+ Author-email: "James M. F. Morris" <jamesmo@liverpool.ac.uk>, Andrea Vezzoli <andrea.vezzoli@liverpool.ac.uk>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/Molecular-Electronics-Liverpool/bayesnegf
8
+ Project-URL: Repository, https://github.com/Molecular-Electronics-Liverpool/bayesnegf
9
+ Requires-Python: >=3.10
10
+ Description-Content-Type: text/markdown
11
+ License-File: LICENSE
12
+ Requires-Dist: numpy>=2.0
13
+ Requires-Dist: scipy
14
+ Requires-Dist: pandas
15
+ Requires-Dist: dynesty
16
+ Requires-Dist: tqdm
17
+ Requires-Dist: corner
18
+ Requires-Dist: matplotlib
19
+ Dynamic: license-file
20
+
21
+ # BayesNEGF
22
+
23
+ [![DOI](https://zenodo.org/badge/1459965894.svg)](https://doi.org/10.5281/zenodo.24379288)
24
+
25
+ ## About
26
+
27
+ Bayesian inference on single-molecule electronics data for quantum transport. Uses dynamic nested sampling (dynesty) and non-equilibrium Green's functions (NEGF) to parameterise transport models and extract transmission spectra.
28
+
29
+
30
+ ### Current Version
31
+
32
+ Barebones implementation in v0.2.1 similar to the initial scripts found in our recent work.
33
+ Plans to extend this to a more user friendly general framework in the future are underway.
34
+ This codebase currently only supports the SSH tight-binding model.
35
+
36
+ Version 0.2.0 update: Reimplementation of transmission calculations to improve speed and accuracy. Approximately an order of magntude faster than the previous implementation (v0.1.0).
37
+
38
+
39
+ ## How to Cite
40
+
41
+ If you use bayesnegf or its code, please cite according to the CITATION.cff file or the format below:
42
+
43
+ > J. M. F. Morris, and A. Vezzoli (2026). bayesnegf: A Single-Molecule Bayesian Inference Quantum Transport Package, (Version 0.2.1), https://doi.org/10.5281/zenodo.24379288
44
+
45
+
46
+ ## Installation
47
+
48
+ Requires python >= 3.10
49
+
50
+ ### Install from PyPI (Recommended)
51
+ To install the core `bayesnegf` library to use in your own scripts, run:
52
+ ```bash
53
+ pip install bayesnegf
54
+ ```
55
+
56
+ ### Installing from Source (For Development and Example Scripts)
57
+ If you wish to run or modify the scripts in `scripts/` or modify the source code, clone the repository and install:
58
+
59
+ ```bash
60
+ git clone https://github.com/Molecular-Electronics-Liverpool/bayesnegf.git
61
+ cd bayesnegf
62
+ pip install .
63
+ ```
64
+
65
+
66
+ ## Repository Structure & Modules
67
+
68
+ | Module | Description |
69
+ | --- | --- |
70
+ | src/bayesnegf/transmission.py | SSH Hamiltonian, Stark shifts, WBL self-energies, NEGF transmission function calculation. |
71
+ | src/bayesnegf/iv.py | Landauer–B&uuml;ttiker current integration. |
72
+ | src/bayesnegf/optimisation.py | Prior transform and log-likelihood functions for `dynesty` |
73
+ | scripts/run_bayesnegf.py | Runs dynamic nested sampling on exp median I-V file in parallel. |
74
+ | scripts/post_process.py | Slices posterior distributions and calculates the weighted I-V and T(E) and credible interval |
75
+ | scripts/extract_parameters.py | Calculates the weighted medians, credible intervals and derived quantities of the posterior parameters |
76
+ | scripts/plot_corner.py | Produces the weighted corner plots of the posterior space. |
77
+
78
+
79
+ ## Example Usage (Cn = 8 SSH chain)
80
+
81
+ **1. Run the sampling (args: input_file, output_dir, N_atoms)**
82
+ ```bash
83
+ python scripts/run_bayesnegf.py ./data/C8_Med.txt ./Processed 8
84
+ ```
85
+ **2. Post-process the SSH chains and generate I-V and T(E) envelopes (run with --help for slicing options)**
86
+ ```bash
87
+ python scripts/post_process.py --raw_file ./Processed/C8_Med_RawChain.txt --save_dir ./Processed --N 8 --exp_file ./data/C8_Med.txt
88
+ ```
89
+
90
+
91
+ ## Future Plans
92
+
93
+ **Planned extensions:**
94
+
95
+ * **The Single Level Model - SLM (Breit-Wigner):** The simplest model a molecular junction can take. With optional temperature dependence.
96
+
97
+ * **The 2-Level Model:** A step up from the SLM, for tracking transport gap trends.
98
+
99
+ * **o/m/p-Benzene Model:** An abstracted model for archetypal quantum interfering systems to locate DQI nodes.
100
+
101
+ * **Joint-Conditioning:** Enabling combinations of I-V curves, dI/dV, d2I/dV2 (from analogue sources e.g. lock-in methods), polar environments etc to improve the likelihood function and increase constraints.
@@ -0,0 +1,12 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ src/bayesnegf/__init__.py
5
+ src/bayesnegf/iv.py
6
+ src/bayesnegf/optimisation.py
7
+ src/bayesnegf/transmission.py
8
+ src/bayesnegf.egg-info/PKG-INFO
9
+ src/bayesnegf.egg-info/SOURCES.txt
10
+ src/bayesnegf.egg-info/dependency_links.txt
11
+ src/bayesnegf.egg-info/requires.txt
12
+ src/bayesnegf.egg-info/top_level.txt
@@ -0,0 +1,7 @@
1
+ numpy>=2.0
2
+ scipy
3
+ pandas
4
+ dynesty
5
+ tqdm
6
+ corner
7
+ matplotlib
@@ -0,0 +1 @@
1
+ bayesnegf