Skip to content

Instantly share code, notes, and snippets.

@rroohhh
Last active November 2, 2022 07:19
Show Gist options
  • Save rroohhh/12b3b4b4ee8d822195bd3f530e8e6e4b to your computer and use it in GitHub Desktop.
Save rroohhh/12b3b4b4ee8d822195bd3f530e8e6e4b to your computer and use it in GitHub Desktop.

We fit a exponential function for $f$: $f(V) = a \exp(V / s)$ and obtain $a \approx 0.02485702\ \mathrm{A}$ and $s \approx 0.229551831\ \mathrm{V}$. With this the deviation from the measured values from the total model $P(V) = 414\ \mathrm{mW} + V · 130 · f(V)$ is always below $8 \ \mathrm{mW}$, indeed it is atmost $\approx 3.19\ \mathrm{mW}$ and on average $\approx 1.28\ \mathrm{mW}$.

When not taking a fixed offset of $414\ \mathrm{mW}$, but instead also leave this as a variable of the fit, we obtain $\approx 412.3\ \mathrm{mW}$ for the offset, $a \approx 0.0249451511\ \mathrm{A}$ and $s \approx 0.229653915\ \mathrm{V}$ with a maximum error of $\approx 2.28\ \mathrm{mW}$ and a average error of $\approx{0.74}\ \mathrm{mW}$.

#!/usr/bin/env python3
import numpy as np
from scipy.optimize import curve_fit
data = np.loadtxt("agx_sram_mW_mV.txt")
x = data[:,0]
y = data[:,1]
def model(x, fac, s):
return 414 + x / 1000 * 130 * fac * np.exp(x / s / 1000)
def evaluate(x, y, fitted):
dist = np.abs(fitted - y)
assert len(np.where(dist > 8)[0]) == 0
def fit(model, x, y):
popt, pcov = curve_fit(model, x, y)
print(popt)
fitted = model(x, *popt)
evaluate(x, y, fitted)
return fitted
fit(model, x, y)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment