Skip to content

Commit

Permalink
Total loss
Browse files Browse the repository at this point in the history
  • Loading branch information
smariel committed Dec 26, 2022
1 parent 385a8ba commit 3372528
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
10 changes: 8 additions & 2 deletions html/PTree.html
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,19 @@
<td class="totalcell totalpower max">0</td>
<td class="totalcell">W</td>
</tr>
<tr>
<td class="totalcell">Total Loss</td>
<td class="totalcell totalloss typ">0</td>
<td class="totalcell totalloss max">0</td>
<td class="totalcell">W</td>
</tr>
<tr>
<td class="totalcell">Efficiency</td>
<td class="totalcell totaleff typ">100</td>
<td class="totalcell totaleff max">100</td>
<td class="totalcell">%</td>
</tr>
<tr>
<!--<tr>
<td class="totalcell">DC/DC loss</td>
<td class="totalcell totaldcdcloss typ">0</td>
<td class="totalcell totaldcdcloss max">0</td>
Expand All @@ -88,7 +94,7 @@
<td class="totalcell totalldoloss typ">0</td>
<td class="totalcell totalldoloss max">0</td>
<td class="totalcell">W</td>
</tr>
</tr>-->
</table>
</section>

Expand Down
9 changes: 8 additions & 1 deletion js/class.Canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -583,11 +583,17 @@ class Canvas {
$('.totalpower.typ').text(Util.numberToSi(totalpower.typ,3));
$('.totalpower.max').text(Util.numberToSi(totalpower.max,3));

// refresh the total losses
const loss = this.tree.getTotalLoss();
$('.totalloss.typ').text(Util.numberToSi(loss.typ,3));
$('.totalloss.max').text(Util.numberToSi(loss.max,3));


// refresh the total efficiency
const efficiency = this.tree.getTotalEfficiency();
$('.totaleff.typ').text(Util.numberToSi(efficiency.typ,3));
$('.totaleff.max').text(Util.numberToSi(efficiency.max,3));

/*
// refresh the total losses
const dcdcloss = this.tree.getTotalDCDCloss();
$('.totaldcdcloss.typ').text(Util.numberToSi(dcdcloss.typ,3));
Expand All @@ -597,6 +603,7 @@ class Canvas {
const ldoloss = this.tree.getTotalLDOloss();
$('.totalldoloss.typ').text(Util.numberToSi(ldoloss.typ,3));
$('.totalldoloss.max').text(Util.numberToSi(ldoloss.max,3));
*/
}


Expand Down
14 changes: 14 additions & 0 deletions js/class.Tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,20 @@ class Tree {
}


// return the loss of all sources
getTotalLoss(typmax='both') {
let totalloss = {typ:0, max:0};
this.forEachSource((source) => {
totalloss.typ += source.getPowerLoss('typ');
totalloss.max += source.getPowerLoss('max');
});

// return the typ or max or both
if('both' === typmax) return totalloss;
else return totalloss[typmax];
}


// Remove the reference to this tree from each item
// Caution! Call .convertToCircular() before calling any other method
convertToUncircular() {
Expand Down

0 comments on commit 3372528

Please sign in to comment.