-
Dear Jo Bovy, (1) - MoND theories in Galpy: #570 I'd like to mixing those two questions. I implemented the Effects of LMC & SMC for different potentials, but now I'd like to include also a simulation of MoND in my analysis, along with the effects of LMC & SMC. As we discussed in (2) this week, I implemented the effects of those satellites for other potentials different from the MWPotential2014. I tryed to do the same with the potential you developed in (1). "ValueError: Found time value not in the integration time domain". Which I don't know what it means. However the same procedure is adopted for other potentials, and nothing bad happens. import numpy as np
from galpy.potential import MovingObjectPotential, NonInertialFrameForce, HernquistPotential, ChandrasekharDynamicalFrictionForce, DissipativeForce, evaluateRforces, evaluatezforces, evaluatephitorques, _isNonAxi
from galpy.util import conversion
from galpy.potential import MWPotential2014
import matplotlib.pyplot as plt
import matplotlib
from galpy.util.conversion import get_physical
from galpy.orbit import Orbit
from galpy.potential.mwpotentials import Irrgang13I as asi
from astropy import units
MWPotential2014[2]*= 1.5
ts= np.linspace(0, 2, 10001)*units.Gyr
class MondForce(DissipativeForce.DissipativeForce):
def __init__(self,amp=1.,baryon_force=None,a0=0.612,ro=8.,vo=220.):
DissipativeForce.DissipativeForce.__init__(self,amp=amp,ro=ro,vo=vo)
self._a0= conversion.parse_force(a0,ro=ro,vo=vo)
self._baryon_force= baryon_force
self.isNonAxi= _isNonAxi(self._baryon_force)
def _calc_abar(self,R,z,t,phi):
return np.sqrt(evaluateRforces(self._baryon_force,R,z,t=t,phi=phi,use_physical=False)**2.
+evaluatephitorques(self._baryon_force,R,z,t=t,phi=phi,use_physical=False)**2./R**2.
+evaluatezforces(self._baryon_force,R,z,t=t,phi=phi,use_physical=False)**2.)
def _Rforce(self,R,z,t=0.,phi=0.,v=None):
abar= self._calc_abar(R, z, t, phi)
return 0.5*(abar+np.sqrt(abar**2.+4.*self._a0*abar))*evaluateRforces(self._baryon_force, R, z, t=t, phi=phi, use_physical=False)/abar
def _phitorque(self,R, z, t=0., phi=0., v=None):
abar= self._calc_abar(R, z, t, phi)
return 0.5*(abar+np.sqrt(abar**2.+4.*self._a0*abar))*evaluatephitorques(self._baryon_force, R, z, t=t, phi=phi, use_physical=False)/abar
def _zforce(self,R, z, t=0., phi=0., v=None):
abar= self._calc_abar(R, z, t, phi)
return 0.5*(abar+np.sqrt(abar**2.+4.*self._a0*abar))*evaluatezforces(self._baryon_force, R, z, t=t, phi=phi, use_physical=False)/abar
mond= MondForce(baryon_force=MWPotential2014[:2], a0=1.2*1e-10*units.m/units.s**2)
o_LMC_mond= Orbit.from_name('LMC')
cdf_mond= ChandrasekharDynamicalFrictionForce(GMs=(1.88/2)*10.**11.*units.Msun,rhm=5*units.kpc, dens=MWPotential2014[:2])
o_LMC_mond.integrate(ts,mond + cdf_mond, method="odeint")
lmcpot= HernquistPotential(amp=1.88*10.**11.*units.Msun, a=5*units.kpc/(1.+np.sqrt(2.)))
moving_lmcpot_mond= MovingObjectPotential(o_LMC_mond,pot=lmcpot)
#LMC on MW influence
loc_origin= 1e-4
ax= lambda t: evaluateRforces(moving_lmcpot_mond,loc_origin,0.,phi=0.,t=t, use_physical=False)
ay= lambda t: evaluatephitorques(moving_lmcpot_mond,loc_origin,0.,phi=0.,t=t, use_physical=False)/loc_origin
az= lambda t: evaluatezforces(moving_lmcpot_mond,loc_origin,0.,phi=0.,t=t, use_physical=False)
if o_LMC_mond.time(use_physical=False)[0] > o_LMC_mond.time(use_physical=False)[1]:
t_intunits= o_LMC_mond.time(use_physical=False)[::-1] # need to reverse the order for interp
else:
t_intunits= o_LMC_mond.time(use_physical=False)
ax4int= np.array([ax(t) for t in t_intunits])
ax_int= lambda t: np.interp(t,t_intunits,ax4int)
ay4int= np.array([ay(t) for t in t_intunits])
ay_int= lambda t: np.interp(t,t_intunits,ay4int)
az4int= np.array([az(t) for t in t_intunits])
az_int= lambda t: np.interp(t,t_intunits,az4int)
if o_LMC_mond.time(use_physical=False)[0] > o_LMC_mond.time(use_physical=False)[1]:
t_intunits= o_LMC_mond.time(use_physical=False)[::-1] # need to reverse the order for interp
else:
t_intunits= o_LMC_mond.time(use_physical=False)
ax4int= np.array([ax(t) for t in t_intunits])
ax_int= lambda t: np.interp(t, t_intunits, ax4int)
ay4int= np.array([ay(t) for t in t_intunits])
ay_int= lambda t: np.interp(t, t_intunits, ay4int)
az4int= np.array([az(t) for t in t_intunits])
az_int= lambda t: np.interp(t, t_intunits, az4int)
nip_LMC_mond= NonInertialFrameForce(a0=[ax_int, ay_int, az_int])
#SMC moving potential
o_SMC_mond=Orbit.from_name('SMC')
cdf2_mond= ChandrasekharDynamicalFrictionForce(GMs=(7/2)*10.**9.*units.Msun, rhm=2*units.kpc, dens=MWPotential2014[:2])
o_SMC_mond.integrate(ts, mond + cdf2_mond + nip_LMC_mond + moving_lmcpot_mond, method="odeint")
smcpot_SMC_mond= HernquistPotential(amp=7*10**9*units.Msun, a=2*units.kpc/(1.+np.sqrt(2.)))
moving_smcpot_mond= MovingObjectPotential(o_SMC_mond, pot=smcpot_SMC_mond)
#Final potential
pot_mond=mond + nip_LMC_mond + moving_lmcpot_mond + moving_smcpot_mond
rs= np.linspace(0.,50.,1001)*units.kpc
plt.plot(rs,units.Quantity([np.sqrt(-r*evaluateRforces(MWPotential2014,r,0.,v=[0.,0.,0.],ro=8.,vo=220.,quantity=True)) for r in rs]).to(units.km/units.s), label=r'MW2014',color='r')
plt.plot(rs,units.Quantity([np.sqrt(-r*evaluateRforces(asi,r,0.,v=[0.,0.,0.],ro=8.,vo=220.,quantity=True)) for r in rs]).to(units.km/units.s), label=r'ASI',color='lime')
plt.plot(rs,units.Quantity([np.sqrt(-r*evaluateRforces(mond,r,0.,v=[0.,0.,0.],ro=8.,vo=220.,quantity=True)) for r in rs]).to(units.km/units.s), label=r'MoND',color='slategray')
plt.ylim(0.,300.)
plt.legend(bbox_to_anchor=(1.05,1), loc='upper left', borderaxespad=0)
"""
sunts= np.linspace(0.,0.5,10001)*units.Gyr
osun_inertial_mond= Orbit([8.4*units.kpc, 22.*units.km/units.s, 242*units.km/units.s, 0.*units.kpc, 22.*units.km/units.s, 0.*units.deg], **get_physical(mond))
osun_inertial_mond.integrate(sunts, mond, method='rk4_c')
osun_noninertial_mond= Orbit([8.4*units.kpc, 22.*units.km/units.s, 242*units.km/units.s, 0.*units.kpc, 22.*units.km/units.s, 0.*units.deg], **get_physical(pot_mond))
osun_noninertial_mond.integrate(sunts, pot_mond, method='rk4_c')
osun_inertial_mond.plotx(color='r', label=r'$\text{Inertial}$')
osun_noninertial_mond.plotx(overplot=True, color='b', label=r'$\text{Non-inertial}$', linestyle='--')
plt.legend(bbox_to_anchor=(1.005,0.9), loc='upper left', borderaxespad=0)
""" In advance, thanks for the help! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
To address your two questions:
|
Beta Was this translation helpful? Give feedback.
To address your two questions:
odeint
integrator tries to evaluate the force from the LMC just outside the integration-time interval as part of its dynamic time-stepping, but the LMC force is only defined within the integration-time interval. Thi…