-
Notifications
You must be signed in to change notification settings - Fork 168
Double precision #552
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Double precision #552
Changes from all commits
2a9c691
1982556
b356a98
8c10d1a
694c8df
9fc6bd1
e4302e9
aa047b1
164fe09
dc575cb
6c7c3c5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -47,17 +47,17 @@ def test_advection_zonal(lon, lat, depth, mode, npart=10): | |
| assert fieldset2D.U.creation_log == 'from_data' | ||
|
|
||
| pset2D = ParticleSet(fieldset2D, pclass=ptype[mode], | ||
| lon=np.zeros(npart, dtype=np.float32) + 20., | ||
| lat=np.linspace(0, 80, npart, dtype=np.float32)) | ||
| lon=np.zeros(npart) + 20., | ||
| lat=np.linspace(0, 80, npart)) | ||
| pset2D.execute(AdvectionRK4, runtime=delta(hours=2), dt=delta(seconds=30)) | ||
| assert (np.diff(np.array([p.lon for p in pset2D])) > 1.e-4).all() | ||
|
|
||
| dimensions['depth'] = depth | ||
| fieldset3D = FieldSet.from_data(data3D, dimensions, mesh='spherical', transpose=True) | ||
| pset3D = ParticleSet(fieldset3D, pclass=ptype[mode], | ||
| lon=np.zeros(npart, dtype=np.float32) + 20., | ||
| lat=np.linspace(0, 80, npart, dtype=np.float32), | ||
| depth=np.zeros(npart, dtype=np.float32) + 10.) | ||
| lon=np.zeros(npart) + 20., | ||
| lat=np.linspace(0, 80, npart), | ||
| depth=np.zeros(npart) + 10.) | ||
| pset3D.execute(AdvectionRK4, runtime=delta(hours=2), dt=delta(seconds=30)) | ||
| assert (np.diff(np.array([p.lon for p in pset3D])) > 1.e-4).all() | ||
|
|
||
|
|
@@ -73,8 +73,8 @@ def test_advection_meridional(lon, lat, mode, npart=10): | |
| fieldset = FieldSet.from_data(data, dimensions, mesh='spherical', transpose=True) | ||
|
|
||
| pset = ParticleSet(fieldset, pclass=ptype[mode], | ||
| lon=np.linspace(-60, 60, npart, dtype=np.float32), | ||
| lat=np.linspace(0, 30, npart, dtype=np.float32)) | ||
| lon=np.linspace(-60, 60, npart), | ||
| lat=np.linspace(0, 30, npart)) | ||
| delta_lat = np.diff(np.array([p.lat for p in pset])) | ||
| pset.execute(AdvectionRK4, runtime=delta(hours=2), dt=delta(seconds=30)) | ||
| assert np.allclose(np.diff(np.array([p.lat for p in pset])), delta_lat, rtol=1.e-4) | ||
|
|
@@ -94,9 +94,9 @@ def test_advection_3D(mode, npart=11): | |
| fieldset = FieldSet.from_data(data, dimensions, mesh='flat', transpose=True) | ||
|
|
||
| pset = ParticleSet(fieldset, pclass=ptype[mode], | ||
| lon=np.zeros(npart, dtype=np.float32), | ||
| lat=np.zeros(npart, dtype=np.float32) + 1e2, | ||
| depth=np.linspace(0, 1, npart, dtype=np.float32)) | ||
| lon=np.zeros(npart), | ||
| lat=np.zeros(npart) + 1e2, | ||
| depth=np.linspace(0, 1, npart)) | ||
| time = delta(hours=2).total_seconds() | ||
| pset.execute(AdvectionRK4, runtime=time, dt=delta(seconds=30)) | ||
| assert np.allclose([p.depth*time for p in pset], [p.lon for p in pset], atol=1.e-1) | ||
|
|
@@ -182,8 +182,8 @@ def fieldset_stationary(xdim=100, ydim=100, maxtime=delta(hours=6)): | |
| ('RK45', 1e-5)]) | ||
| def test_stationary_eddy(fieldset_stationary, mode, method, rtol, npart=1): | ||
| fieldset = fieldset_stationary | ||
| lon = np.linspace(12000, 21000, npart, dtype=np.float32) | ||
| lat = np.linspace(12500, 12500, npart, dtype=np.float32) | ||
| lon = np.linspace(12000, 21000, npart) | ||
| lat = np.linspace(12500, 12500, npart) | ||
| pset = ParticleSet(fieldset, pclass=ptype[mode], lon=lon, lat=lat) | ||
| endtime = delta(hours=6).total_seconds() | ||
| pset.execute(kernel[method], dt=delta(minutes=3), endtime=endtime) | ||
|
|
@@ -195,9 +195,9 @@ def test_stationary_eddy(fieldset_stationary, mode, method, rtol, npart=1): | |
|
|
||
| @pytest.mark.parametrize('mode', ['scipy', 'jit']) | ||
| def test_stationary_eddy_vertical(mode, npart=1): | ||
| lon = np.linspace(12000, 21000, npart, dtype=np.float32) | ||
| lat = np.linspace(10000, 20000, npart, dtype=np.float32) | ||
| depth = np.linspace(12500, 12500, npart, dtype=np.float32) | ||
| lon = np.linspace(12000, 21000, npart) | ||
| lat = np.linspace(10000, 20000, npart) | ||
| depth = np.linspace(12500, 12500, npart) | ||
| endtime = delta(hours=6).total_seconds() | ||
|
|
||
| xdim = ydim = 100 | ||
|
|
@@ -263,8 +263,8 @@ def fieldset_moving(xdim=100, ydim=100, maxtime=delta(hours=6)): | |
| ('RK45', 1e-5)]) | ||
| def test_moving_eddy(fieldset_moving, mode, method, rtol, npart=1): | ||
| fieldset = fieldset_moving | ||
| lon = np.linspace(12000, 21000, npart, dtype=np.float32) | ||
| lat = np.linspace(12500, 12500, npart, dtype=np.float32) | ||
| lon = np.linspace(12000, 21000, npart) | ||
| lat = np.linspace(12500, 12500, npart) | ||
| pset = ParticleSet(fieldset, pclass=ptype[mode], lon=lon, lat=lat) | ||
| endtime = delta(hours=6).total_seconds() | ||
| pset.execute(kernel[method], dt=delta(minutes=3), endtime=endtime) | ||
|
|
@@ -307,8 +307,8 @@ def fieldset_decaying(xdim=100, ydim=100, maxtime=delta(hours=6)): | |
| ('RK45', 1e-5)]) | ||
| def test_decaying_eddy(fieldset_decaying, mode, method, rtol, npart=1): | ||
| fieldset = fieldset_decaying | ||
| lon = np.linspace(12000, 21000, npart, dtype=np.float32) | ||
| lat = np.linspace(12500, 12500, npart, dtype=np.float32) | ||
| lon = np.linspace(12000, 21000, npart) | ||
| lat = np.linspace(12500, 12500, npart) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So does this mean that all user code where
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No. It was breaking only if we were comparing in python the value of a float with a double |
||
| pset = ParticleSet(fieldset, pclass=ptype[mode], lon=lon, lat=lat) | ||
| endtime = delta(hours=6).total_seconds() | ||
| pset.execute(kernel[method], dt=delta(minutes=3), endtime=endtime) | ||
|
|
@@ -344,8 +344,8 @@ def test_decaying_eddy(fieldset_decaying, mode, method, rtol, npart=1): | |
|
|
||
| npart = args.particles | ||
| pset = ParticleSet(fieldset, pclass=ptype[args.mode], | ||
| lon=np.linspace(4000, 21000, npart, dtype=np.float32), | ||
| lat=np.linspace(12500, 12500, npart, dtype=np.float32)) | ||
| lon=np.linspace(4000, 21000, npart), | ||
| lat=np.linspace(12500, 12500, npart)) | ||
| if args.verbose: | ||
| print("Initial particle positions:\n%s" % pset) | ||
| pset.execute(kernel[args.method], dt=delta(minutes=3), runtime=delta(hours=6)) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.