-
Cristian Lalescu authoredCristian Lalescu authored
test_interpolation.py 1.25 KiB
#! /usr/bin/env python
import os
import numpy as np
import h5py
import sys
import bfps
from bfps import TEST
try:
import matplotlib.pyplot as plt
matplotlib_on = True
except ImportError:
matplotlib_on = False
def main():
nparticles = 100
c = TEST()
c.launch(
['test_interpolation',
'-n', '32',
'--np', '4',
'--ntpp', '1',
#'--nparticles', '{0}'.format(nparticles),
'--wd', './'] +
sys.argv[3:])
ifile = h5py.File(
'test_input.h5',
'r')
ofile = h5py.File(
'test_output.h5',
'r')
pos0 = ifile['tracers0/state/0'].value
pos1 = ofile['tracers0/position/0'].value
print('maximum position error is ', np.max(np.abs(pos0-pos1) / np.abs(pos0)))
vort0 = ofile['tracers0/vorticity/0'].value
print(vort0)
vel_gradient = ofile['tracers0/velocity_gradient/0'].value
print(vel_gradient)
vort1 = vort0.copy()
vort1[:, 0] = vel_gradient[:, 7] - vel_gradient[:, 5]
vort1[:, 1] = vel_gradient[:, 2] - vel_gradient[:, 6]
vort1[:, 2] = vel_gradient[:, 3] - vel_gradient[:, 1]
print(np.abs(vort0-vort1) / np.abs(vort0))
return None
if __name__ == '__main__':
main()