diode-analyzer
v1.0.2
Published
A JavaScript library for parameter extraction of the Five-Parameter Diode Model. Calculates Vth (Threshold Voltage), Rsh (Shunt Resistance), Rs (Series Resistance), Io (Saturation Current), and n (Ideality Factor).
Maintainers
Readme
Semiconductor Physics Tools
A JavaScript library for Parameter Extraction of the Five-Parameter Diode Model.
Parameters Calculated:
- Vth: Threshold Voltage
- Rsh: Shunt Resistance (Leakage)
- Rs: Series Resistance (Contact quality)
- Io: Saturation Current (Material quality)
- n (nte/ncc): Ideality Factor (Physics perfection)
Installation
npm install diode-analyzerUsage
import {
calculateVth,
calculateRsh,
processStepNine,
findThresholdIndex,
processStepTen,
} from "diode-analyzer";
// Example: Calculate Threshold Voltage (Vth)
const voltages = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0];
const currents = [
0.000000035767, 0.00000004389, 0.000000057498, 0.000000076319, 0.000000097812,
0.000000121201, 0.00000015031, 0.00000018914, 0.000000212217, 0.000000248738,
];
const vth = calculateVth(voltages, currents);
console.log("Threshold Voltage:", vth);
// Example: Calculate Shunt Resistance (Rsh)
const resistances = [28842.998823692906, 5724.990842589983, 3234.683524429178];
const rshResult = calculateRsh(voltages, resistances);
console.log("Rsh:", rshResult.rsh);
console.log("Rsh Formatted:", rshResult.rshFormatted);
// Example: Find threshold index
const thresholdIndex = findThresholdIndex(voltages, vth);
console.log("Threshold Index:", thresholdIndex);
// Example: Process Step 9 (Io and nTE calculation)
const lnlValues = [
-17.14623801998393, -16.941583763247255, -16.671516179696415,
];
const step9Result = processStepNine(voltages, lnlValues, thresholdIndex);
console.log("Io:", step9Result.io);
console.log("nTE:", step9Result.nte);
// Example: Process Step 10 (Rs and ncc calculation)
const dvdlnI = [0.0026878518619670205, 0.488628976472591, 0.3702776863672527];
const step10Result = processStepTen(currents, dvdlnI);
console.log("Rs:", step10Result.rs);
console.log("ncc:", step10Result.ncc);API Reference
calculateVth(voltages, currents)
Calculates Threshold Voltage using K-means clustering on rolling slopes.
- Parameters:
voltages(Array): Array of voltage valuescurrents(Array): Array of current values
- Returns:
number- The threshold voltage value
calculateRsh(voltages, resistances)
Calculates Shunt Resistance (Rsh) by finding the maximum resistance value.
- Parameters:
voltages(Array): Array of voltage valuesresistances(Array): Array of resistance values
- Returns:
Object-{ rsh: number, rshFormatted: string, success: boolean }
findThresholdIndex(voltages, vth)
Finds the 1-based index of the threshold voltage in the voltage array.
- Parameters:
voltages(Array | string): Array of voltage values or comma-separated stringvth(number): Threshold voltage value
- Returns:
number | null- 1-based index or null if not found
processStepNine(voltages, lnlValues, threshold)
Calculates Io (Saturation Current) and nTE (Ideality Factor) using linear regression.
- Parameters:
voltages(Array): Array of voltage valueslnlValues(Array): Array of ln(I) valuesthreshold(number): Threshold index (1-based)
- Returns:
Object-{ io: string, nte: string, success: boolean }
processStepTen(currents, dvdlnI)
Calculates Rs (Series Resistance) and ncc (Ideality Factor) using segmentation analysis.
- Parameters:
currents(Array): Array of current valuesdvdlnI(Array): Array of dV/d(ln(I)) values
- Returns:
Object-{ rs: string, ncc: string, success: boolean }
License
ISC
