FIX: signs of Circuit admittance matrix
This commit is contained in:
parent
19b3d01bd3
commit
6ae15ea149
@ -47,14 +47,14 @@ export class Circuit {
|
||||
const index1 = this.junctionsWithoutPivot.indexOf(wire.end);
|
||||
const conductance = 1.0 / wire.resistance;
|
||||
if (index0 >= 0) {
|
||||
this.matrix[index0][index0] += conductance;
|
||||
this.matrix[index0][index0] -= conductance;
|
||||
}
|
||||
if (index1 >= 0) {
|
||||
this.matrix[index1][index1] += conductance;
|
||||
this.matrix[index1][index1] -= conductance;
|
||||
}
|
||||
if (index0 >= 0 && index1 >= 0) {
|
||||
this.matrix[index0][index1] -= conductance;
|
||||
this.matrix[index1][index0] -= conductance;
|
||||
this.matrix[index0][index1] += conductance;
|
||||
this.matrix[index1][index0] += conductance;
|
||||
}
|
||||
}
|
||||
|
||||
@ -83,10 +83,10 @@ export class Circuit {
|
||||
const indexPlus = this.junctionsWithoutPivot.indexOf(battery.plus);
|
||||
const current = battery.voltage / battery.resistance;
|
||||
if (indexMinus >= 0) {
|
||||
this.currents[indexMinus] -= current;
|
||||
this.currents[indexMinus] += current;
|
||||
}
|
||||
if (indexPlus >= 0) {
|
||||
this.currents[indexPlus] += current;
|
||||
this.currents[indexPlus] -= current;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user