Commit 2d68e396 by cjt

update current labeling to match AA's expectations

parent 1c273c07
...@@ -323,7 +323,7 @@ cktsim = (function() { ...@@ -323,7 +323,7 @@ cktsim = (function() {
// Standard to do a dc analysis before transient // Standard to do a dc analysis before transient
// Otherwise, do the setup also done in dc. // Otherwise, do the setup also done in dc.
//no_dc = true; no_dc = true;
if ((this.diddc == false) && (no_dc == false)) this.dc(); if ((this.diddc == false) && (no_dc == false)) this.dc();
else { else {
// Allocate matrices and vectors. // Allocate matrices and vectors.
...@@ -394,9 +394,10 @@ cktsim = (function() { ...@@ -394,9 +394,10 @@ cktsim = (function() {
this.oldc[i] = this.c[i]; this.oldc[i] = this.c[i];
} }
var step_index = -2; // Start with two pseudo-Euler steps
var beta0,beta1; var beta0,beta1;
while (this.time <= tstop) { // Start with two pseudo-Euler steps, maximum 50000 steps
for(var step_index = -3; step_index < 50000; step_index++) {
// Save the just computed solution, and move back q and c. // Save the just computed solution, and move back q and c.
for (var i = this.N - 1; i >= 0; --i) { for (var i = this.N - 1; i >= 0; --i) {
if (step_index >= 0) if (step_index >= 0)
...@@ -437,9 +438,6 @@ cktsim = (function() { ...@@ -437,9 +438,6 @@ cktsim = (function() {
beta1 = 0.5; beta1 = 0.5;
} }
// Keep track of step index.
step_index += 1;
// For trap rule, turn off current avging for algebraic eqns // For trap rule, turn off current avging for algebraic eqns
for (var i = this.N - 1; i >= 0; --i) { for (var i = this.N - 1; i >= 0; --i) {
this.beta0[i] = beta0 + this.ar[i]*beta1; this.beta0[i] = beta0 + this.ar[i]*beta1;
...@@ -1301,8 +1299,8 @@ cktsim = (function() { ...@@ -1301,8 +1299,8 @@ cktsim = (function() {
// MNA stamp for independent voltage source // MNA stamp for independent voltage source
ckt.add_to_Gl(this.branch,this.npos,1.0); ckt.add_to_Gl(this.branch,this.npos,1.0);
ckt.add_to_Gl(this.branch,this.nneg,-1.0); ckt.add_to_Gl(this.branch,this.nneg,-1.0);
ckt.add_to_Gl(this.npos,this.branch,-1.0); ckt.add_to_Gl(this.npos,this.branch,1.0);
ckt.add_to_Gl(this.nneg,this.branch,1.0); ckt.add_to_Gl(this.nneg,this.branch,-1.0);
} }
// Source voltage added to b. // Source voltage added to b.
...@@ -1486,8 +1484,8 @@ cktsim = (function() { ...@@ -1486,8 +1484,8 @@ cktsim = (function() {
// MNA stamp for inductor linear part // MNA stamp for inductor linear part
// L on diag of C because L di/dt = v(n1) - v(n2) // L on diag of C because L di/dt = v(n1) - v(n2)
ckt.add_to_Gl(this.n1,this.branch,1); ckt.add_to_Gl(this.n1,this.branch,1);
ckt.add_to_Gl(this.branch,this.n1,-1);
ckt.add_to_Gl(this.n2,this.branch,-1); ckt.add_to_Gl(this.n2,this.branch,-1);
ckt.add_to_Gl(this.branch,this.n1,-1);
ckt.add_to_Gl(this.branch,this.n2,1); ckt.add_to_Gl(this.branch,this.n2,1);
ckt.add_to_C(this.branch,this.branch,this.value) ckt.add_to_C(this.branch,this.branch,this.value)
} }
...@@ -1529,10 +1527,10 @@ cktsim = (function() { ...@@ -1529,10 +1527,10 @@ cktsim = (function() {
var invA = 1.0/this.gain; var invA = 1.0/this.gain;
ckt.add_to_Gl(this.no,this.branch,1); ckt.add_to_Gl(this.no,this.branch,1);
ckt.add_to_Gl(this.ng,this.branch,-1); ckt.add_to_Gl(this.ng,this.branch,-1);
ckt.add_to_Gl(this.branch,this.no,-invA); ckt.add_to_Gl(this.branch,this.no,invA);
ckt.add_to_Gl(this.branch,this.ng,invA); ckt.add_to_Gl(this.branch,this.ng,-invA);
ckt.add_to_Gl(this.branch,this.np,1); ckt.add_to_Gl(this.branch,this.np,-1);
ckt.add_to_Gl(this.branch,this.nn,-1); ckt.add_to_Gl(this.branch,this.nn,1);
} }
Opamp.prototype.load_dc = function(ckt,soln,rhs) { Opamp.prototype.load_dc = function(ckt,soln,rhs) {
......
...@@ -71,7 +71,7 @@ schematic = (function() { ...@@ -71,7 +71,7 @@ schematic = (function() {
annotation_style = 'rgb(255,64,64)'; // color for diagram annotations annotation_style = 'rgb(255,64,64)'; // color for diagram annotations
property_size = 5; // point size for Component property text property_size = 5; // point size for Component property text
annotation_size = 7; // point size for diagram annotations annotation_size = 6; // point size for diagram annotations
// list of all the defined parts // list of all the defined parts
parts_map = { parts_map = {
...@@ -282,13 +282,11 @@ schematic = (function() { ...@@ -282,13 +282,11 @@ schematic = (function() {
tr = document.createElement('tr'); tr = document.createElement('tr');
table.appendChild(tr); table.appendChild(tr);
td = document.createElement('td'); td = document.createElement('td');
td.style.left = '0';
td.style.top = '0';
tr.appendChild(td); tr.appendChild(td);
var wrapper = document.createElement('div'); var wrapper = document.createElement('div');
td.appendChild(wrapper);
wrapper.style.position = 'relative'; // so we can position subwindows wrapper.style.position = 'relative'; // so we can position subwindows
wrapper.appendChild(this.canvas); wrapper.appendChild(this.canvas);
td.appendChild(wrapper);
td = document.createElement('td'); td = document.createElement('td');
td.style.verticalAlign = 'top'; td.style.verticalAlign = 'top';
tr.appendChild(td); tr.appendChild(td);
...@@ -3192,7 +3190,7 @@ schematic = (function() { ...@@ -3192,7 +3190,7 @@ schematic = (function() {
function OpAmp(x,y,rotation,name,A) { function OpAmp(x,y,rotation,name,A) {
Component.call(this,'o',x,y,rotation); Component.call(this,'o',x,y,rotation);
this.properties['name'] = name; this.properties['name'] = name;
this.properties['A'] = A ? A : '300000'; this.properties['A'] = A ? A : '30000';
this.add_connection(0,0); // + this.add_connection(0,0); // +
this.add_connection(0,16); // - this.add_connection(0,16); // -
this.add_connection(48,8); // output this.add_connection(48,8); // output
...@@ -3274,9 +3272,9 @@ schematic = (function() { ...@@ -3274,9 +3272,9 @@ schematic = (function() {
//this.draw_line(c,3,20,0,28); //this.draw_line(c,3,20,0,28);
} else if (this.type == 'i') { // current source } else if (this.type == 'i') { // current source
// draw arrow: pos to neg // draw arrow: pos to neg
this.draw_line(c,0,16,0,32); this.draw_line(c,0,15,0,32);
this.draw_line(c,-3,24,0,32); this.draw_line(c,-3,26,0,32);
this.draw_line(c,3,24,0,32); this.draw_line(c,3,26,0,32);
} }
if (this.properties['name']) if (this.properties['name'])
...@@ -3442,14 +3440,16 @@ schematic = (function() { ...@@ -3442,14 +3440,16 @@ schematic = (function() {
var v = vmap[label]; var v = vmap[label];
if (v != undefined) { if (v != undefined) {
// first draw some solid blocks in the background // first draw some solid blocks in the background
c.globalAlpha = 0.85; c.globalAlpha = 0.5;
this.draw_text(c,'\u2588\u2588\u2588',0,24,4,annotation_size,element_style); this.draw_text(c,'\u2588\u2588\u2588',-8,8,4,annotation_size,element_style);
c.globalAlpha = 1.0; c.globalAlpha = 1.0;
// display the node voltage at this connection point // display the element current
var i = engineering_notation(v,2) + 'A'; var i = engineering_notation(v,2) + 'A';
this.draw_text(c,i,0,24,4,annotation_size,annotation_style); this.draw_text(c,i,-3,5,5,annotation_size,annotation_style);
// draw arrow for current
this.draw_line(c,-3,4,0,8);
this.draw_line(c,3,4,0,8);
// only display each current once // only display each current once
delete vmap[label]; delete vmap[label];
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment