Dr Wei Hu / Dr Maurice McCabe / Dr David Apsley / Prof Peter Stansby
Implements the SWAB Model
1-D nearshore wave simulation
Researchers interested in sharing their tools
Web devs interested in making similar apps
You don't need to know about web technologies or the SWAB model
Why share?
&
&
Written in FORTRAN
Command line tool
&RUNVARS
RUNNAME = '000-10-original'/
&WavesVARS
HOUT = 10,
NTPER = 1500,
NCYCLE = 10,
TNTIME = 'NCYCLE',
RTF = 1,
FMAX = 5,
PERIOD = 8,
HEIGHT = 2,
SPECFUN = 'JONSWAP',
GAMMA = 3.3,
RANSEED = T,
RANPUT = 1,
TIDE = F,
WAVETYPE = '000'
TIDEFILE = '000-10-original/Tide.in' /
&BedVARS
SEAWALL = T,
CFCONST = 0.01,
IWAVE = 100,
XWAVE = 100,
XIWAVE = 'IWAVE',
xzFileType = 'IX-XZ',
xzFile = '000-10-original/Bed.in' /
&BreakingVARS
Cbreak = 0.6/
&OutputVARS
NTPLOT = 2,
NXPLOT = 3,
TVAR = 'E, E0, EAV, U, HU, H, ADV, DIF, BOU, DHU, DEX, BRK, BED, QB, CHB',
XVAR = 'E, E0, EAV, U, HU, H, ADV, DIF, BOU, DHU, DEX, BRK, BED, QB, CHB',
OTHERVAR = 'BREAK, DXZ, SWASH, EIN, TRAIN, SF, AF, FORCE, VOLUME',
OUTTIME = '1',
OUTLOC = '110, 460',
AUTO = F/
&WallForceVARS
IWALL = '2',
KWALL = '0.5'/
0.00000000E+00 1.00000000E+01
2.39119500E-01 1.00000000E+01
4.78239000E-01 1.00000000E+01
7.17358500E-01 1.00000000E+01
9.56478000E-01 1.00000000E+01
1.19559750E+00 1.00000000E+01
1.43471700E+00 1.00000000E+01
1.67383650E+00 1.00000000E+01
1.91295600E+00 1.00000000E+01
2.15207550E+00 1.00000000E+01
2.39119500E+00 1.00000000E+01
2.63031450E+00 1.00000000E+01
2.86943400E+00 1.00000000E+01
3.10855350E+00 1.00000000E+01
3.34767300E+00 1.00000000E+01
3.58679250E+00 1.00000000E+01
3.82591200E+00 1.00000000E+01
4.06503150E+00 1.00000000E+01
4.30415100E+00 1.00000000E+01
4.54327050E+00 1.00000000E+01
4.78239000E+00 1.00000000E+01
5.02150950E+00 1.00000000E+01
5.26062900E+00 1.00000000E+01
5.49974850E+00 1.00000000E+01
5.73886800E+00 1.00000000E+01
5.97798750E+00 1.00000000E+01
6.21710700E+00 1.00000000E+01
6.45622650E+00 1.00000000E+01
6.69534600E+00 1.00000000E+01
6.93446550E+00 1.00000000E+01
7.17358500E+00 1.00000000E+01
7.41270450E+00 1.00000000E+01
7.65182400E+00 1.00000000E+01
7.89094350E+00 1.00000000E+01
8.13006300E+00 1.00000000E+01
8.36918250E+00 1.00000000E+01
8.60830200E+00 1.00000000E+01
8.84742150E+00 1.00000000E+01
9.08654100E+00 1.00000000E+01
9.32566050E+00 1.00000000E+01
9.56478000E+00 1.00000000E+01
9.80389950E+00 1.00000000E+01
1.00430190E+01 1.00000000E+01
1.02821385E+01 1.00000000E+01
1.05212580E+01 1.00000000E+01
Excel → parameter files → batch script
Can't we just share that?
We're not picking on SWAB 4.0
All native applications have these problems
Different operating systems (Linux/Windows/OSX...)
SWAB is a Windows .exe
Compiling source code - a mess of dependencies
SWAB 4.0 only compiles with the NAG compiler
Machine architectures (32 bit / 64 bit)
Excel wrapper written in VBA: 64 bit issues
Free download, requires proprietary software
Microsoft Excel / NAG compiler
more time getting it to work, than using it
Where you come in
n = 5
x = 2
def simulate():
y = 0
for i in range(n):
y += x
print('%d) y = %d' % (i, y))
simulate()
n = 5
x = 2
def simulate():
y = 0 # Initialisation
for i in range(n):
y += x # Step
print('%d) y = %d' % (i, y)) # Output
simulate()
n = 5
x = 2
def simulate():
y = 0
for i in range(n):
y += x
print('%d) y = %d' % (i, y))
simulate()
class Context:
def __init__(self, n, x):
self.n = n
self.x = x
def simulate(ctx):
y = 0
for i in range(ctx.n):
y += ctx.x
print('%d) y = %d' % (i, y))
simulate(Context(5, 2))
for i in range(ctx.n):
y += ctx.x
print('%d) y = %d' % (i, y))
I can't change the output without change the simulation!
class Context:
def __init__(self, n, x):
self.n = n
self.x = x
self.i = None
self.y = None
def simulate(ctx):
ctx.y = 0
for ctx.i in range(ctx.n):
ctx.y += ctx.x
print('%d) y = %d' % (ctx.i, ctx.y))
simulate(Context(5, 2))
def initialise(ctx):
ctx.y = 0
def canstep(ctx):
return ctx.i < ctx.n
def step(ctx):
ctx.y += ctx.x
ctx.i += 1
def output(ctx):
print('%d) y = %d' % (ctx.i, ctx.y))
ctx = Context(5, 2)
initialise(ctx)
while canstep(ctx):
step(ctx)
output(ctx)
from pymongo import MongoClient
client = MongoClient()
results = client.experiments.results
ctx = Context(5, 2)
initialise(ctx)
while canstep(ctx):
step(ctx)
results.insert({'i': ctx.i, 'y': ctx.y})
You're responsible for everything
Cloud computing / Amazon EC2
Interesting technologies
Meteor / D3 / threejs / RabbitMQ / MongoDB
Want to build a web application?