-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzener_test_model_9V1.ngjs
executable file
·45 lines (40 loc) · 1.22 KB
/
zener_test_model_9V1.ngjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env ngspicejs
// Draw V-A curve using ZENER_C9V1ST model from the model/DIODE/ZENER_C9V1ST.sub
// linter: ngspicejs-lint
"use strict";
// Simulate circuit
pwl('U1', 1, 0).shape([[0, 0.8], [0.020, 16]]);
ammeter('A1', 1, 2);
resistor('R1', 2, 3, 330);
var d1 = diode('D1', 0, 3, 'ZENER_C9V1ST');
var t = tran().run();
// Load table of measured reverse voltages and currents (for comparison)
var csv = file_read_csv('ZENER_C9V1ST_REVERSE.csv');
var volts = csv.column(0, 1).map(parseFloat);
var amps = csv.column(1, 1).map(parseFloat);
// log chart
chart_xy()
.min_x(4)
.max_x(10)
.min_y(1e-6)
.max_y(0.025)
.label_x('Vr/V')
.label_y('Ir/A')
.log_x(true)
.log_y(true)
.title(d1.attr.model + ' - Reverse V-A characteristic (logarithmic)')
.add_series(t.data['V(3)'], t.data['I(A1)'].clamp(1e-7, 999), 'simulated')
.add_series(volts, amps, 'measured')
.show();
// chart linear
chart_xy()
.min_x(4)
.max_x(10)
.min_y(1e-6)
.max_y(0.025)
.label_x('Vr/V')
.label_y('Ir/A')
.title(d1.attr.model + ' - Reverse V-A characteristic')
.add_series(t.data['V(3)'], t.data['I(A1)'].clamp(1e-7, 999), 'simulated')
.add_series(volts, amps, 'measured')
.show();