Repository navigation
Expand file tree
/
Copy pathplotAndDisplayTimeSimResults.js
More file actions
91 lines (79 loc) · 2.02 KB
/
Copy pathplotAndDisplayTimeSimResults.js
File metadata and controls
91 lines (79 loc) · 2.02 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
function plotAndDisplayTimeSimResults(
i1,
i2,
sw1,
VDC,
efficiency,
tvec,
F,
loadValue_RL_VL_IL_PL
) {
//Let's first find S1 switch off current
let PL = VDC ** 2 / loadValue_RL_VL_IL_PL; //ASSUMES RESISTIVE LOAD.
let fallingEdge = 0.125 * tvec.length;
let i1FallingEdge = i1[math.floor(fallingEdge)];
//
let convergenceMessage = [];
let efficiencyMessage = [];
let outputVoltageMessage = [];
let IS1offMessage = [];
solverMessage = "Optimizer's least squares error= " + F;
efficiencyMessage = "Efficiency = " + efficiency.toFixed(5);
outputVoltageMessage = "Output (load) voltage = " + VDC.toFixed(5) + " VDC";
outputPowerMessage = "Output Power = " + PL.toFixed(5) + " W";
IS1offMessage =
"Switch off current (IS1off) = " + i1FallingEdge.toFixed(5) + " A";
//Update time-domain analysis message:
document.getElementById("timeDomainMessage").innerHTML =
solverMessage +
"<br>" +
efficiencyMessage +
"<br>" +
outputVoltageMessage +
"<br>" +
outputPowerMessage +
"<br>" +
IS1offMessage;
let numSigFig = 5; //number of significant digits for plot.
let plotId = "timeDomainPlot";
//tvec = tvec.map((a) => a.toFixed(numSigFig));
i1 = i1.map((a) => a.toFixed(numSigFig));
i2 = i2.map((a) => a.toFixed(numSigFig));
sw1 = sw1.map((a) => a.toFixed(numSigFig));
let trace1 = {
x: tvec,
y: i1,
name: "i1",
};
let trace2 = {
x: tvec,
y: i2,
name: "i2",
};
let trace3 = {
x: tvec,
y: sw1,
name: "V1",
yaxis: "y2",
};
data = [trace1, trace2, trace3];
var layout = {
title: "Time-domain waveforms",
showlegend: true,
legend: {
x: 1.05,
y: 1,
},
yaxis: { title: "Current (A)" },
xaxis: { title: "Time (s)" },
yaxis2: {
title: "V1",
titlefont: { color: "rgb(25, 127, 0)" },
tickfont: { color: "rgb(25, 127, 0)" },
overlaying: "y",
side: "right",
},
};
//Plotly.newPlot(plotId, data, layout);
Plotly.newPlot(plotId, data, layout);
}