  Within the framework of the relativistic Vlasov-Uehling-Uhlenbeck transport
model based on the relativistic nonlinear NL$\rho$ interaction, we study pion
in-medium effects on the $\pi^-/\pi^+$ ratio in Au+Au collisions at the energy
of $E/A=400~\mathrm{MeV}$. These effects include the isospin-dependent pion
s-wave and p-wave potentials, which are taken from calculations based on the
chiral perturbation theory and the $\Delta$-hole model, respectively. We find
that the $\pi^-/\pi^+$ ratio in this collision is suppressed by the pion s-wave
potential but enhanced by the p-wave potential, with a net effect of a
significantly suppressed $\pi^-/\pi^+$ ratio. Including also the in-medium
threshold effects on $\Delta$ resonance production and decay and using a
nuclear symmetry energy with a slope parameter $L=59~\mathrm{MeV}$ by reducing
the coupling of isovector-vector $\rho$ meson to nucleon, our result is in good
agreement with measured $\pi^-/\pi^+$ ratio from the FOPI Collaboration. We
further investigate the pion in-medium effects on the ratio of charged pions as
a function of their kinetic energies.
