@@ -7322,6 +7322,94 @@ def test_TimeDependentAmplitudeWrapperPotential_inputerrors():
7322
7322
return None
7323
7323
7324
7324
7325
+ def test_KuzminLikeWrapperPotential_against_KuzminDisk ():
7326
+ # Test that the KuzminLikeWrapperPotential applied to a KeplerPotential gives the
7327
+ # same potential as the KuzminDiskPotential
7328
+ from galpy .potential import (
7329
+ KeplerPotential ,
7330
+ KuzminDiskPotential ,
7331
+ KuzminLikeWrapperPotential ,
7332
+ )
7333
+
7334
+ kp = KeplerPotential (amp = 1.0 )
7335
+ kdp = KuzminDiskPotential (amp = 1.0 , a = 1.3 )
7336
+ kwp = KuzminLikeWrapperPotential (pot = kp , a = 1.3 )
7337
+ # Check that the potentials are the same in all ways
7338
+ R , z = 1.1 , 0.2
7339
+ tol = 1e-10
7340
+ assert (
7341
+ numpy .fabs (kdp (R , z ) - kwp (R , z )) < tol
7342
+ ), "KuzminLikeWrapperPotential does not give the same potential as KuzminDiskPotential"
7343
+ assert (
7344
+ numpy .fabs (kdp .Rforce (R , z ) - kwp .Rforce (R , z )) < tol
7345
+ ), "KuzminLikeWrapperPotential does not give the same Rforce as KuzminDiskPotential"
7346
+ assert (
7347
+ numpy .fabs (kdp .zforce (R , z ) - kwp .zforce (R , z )) < tol
7348
+ ), "KuzminLikeWrapperPotential does not give the same zforce as KuzminDiskPotential"
7349
+ assert (
7350
+ numpy .fabs (kdp .R2deriv (R , z ) - kwp .R2deriv (R , z )) < tol
7351
+ ), "KuzminLikeWrapperPotential does not give the same R2deriv as KuzminDiskPotential"
7352
+ assert (
7353
+ numpy .fabs (kdp .z2deriv (R , z ) - kwp .z2deriv (R , z )) < tol
7354
+ ), "KuzminLikeWrapperPotential does not give the same z2deriv as KuzminDiskPotential"
7355
+ assert (
7356
+ numpy .fabs (kdp .Rzderiv (R , z ) - kwp .Rzderiv (R , z )) < tol
7357
+ ), "KuzminLikeWrapperPotential does not give the same Rzderiv as KuzminDiskPotential"
7358
+ return None
7359
+
7360
+
7361
+ def test_KuzminLikeWrapperPotential_against_MiyamotoNagai ():
7362
+ # Test that the KuzminLikeWrapperPotential applied to a KeplerPotential with non-zero
7363
+ # b gives the same potential as the MiyamotoNagaiPotential
7364
+ from galpy .potential import (
7365
+ KeplerPotential ,
7366
+ KuzminLikeWrapperPotential ,
7367
+ MiyamotoNagaiPotential ,
7368
+ )
7369
+
7370
+ kp = KeplerPotential (amp = 1.0 )
7371
+ mnp = MiyamotoNagaiPotential (amp = 1.0 , a = 1.3 , b = 0.2 )
7372
+ kwp = KuzminLikeWrapperPotential (pot = kp , a = 1.3 , b = 0.2 )
7373
+ # Check that the potentials are the same in all ways
7374
+ R , z = 1.1 , 0.2
7375
+ tol = 1e-10
7376
+ assert (
7377
+ numpy .fabs (mnp (R , z ) - kwp (R , z )) < tol
7378
+ ), "KuzminLikeWrapperPotential does not give the same potential as MiyamotoNagaiPotential"
7379
+ assert (
7380
+ numpy .fabs (mnp .Rforce (R , z ) - kwp .Rforce (R , z )) < tol
7381
+ ), "KuzminLikeWrapperPotential does not give the same Rforce as MiyamotoNagaiPotential"
7382
+ assert (
7383
+ numpy .fabs (mnp .zforce (R , z ) - kwp .zforce (R , z )) < tol
7384
+ ), "KuzminLikeWrapperPotential does not give the same zforce as MiyamotoNagaiPotential"
7385
+ assert (
7386
+ numpy .fabs (mnp .R2deriv (R , z ) - kwp .R2deriv (R , z )) < tol
7387
+ ), "KuzminLikeWrapperPotential does not give the same R2deriv as MiyamotoNagaiPotential"
7388
+ assert (
7389
+ numpy .fabs (mnp .z2deriv (R , z ) - kwp .z2deriv (R , z )) < tol
7390
+ ), "KuzminLikeWrapperPotential does not give the same z2deriv as MiyamotoNagaiPotential"
7391
+ assert (
7392
+ numpy .fabs (mnp .Rzderiv (R , z ) - kwp .Rzderiv (R , z )) < tol
7393
+ ), "KuzminLikeWrapperPotential does not give the same Rzderiv as MiyamotoNagaiPotential"
7394
+ return None
7395
+
7396
+
7397
+ def test_KuzminLikeWrapperPotential_NonAxiError ():
7398
+ # Test that the KuzminLikeWrapperPotential applied to a non-axisymmetric potential
7399
+ # raises a RuntimeError
7400
+ from galpy .potential import KuzminLikeWrapperPotential , LogarithmicHaloPotential
7401
+
7402
+ with pytest .raises (RuntimeError ) as excinfo :
7403
+ kwp = KuzminLikeWrapperPotential (
7404
+ pot = LogarithmicHaloPotential (q = 0.8 , b = 0.9 ), a = 1.3
7405
+ )
7406
+ assert (
7407
+ "KuzminLikeWrapperPotential only works for spherical or axisymmetric potentials"
7408
+ == excinfo .value .args [0 ]
7409
+ )
7410
+ return None
7411
+
7412
+
7325
7413
def test_phiforce_deprecation ():
7326
7414
# Test that phiforce is being deprecated correctly for phitorque
7327
7415
import warnings
0 commit comments