# American Public Power Association tools

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

# TRANSMISSION LINE ENVIRONMENTAL EFFECTS PROGRAM¶

## MAGNETIC FIELD CALCULATION MODULE¶

TL EFFECTS VERSION 1/4

ENTER MAGNITUDE AND ANGLE

MAGNITUDE SHOULD BE RMS LINE CURRENT

{mag_angles_table: magnitudes and angles}

{rho : EARTH RESISTIVITY IN OHM-METER}

{epsrel: RELATIVE EARTH PERMITTIVITY}

ENTER COORDINATES WHERE MAGNETIC FIELD IS DESIRED

ENTER DISTANCE DATA IN FEET, NUMBER OF DATA POINTS AS AN INTEGER.

For example, if xstart is 0, xstop is 10 and the number of data points is 3, then the program will calculate noise at ground level at the following distances away from the distribution line: 0 feet, 5 feet, 10 feet.

{xstart: FIRST X COORDINATE}

{xstop: LAST X COORDINATE}

{y : HEIGHT ABOVE GROUND}

{n: NUMBER OF POINTS}

In [5]:
#CrossCompute
mag_angles_table_path = 'magnitude_angles.csv'

rho = 100
epsrel = .25
xstart = 0
xstop = 250
y = 3.28
n = 100

target_folder = '/tmp'

In [6]:
from os.path import join
output_text_path = join(target_folder, 'magnetic_field.log')
target_text_path = join(target_folder, 'magnetic_field.txt')

In [7]:
from pandas import read_csv
df

Out[7]:
<style scoped> .dataframe tbody tr th:only-of-type { vertical-align: middle; } .dataframe tbody tr th { vertical-align: top; } .dataframe thead th { text-align: right; } </style>
magnitudes angles
0 10 1232
1 123 13
In [8]:
mag_angles = [','.join((str(x), str(y))) for x,y in zip(df['magnitudes'], df['angles'])]

In [11]:
pylon_text_path = ''

In [12]:
from subprocess import run

executable = '2.out'
script = '2.f'

output_text = run([
'gfortran',
'-o',
executable,
script,])

In [13]:
from itertools import chain
from os.path import expanduser

cmd = list(chain([
join('.', executable),
pylon_text_path,
expanduser(target_text_path)
],
mag_angles,
[str(rho),
str(epsrel),
str(xstart),
str(xstop),
str(y),
str(n)]))

In [ ]:
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 [ ]:
print('output_text_path = ' + output_text_path)
print('target_text_path = ' + target_text_path)