Commit d470bc53 by Reda Lemeden

Merge with head

parents 52715238 9201fbe6
......@@ -323,7 +323,7 @@ cktsim = (function() {
// Standard to do a dc analysis before transient
// Otherwise, do the setup also done in dc.
//no_dc = true;
no_dc = true;
if ((this.diddc == false) && (no_dc == false)) this.dc();
else {
// Allocate matrices and vectors.
......@@ -394,9 +394,10 @@ cktsim = (function() {
this.oldc[i] = this.c[i];
}
var step_index = -2; // Start with two pseudo-Euler steps
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.
for (var i = this.N - 1; i >= 0; --i) {
if (step_index >= 0)
......@@ -437,9 +438,6 @@ cktsim = (function() {
beta1 = 0.5;
}
// Keep track of step index.
step_index += 1;
// For trap rule, turn off current avging for algebraic eqns
for (var i = this.N - 1; i >= 0; --i) {
this.beta0[i] = beta0 + this.ar[i]*beta1;
......@@ -1301,8 +1299,8 @@ cktsim = (function() {
// MNA stamp for independent voltage source
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.npos,this.branch,-1.0);
ckt.add_to_Gl(this.nneg,this.branch,1.0);
ckt.add_to_Gl(this.npos,this.branch,1.0);
ckt.add_to_Gl(this.nneg,this.branch,-1.0);
}
// Source voltage added to b.
......@@ -1486,8 +1484,8 @@ cktsim = (function() {
// MNA stamp for inductor linear part
// 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.branch,this.n1,-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_C(this.branch,this.branch,this.value)
}
......@@ -1529,10 +1527,10 @@ cktsim = (function() {
var invA = 1.0/this.gain;
ckt.add_to_Gl(this.no,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.ng,invA);
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.no,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.nn,1);
}
Opamp.prototype.load_dc = function(ckt,soln,rhs) {
......
......@@ -71,7 +71,7 @@ schematic = (function() {
annotation_style = 'rgb(255,64,64)'; // color for diagram annotations
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
parts_map = {
......@@ -282,13 +282,11 @@ schematic = (function() {
tr = document.createElement('tr');
table.appendChild(tr);
td = document.createElement('td');
td.style.left = '0';
td.style.top = '0';
tr.appendChild(td);
var wrapper = document.createElement('div');
td.appendChild(wrapper);
wrapper.style.position = 'relative'; // so we can position subwindows
wrapper.appendChild(this.canvas);
td.appendChild(wrapper);
td = document.createElement('td');
td.style.verticalAlign = 'top';
tr.appendChild(td);
......@@ -1182,7 +1180,7 @@ schematic = (function() {
if (code == 16) sch.shiftKey = false;
else if (code == 17) sch.ctrlKey = false;
else if (code == 18) sch.altKey = false;
else if (code == 91) sch.commandKey = false;
else if (code == 91) sch.cmdKey = false;
}
function schematic_mouse_enter(event) {
......@@ -1779,12 +1777,22 @@ schematic = (function() {
// given a range of values, return a new range [vmin',vmax'] where the limits
// have been chosen "nicely". Taken from matplotlib.ticker.LinearLocator
function view_limits(vmin,vmax) {
// deal with degenerate case...
if (vmin == vmax) {
if (vmin == 0) { vmin = -0.5; vmax = 0.5; }
else {
vmin = vmin > 0 ? 0.9*vmin : 1.1*vmin;
vmax = vmax > 0 ? 1.1*vmax : 0.9*vmax;
}
}
var log_range = Math.log(vmax - vmin)/Math.LN10;
var exponent = Math.floor(log_range);
//if (log_range - exponent < 0.5) exponent -= 1;
var scale = Math.pow(10,-exponent);
vmin = Math.floor(scale*vmin)/scale;
vmax = Math.ceil(scale*vmax)/scale;
return [vmin,vmax,1.0/scale];
}
......@@ -3192,7 +3200,7 @@ schematic = (function() {
function OpAmp(x,y,rotation,name,A) {
Component.call(this,'o',x,y,rotation);
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,16); // -
this.add_connection(48,8); // output
......@@ -3274,9 +3282,9 @@ schematic = (function() {
//this.draw_line(c,3,20,0,28);
} else if (this.type == 'i') { // current source
// draw arrow: pos to neg
this.draw_line(c,0,16,0,32);
this.draw_line(c,-3,24,0,32);
this.draw_line(c,3,24,0,32);
this.draw_line(c,0,15,0,32);
this.draw_line(c,-3,26,0,32);
this.draw_line(c,3,26,0,32);
}
if (this.properties['name'])
......@@ -3442,14 +3450,16 @@ schematic = (function() {
var v = vmap[label];
if (v != undefined) {
// first draw some solid blocks in the background
c.globalAlpha = 0.85;
this.draw_text(c,'\u2588\u2588\u2588',0,24,4,annotation_size,element_style);
c.globalAlpha = 0.5;
this.draw_text(c,'\u2588\u2588\u2588',-8,8,4,annotation_size,element_style);
c.globalAlpha = 1.0;
// display the node voltage at this connection point
// display the element current
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
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