-
Notifications
You must be signed in to change notification settings - Fork 1
/
Fenton.py
39 lines (34 loc) · 1.34 KB
/
Fenton.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import numpy as np
from subprocess import check_call
def writeInput(waveheight, depth, period, mode='Period', current_criterion=1, current_magnitude=0, ncoeffs=8, height_steps=1, g=9.81):
with open('Data.dat', 'w') as f:
waveheight_dimless = waveheight/depth
mode = mode
if mode == 'Period':
length_dimless = period*np.sqrt(g/depth)
elif mode == 'Wavelength':
length_dimless = period*np.sqrt(g/depth)
current_magnitude_dimless = current_magnitude/np.sqrt(g*depth)
f.write('''Wave
{waveheight}
{mode}
{length}
{current_criterion}
{current_magnitude}
{ncoeffs}
{height_steps}
'''.format(waveheight=waveheight_dimless, mode=mode, length=length_dimless, current_criterion=current_criterion,
current_magnitude=current_magnitude_dimless, ncoeffs=ncoeffs, height_steps=height_steps))
def runFourier():
check_call('./Fourier', shell=True)
def getBYCoeffs():
FFT = np.genfromtxt('./Solution.res', delimiter=None, comments='#')
BCoeffs = FFT[:,1]
YCoeffs = FFT[:,2]
return BCoeffs, YCoeffs
def copyFiles():
from proteus import Profiling
print Profiling.logDir
import os
check_call('cp ./Data.dat {0}'.format(os.path.join(Profiling.logDir, 'Data.dat')))
check_call('cp ./Solution.res {0}'.format(os.path.join(Profiling.logDir, 'Solution.res')))