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}
# 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'
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
distances
if n > 500 or n < 2:
raise Exception
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')
from subprocess import run
executable = 'arb_arr_vertical_rods.out'
script = 'arb_arr_vertical_rods.f'
output_text = run([
'gfortran',
'-o',
executable,
script,])
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),
]))
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)
print('output_text_path = ' + output_text_path)
print('target_text_path = ' + target_text_path)