Commit a20acb25 authored by Dion Häfner's avatar Dion Häfner

fix tests

parent 3ba9c025
......@@ -28,5 +28,7 @@ def test_veros_copy_setup(runner):
ignore = [f for f in os.listdir(srcpath) if any(
fnmatch.fnmatch(f, pattern) for pattern in veros.cli.veros_copy_setup.IGNORE_PATTERNS
)]
ignore.append('version.txt')
comparer = filecmp.dircmp(outpath, srcpath, ignore=ignore)
assert not comparer.left_only and not comparer.right_only and not comparer.diff_files
......@@ -186,17 +186,17 @@ class VerosPyOMUnitTest:
for a, (v1, v2) in differing_arrays.items():
print('{}, {!r}, {!r}'.format(a, np.max(v1), np.max(v2)))
veros_timers = {k: Timer('veros ' + k) for k in self.test_routines}
veros_legacy_timers = {k: Timer('veros legacy ' + k) for k in self.test_routines}
veros_timers = {k: Timer() for k in self.test_routines}
veros_legacy_timers = {k: Timer() for k in self.test_routines}
for routine in self.test_routines.keys():
veros_args, veros_legacy_args = self.test_routines[routine]
with veros_timers[routine]:
getattr(self.test_module, routine)(*veros_args)
veros_timers[routine].print_time()
print('[{}]: {:.3f}s'.format(routine, veros_timers[routine].get_last_time()))
with veros_legacy_timers[routine]:
self.veros_legacy.call_fortran_routine(routine, **veros_legacy_args)
veros_legacy_timers[routine].print_time()
print('[legacy {}]: {:.3f}s'.format(routine, veros_legacy_timers[routine].get_last_time()))
self.test_passed(routine)
self.initialize()
......
......@@ -104,39 +104,37 @@ def biharmonic_diffusion(vs, tr, diffusivity):
"""
Biharmonic mixing of tracer tr
"""
flux_east = allocate(vs, ('xt', 'yt', 'zt'))
flux_north = allocate(vs, ('xt', 'yt', 'zt'))
del2 = allocate(vs, ('xt', 'yt', 'zt'))
dtr = allocate(vs, ('xt', 'yt', 'zt'))
flux_east[:-1, :, :] = -diffusivity * (tr[1:, :, :] - tr[:-1, :, :]) \
vs.flux_east[:-1, :, :] = -diffusivity * (tr[1:, :, :] - tr[:-1, :, :]) \
/ (vs.cost[np.newaxis, :, np.newaxis] * vs.dxu[:-1, np.newaxis, np.newaxis]) \
* vs.maskU[:-1, :, :]
flux_north[:, :-1, :] = -diffusivity * (tr[:, 1:, :] - tr[:, :-1, :]) \
vs.flux_north[:, :-1, :] = -diffusivity * (tr[:, 1:, :] - tr[:, :-1, :]) \
/ vs.dyu[np.newaxis, :-1, np.newaxis] * vs.maskV[:, :-1, :] \
* vs.cosu[np.newaxis, :-1, np.newaxis]
del2[1:, 1:, :] = vs.maskT[1:, 1:, :] * (flux_east[1:, 1:, :] - flux_east[:-1, 1:, :]) \
del2[1:, 1:, :] = vs.maskT[1:, 1:, :] * (vs.flux_east[1:, 1:, :] - vs.flux_east[:-1, 1:, :]) \
/ (vs.cost[np.newaxis, 1:, np.newaxis] * vs.dxt[1:, np.newaxis, np.newaxis]) \
+ (flux_north[1:, 1:, :] - flux_north[1:, :-1, :]) \
+ (vs.flux_north[1:, 1:, :] - vs.flux_north[1:, :-1, :]) \
/ (vs.cost[np.newaxis, 1:, np.newaxis] * vs.dyt[np.newaxis, 1:, np.newaxis])
utilities.enforce_boundaries(vs, del2)
flux_east[:-1, :, :] = diffusivity * (del2[1:, :, :] - del2[:-1, :, :]) \
vs.flux_east[:-1, :, :] = diffusivity * (del2[1:, :, :] - del2[:-1, :, :]) \
/ (vs.cost[np.newaxis, :, np.newaxis] * vs.dxu[:-1, np.newaxis, np.newaxis]) \
* vs.maskU[:-1, :, :]
flux_north[:, :-1, :] = diffusivity * (del2[:, 1:, :] - del2[:, :-1, :]) \
vs.flux_north[:, :-1, :] = diffusivity * (del2[:, 1:, :] - del2[:, :-1, :]) \
/ vs.dyu[np.newaxis, :-1, np.newaxis] * vs.maskV[:, :-1, :] \
* vs.cosu[np.newaxis, :-1, np.newaxis]
flux_east[-1, :, :] = 0.
flux_north[:, -1, :] = 0.
vs.flux_east[-1, :, :] = 0.
vs.flux_north[:, -1, :] = 0.
dtr[1:, 1:, :] = (flux_east[1:, 1:, :] - flux_east[:-1, 1:, :]) \
dtr[1:, 1:, :] = (vs.flux_east[1:, 1:, :] - vs.flux_east[:-1, 1:, :]) \
/ (vs.cost[np.newaxis, 1:, np.newaxis] * vs.dxt[1:, np.newaxis, np.newaxis]) \
+ (flux_north[1:, 1:, :] - flux_north[1:, :-1, :]) \
+ (vs.flux_north[1:, 1:, :] - vs.flux_north[1:, :-1, :]) \
/ (vs.cost[np.newaxis, 1:, np.newaxis] * vs.dyt[np.newaxis, 1:, np.newaxis])
dtr[...] *= vs.maskT
......@@ -150,27 +148,25 @@ def horizontal_diffusion(vs, tr, diffusivity):
Diffusion of tracer tr
"""
dtr_hmix = allocate(vs, ('xt', 'yt', 'zt'))
flux_east = allocate(vs, ('xt', 'yt', 'zt'))
flux_north = allocate(vs, ('xt', 'yt', 'zt'))
# horizontal diffusion of tracer
flux_east[:-1, :, :] = diffusivity * (tr[1:, :, :] - tr[:-1, :, :]) \
vs.flux_east[:-1, :, :] = diffusivity * (tr[1:, :, :] - tr[:-1, :, :]) \
/ (vs.cost[np.newaxis, :, np.newaxis] * vs.dxu[:-1, np.newaxis, np.newaxis])\
* vs.maskU[:-1, :, :]
flux_east[-1, :, :] = 0.
vs.flux_east[-1, :, :] = 0.
flux_north[:, :-1, :] = diffusivity * (tr[:, 1:, :] - tr[:, :-1, :]) \
vs.flux_north[:, :-1, :] = diffusivity * (tr[:, 1:, :] - tr[:, :-1, :]) \
/ vs.dyu[np.newaxis, :-1, np.newaxis] * vs.maskV[:, :-1, :]\
* vs.cosu[np.newaxis, :-1, np.newaxis]
flux_north[:, -1, :] = 0.
vs.flux_north[:, -1, :] = 0.
if vs.enable_hor_friction_cos_scaling:
flux_east[...] *= vs.cost[np.newaxis, :, np.newaxis] ** vs.hor_friction_cosPower
flux_north[...] *= vs.cosu[np.newaxis, :, np.newaxis] ** vs.hor_friction_cosPower
vs.flux_east[...] *= vs.cost[np.newaxis, :, np.newaxis] ** vs.hor_friction_cosPower
vs.flux_north[...] *= vs.cosu[np.newaxis, :, np.newaxis] ** vs.hor_friction_cosPower
dtr_hmix[1:, 1:, :] = ((flux_east[1:, 1:, :] - flux_east[:-1, 1:, :])
dtr_hmix[1:, 1:, :] = ((vs.flux_east[1:, 1:, :] - vs.flux_east[:-1, 1:, :])
/ (vs.cost[np.newaxis, 1:, np.newaxis] * vs.dxt[1:, np.newaxis, np.newaxis])
+ (flux_north[1:, 1:, :] - flux_north[1:, :-1, :])
+ (vs.flux_north[1:, 1:, :] - vs.flux_north[1:, :-1, :])
/ (vs.cost[np.newaxis, 1:, np.newaxis] * vs.dyt[np.newaxis, 1:, np.newaxis]))\
* vs.maskT[1:, 1:, :]
......
......@@ -142,7 +142,7 @@ def isoneutral_diffusion(vs, tr, istemp, iso=True, skew=False):
else:
dtracer_iso = vs.dsalt_iso
isoneutral_diffusion_tracer(vs, tr, dtracer_iso)
isoneutral_diffusion_tracer(vs, tr, dtracer_iso, iso=iso, skew=skew)
"""
dissipation by isopycnal mixing
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment