# findLongestDistanceBus

Finds the bus for each phase that is farthest distance from the source bus

## Contents

- Syntax
- Description
- Inputs
- Outputs
- Example

## Syntax

    [longestDistance toBus] = findLongestDistanceBus(DSSCircObj, phaseOption);

## Description

Function to find the bus for each phase that is farthest distance from the source bus. This can be run to find the farthest bus for each phase (generally single phase) or farthest 3 phase bus.

## Inputs

- `DSSCircObj` - link to OpenDSS active circuit and command text (from DSSStartup)
- `phaseOption` - 'perPhase' for the farthest bus on each phase or '3phase' for the farthest 3 phase bus

## Outputs

- `longestDistance` - distance between fromBus to toBus
- `toBus` - name of bus with highest impedance to the energy monitor

## Example

Returns the bus names and distance for the farthest bus

    [DSSCircObj, DSSText, gridpvPath] = DSSStartup;
    DSSText.command = ['Compile "' gridpvPath 'ExampleCircuit\master_Ckt24.dss"'];
    DSSText.command = 'solve';
    [longestDistance toBus] = findLongestDistanceBus(DSSCircObj, 'perPhase')
    %

    longestDistance =

       12.8993   11.2051   10.9983

    toBus =

        'n284397.1'    'n292752.2'    'g2000sn2500_n2741...'