American Public Power Association tools




Pay Notebook Creator: Salah Ahmed0
Set Container: Numerical CPU with TINY Memory for 10 Minutes 0
Total0

TOWER GROUNDING RESISTANCE PROGRAM: ARBITRARY ARRANGEMENT OF VERTICAL GROUND RODS

I.E., IDENTICAL RODS SPACED AS SPECIFIED BY USER.

This program was originally written in Fortran in 1989 by David R. Brown and the American Public Power Association.

ARBITRARY ARRANGEMENT OF VERTICAL RODS IMPLIES IDENTICAL RODS WITH ARRANGEMENT OF RODS DEFINED BY PROGRAM USER.

NUMBER THE RODS FROM 1 TO N WHERE N IS THE TOTAL NUMBER OF IDENTICAL VERTICAL RODS.

ENTER THE DISTANCES FROM RODS 2 THROUGH N TO ROD 1.

{distance_rods_text : DISTANCES (FT) FROM RODS 2 THROUGH N TO ROD 1 for N up to 500 ? separate each distance with new line}

{rho: EARTH RESISTIVITY IN OHM-METERS}

{xl: LENGTH OF THE RODS IN FEET}

{rd: DIAMETER OF THE RODS IN INCHES}

In [4]:
# Click the Blue Plane to preview this as a CrossCompute tool
distance_rods_text_path = 'distances.txt'

rho = 10
xl = 10
rd = 10

target_folder = '/tmp'
In [22]:
try:
    with open(distance_rods_text_path, 'r') as f:
        distances = [str(int(x)) for x in f]
except ValueError:
    raise Exception("distances must be integers")
n = len(distances) + 1
In [23]:
distances
Out[23]:
['10', '12', '130', '41', '123']
In [24]:
if n > 500 or n < 2:
    raise Exception
In [25]:
from os.path import join
output_text_path = join(target_folder, 'arb_arr_vertical_rods.log')
target_text_path = join(target_folder, 'arb_arr_vertical_rods.txt')
In [1]:
from subprocess import run

executable = 'arb_arr_vertical_rods.out'
script = 'arb_arr_vertical_rods.f'

output_text = run([
    'gfortran',
    '-o',
    executable,
    script,])
In [26]:
from itertools import chain
from os.path import expanduser

cmd = list(chain([
    join('.', executable),
    expanduser(target_text_path),
    str(n)
], distances, [
    str(rho),
    str(xl),
    str(rd),
]))
In [28]:
from subprocess import check_output, STDOUT
output_text = check_output(cmd, stderr=STDOUT)
with open(output_text_path, 'wb') as output_file:
    output_file.write(output_text)
In [29]:
print('output_text_path = ' + output_text_path)
print('target_text_path = ' + target_text_path)
output_text_path = /tmp/arb_arr_vertical_rods.log
target_text_path = /tmp/arb_arr_vertical_rods.txt