PHP Classes
elePHPant
Icontem

File: example.php

Recommend this page to a friend!
  Classes of Bart Plovie  >  Nodal Analysis  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example network
Class: Nodal Analysis
Perform nodal analysis of linear circuit networks
Author: By
Last change:
Date: 9 years ago
Size: 768 bytes
 

 

Contents

Class file image Download
This script solves the following network:<br />
<img src="network.jpeg"><br />
<pre>
<?php
   
require_once('nodal.class.php');
   
   
$nodal = new Nodal();
   
$nodal->setnodes(4);
   
$nodal->refnode(0);
   
$nodal->connection(0, 1, 200, 0, 0, 'AB');
   
$nodal->connection(0, 2, 10000, 9, 0, 'AC');
   
$nodal->connection(0, 3, 15000, 0, 0, 'AB');
   
$nodal->connection(1, 2, 20, 0, 0, 'BC');
   
$nodal->connection(2, 3, 5000, 0, 0, 'CD');
   
$nodal->connection(1, 3, 1000, 0, 0, 'BD');
   
   
$table = $nodal->connectiontable();
    echo
"<table>";
    foreach(
$table as $trow)
    {
        echo
"<tr>";
        foreach(
$trow as $element)
        {
            echo
"<td>$element</td>";
        }
        echo
"</tr>";
    }
    echo
"</table>\n\nResults:";
   
$nodal->calculate();
   
print_r($nodal->results());
?>
</pre>